josephwright / beamer

A LaTeX class for producing presentations and slides
Other
1.41k stars 142 forks source link

Problems with hyperlinks from wikipedia in beamer, but article is ok #821

Closed ouboub closed 1 year ago

ouboub commented 1 year ago

Hi I copied a link from my browser into a document in article mode:

\documentclass[12pt]{article}
\usepackage{xcolor}
\usepackage[colorlinks]{hyperref}
\makeatletter
\Hy@AtBeginDocument{%
  \def\@pdfborder{0 0 1}% Overrides border definition set with colorlinks=true
  \def\@pdfborderstyle{/S/U/W 1}% Overrides border style set with colorlinks=true
                                % Hyperlink border style will be underline of width 1pt
}
\makeatother
\hypersetup{%
  colorlinks=true,% hyperlinks will be coloured
  linkcolor=blue,% hyperlink text will be blue
  urlcolor=blue,% hyperlink text will be blue
  linkbordercolor=red,% hyperlink border will be red
  urlbordercolor=red,% hyperlink border will be red
}
\begin{document}
\href{https://es.wikipedia.org/wiki/M%C3%A9todo_de_Cardano}{Método  de Cardano (wikipedia)}
\end{document}

and it works fine, however when I try to use the same link in beamer (using pdflatex/xelatex)

\documentclass{beamer}
\usepackage{xcolor}
\usepackage[colorlinks]{hyperref}
\makeatletter
\Hy@AtBeginDocument{%
  \def\@pdfborder{0 0 1}% Overrides border definition set with colorlinks=true
  \def\@pdfborderstyle{/S/U/W 1}% Overrides border style set with colorlinks=true
                                % Hyperlink border style will be underline of width 1pt
}
\makeatother
\hypersetup{%
  colorlinks=true,% hyperlinks will be coloured
  linkcolor=blue,% hyperlink text will be blue
  urlcolor=blue,% hyperlink text will be blue
  linkbordercolor=red,% hyperlink border will be red
  urlbordercolor=red,% hyperlink border will be red
}
\begin{document}
\begin{frame}
  \frametitle{Wikipedia}
\href{https://es.wikipedia.org/wiki/M%C3%A9todo_de_Cardano}{Método  de Cardano (wikipedia)}
\end{frame}

\end{document}

compilation fails (the hyperref options do no matter, even without them compilation fails with the error

 Runaway argument?
\frametitle {Wikipedia} \href {https://es.wikipedia.org/wiki/M\end {f\ETC.
! File ended while scanning use of \frame.
<inserted text> 
                \par 
<*> wikipedia-beamer.tex

! Emergency stop.
<*> wikipedia-beamer.tex

No pages of output.
Transcript written on build//wikipedia-beamer.log.

TeX Output exited abnormally with code 1 at Tue Jan 10 10:53:21

any ideas?

samcarter commented 1 year ago
\documentclass{beamer}
%\usepackage{xcolor}
%\usepackage[colorlinks]{hyperref}
\makeatletter
\Hy@AtBeginDocument{%
  \def\@pdfborder{0 0 1}% Overrides border definition set with colorlinks=true
  \def\@pdfborderstyle{/S/U/W 1}% Overrides border style set with colorlinks=true
                                % Hyperlink border style will be underline of width 1pt
}
\makeatother
\hypersetup{%
  colorlinks=true,% hyperlinks will be coloured
  linkcolor=blue,% hyperlink text will be blue
  urlcolor=blue,% hyperlink text will be blue
  linkbordercolor=red,% hyperlink border will be red
  urlbordercolor=red,% hyperlink border will be red
}
\begin{document}
\begin{frame}[fragile]
  \frametitle{Wikipedia}
\href{https://es.wikipedia.org/wiki/M%C3%A9todo_de_Cardano}{Método  de Cardano (wikipedia)}
\end{frame}

\end{document}
ouboub commented 1 year ago

thanks!