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 am getting an error when I try to use \color{} in the the author field with beamer, even though the file compiles and I get the the words I want coloured in the author field.

This is the error description:

ERROR: Argument of \beamer@stripands has an extra }.

--- TeX said --- \par l.8 ...\ \small \vspace{1cm} \color{viv} My name}

--- HELP --- From the .log file...

I've run across a }' that doesn't seem to match anything. For example,\def\a#1{...}' and \a}' would produce this error. If you simply proceed now, the\par' that I've just inserted will cause me to report a runaway argument that might be the root of the problem. But if your }' was spurious, just type2' and it will go away.

My MWE:

\documentclass{beamer}

\usepackage{color}
\definecolor{viv}{RGB}{255,109,254}
\title[]{\Large Credit and Banking in a DSGE Model\\ of the Euro Area} 
\author[]{\Large Gerali, Neri, Sessa and Signoretti (2010) \\ \small \vspace{1cm} \color{viv} My name}

\begin{document}    
\begin{frame}
  \titlepage
\end{frame}  
\end{document}

This MWE compiles and gives me the words "My name" coloured as desired. If I get rid of \color{viv} I no longer get the error message, but then, I don't get the colouring as I wish.

Does anyone know why I am getting this error message and how I can fix it?

share|improve this question
add comment

1 Answer

up vote 12 down vote accepted

This is a classic instance of needing \texorpdfstring, since the material you put in these metadata fields will also be made into PDF bookmarks, which can't have formatting like color. Here is a fix for you:

\documentclass{beamer}

\usepackage{color}
\definecolor{viv}{RGB}{255,109,254}
\title[]{\Large Credit and Banking in a DSGE Model\\ of the Euro Area} 
\author[]{\Large Gerali, Neri, Sessa and Signoretti(2010)\texorpdfstring{\\ \small \vspace{1cm} \color{viv}}{ }My name}

\begin{document}    
\begin{frame}
  \titlepage
\end{frame}  
\end{document}

(\texorpdfstring presents two alternatives, the first to be put in the TeX source, the second to be put in the PDF metadata)

share|improve this answer
1  
I think the use of \textcolor here is also better, since beamer treats \color differently than it does \textcolor. To see this, use \show\color and \show\textcolor. –  Werner Feb 27 '12 at 6:05
    
@Werner I am not sure how to use \textcolor here, since if I just substitute \color{viv} by \textcolor{viv} only the first letter of "My name" will be coloured. Can you give me the full line example using \textcolor? And I also don't understand why \textcolor is better... –  Vivi Feb 27 '12 at 6:11
2  
@Vivi: You need to use \textcolor{viv}{My name}. \textcolor takes two arguments. If you don't supply the second argument, then the first character of the next token is taken as the argument. If you use \textcolor rather than \color, your MWE compiles with only warnings and no error. That led me to look at the definitions of both \color and \textcolor. The former seems to pass through a beamer "inspection", while the latter does not. So, that's why I say using \textcolor seems to be an unaltered use, and therefore perhaps preferred. –  Werner Feb 27 '12 at 6:15
    
@Werner I could swear I had tried to use \textcolor{viv}{My name} before asking this question! I was confused now with the use of \textcolor because in the example Ryan gave "My name" was put outside of \texorpdfstring{}{}, but if using \textcolor it would have to be inside \texorpdfstring{}{}. I just tried though and it doesn't seem to matter whether "My name" goes inside or outside \texorpdfstring. Thanks for pointing out about \textcolor :) –  Vivi Feb 27 '12 at 6:24
2  
@Vivi: Ryan's answer puts the TeX expression inside the "conditional" \texorpdfstring. This means that the colour change is decided upon conditionally, and affects everything after it - in your case, "My name". If you were to use \textcolor, you would have "My name" in both parts of \texorpdfstring. As in \texorpdfstring{\textcolor{viv}{My name}}{My name}. –  Werner Feb 27 '12 at 6:29
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.