Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have a strange effect, when I want to typeset a URI inside a tabular in a frame.

Example:

\documentclass[10pt]{beamer}
\usepackage{hyperref}
\begin{document}

\begin{frame}
\href{http://www.mysite.de/xxx}{page 1} --
\href{http://www.mysite.de/xxx&}{page 1}
\end{frame}

\begin{frame}
\begin{tabular}{l}
\href{http://www.mysite.de/xxx}{url without \&} %ok
\end{tabular}
\end{frame}

%Error
\begin{frame}%[fragile]
\begin{tabular}{l}
\href{http://www.mysite.de/xxx&}{url with \&}   %! Argument of \href@split has an extra }.
\end{tabular}
\end{frame}

 \end{document}

When I translate the document, I get the error

! Argument of \href@split has an extra }.
<inserted text> 
                \par 
l.21     \end{frame}

I have no problem with \href in a frame (see first frame), I have no problem with \href inside a tabular (see 2nd frame), but I have a problem if \href contains a & and it is part of a tabular.

The example works fine, if the frame gets a fragile flag. I understand, why I need the fragile flag, if I use verbatim text, but why is the fragile flag needed, if there is a combination of tabular and href-content?

Is there a way to avoid the fragile-flag in this situations?

share|improve this question
3  
You said it: the treatment of URLs by \href is very similar to verbatim mode. –  egreg Jul 9 '12 at 10:18
add comment

1 Answer 1

up vote 2 down vote accepted

The solution is to "hide" the & from the tabular environment by closing the \href into brackets:

\documentclass[10pt]{beamer}
\begin{document}

\begin{frame}
\href{http://www.mysite.de/xxx}{page 1} --
\href{http://www.mysite.de/xxx&}{page 1}
\end{frame}

\begin{frame}
\begin{tabular}{l}
\href{http://www.mysite.de/xxx}{url without \&}
\end{tabular}
\end{frame}

%Error
\begin{frame}%[fragile]
\begin{tabular}{l}
{\href{http://www.mysite.de/xxx&}{url with \&}}
\end{tabular}
\end{frame}

\end{document}

Note: beamer loads hyperref as default, you do not need to load it yourself.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.