Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}}
\g@addto@macro\beamer@lastminutepatches{\ITI@computeheight\expandafter\title\expandafter{\expandafter\ITI@titleoffset\inserttitle}}

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}}
share|improve this question
add comment

1 Answer 1

up vote 2 down vote accepted

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:

Sample output

\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}
share|improve this answer
    
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.