Blogdown fails rendering a tikz block in my Rmd document - r

This question is very closely related to this question, however the following differences apply:
OS: Unix CentOS in Docker container (image is centos) with Windows host.
Error: Conceptually the same error, but the fix that worked on Windows does not work here and the error message is also different.
I have created a project by using template Hugo-Xmin. In RStudio, after creating the project in blogdown, it created some predefined posts, I am editing this one:
/content/post/2015-07-23-r-rmarkdown.Rmd
I modified that file by adding this snippet at the end of the file:
This is a tikz picture:
```{r, echo=FALSE, engine='tikz', out.width='90%', fig.ext=if (knitr:::is_latex_output()) 'pdf' else 'png', fig.cap='Some caption.'}
\begin{tikzpicture}[scale=.7]
\draw [fill=gray!30,very thick] (0,-1) rectangle (5,1);
\draw [very thick] (5, 0) -- (13,0);
\node [below] at (2,-1) {\large Hello};
\node [below, align=center] at (0,-1) {\large Two\\ lines};
\end{tikzpicture}
```
Failed to process the post
My working directory is the project folder, I run from there, in the R console, the command:
blogdown::build_site()
And get this:
> blogdown::build_site()
Rendering content/_index.Rmarkdown
running: bash -c "cd ../..;
find . -not -path '*/exampleSite/*' \\( -name '*.html' -o -name '*.css' \\) | xargs wc -l"
Rendering content/post/2015-07-23-r-rmarkdown.Rmd
This is pdfTeX, Version 3.1415926-2.5-1.40.14 (TeX Live 2013)
restricted \write18 enabled.
entering extended mode
! LaTeX Error: File `preview.sty' not found.
! Emergency stop.
<read *>
Quitting from lines 49-55 (2015-07-23-r-rmarkdown.Rmd)
Error: Failed to compile tikz2b145b766cfa.tex. See https://yihui.name/tinytex/r/#debugging for debugging tips. See tikz2b145b766cfa.log for more info.
Execution halted
Error in render_page(f) :
Failed to render 'content/post/2015-07-23-r-rmarkdown.Rmd'
Important Please notice that I have followed the help link and added, at the beginning of the file, this snippet:
```{r, include=FALSE}
options(tinytex.verbose = TRUE)
```
The output I reported above, is the output I get when this snippet is in place.
Troubleshooting 1
By inspecting file tikz2b145b766cfa.log (as reported in the error message), I can see the following error:
This is pdfTeX, Version 3.1415926-2.5-1.40.14 (TeX Live 2013) (format=pdflatex 2019.3.18) 18 MAR 2019 21:12
entering extended mode
restricted \write18 enabled.
%&-line parsing enabled.
**tikz2b145b766cfa.tex
(./tikz2b145b766cfa.tex
LaTeX2e <2011/06/27>
Babel <v3.8m> and hyphenation patterns for english, dumylang, nohyphenation, ru
ssian, ukrainian, bulgarian, loaded.
(/usr/share/texlive/texmf-dist/tex/latex/base/article.cls
Document Class: article 2007/10/19 v1.4h Standard LaTeX document class
(/usr/share/texlive/texmf-dist/tex/latex/base/size10.clo
File: size10.clo 2007/10/19 v1.4h Standard LaTeX file (size option)
)
\c#part=\count79
\c#section=\count80
\c#subsection=\count81
\c#subsubsection=\count82
\c#paragraph=\count83
\c#subparagraph=\count84
\c#figure=\count85
\c#table=\count86
\abovecaptionskip=\skip41
\belowcaptionskip=\skip42
\bibindent=\dimen102
)
\#input{preview.aux}
\openout2 = `preview.aux'.
No file preview.tex.
! LaTeX Error: File `preview.sty' not found.
Type X to quit or <RETURN> to proceed,
or enter new name. (Default extension: sty)
Enter file name:
! Emergency stop.
<read *>
l.4 \usepackage
{amsmath}^^M
Here is how much of TeX's memory you used:
200 strings out of 494820
2171 string characters out of 3178049
47774 words of memory out of 3000000
3480 multiletter control sequences out of 15000+200000
3640 words of font info for 14 fonts, out of 3000000 for 9000
198 hyphenation exceptions out of 8191
23i,0n,17p,164b,36s stack positions out of 5000i,500n,10000p,200000b,50000s
! ==> Fatal error occurred, no output PDF file produced!
It is important to know I have installed on the CentOS system a lot of packages and software:
yum install texlive*
And:
install.packages("devtools")
remotes::install_github('yihui/knitr')
install.packages(c('magick', 'pdftools'))
In R.
Troubleshooting 2
As advised, I installed: tinytex. It succeeded. After that, after running build_site(), I always got prompted for a missing library I had to install. After 30 minutes, I got this message:
> blogdown::build_site()
Rendering content/_index.Rmarkdown
running: bash -c "cd ../..;
find . -not -path '*/exampleSite/*' \\( -name '*.html' -o -name '*.css' \\) | xargs wc -l"
Rendering content/post/2015-07-23-r-rmarkdown.Rmd
hugo: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by hugo)
hugo: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by hugo)
This one I am struggling with unfortunately as libstdc++-4.8.5-36.el7.x86_64 is already installed and I am not sure how to fix GLIBCXX_3.4.20 and GLIBCXX_3.4.21. Trying yum install on them does not work.

I don't know why your TeX Live could not find preview.sty, but I'm pretty sure TinyTeX will work automatically:
# first make sure all your R packages are up-to-date, then
tinytex::install_tinytex()

Related

Running R tikzDevice with tinytex: Help troubleshooting `! LaTeX Error: File `tikz.sty' not found`

