I want to change the documentclass to 'scrbook'. In the index.Rmd file of minimal bookdown example I changed the line documentclass: book to documentclass: scrbook but this didn't work. I got the following error message:
Latexmk: applying rule 'pdflatex'...
Latexmk: This is Latexmk, John Collins, 19 Jan. 2017, version: 4.52c.
Rule 'pdflatex': File changes, etc:
Non-existent destination files:
'test-bookdown.pdf'
------------
Run number 1 of rule 'pdflatex'
------------
------------
Running '/Library/TeX/texbin/xelatex -halt-on-error -interaction=batchmode -recorder "test-bookdown.tex"'
------------
This is XeTeX, Version 3.14159265-2.6-0.99998 (TeX Live 2017) (preloaded format=xelatex)
restricted \write18 enabled.
entering extended mode
=== TeX engine is 'XeTeX'
Latexmk: Errors, so I did not complete making targets
Latexmk: Log file says no output from latex
Latexmk: For rule 'pdflatex', no output was made
Collected error summary (may duplicate other messages):
pdflatex: Command for 'pdflatex' gave return code 1
Refer to 'test-bookdown.log' for details
Latexmk: Use the -f option to force complete processing,
unless error was exceeding maximum runs of latex/pdflatex.
! LaTeX Error: Command \subtitle already defined.
Or name \end... illegal, see p.192 of the manual.
Error: Failed to compile test-bookdown.tex. See test-bookdown.log for more info.
Please delete test-bookdown.Rmd after you finish debugging the error.
Execution halted
Exited with status 1.
Is there a way to change to other document classes besides those supported by pandoc (article, report, book, memoir)?
I used for the compilation the command rmarkdown::render_site(output_format = 'bookdown::pdf_book', encoding = 'UTF-8') as provided by the Build Book tab.
R version 3.4.2 (2017-09-28)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Sierra 10.12.6
Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_3.4.2 backports_1.1.1 bookdown_0.5.4 magrittr_1.5 rprojroot_1.2
[6] htmltools_0.3.6 tools_3.4.2 yaml_2.1.14 Rcpp_0.12.13 stringi_1.1.5
[11] rmarkdown_1.6.0.9004 knitr_1.17 stringr_1.2.0 digest_0.6.12 evaluate_0.10.1
> rmarkdown::pandoc_version()
[1] ‘1.19.2.1’
> system('pdflatex --version')
pdfTeX 3.14159265-2.6-1.40.18 (TeX Live 2017)
kpathsea version 6.2.3
Copyright 2017 Han The Thanh (pdfTeX) et al.
There is NO warranty. Redistribution of this software is
covered by the terms of both the pdfTeX copyright and
the Lesser GNU General Public License.
For more information about these matters, see the file
named COPYING and the pdfTeX source.
Primary author of pdfTeX: Han The Thanh (pdfTeX) et al.
Compiled with libpng 1.6.29; using libpng 1.6.29
Compiled with zlib 1.2.11; using zlib 1.2.11
Compiled with xpdf version 3.04
I used scrbook as an example in the bookdown book in Section 4.2. Had you searched for scrbook using the search button, you would have discovered it. I'm not going to copy the full example here, but the key is template: null, and that is because rmarkdown's default Pandoc LaTeX template does not work with scrbook, and Pandoc's LaTeX template does. You can certainly provide your own Pandoc LaTeX template.
Related
I am trying to install some packages to work with spatial data such as sf, stars, rgdal, on a Mac Book Air M1 with Ventura.
To do so, I need to have gdal installed to my compute, which I have. My problem is that when I try to install a library (see example with sf here below), the gdal-config file is not found.
But I have it on my computer, so my question is :
Is there a way to indicate the path to R to find that file ?
I tried to to uninstall and reinstall gdal with homebrew, I have proj that is also a dependency rightly installed.
I need to install from sf from sources as it is needed to install the stars package.
(base)#MacBook-Air ~ % echo $PATH
/opt/homebrew/bin:/opt/anaconda3/bin:/opt/anaconda3/condabin:/Library/Frameworks/Python.framework/Versions/3.9/bin:/Library/Frameworks/Python.framework/Versions/3.8/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/opt/X11/bin
(base)#MacBook-Air ~ % whereis gdal-config
gdal-config: /opt/homebrew/bin/gdal-config /opt/homebrew/share/man/man1/gdal-config.1
(base)#MacBook-Air ~ % gdal-config
Usage: gdal-config [OPTIONS]
Options:
[--prefix[=DIR]]
[--libs]
[--dep-libs]
[--cflags]
[--datadir]
[--version]
[--ogr-enabled]
[--gnm-enabled]
[--formats]
> sessionInfo()
R version 4.0.3 (2020-10-10)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS 13.1
Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_4.0.3 tools_4.0.3
(base)#MacBook-Air ~ % proj
DeprecationWarning: PROJ_LIB environment variable is deprecated, and will be removed in a future release. You are encouraged to set PROJ_DATA instead.
Rel. 9.1.1, December 1st, 2022
usage: proj [-bdeEfiIlmorsStTvVwW [args]] [+opt[=arg] ...] [file ...]
P.S: I know there are a lots of related topics (Error: gdal-config not found while installing R dependent packages whereas gdal is installed), but all of them are on Linux, and the solutions are not working for me on Mac machine.
I solved it by reinstalling the latest version of R and R Studio.
I'm having problems knitting an .rmd file to a .html (and pdf for that matter) file using rmarkdown. The report that I'm trying to knit in the following example is just the example report you get when starting a new rmakrdown document.
This is the error message I get:
==> rmarkdown::render('C:/Users/***/Documents/test/test.Rmd', encoding = 'UTF-8');
processing file: test.Rmd
|.......... | 14%
ordinary text without R code
|.................... | 29%
label: setup (with options)
List of 1
$ include: logi FALSE
|.............................. | 43%
ordinary text without R code
|........................................ | 57%
label: cars
|.................................................. | 71%
ordinary text without R code
|............................................................ | 86%
label: pressure (with options)
List of 1
$ echo: logi FALSE
|......................................................................| 100%
ordinary text without R code
output file: test.knit.md
"C:/Program Files/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS test.utf8.md --to html4 --from markdown+autolink_bare_uris+tex_math_single_backslash --output test.html --email-obfuscation none --self-contained --standalone --section-divs --template "\\storage-***.se\home$\****\My Documents\R\win-library\4.0\rmarkdown\rmd\h\default.html" --no-highlight --variable highlightjs=1 --variable "theme:bootstrap" --include-in-header "C:\Users\*****\AppData\Local\Temp\Rtmpc1mrLs\rmarkdown-str511010115ff7.html" --mathjax --variable "mathjax-url:https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" --lua-filter "\\storage-****.se/home$/****/My Documents/R/win-library/4.0/rmarkdown/rmd/lua/pagebreak.lua" --lua-filter "\\storage-***-se/home$/*****/My Documents/R/win-library/4.0/rmarkdown/rmd/lua/latex-div.lua"
pandoc.exe: \\: openBinaryFile: does not exist (No such file or directory)
Error: pandoc document conversion failed with error 1
Execution halted
Pandoc tries to reach a file saved on my computer but for some reason can't find it. This is my work computer where everything is saved locally and then uploaded to a server. I have talked with IT at my office and they don't know why it wont work.
I have managed to get a rmarkdown report before when I moved EVERYTHING (r project, packages and the files where I do my analysis) to a map that is not uploaded to the backup server.
However, this is not a safe way since there is no backup, obviously. I've tried to just have the r-project locally for the knitting but it doesn't work either.
Why can't pandoc find this binary file and is there a way I can get it to work without having to risk the safety of my work? If not, is there another way of creating similar files without pandoc?
I have seen similar questions but nothing that could give me any answers. Or give the people at the IT department any clues.
Thanks!
Johanna
Here is the session information:
> sessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 17134)
Matrix products: default
locale:
[1] LC_COLLATE=Swedish_Sweden.1252 LC_CTYPE=Swedish_Sweden.1252
[3] LC_MONETARY=Swedish_Sweden.1252 LC_NUMERIC=C
[5] LC_TIME=Swedish_Sweden.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_4.0.2 htmltools_0.5.0 tools_4.0.2 yaml_2.2.1 rmarkdown_2.3
[6] knitr_1.29 xfun_0.16 digest_0.6.25 rlang_0.4.7 evaluate_0.14
Versions:
> version
_
platform x86_64-w64-mingw32
arch x86_64
os mingw32
system x86_64, mingw32
status
major 4
minor 0.2
year 2020
month 06
day 22
svn rev 78730
language R
version.string R version 4.0.2 (2020-06-22)
nickname Taking Off Again
> pandoc_version()
[1] ‘2.7.2’
> pandoc_available()
[1] TRUE
I have solved the problem!
The actual problem was the path of the rmarkdown package. It was on my //storage... path. What I finally had to do was to go into system settings and add an environmental variable for R_LIBS_USER to my H:/ path. Now when pandoc is looking for the rmarkdown details it can find the path.
Using this link as research. try using the RELATIVE path for your file. in this one you are using the absolute path C:/Users/... and this temporarily changes R's working directory.
I'm getting an error building R for Data Science in ePub format
> render_book("index.rmd", epub_book())
output file: strings.knit.md
Error: Functions that produce HTML output found in document targeting epub3 output.
Please change the output type of this document to HTML. Alternatively, you can allow
HTML output in non-HTML formats by adding this option to the YAML front-matter of
your rmarkdown file:
always_allow_html: true
Note however that the HTML output will not be visible in non-HTML formats.
Execution halted
Error in Rscript_render(f, render_args, render_meta, add1, add2) :
Failed to compile strings.Rmd
sessionInfo()
R version 3.5.2 (2018-12-20)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Debian GNU/Linux 10 (buster)
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.8.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.8.0
attached base packages:
[1] stats graphics grDevices utils datasets methods base
Is there something I can do to allow compilation to ePub that will keep all content intact?
For my bookdown::gitbook project I deleted my _output.yml and _bookdon.yml files from the book directory and specified the sharing settings, documentation class etc in the Index.Rmd file.This solved it for my HTML output but I'm not sure whether the same applies for ePub formats.
I am having similar problems, and (for me) narrowed it down to using kable_styling (epub format with kable_styling fails)
No solution yet though... :-<
P.
I'm compiling a pdf using child .Rmd's. The example_child.Rmd calls an image using knitr::include_graphics() and compiles fine on its own, but trying to compile example_main.Rmd produces the following error.
TeX Live 2019 is frozen forever and will no
longer be updated. This happens in preparation for a new release.
If you're interested in helping to pretest the new release (when
pretests are available), please read https://tug.org/texlive/pretest.html.
Otherwise, just wait, and the new release will be ready in due time.
! LaTeX Error: File `images/example_image' not found.
Error: LaTeX failed to compile example_main.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See example_main.log for more info.
Execution halted
example_main.Rmd compiles fine when only calling child documents that don't call images (it calls data from sub-folders just fine). Any help would be appreciated! All the relevant info about my session and files is below:
My working directory is "/Users/example_project"
The example_main.Rmd (file path "/Users/example_project/folder_1/example_main.Rmd") YAML and code-chunk are as follows:
---
output:
pdf_document:
latex_engine: xelatex
---
```{r child = './folder_2/example_child.Rmd'}
```
The example_child.Rmd (file path "/Users/example_project/folder_1/folder_2/example_child.Rmd") YAML and code chunk are as follows:
---
output: pdf_document
---
```{r example, echo = FALSE, out.width='80%', out.height='50%'}
knitr::include_graphics("./images/example_image.png")
```
The full image file path is "/Users/example_project/folder_1/folder_2/images/example_image.png".
My session info is as follows:
R version 3.6.3 (2020-02-29)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Mojave 10.14.6, RStudio 1.2.5033
Locale: en_US.UTF-8 / en_US.UTF-8 / en_US.UTF-8 / C / en_US.UTF-8 / en_US.UTF-8
Package version:
base64enc_0.1.3 digest_0.6.25 evaluate_0.14 glue_1.4.0 graphics_3.6.3 grDevices_3.6.3 highr_0.8
htmltools_0.4.0 jsonlite_1.6.1 knitr_1.28.2 magrittr_1.5 markdown_1.1 methods_3.6.3 mime_0.9
Rcpp_1.0.4 rlang_0.4.5 rmarkdown_2.1 stats_3.6.3 stringi_1.4.6 stringr_1.4.0 tinytex_0.21.1
tools_3.6.3 utils_3.6.3 xfun_0.12 yaml_2.2.1
Pandoc version: 2.3.1
You can reconstruct the path to the image using the working directory of the child document (in example_child.Rmd)
---
output: pdf_document
---
```{r example, echo = FALSE, out.width='80%', out.height='50%'}
knitr::include_graphics(paste0(getwd(), "/images/example_image.png"))
```
It seem that this is an issue with 'grandchild' documents similar to that described here and here
Mathematical equations written in LaTeX are often presented within the function documentation accessed in R via help() or ? and presented in the help pane in Rstudio. They do not render correctly within the help pane of Rstudio on my machine. I am however able to use LaTeX successfully in all other application and with knitR outputs.
> sessionInfo()
R version 3.3.3 (2017-03-06)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: macOS Sierra 10.12.3
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] tools_3.3.3
Output from Terminal showing my LaTeX version
latex -v
pdfTeX 3.14159265-2.6-1.40.17 (TeX Live 2016)
kpathsea version 6.2.2
Copyright 2016 Han The Thanh (pdfTeX) et al.
There is NO warranty. Redistribution of this software is
covered by the terms of both the pdfTeX copyright and
the Lesser GNU General Public License.
For more information about these matters, see the file
named COPYING and the pdfTeX source.
Primary author of pdfTeX: Han The Thanh (pdfTeX) et al.
Compiled with libpng 1.6.21; using libpng 1.6.21
Compiled with zlib 1.2.8; using zlib 1.2.8
Compiled with xpdf version 3.04
E.g. when I input ?glm() the following function description loads in Rstudio:
Help in R renders essentially in HTML or LaTeX. The .Rd files that the documentation is written in are rendered as PDF manual, the help page showing upon ?topic or help("topic") call is the HTML one and this does not any math rendering, it is basically only enclosed in <i> </i> tags.
It is really a shame that the HTML form of the documentation that is used the most completely resigns over the math typesetting. One would think that R as "statistical environment" should definitely handle that. Long story short - this behaviour is no error.
However, actually, if you are a package developer and you care about your users' sanity, there is a way how to achieve that math correctly renders in RStudio Help pane, see https://github.com/wviechtb/mathjaxr.
EDIT: I have created a package that hacks Rd to HTML documentation "conversion" which enables proper math rendering for EVERY help page, see https://github.com/netique/documath. It is a sort of monkey patch, but works well. I am in contact with R developers, so maybe we'll see the feature in a proper release. However, that's for a long run.
EDIT2: R 4.2.0+ actually implements the feature from the aforementioned package, so if you want to see the math rendered properly in HTML help, update your R.