开发者

LaTeX - Using hyperref & \ref - Special characters in reference name?

I'm making a LaTeX PDF document and using the hyperref package and \ref to make references to section & subsections later in the document. Some of my (sub)section references have an underscore (_) in them, so I have escaped them (i.e. put in \_), however when I run pdflatex on it I get the following error:

! Missing \endcsname inserted.
<to be read again> 
                   \relax 
l.169 \ref{ some stuff \(60 sec\)\_aaa } }
                                           &  01:00  & . & . \\

If I take away the \ I get the same error. I have to take away the underscore _ to make the problem go away. From this I deduce that you can't have underscores in a \ref in LaTeX. Is there some way to allow me to have underscores? Is there any list of what you can and cannot have in a 开发者_开发知识库ref?

UPDATE: Turned out it was a bug in my code.


There's no problem including underscores in labels, with or without hyperref.

\documentclass{article}
\usepackage{hyperref}
\begin{document}
\section{first}
\label{section_one}
Hello.

This is section~\ref{section_one}.
\end{document}

Can you update your question to show a minimal document which illustrates the problem you're having?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