8

I found when I use the article class and hyperref package, the % can be printed by \href{url}{text}but things changes when I use beamer, for example

% Works fine
\documentclass{article}
\usepackage{hyperref}
\begin{document}
  \href{www.google.com}{google}
  \href{http://www.google.com%some site}{google}
 \end{document}

and

% Doesn't work
\documentclass{beamer}
\begin{document}
\begin{frame}{test page}
  \href{www.google.com}{google}
  \href{http://www.google.com%some site}{google}
\end{frame}
\end{document} 

How can I include the % in the url link? Thanks a lot.

  • 1
    doesn't escaping (\%) work? – chan1142 Oct 15 '16 at 2:39
  • 1
    Thanks. \% works. But I want to know why it failed in beamer. – Ice0cean Oct 15 '16 at 3:20
9

In order to do its work, beamer has to absorb a frame environment's contents at once. This has the consequence that \href cannot perform its duty of changing the nature of %, because when the contents is absorbed, TeX does not interpret commands and % is still the comment character.

You have two ways to go around the issue:

  • escape % into \%

  • use \begin{frame}[fragile], that's recommended whenever the frame contains verbatim material.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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