在我将MikTex更新到最新版本之后,我的Rmd文件就不再编译了。我安装了几次tinytex,重新安装miktex,R和RStudio。我在一个tex文档中使用了一些新命令,如\C、\G等,这些命令都包含在我的Rmd文件中。我使用windows 10,最新版本的R,RStudio和Miktex。
我还请一位同事(没有编译问题)更新他的MikTex。在更新了他的MikTex之后,他也遇到了同样的问题。
这里是Rmd代码:
---
documentclass: scrartcl
fontsize: 11pt
output:
pdf_document:
includes:
in_header: commands.tex
---
This is an example:
\begin{itemize}
\item hello
\item world
\end{itemize}这是tex代码:
\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}}我得到了:
处理文件: example1.Rmd |......................................................................| 100%普通文本而没有R代码
"C:/Program /RStudio/bin/pandoc/pandoc“+RTS -K512m -RTS example1.utf8.md --从"C:\Users\saski\Documents\R\win-library\4.0\rmarkdown\rmarkdown\lua\latex-div.到-K512m--输出实例1.tex- latex "C:\Users\saski\Documents\R\win-library\4.0\rmarkdown\rmarkdown\lua\pagebreak.lua”-latex“C:\Users\saski\Documents\R\win-library\4.0\rmarkdown\rmarkdown\lua\latex-div.lua“??自带??高亮风格的探戈-pdf引擎pdflatex -包括在头中的commands.tex -变量图形输出文件: example1.knit.md。
好了!LaTeX错误:命令\C未定义。
Fehler: LaTeX未能编译example1.tex。有关调试技巧,请参见https://yihui.org/tinytex/r/#debugging。有关更多信息,请参见example1.log。奥斯夫·赫隆
发布于 2021-04-19 14:46:53
最好的解决方案是避免使用一个字母宏名。
您的代码不再工作,因为\C现在只在某些情况下由hyperref定义,有关更多信息,请参见https://tex.stackexchange.com/questions/582625/command-c-already-defined-and-the-hyperref-package/582630#582630。
如果您使用\newcommand而不是\renewcommand,您可以看到错误消失了。
% simple letters
\newcommand{\A}{{\mathbb A}}
\newcommand{\B}{{\mathbb B}}
\newcommand{\C}{{\mathbb C}}
\newcommand{\D}{{\mathbb D}}
\newcommand{\E}{{\mathbb E}}(但您仍然不应该这样做,如果一个字母名,则使用其他宏名称)
结论:不要使用一个字母宏名称
https://stackoverflow.com/questions/67163580
复制相似问题