views:

31

answers:

1

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.

+2  A: 

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?

Norman Gray