# Modifying \title without recursion problem

## EDIT: Much shorter problem definition

Having defined a title by

\title[short]{long}


how can I later add something to the title? The simple assumption

\title[\insertshorttitle]{\inserttitle plus x}


obviously does not work due to recursion. I managed to get a version working using \expandafter with only the full title:

\expandafter\title\expandafter{\inserttitle plus x}


But so far I haven't found out how to also include the short title in this. Also, adding something before \inserttile does not seem to work either, only after inserttitle.

## Original Question:

In our group, we are required to use a given beamer class for presentations. Unfortunately. the vertical placement of the title is bad for titles that use two lines. As we cannot modify the beamer class itself, we use a slightly dirty hack to move the title into an appropriate position with a vspace.

I would like to automate this hack and make it transparent to the other users. So far, I have come up with the following solution that can be included at the beginning of a presentation (as a package for example):

\newlength{\ITI@titleheight}
\newcommand{\ITI@computeheight}{...}
\newcommand{\ITI@titleoffset}{\vspace*{\ITI@titleheight}}


Basically the following happens:

At the beginning of the beamer presentation, the macro \ITI@computeheight is expanded and computes an offset height \ITI@titleheight. I have left out the details of the macro as they are not important. Then, \title is redefined, basically only a \vspace command is added to the previous title.

My current problem is that with the redefinition of the title, the short title gets lost. And I have no clue how to correctly use \expandafter or other commands to make it work.

The following code works when using a predefined short title (1 in this case):

\g@addto@macro\beamer@lastminutepatches{\ITI@computeheight\expandafter\title\expandafter[\expandafter1\expandafter]\expandafter{\expandafter\ITI@titleoffset\inserttitle}}


But when actually using \insertshorttitle, Latex gets into an infinite loop as it wants to expand the new short title over and over again:

\g@addto@macro\beamer@lastminutepatches{\ITI@computeheight\expandafter\title\expandafter[\expandafter\insertshorttitle\expandafter]\expandafter{\expandafter\ITI@titleoffset\inserttitle}}

-

The title is stored in \inserttitle, whereas the shorttitle is saved in \beamer@shorttitle. Thus to redefine these two entities you can directly redefine those commands:

\documentclass{beamer}

\begin{document}

\title[short]{long}
\author{me}
\date{Today}

\def\inserttitle{New title}
\makeatletter
\def\beamer@shorttitle{New short title}
\makeatother

\begin{frame}
\maketitle

Short title is: \insertshorttitle
\end{frame}

\end{document}


If you wish to use the old title definitions in the new ones you can either use \xdef:

\xdef\inserttitle{New title \inserttitle}


or you can save the old title in another macro and use that

\let\oldtitle\inserttitle
\def\inserttitle{New title \oldtitle}

-
Thank you for the answer. But in my case this would not work as the new title is a concatenation of the old title and something else, e.g. \def\inserttitle{new prefix \inserttitle}, And this will cause and infinite recursion in latex. –  shiin Sep 26 '13 at 6:48
Methods to do this now added to answer. –  Andrew Swann Sep 26 '13 at 13:54
Thanks for these methods. I didn't know abotu \xdef. –  shiin Sep 26 '13 at 15:21