6

I'm trying to use \MakeUppercase on \insertsectionhead of the beamer class:

\documentclass[]{beamer}
\begin{document}
\section{Section 1}
\begin{frame}{Frame 1}
    \MakeUppercase{\insertsectionhead}
\end{frame}
\end{document}

Unfortunately this example produces an endless series of errors. Any ideas?

  • Try substituting {\MakeUppercase\protect\insertsectionhead} for \MakeUppercase{\insertsectionhead}. – jub0bs May 5 '13 at 7:26
  • Thank you for your answer. This eliminates the errors, but the sectiontext is still not uppercase. – Benjamin May 5 '13 at 8:07
7

You have to expand \insertsectionhead before applying \MakeUppercase:

\documentclass[]{beamer}

\newcommand{\insertsectionHEAD}{%
  \expandafter\insertsectionHEADaux\insertsectionhead}
\newcommand{\insertsectionHEADaux}[3]{#1{#2}{\MakeUppercase{#3}}}

\begin{document}
\section{Section 1}

\begin{frame}{Frame 1}

\insertsectionHEAD

\end{frame}
\end{document}

In your case \insertsectionhead expands to

\hyperlink{Navigation\the\c@page}{Section 1}

so we add before it \insertsectionHEADaux that gets \hyperlink as argument #1, Navigation\the\c@page as #2 and Section 1 as #3, and eventually

\hyperlink{Navigation \the\c@page}{\MakeUppercase{Section 1}}

is executed. In this way the link name is not uppercased.


A different solution is patching the commands responsible for defining \insertsectionhead; this might be better, because it doesn't require different commands in the document.

\documentclass[]{beamer}

\usepackage{etoolbox}
\makeatletter
\patchcmd{\sectionentry}
  {\def\insertsectionhead{#2}}
  {\def\insertsectionhead{\MakeUppercase{#2}}}
  {}{}
\patchcmd{\beamer@section}
  {\def\insertsectionhead{\hyperlink{Navigation\the\c@page}{#1}}}
  {\def\insertsectionhead{\hyperlink{Navigation\the\c@page}{\MakeUppercase{#1}}}}
  {}{}
\makeatother

\begin{document}

\section{Section 1}

\begin{frame}{Frame 1}

\insertsectionhead

\end{frame}
\end{document}
  • Thanks a lot for the solution and the detailed explanation. – Benjamin May 5 '13 at 10:42
  • @Benjamin You're welcome. I added a different solution. – egreg May 5 '13 at 11:04
  • Do you know why your first solution won't work with \insertframetitle? IOW, replace line 4 with \expandafter\insertsectionHEADaux\insertframetitle} and you get many errors. I tried a few combinations of \protect and [fragile], but no luck. TIA! – Leo Dec 9 '13 at 20:40
  • @Leo That probably warrants a different question – egreg Dec 9 '13 at 20:50
  • Thanks @egreg. Here it is: tex.stackexchange.com/questions/149231 – Leo Dec 9 '13 at 21:19
2
\documentclass[]{beamer}
\begin{document}
\section{Section 1}
\begin{frame}{Frame 1}
    \MakeUppercase{\expandafter\protect\insertsectionhead}
\end{frame}
\end{document}

Just a little expansion control. Please note that this does tweak the appearance of the current \insertsection, the stored string it self is still lowercase. And it may break the pdf links.

enter image description here

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.