在标签中包含 &

在标签中包含 &

以下是一个 MWE,用于说明我在尝试在标签中包含 & 时遇到的问题。有什么想法可以解决这个问题吗?

\documentclass[14pt,a4paper]{extreport}
\usepackage[latin9]{inputenc}

\newcounter{SlideCounter}
\newcommand{\slide}[1]{%
\stepcounter{SlideCounter}%
\paragraph{\newline Slide \arabic{SlideCounter}) #1}
\paragraph{\newline}}

\begin{document}
I have a document in which I refer to numbered `slides' and I want to label 
the slides to help navigate the document in TeXstudio. TeXstudio has a
document structure window which shows the labels. However, if I include
\& in the label, as in:

\begin{verbatim}
\label{Alvarado Rudy \& design and procedure}
\end{verbatim} 

I get the message: \\

\begin{verbatim}
! Missing \endcsname inserted.
<to be read again> 
\&
l.3 ...varado \& Rudy design and procedure}{{}{1}}

The control sequence marked <to be read again> should
not appear between \csname and \endcsname.

LaTeX Warning: Label(s) may have changed. Rerun to get cross-references right.
\end{verbatim}

\slide{Alvarado \& Rudy design and procedure}
\label{Alvarado Rudy design and procedure}

\slide{Next Slide}
\label{Next Slide}
\end{document}

答案1

好的,来自的评论莱安德里斯帮我解决了这个问题。单独使用“&”而不是“\&”就可以了。我之前确实尝试过,但还是出现了同样的错误,直到看到上面的评论后,我尝试清除辅助文件,但由于某种原因该文件没有更新。

相关内容