Sa So
Sa So

Reputation: 11

LearnR Rmd knit to pdf failed to compile after update of MikTex

After I updated MikTex to the latest version, my Rmd files don't compile anymore. I installed tinytex, reinstalled miktex, R and RStudio several times. I use some newcommands like \C, \G etc. in a tex document which I include in my Rmd file. I use windows 10, the latest versions of R, RStudio and Miktex.

I asked a colleague (who had no compiling issues) to update his MikTex as well. After updating his MikTex, he had the same issue.

Here is the Rmd code:

---
documentclass: scrartcl
fontsize: 11pt
output:
    pdf_document:
        includes:
            in_header: commands.tex

---

This is an example:

\begin{itemize}
    \item hello
    \item world
\end{itemize}

And here is the tex code:

\usepackage[utf8]{inputenc}             
\usepackage{amsmath}                    
\usepackage{amssymb}                    
\usepackage{icomma}                     
\usepackage[right,official]{eurosym}    
\usepackage{hyperref}                   
\usepackage{booktabs}                   
\usepackage{graphicx}                   
\usepackage[shortlabels]{enumitem}      
\usepackage{setspace}
\singlespacing
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Seitenformat und Layoutparameter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\hbadness=1000
\tolerance=10000
\voffset-2.80cm
\hoffset-2.60cm
\topmargin1.50cm
\headheight0.65cm
\headsep1.0cm
\topskip0cm
\textheight24.00cm
\footskip1.5cm
\footnotesep11pt
\evensidemargin2.50cm
\oddsidemargin2.50cm
\textwidth16cm
%\parindent0cm
%\parskip1.5ex plus0.5ex minus 0.5ex

% simple letters
\newcommand{\A}{{\mathbb A}}
\newcommand{\B}{{\mathbb B}}
\renewcommand{\C}{{\mathbb C}}
\newcommand{\D}{{\mathbb D}}
\newcommand{\E}{{\mathbb E}}

And I get:

processing file: example1.Rmd |......................................................................| 100% ordinary text without R code

"C:/Program Files/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS example1.utf8.md --to latex --from markdown+autolink_bare_uris+tex_math_single_backslash --output example1.tex --lua-filter "C:\Users\saski\Documents\R\win-library\4.0\rmarkdown\rmarkdown\lua\pagebreak.lua" --lua-filter "C:\Users\saski\Documents\R\win-library\4.0\rmarkdown\rmarkdown\lua\latex-div.lua" --self-contained --highlight-style tango --pdf-engine pdflatex --include-in-header commands.tex --variable graphics output file: example1.knit.md

! LaTeX Error: Command \C undefined.

Fehler: LaTeX failed to compile example1.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See example1.log for more info. Ausführung angehalten

Upvotes: 1

Views: 316

Answers (1)

The best solution would be to avoid one letter macro names


your code no longer works because \C is now only defined by hyperref under certain circumstances, see https://tex.stackexchange.com/questions/582625/command-c-already-defined-and-the-hyperref-package/582630#582630 for more information

If you use \newcommand instead of \renewcommand you can see that the error vanishes

% simple letters
\newcommand{\A}{{\mathbb A}}
\newcommand{\B}{{\mathbb B}}
\newcommand{\C}{{\mathbb C}}
\newcommand{\D}{{\mathbb D}}
\newcommand{\E}{{\mathbb E}}

(but you should still not do that, use some other macro names instead if the one letter names)


Conclusion: don't use one letter macro names

Upvotes: 0

Related Questions