\documentclass{beamer}
\begin{document}
\begin{frame}
\frametitle{Contents}
\tableofcontents
\end{frame}
\section[Sec. A]{Section A}
\subsection{SubSec a}
\begin{frame}
\frametitle{\insertsection: \insertsubsection}
\end{frame}
\subsection{SubSec b}
\begin{frame}
\frametitle{\insertsection: \insertsubsection}
\end{frame}
\section[Sec. B]{Section B}
\subsection{SubSec a}
\begin{frame}
\frametitle{\insertsection: \insertsubsection}
\end{frame}
\subsection{SubSec b}
\begin{frame}
\frametitle{\insertsection: \insertsubsection}
\end{frame}
\end{document}
- I often use
\frametitle{\insertsection: \insertsubsection}(or similar) to automatically generate frame titles inbeamer. - Sometimes I would like to use the short version of the title, such as in
\section[Sec. A]{Section A}-->\insertshortsection(= Sec. A) which is not available (see also here).
Is there an easy way to access the short version of section and friends? With "easy" I mean that the solution does not have many side effects.
Probably Related
Solution
\documentclass{beamer}
\let\oldsection\section
\makeatletter
\def\section{%
\@ifstar{\@Starred}{\@nonStarred}%
}
\def\@Starred{%
\@ifnextchar[%
{\GenericWarning{}{Warning: A starred section can not have parameters. I am going to ignore them!}\@StarredWith}%
{\@StarredWithout}%
}
\def\@StarredWith[#1]#2{%
\xdef\myshortsec{#1}
\oldsection*{#2}%
}
\def\@StarredWithout#1{
\xdef\myshortsec{#1}
\oldsection*{#1}%
}
\def\@nonStarred{%
\@ifnextchar[%
{\@nonStarredWith}%
{\@nonStarredWithout}%
}
\def\@nonStarredWith[#1]#2{%
\xdef\myshortsec{#1}
\oldsection[#1]{#2}%
}
\def\@nonStarredWithout#1{%
\xdef\myshortsec{#1}
\oldsection{#1}%
}
\makeatother
\begin{document}
\begin{frame}
\frametitle{Contents}
\tableofcontents
\end{frame}
\section[Sec. A]{Section A}
\subsection{SubSec a}
\begin{frame}
\frametitle{\insertsection\ \texttt{(long)}: \myshortsec\ \texttt{(short)}: \insertsubsection}
\end{frame}
\subsection{SubSec b}
\begin{frame}
\frametitle{\insertsection\ \texttt{(long)}: \myshortsec\ \texttt{(short)}: \insertsubsection}
\end{frame}
\end{document}


\namerefrelated approach -- this requires labels, however – Feb 26 '18 at 21:42