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.

I have the following beamer presentation:

\documentclass{beamer}
\usepackage{hyperref}

\title{%
\parbox{.25\textwidth}{funny}%
\parbox{.5\textwidth}{Real Title}%
\parbox{.25\textwidth}{stuff}}

\hypersetup{pdftitle={Real Title}}

\begin{document}
Hello, World!
\end{document}

and no matter what I try (removing hyperref and using \pdfinfo, for example), the title always comes out as the entire ASCII portion of the \title, less control sequences:

.25funny.5Real Title.25stuff

Is there no way to absolutely set the title of the PDF using only LaTeX? (I know metadata editors exist, but this could be considered a bug in some lines of thought.)


I should note that the problem is not reproducible in article.

share|improve this question
1  
The problem here is hyperref, it can only handle text. If you create a titlepage in your document, the title looks fine. If you try using your title as a section title in article, the navigation will be messed up as well. I'm not aware of any way to trick hyperref into doing non-text right... –  Anke Apr 19 '13 at 13:45
1  
IMO formatting macros like \parbox should not go into a moving argument such as for \title. If you want to change how the title is shown patch \maketitle. –  Matthew Leingang Apr 19 '13 at 13:51
    
@MatthewLeingang I completely agree, but I don't really know how to 'patch' \maketitle in the same sense I'd 'patch' some listing; there is probably a lot going on in beamer's maketitle, very little of which I would understand at a glance. –  Sean Allred Apr 19 '13 at 14:00
    
