为什么取消注释includegraphics会显示错误失控参数和LaTeX错误:\begin{figure}在输入行131以\end{document}结束错误?

为什么取消注释includegraphics会显示错误失控参数和LaTeX错误:\begin{figure}在输入行131以\end{document}结束错误?

我正在使用官方模板在 Overleaf 上为 MLHC 会议撰写论文。因此,在模板中,当我尝试取消注释给定的图像样本时,它会显示前面提到的错误。即使我将其更改为我的图像,它也会显示相同的错误,并在其下方的每个空白行中显示失控参数 }。如果我注释掉 includegraphics,错误就会消失。我也没有在整个文档中发现任何失控参数。文档类来自 jmlr.cls 文件。

\documentclass[pmlr]{jmlr}% new name PMLR (Proceedings of Machine Learning)

 % The following packages will be automatically loaded:
 % amsmath, amssymb, natbib, graphicx, url, algorithm2e
 \usepackage{booktabs}
 %\usepackage{rotating}% for sideways figures and tables
\usepackage{longtable}% for long tables
 % The booktabs package is used by this sample document
 % (it provides \toprule, \midrule and \bottomrule).
 % 
 % book quality tables

 
 % The siunitx package is used by this sample document
 % to align numbers in a column by their decimal point.
 % Remove the next line if you don't require it.
 %\usepackage[load-configurations=version-1]{siunitx} % newer version
 %\usepackage{siunitx}

\makeatletter
\def\set@curr@file#1{\def\@curr@file{#1}} %temp workaround for 2019 latex release
\makeatother

 % The following command is just for this sample document:
\newcommand{\cs}[1]{\texttt{\char`\\#1}}

 % Define an unnumbered theorem just for this sample document:
\theorembodyfont{\upshape}
\theoremheaderfont{\scshape}
\theorempostheader{:}
\theoremsep{\newline}
\newtheorem*{note}{Note}

 % change the arguments, as appropriate, in the following:
\jmlrvolume{[VOLUME \# TBD]}
\jmlryear{2024}
\jmlrworkshop{Machine Learning for Healthcare}
\begin{document}
 %other sections and subsections
    \begin{figure}[t]
      \centering 
      % \includegraphics[width=2.5in]{images/plot.png} 
      \caption{Description with the main takeaway point. Note that figure captions should appear below the figure.}
      \label{fig:example} 
    \end{figure} 
\end{document}

这是日志中的第一个错误。第 221 行有一个空白行。因此,如果我删除它,它将在下一个空白行中显示错误。

images/plot.png \edef \Gin@ext {\Gin@sepdefault \filename@ext }\ifx \Gin@ext \ETC.
! Paragraph ended before \@tempa was complete.
<to be read again> 
                   \par 
l.221 
      
I suspect you've forgotten a `}', causing me to apply this
control sequence to too much text. How can we recover?
My plan is to forget the whole thing and hope for the best.

答案1

我将图像更改为example-image.png通常可用于这些测试的图像,并得到了您显示的错误。

注释掉此行

\def\set@curr@file#1{\def\@curr@file{#1}}

修复了这个问题。最好不要重新定义核心 latex 命令,尤其是使用,\def这样你就不会收到警告。

\documentclass[pmlr]{jmlr}% new name PMLR (Proceedings of Machine Learning)

 % The following packages will be automatically loaded:
 % amsmath, amssymb, natbib, graphicx, url, algorithm2e
 \usepackage{booktabs}
 %\usepackage{rotating}% for sideways figures and tables
\usepackage{longtable}% for long tables
 % The booktabs package is used by this sample document
 % (it provides \toprule, \midrule and \bottomrule).
 % 
 % book quality tables

 
 % The siunitx package is used by this sample document
 % to align numbers in a column by their decimal point.
 % Remove the next line if you don't require it.
 %\usepackage[load-configurations=version-1]{siunitx} % newer version
 %\usepackage{siunitx}

\makeatletter
%NO!!!!!!!!!!!!\def\set@curr@file#1{\def\@curr@file{#1}} %temp workaround for 2019 latex release
\makeatother

 % The following command is just for this sample document:
\newcommand{\cs}[1]{\texttt{\char`\\#1}}

 % Define an unnumbered theorem just for this sample document:
\theorembodyfont{\upshape}
\theoremheaderfont{\scshape}
\theorempostheader{:}
\theoremsep{\newline}
\newtheorem*{note}{Note}

 % change the arguments, as appropriate, in the following:
\jmlrvolume{[VOLUME \# TBD]}
\jmlryear{2024}
\jmlrworkshop{Machine Learning for Healthcare}
\begin{document}
 %other sections and subsections
    \begin{figure}[t]
      \centering 
      \includegraphics[width=2.5in]{example-image.png} 
      \caption{Description with the main takeaway point. Note that figure captions should appear below the figure.}
      \label{fig:example} 
    \end{figure} 
\end{document}

相关内容