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?

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

2 Answers2

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}
egreg
  • 1,121,712
  • Thanks a lot for the solution and the detailed explanation. – Benjamin May 05 '13 at 10:42
  • @Benjamin You're welcome. I added a different solution. – egreg May 05 '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 09 '13 at 20:40
  • @Leo That probably warrants a different question – egreg Dec 09 '13 at 20:50
  • Thanks @egreg. Here it is: http://tex.stackexchange.com/questions/149231 – Leo Dec 09 '13 at 21:19
  • This also works if you're trying to override the color of \insertsectionhead. – EL_DON Apr 23 '18 at 20:17
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

bloodworks
  • 10,178