我正在尝试编译以下代码,该代码末尾包含一个传记,以便
\newif\iffinal
\finaltrue
%\finalfalse
\iffinal
\documentclass[]{IEEEtran} %
\else
\documentclass[11pt,onecolumn,draftcls]{IEEEtran} %
\fi
\usepackage[ruled,vlined,linesnumbered]{algorithm2e}
\usepackage{ifpdf}
\ifpdf
\usepackage[]{graphicx}
\else
\usepackage[draft]{graphicx}
\fi
\SetKw{return}{return}
\SetKw{throw}{throw}
\SetKw{event}{event}
\SetKw{break}{break}
\begin{document}
......
\begin{IEEEbiography}{Name}
received his B.S degree from.......
\end{IEEEbiography}
\end{document}
我一直收到错误
use of \\ieeebiography doesnt match its definition.
Argument of \@break has an extra }
Runaway argument?
Extra }, or forgotten \endgroup.
尝试了很多次之后,我意识到导致此问题的原因是 \SetKw{break}{break}
我在算法中使用了关键字。
我怎样才能定义这个词break
而不引起这个问题?
答案1
重现该问题的一个最小示例是
\documentclass{IEEEtran}
\usepackage{graphicx}
\usepackage{duckuments}
\usepackage{algorithm2e}
\SetKw{break}{break}
\begin{document}
\begin{algorithm}
\While{condition}{%
\break
}
\end{algorithm}
\begin{IEEEbiography}[{\includegraphics[width=1in,height=1.25in,clip,keepaspectratio]{example-image-duck}}]{Prof.\ van Duck}
Prof.\ van Duck is an esteemed scientist at the University of Quackland.
\end{IEEEbiography}
\end{document}
问题是\SetKw{break}{break}
重新定义了在as\break
中定义的内容,但没有进一步的警告。latex.ltx
\def\break{\penalty-\@M}
algorithm2e
文档在§11中简要提到了这一点。
环境IEEEbiography
使用\break
,但由于它已被重新定义为完全不同的含义,因此该命令现在会导致错误。
一个简单的解决方案是选择一个不同的命令名称作为中断指令algorithm2e
\documentclass{IEEEtran}
\usepackage{graphicx}
\usepackage{duckuments}
\usepackage{algorithm2e}
\SetKw{algobreak}{break}
\begin{document}
\begin{algorithm}
\While{condition}{%
\algobreak
}
\end{algorithm}
\begin{IEEEbiography}[{\includegraphics[width=1in,height=1.25in,clip,keepaspectratio]{example-image-duck}}]{Prof.\ van Duck}
Prof.\ van Duck is an esteemed scientist at the University of Quackland.
\end{IEEEbiography}
\end{document}