@MatthewLeingang that is a really sensible advice. Do you mind if I add it to my answer? (That is, of course, if you're not planning to give an answer.) –  Gonzalo Medina Apr 19 '13 at 14:05
1  
@GonzaloMedina: Sean's right, digging into beamer internals is intimidating, so it's not trivial. I'm toying with an answer now. –  Matthew Leingang Apr 19 '13 at 14:10

2 Answers 2

up vote 7 down vote accepted

You can use \texorpdfstring:

\documentclass{beamer}

\title{%
\texorpdfstring{\parbox{.25\textwidth}{funny}%
\parbox{.5\textwidth}{Real Title}%
\parbox{.25\textwidth}{stuff}}{Real Title}}

\begin{document}
Hello, World!
\end{document}

Since some themes use the title in other places (in the footline, for example), it would alos be a good idea to use the optional argument, so this will be picked up for displaying the title in footlines:

\documentclass{beamer}

\title[Title]{%
\texorpdfstring{\parbox{.25\textwidth}{funny}%
\parbox{.5\textwidth}{Real Title}%
\parbox{.25\textwidth}{stuff}}{Real Title}}

\begin{document}
Hello, World!
\end{document}

By the way, there's no need to load hyperref with beamer.

As Matthew Leingang mentioned in a comment, a more sensible approach would be to make a modification to the way the title is built. In the following example I modified the title page template to insert information using three \parboxes in the title field. The \triplebox command receives three mandatory arguments: the first and third ones will be used for the lateral \parboxes, and the second one will be used for the title; there's also an optional argument that can be used to pass an optional argument to \title:

\documentclass{beamer}

\def\insertfirst{}
\def\insertsecond{}

\makeatletter
\defbeamertemplate*{title page}{mydefault}[1][]
{
  \vbox{}
  \vfill
  \begin{centering}
    \begin{beamercolorbox}[sep=0pt,center,#1]{title}
      \usebeamerfont{title}%
      \parbox{.25\linewidth}{\centering\insertfirst}%
      \parbox{0.5\linewidth}{\centering\inserttitle}%
      \parbox{.25\linewidth}{\centering\insertsecond}\par%
      \ifx\insertsubtitle\@empty%
      \else%
        \vskip0.25em%
        {\usebeamerfont{subtitle}\usebeamercolor[fg]{subtitle}\insertsubtitle\par}%
      \fi%     
    \end{beamercolorbox}%
    \vskip1em\par
    \begin{beamercolorbox}[sep=8pt,center,#1]{author}
      \usebeamerfont{author}\insertauthor
    \end{beamercolorbox}
    \begin{beamercolorbox}[sep=8pt,center,#1]{institute}
      \usebeamerfont{institute}\insertinstitute
    \end{beamercolorbox}
    \begin{beamercolorbox}[sep=8pt,center,#1]{date}
      \usebeamerfont{date}\insertdate
    \end{beamercolorbox}\vskip0.5em
    {\usebeamercolor[fg]{titlegraphic}\inserttitlegraphic\par}
  \end{centering}
  \vfill
}
\makeatother

\newcommand\triplebox[4][]{%
  \gdef\insertfirst{#2}\gdef\insertsecond{#4}\title[]{#3}
}

\triplebox{funny}{Real Title}{stuff}
\author{Author}
\institute{Institute}

\begin{document}

\begin{frame}
\maketitle
\end{frame}

\end{document}

enter image description here

share|improve this answer
    
Thanks for the macro and the tip! (It didn't hit me that beamer already does its own hyperlinking.) –  Sean Allred Apr 19 '13 at 13:57
    
@SeanAllred please see my updated answer. –  Gonzalo Medina Apr 19 '13 at 14:40
    
Good answer. If you look at mine you'll see I took a slightly different route with \addtobeamertemplate. –  Matthew Leingang Apr 19 '13 at 14:47
    
@SeanAllred No. You only use the optional argument if you want to provide an optional argument for \title. –  Gonzalo Medina Apr 19 '13 at 14:51

I guess I'm answering the broader question “How can I alter the display of the title in beamer?”. In my comment I said that I think “the right way” to do this is to alter the formatting macros (i.e., \maketitle) instead of the metadata-declaration macros (i.e., \title).

Here is an example. Explanation follows.

\documentclass{beamer}
\usepackage{etoolbox}
\usetheme{AnnArbor}

\title{Real Title}

\makeatletter
\addtobeamertemplate{title page}{%
    \let\beamerorig@inserttitle\inserttitle%
    \renewcommand{\inserttitle}{%
       \makebox[0.20\textwidth][c]{funny}
       \makebox[0.5 \textwidth][c]{\beamerorig@inserttitle}
       \makebox[0.20\textwidth][c]{stuff}
    }
}{}
\makeatother

\begin{document}
\begin{frame}
\maketitle
Hello, World!
\end{frame}
\end{document}

sample code output

I used the fancy AnnArbor theme so you can see that the display of “Real Title” in the footer isn't affected.

The titling macros (which I found with grep) are found in beamerbasetitle.sty:

\def\maketitle{\ifbeamer@inframe\titlepage\else\frame{\titlepage}\fi}
%...
\def\titlepage{\usebeamertemplate*{title page}\@thanks}

We see that for flexibility \maketitle uses beamer's templating system. The title page template is usually defined in an inner theme. Here is the one from beamerinnerthemedefault.sty (again, found with grep):

\defbeamertemplate*{title page}{default}[1][]
{
  \vbox{}
  \vfill
  \begin{centering}
    \begin{beamercolorbox}[sep=8pt,center,#1]{title}
      \usebeamerfont{title}\inserttitle\par%
      \ifx\insertsubtitle\@empty%
      \else%
        \vskip0.25em%
        {\usebeamerfont{subtitle}\usebeamercolor[fg]{subtitle}\insertsubtitle\par}%
      \fi%     
    \end{beamercolorbox}%
    \vskip1em\par
    \begin{beamercolorbox}[sep=8pt,center,#1]{author}
      \usebeamerfont{author}\insertauthor
    \end{beamercolorbox}
    \begin{beamercolorbox}[sep=8pt,center,#1]{institute}
      \usebeamerfont{institute}\insertinstitute
    \end{beamercolorbox}
    \begin{beamercolorbox}[sep=8pt,center,#1]{date}
      \usebeamerfont{date}\insertdate
    \end{beamercolorbox}\vskip0.5em
    {\usebeamercolor[fg]{titlegraphic}\inserttitlegraphic\par}
  \end{centering}
  \vfill
}

The part that is inside the {beamercolorbox}[...]{title} environment is where the title goes. At this point you have to decide if you want to create a new title page template with \defbeamertemplate, similar to that template but with alterations inside the title beamercolorbox, and invoke it with \usebeamertemplate, or hack the way that \inserttitle displays the title. I chose the latter, because (a) you don't have to know which template is used, and (b) beamer provides commands to locally alter templates.

So my code uses \addtobeamertemplate to preprend to the current title page template (whichever is in use) a patch to the \inserttitle command. However you want the title really displayed should go there.

share|improve this answer

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.