# How to use color declarations in titles?

How can I use color declarations when setting the title of a document?

I tried

\title{\color{blue} Colors in typesetting}


but I get an error from LaTeX.

Update: The error reads as followed:

doc.tex:89: Argument of \reserved@a has an extra }.
<inserted text>
\par
l.89 \begin{document}


Can I define a declaration or an environment which works inside \title? Or is there a way to enhance the definition of \title to accommodate declarations?

Update 2: To give more context, the base class pandoc uses here is beamer, but it draws in a lot of packages. (beamer itself behaves correct as the standard classes.)

Note: For technical reasons(*) I do not want to use

\title{\textcolor{blue}{Colors in typesetting}}


so, as stated above, it must be a color declaration.

(*) I really use pandoc to generate the TeX document from markdown and parameter-taking commands like \command{text} will skip "text" if I convert the markdown document to any other output format.

• An open \color{blue} statement is 'dangerous'. Bleeding blue colour in to the rest of the document is avoided here due to grouping. – user31729 May 27 '15 at 5:02
• Which error message do you get? The solution that @jak123 suggests should be equivalent to \title{\color{blue}{My Title}} (I would rather say \title{{\color{blue}My Title}}, though). Unfortunately, I'm away from my desktop, now, so I cannot check with a compiler. – GuM May 27 '15 at 5:09
• @GustavoMezzetti See my updates to the question. – halloleo May 27 '15 at 5:13
• You need to give a minimal working example . With any class that I have tried, including beamer, using \title{\color{blue}...} works fine. – Andrew May 27 '15 at 6:07
• With the KOMA-classes, you can set font attributes and coloring to a special variable. The title-field really should only contain the title, nothing more. – Johannes_B Jun 16 '15 at 14:51

I'm sure there is a package for that, but here is a solution based on redefining the maketitle command (for the article class).

Create a style file (I saved as titlecolor.sty) with the following content (I copied this from the book.cls file and add the \color command to the title, you can change the format):

 \renewcommand\maketitle{\begin{titlepage}%
\let\footnotesize\small
\let\footnoterule\relax
\let \footnote \thanks
\null\vfil
\vskip 60\p@
\begin{center}%
{\LARGE \color{blue}{\@title} \par}%
\vskip 3em%
{\large
\lineskip .75em%
\begin{tabular}[t]{c}%
\@author
\end{tabular}\par}%
\vskip 1.5em%
{\large \@date \par}%       % Set date in \large size.
\end{center}\par
\@thanks
\vfil\null
\end{titlepage}%
\setcounter{footnote}{0}%
\global\let\thanks\relax
\global\let\maketitle\relax
\global\let\@thanks\@empty
\global\let\@author\@empty
\global\let\@date\@empty
\global\let\@title\@empty
\global\let\title\relax
\global\let\author\relax
\global\let\date\relax
\global\let\and\relax
}


Put \usepackage{titlecolor} in your document:

\documentclass{article}
\usepackage{xcolor} % You need this also of course
\usepackage{titlecolor}

\title{My title in Blue}

\begin{document}
\maketitle

Text....
\end{document}


Now you will get a coloured title.

• Well, I'm curious whether there is a package to make declarations possible in titles... – halloleo May 27 '15 at 4:45
• Of course, this patch to \maketitle forces a separate title page even if the notitlepage option has been specified. – GuM May 27 '15 at 5:00
• @GustavoMezzetti I have no clue if it would. But it is just a redefinition of a class command, why would it behave differently than the original one? – jak123 May 27 '15 at 6:27

For standard classes there's the titling package.

After the edit to the question, the class used here is beamer. In this case, the answer is really simple since beamer provides an easy way to change the color attributes for the title:

\documentclass{beamer}

\setbeamercolor{title}{fg=red,bg=blue}
\title{The Title}

\begin{document}

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

\end{document}


The result:

In

\setbeamercolor{title}{fg=red,bg=blue}


fg stands for foreground and bg for background. In my example I changed both for illustration purposes, but ou can change only one of them.