I am trying to generate a tikz plot using R/ggplot2 via the tikzDevice package. I've had to wade through many errors as I figured out how to install R and tinytex on my docker image, but I've run into the following error which has simply stumped me.
When I run the code that generates my plot, this is the error I get:
Error in getMetricsFromLatex(TeXMetrics, verbose = verbose) :
TeX was unable to calculate metrics for:
\char77
Run the following commands for diagnosis:
tikzTest()
tikzTest("\\char77")
Common reasons for failure include:
* The string contains a character which is special to LaTeX unless
escaped properly, such as % or $.
* The string makes use of LaTeX commands provided by a package and
the tikzDevice was not told to load the package.
The TeX and log files used for the calculation can help diagnose the
problem. If these files are missing, rerun the plot and make sure to
keep the R session open.
TeX file: tikzStringWidthCalc.tex
Log file: tikzStringWidthCalc.log
Calls: <Anonymous> ... descentDetails.text -> grid.Call -> <Anonymous> -> getMetricsFromLatex
Execution halted
And the output of tikzDevice::tikzTest() is as follows:
Active compiler:
/home/jovyan/.TinyTeX/bin/x86_64-linux/pdflatex
pdfTeX 3.141592653-2.6-1.40.23 (TeX Live 2021)
kpathsea version 6.3.3
Measuring dimensions of: A
Running command: '/home/jovyan/.TinyTeX/bin/x86_64-linux/pdflatex' -interaction=batchmode -halt-on-error -output-directory '/tmp/RtmpLhckyy/tikzDevice29a5e00452e' 'tikzStringWidthCalc.tex'
This is pdfTeX, Version 3.141592653-2.6-1.40.23 (TeX Live 2021) (preloaded format=pdflatex)
restricted \write18 enabled.
entering extended mode
TeX was unable to calculate metrics for:
A
Contents of TeX file tikzStringWidthCalc.tex:
\documentclass[10pt]{article}
\usepackage{tikz}
\usepackage[active,tightpage,psfixbb]{preview}
\PreviewEnvironment{pgfpicture}
\setlength\PreviewBorder{0pt}
\usepackage{tikz}
\usepackage[T1]{fontenc}
\usetikzlibrary{calc}
\batchmode
\begin{document}
\begin{tikzpicture}
\node[inner sep=0pt, outer sep=0pt, scale=1] (TeX) {A};
\path let \p1 = ($(TeX.east) - (TeX.west)$),
\n1 = {veclen(\x1,\y1)} in (TeX.east) -- (TeX.west)
node{ \typeout{tikzTeXWidth=\n1} };
\end{tikzpicture}
\end{document}
Contents of log file tikzStringWidthCalc.log:
This is pdfTeX, Version 3.141592653-2.6-1.40.23 (TeX Live 2021) (preloaded format=pdflatex 2022.3.16) 16 MAR 2022 23:30
entering extended mode
restricted \write18 enabled.
%&-line parsing enabled.
**tikzStringWidthCalc.tex
(/tmp/RtmpLhckyy/tikzDevice29a5e00452e/tikzStringWidthCalc.tex
LaTeX2e <2021-11-15> patch level 1
L3 programming layer <2022-02-24> (/home/jovyan/.TinyTeX/texmf-dist/tex/latex/base/article.cls
Document Class: article 2021/10/04 v1.4n Standard LaTeX document class
(/home/jovyan/.TinyTeX/texmf-dist/tex/latex/base/size10.clo
File: size10.clo 2021/10/04 v1.4n Standard LaTeX file (size option)
)
\c#part=\count185
\c#section=\count186
\c#subsection=\count187
\c#subsubsection=\count188
\c#paragraph=\count189
\c#subparagraph=\count190
\c#figure=\count191
\c#table=\count192
\abovecaptionskip=\skip47
\belowcaptionskip=\skip48
\bibindent=\dimen138
)
! LaTeX Error: File `tikz.sty' not found.
Type X to quit or <RETURN> to proceed,
or enter new name. (Default extension: sty)
Enter file name:
! Emergency stop.
<read *>
l.4 ^^M
Here is how much of TeX's memory you used:
235 strings out of 480236
3181 string characters out of 5895451
287032 words of memory out of 5000000
18278 multiletter control sequences out of 15000+600000
469259 words of font info for 28 fonts, out of 8000000 for 9000
14 hyphenation exceptions out of 8191
34i,0n,38p,138b,36s stack positions out of 5000i,500n,10000p,200000b,80000s
! ==> Fatal error occurred, no output PDF file produced!
As you can see I am using tinytex, but I have installed the recommended packages for this setup as described in the tinytex documentation (i.e., I've already ran tlmgr install pgf preview xcolor).
I've read every post I could possibly find on this subject but am coming up empty. Any tips to help me troubleshoot this problem would be greatly appreciated.
it would help if you had a minimum reproducible example to check on our end.
This said, the message LaTeX Error: File `tikz.sty' not found. suggests that a possible solution would be for you to throw:
library(tinytex)
tlmgr_search('/tikz.sty') # search for tikz.sty
tlmgr_install('pgf') # install the psnfss package
tlmgr_update() # update everything
since tlmgr_search('/tikz.sty') gives you
tlmgr search --file --global "/tikz.sty"
tlmgr.pl: package repository https://ctan.mirror.garr.it/mirrors/ctan/systems/texlive/tlnet
pgf:
texmf-dist/tex/latex/pgf/frontendlayer/tikz.sty
but then you already installed pgf... that's where tikz.sty lives.

Unable to knit pdf, receiving tinytex error with failed tlmgr search

Using
- RStudio Version 1.2.1335
- R version
I am able to knit the R markdown file to HTML and Word, but fail with PDF. I keep receiving the same error message telling me that it is unable to locate the "Palatino" font.
The file is successfully processed (all chunks run).
I have tried re-installing and resetting Miktex and Tinytex, as well as R itself. I am pretty new to this, so I am unsure how to proceed. Should I install TexLive?
This is the header of the file I am trying to run:
--
title: "Assignment 1"
fontsize: 11pt
header-includes: \usepackage{fancyhdr}
geometry: "left=.5in,right=.5in,top=1in,bottom=1in"
output:
pdf_document:
latex_engine: xelatex
md_extensions: +inline_notes
number_sections: no
word_document: default
mathfont: Palatino
monofont: Courier
mainfont: Palatino
sansfont: Helvetica
subtitle: \textbf{Due Wednesday, 11 September 2019 (beginning of class)}
fontfamily: mathpazo
---
And this is the error I continue to receive, without rendering of a PDF file:
output file: PBHLTH252-Assignment-1_post.knit.md
"C:/Program Files/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS PBHLTH252-Assignment-1_post.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash+inline_notes --output PBHLTH252-Assignment-1_post.tex --template "C:\Users\UYser\Documents\R\win-library\3.6\rmarkdown\rmd\latex\default-1.17.0.2.tex" --highlight-style tango --pdf-engine xelatex --variable graphics=yes --lua-filter "C:/Users/UYser/Documents/R/win-library/3.6/rmarkdown/rmd/lua/pagebreak.lua" --variable "compact-title:yes"
tlmgr search --file --global "/Palatino."
! Package fontspec Error: The font "Palatino" cannot be found.
! kpathsea: Running mktextfm Palatino
! The command name is C:\Users\UYser\AppData\Roaming\TinyTeX\bin\win32\mktextfm
! kpathsea: Appending font creation commands to missfont.log.
Error: Failed to compile PBHLTH252-Assignment-1_post.tex. See https://yihui.name/tinytex/r/#debugging for debugging tips. See PBHLTH252-Assignment-1_post.log for more info.
In addition: Warning message:
In parse_packages(logfile, quiet = c(TRUE, FALSE, FALSE)) :
Failed to find a package that contains Palatino.
Execution halted
I tried following this thread, https://github.com/yihui/tinytex/issues/81, with no success:
Running this suggested code
tinytex::tlmgr_search("/Palatino[.](tfm|afm|mf|otf)")
results in:
package repository http://ctan.math.illinois.edu/systems/texlive/tlnet (not verified: gpg unavailable)
Running this one
tinytex::tlmgr_install("multirow")
gives me the following error:
tlmgr install Palatino.
'afm' is not recognized as an internal or external command,
operable program or batch file.
tlmgr update --self
tlmgr.pl: package repository http://ctan.math.illinois.edu/systems/texlive/tlnet (not verified: gpg unavailable)
tlmgr.pl: no self-updates for tlmgr available.
tlmgr install Palatino.
'afm' is not recognized as an internal or external command,
operable program or batch file.
Any help is appreciated!
It looks like you got the template from a Mac user while you are on Windows. The fontnames are different there. Instead of Palatino you could use Palatino Linotype. I am not sure if Helvetica and Courier will work. If not, you could use Arial and Courier New.
However, that sounds like a rather ugly font combination. Palatino is a very fine font, but neither Helvertica/Arial nor Courier (New) fit well. Besides, I don't think that normal Palatino fonts are set-up to be used for math. You could use Asana Math instead, which comes with MikTeX/TinyTeX.
I used to have similar problems. My solution sounds naive (or silly), but it worked perfectly for me. Instead of debugging, in RStudio:
install rticles package
start a new R Markdown file
choose one of journal article templates such as PNAS Journal Article, Springer Journal Article, or Elsevier Journal Article...
knit the template.
Then, it will be trying to automatically install missing LaTeX packages...
You may want to try a few journal templates. It worked for me, and I hope this will solve your problem as well. Enjoy it!

tinytex in r: Font fplmri at 600 not found after tex live 2019 update, how to fix it?

I am using R markdown with tinytex to write my thesis. Some of the templates I'm using has used the mathpazo package. After the Tex Live 2019 update, the tinytex on my computer couldn't use mathpazo: it looks for "/fplmri[.](tfm|afm|mf|otf)", then installs mathpazo, finds out mathpazo is already installed, looks for "/fplmri[.](tfm|afm|mf|otf)" again, and can't find it, then stops.
This problem arises whenever the mathpazo package is used and math symbols are written.
I tried to compare the local mathpazo with the index online, the local copy seems complete to me. I tried to remove mathpazo and reinstall it using tinytex. That did not work either. I tried to use lualatex and xelatex instead of pdfTeX. They did not help/
This is the minimum sample I've written. There's basically nothing except I added mathpazo and wrote a math symbol...
(I have one backtick omitted in the sample below because StackOverflow uses backticks to decide which lines are in the code chunk. I don't know how to keep the backtick for the setup chunk and it still looks good)
---
title: "mini sample"
output: pdf_document
header-includes:
- \usepackage{mathpazo}
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
``
$\epsilon$
The errors messages are as follow
This is pdfTeX, Version 3.14159265-2.6-1.40.20 (TeX Live 2019/W32TeX) (preloaded format=pdflatex)
restricted \write18 enabled.
entering extended mode
name = fplmri, rootname = fplmri, pointsize =
mktexmf: empty or non-existent rootfile!
Cannot find font fplmri in map file(s).
kpathsea: Running mktexmf fplmri.mf
The command name is C:\Users\yangy\AppData\Roaming\TinyTeX\bin\win32\mktexmf
Cannot find fplmri.mf .
I try ps2pk --> gsftopk --> ttf2pk --> hbf2gf.
ps2pk cannot be used.
I try gsftopk.
gsftopk.exe fplmri 600
gsftopk cannot be used.
Next I try ttf2pk.
ttf2pk.exe -q fplmri 600
ttf2pk failed.
Finally I try hbf2gf.
hbf2gf.exe -q -p fplmri 600
All trials failed.
kpathsea: Running mktexpk --mfmode / --bdpi 600 --mag 1+0/600 --dpi 600 fplmri
The command name is C:\Users\yangy\AppData\Roaming\TinyTeX\bin\win32\mktexpk
kpathsea: Appending font creation commands to missfont.log.
tlmgr search --file --global "/fplmri[.](tfm|afm|mf|otf)"
Trying to automatically install missing LaTeX packages...
tlmgr install mathpazo
tlmgr.pl: package repository http://mirror.aarnet.edu.au/pub/CTAN/systems/texlive/tlnet (not verified: gpg unavailable)
tlmgr.pl install: package already present: mathpazo
This is pdfTeX, Version 3.14159265-2.6-1.40.20 (TeX Live 2019/W32TeX) (preloaded format=pdflatex)
restricted \write18 enabled.
entering extended mode
name = fplmri, rootname = fplmri, pointsize =
mktexmf: empty or non-existent rootfile!
Cannot find font fplmri in map file(s).
kpathsea: Running mktexmf fplmri.mf
The command name is C:\Users\yangy\AppData\Roaming\TinyTeX\bin\win32\mktexmf
Cannot find fplmri.mf .
I try ps2pk --> gsftopk --> ttf2pk --> hbf2gf.
ps2pk cannot be used.
I try gsftopk.
gsftopk.exe fplmri 600
gsftopk cannot be used.
Next I try ttf2pk.
ttf2pk.exe -q fplmri 600
ttf2pk failed.
Finally I try hbf2gf.
hbf2gf.exe -q -p fplmri 600
All trials failed.
kpathsea: Running mktexpk --mfmode / --bdpi 600 --mag 1+0/600 --dpi 600 fplmri
The command name is C:\Users\yangy\AppData\Roaming\TinyTeX\bin\win32\mktexpk
kpathse
The last few lines in the log file shows
!pdfTeX error: pdflatex.exe (file fplmri): Font fplmri at 600 not found
Is there anything I can do to fix it?
Just ran into a similar issue I was able to fix with:
install.packages("knitr")
install.packages("rticles")
install.packages("tinytex")
tinytex::reinstall_tinytex()

Failed to compile test.tex after successful TinyTeX installation via tinytex

I am trying to install TinyTeX via the convenient tinytex-package for R.
After having had a few issues with getting the installation to run smoothly on MacOS, the install_tinytex() function now executes properly and ends with the statement:
TinyTeX installed to /Users/X/Library/TinyTeX
However, when trying to execute pdflatex('test.tex') to test the installation, the console instead returns:
Error: Failed to compile test.tex
Apparently the installation did not execute properly. Am I missing something or isn't this supposed to work after a successful TinyTeX installation via tinytex?
The texput.log displays the following error message:
This is pdfTeX, Version 3.14159265-2.6-1.40.19 (TeX Live 2018) (preloaded format=pdflatex 2018.11.2) 2 NOV 2018 14:47
entering extended mode
restricted \write18 enabled.
%&-line parsing enabled.
**test.tex
! Emergency stop.
<*> test.tex
Here is how much of TeX's memory you used: 3 strings out of 494585
99 string characters out of 6174649 51539 words of memory out of
5000000 3743 multiletter control sequences out of 15000+600000 3640
words of font info for 14 fonts, out of 8000000 for 9000 14
hyphenation exceptions out of 8191 0i,0n,0p,1b,6s stack positions out
of 5000i,500n,10000p,200000b,80000s
! ==> Fatal error occurred, no output PDF file produced!
The quoted error message indicates that there is no file test.tex in your current working directory. Either create a sample LaTeX file or use an existing file. If you do not have any LaTeX file available, you can try
pdflatex('sample2e.tex')
This will translate smaple2e.tex, which should be part of every LaTeX distribution.

Waveform file not running under simulation

When I click under the button Run functional Simulation, I see this error:
Determining the location of the ModelSim executable...
Using: C:\altera\13.1\modelsim_ase\win32aloem
To specify a ModelSim executable directory, select: Tools -> Options -> EDA Tool Options
Note: if both ModelSim-Altera and ModelSim executables are available, ModelSim-Altera will be used.
**** Generating the ModelSim Testbench ****
quartus_eda --gen_testbench --check_outputs=on --tool=modelsim_oem --format=verilog ejem_1 -c ejem_1 --vector_source=I:/5 Semestre/Arquitectura Computacional/Ejem_1 - 18-02-15/Waveform1.vwf --testbench_file=I:/5 Semestre/Arquitectura Computacional/Ejem_1 - 18-02-15/simulation/qsim/Waveform1.vwf.vt
Error (23028): Unknown argument "Semestre/Arquitectura". Refer to --help for legal arguments.
Usage:
------
quartus_eda [-h | --help[=] | -v]
quartus_eda []
quartus_eda -t
Error.
This is the directory of ModelSim-Altera.
I'm working with Quartus 13.1 Cyclone III
C:\altera\13.1\modelsim_ase\win32aloem
How can I solve this problem?
Quartus is pretty stupid when it comes to spaces in directory names. Your path has multiple spaces
.../Arquitectura Computacional/Ejem_1 - 18-02-15/...
Try to build your project inside a no space directory path like
C:/altera/projects/my_project

Resources