R: Knitting error rticles \vadjust in vertical mode - r

I tried to use the package rticles within a Rmd file, in order to generate journal publications. When trying to knit the template as it is, I get following error
his is pdfTeX, Version 3.141592653-2.6-1.40.22 (TeX Live 2021) (preloaded format=pdflatex)
restricted \write18 enabled.
entering extended mode
I was unable to find any missing LaTeX packages from the error log UC4_SupplySecurity.log.
! You can't use `\vadjust' in vertical mode.
l.300 \leavevmode\vadjust
pre{\hypertarget{ref-Neurobot2013}{}}%
Error: LaTeX failed to compile UC4_SupplySecurity.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See UC4_SupplySecurity.log for more info.
Execution halted
Within the log file, the same error is reported:
Package pdftex.def Info: UC4_SupplySecurity_files/figure-latex/Figure-1-1.pdf
used on input line 291.
(pdftex.def) Requested size: 241.86113pt x 241.86148pt.
! You can't use `\vadjust' in vertical mode.
l.300 \leavevmode\vadjust
I use following configurations
Latex
pdfTeX 3.141592653-2.6-1.40.22 (TeX Live 2021)
kpathsea version 6.3.3
Copyright 2021 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.37; using libpng 1.6.37
Compiled with zlib 1.2.11; using zlib 1.2.11
Compiled with xpdf version 4.03
R 4.0.5
What am I doing wrong?
Unfortunately I cannot provide a reproductible example, as it corresponds to the raw Frontiers Journal Article. The same issue persists with the Elsevier Journal Article template.
The template compiles if I remove all references and citations [#XY], but a publication without references is a no-go.

I believe this issue with rticles has been reported in the Github repo already
https://github.com/rstudio/rticles/issues/383 and it has been fixed in rticles 0.20 which is not yet on CRAN.
So for now, one should do
remotes::install_github("rstudio/rticles")
Using the dev version, I can render without error the default template for Frontier article.

You cannot knit with code in an \texttt{enumerate} or \texttt{itemize} environment. Maybe this is your problem.

Related

How to get revtex4-2 running in Ubuntu 22.04?

After downloading the file revtex-tds-2020-10-22.zip from https://journals.aps.org/revtex,
what should be done to get revtex4-2 up and running in Ubuntu 22.04?
Where exactly should one unzip the revtex4-2-tds.zip file?
After several trials, I keep getting the following error message which
I fail to understand (my files compile with no error in older revtex
implementations)
! Extra \endgroup. \document ->\endgroup
\document#inithook \true#sw {}\UseOneTimeHook {begindo...
l.74 \begin{document}
latex --version returns the following:
pdfTeX 3.14159265-2.6-1.40.20 (TeX Live 2019/Debian)
kpathsea version 6.3.4/dev
Copyright 2019 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.37; using libpng 1.6.37
Compiled with zlib 1.2.11; using zlib 1.2.11
Compiled with xpdf version 4.01
Thank you for your help!
I had the same issue and solved by installing the full dependency of texlive, that is running apt install texlive-full. There is a way to install a single packages (https://en.wikibooks.org/wiki/LaTeX/Installing_Extra_Packages) but I had other errors using the installer.

R markdown knit issue

I was trying to use Rmarkdown fro the first time to generate a pdf and got error messages.
I tried to download texlive from here http://www.tug.org/texlive/acquire-netinstall.html
" install-tl-unx.tar.gz (4mb) " but i don't quite get the instruction to install and not sure if it is the right solution for my issue.
Error I got:
! Package pdftex.def Error: File `http://www.compbio.dundee.ac.uk/user/pschofie
ld/Projects/teaching_pg//figures/openmarkdown.png' not found: using draft setti
ng.
Error: LaTeX failed to compile RNA-seq-Analysis-1---Introduction-to-R,-RStudio-and-Rmarkdown-.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See RNA-seq-Analysis-1---Introduction-to-R,-RStudio-and-Rmarkdown-.log for more info.
Execution halted
No LaTeX installation detected (LaTeX is required to create PDF output). You should install a LaTeX distribution for your platform: https://www.latex-project.org/get/
If you are not sure, you may install TinyTeX in R: tinytex::install_tinytex()
Otherwise consider MiKTeX on Windows - http://miktex.org
MacTeX on macOS - https://tug.org/mactex/
(NOTE: Download with Safari rather than Chrome strongly recommended)
Linux: Use system package manager

Emojis are not displayed in PDF generated by bookdown

I'm using bookdown to generate both a website and a pdf. I've added some emojies using the r package emo. There is no problem when building the site, they are displayed ok.
But when creating the pdf these emojis are not displayed, although they are shown in the .tex file. So my guess is the problem is converting from tex to pdf.
I'm using these commands:
rmarkdown::clean_site()
rmarkdown::render_site(output_format = 'bookdown::pdf_book', encoding = 'UTF-8')
Session info:
> rmarkdown::pandoc_version()
[1] ‘1.17.2’
> 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
R version 3.4.1
macOS Sierra 10.12.6
rmarkdown_1.6
Thanks!

How to render LaTeX correctly within function help pane in Rstudio?

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.

Error when generating R package manual

I having the following issue when trying to check a package using the command line.
First I get this very general error message:
* checking PDF version of manual ... WARNING
LaTeX errors when creating PDF version.
This typically indicates Rd problems.
LaTeX errors found:
* checking PDF version of manual without hyperrefs or index … ERROR
Then, when I check Rdlatex log, I found the following complain:
Transcript written on Rd2.log.
Error in texi2dvi(file = file, pdf = TRUE, clean = clean, quiet = quiet, :
unable to run 'pdflatex' on 'Rd2.tex'
Error in running tools::texi2pdf()
You may want to clean up by 'rm -rf /var/folders/_q/_kj9kz0n0qq_gwkrv9qjvpxw0000gn/T//Rtmp7uzkmZ/Rd2pdf2a847787e63'
For some reason it didn't manage to run pdflatex though it is properly installed as the following testifies. Does anyone has a clue on how I can fix it?
system("pdflatex --version")
pdfTeX 3.14159265-2.6-1.40.15 (TeX Live 2014)
kpathsea version 6.2.0
Copyright 2014 Peter Breitenlohner (eTeX)/Han The Thanh (pdfTeX).
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: Peter Breitenlohner (eTeX)/Han The Thanh (pdfTeX).
Compiled with libpng 1.6.10; using libpng 1.6.10
Compiled with zlib 1.2.8; using zlib 1.2.8
Compiled with xpdf version 3.03
Very weirdly, running R CMD Rd2pdf man/ produces output.
LaTeX Font Warning: Some font shapes were not available, defaults substituted.
)
(see the transcript file for additional information){/usr/local/texlive/2014bas
ic/texmf-dist/fonts/enc/dvips/inconsolata/i4-ts1.enc}{/usr/local/texlive/2014ba
sic/texmf-dist/fonts/enc/dvips/base/8r.enc}{/usr/local/texlive/2014basic/texmf-
dist/fonts/enc/dvips/inconsolata/i4-t1-0.enc}</usr/local/texlive/2014basic/texm
f-dist/fonts/type1/public/inconsolata/Inconsolata-zi4r.pfb></usr/local/texlive/
2014basic/texmf-dist/fonts/type1/public/amsfonts/cm/cmex10.pfb></usr/local/texl
ive/2014basic/texmf-dist/fonts/type1/public/amsfonts/cm/cmmi10.pfb></usr/local/
texlive/2014basic/texmf-dist/fonts/type1/public/amsfonts/cm/cmmi7.pfb></usr/loc
al/texlive/2014basic/texmf-dist/fonts/type1/public/amsfonts/cm/cmr10.pfb></usr/
local/texlive/2014basic/texmf-dist/fonts/type1/public/amsfonts/cm/cmr5.pfb></us
r/local/texlive/2014basic/texmf-dist/fonts/type1/public/amsfonts/cm/cmr7.pfb></
usr/local/texlive/2014basic/texmf-dist/fonts/type1/public/amsfonts/cm/cmsy10.pf
b></usr/local/texlive/2014basic/texmf-dist/fonts/type1/public/amsfonts/cm/cmsy7
.pfb></usr/local/texlive/2014basic/texmf-dist/fonts/type1/urw/helvetic/uhvr8a.p
fb></usr/local/texlive/2014basic/texmf-dist/fonts/type1/urw/times/utmb8a.pfb></
usr/local/texlive/2014basic/texmf-dist/fonts/type1/urw/times/utmr8a.pfb></usr/l
ocal/texlive/2014basic/texmf-dist/fonts/type1/urw/times/utmr8a.pfb></usr/local/
texlive/2014basic/texmf-dist/fonts/type1/urw/times/utmri8a.pfb>
Output written on Rd2.pdf (62 pages, 264746 bytes).
Transcript written on Rd2.log.
Saving output to 'Rd2.pdf' ...
Done
I had R CMD check and R CMD Rd2pdf fail because one of our collabs created an empty curly-braces block that was not escaped by roxygen and broke the laTeX render, .i.e. the \dontrun{} below :
#' An example of breaking the R CMD Rd2pdf with unescaped curly braces.
#'
#' #param df A dataframe.
#' #return A dataframe.
#'
#' #examples
#' \dontrun{
#' }
#' #export
funcname <- function(df){
df
}

Resources