6

Following Outlined characters, you can make selectable outlined text using the contour package. For example, the following writes "Text text text contour text", with "contour" in green with a red outline. It compiles and displays as expected (using pdflatex and lualatex):

\documentclass[12pt]{article}
\usepackage[outline]{contour}
\begin{document}
Text text text \contour{red}{\textcolor{green}{contour}} text.
\end{document}

However, when I try to do the same in a Beamer presentation—

\documentclass{beamer}
\usepackage[outline]{contour}
\begin{document}
\begin{frame}{Example}
Text text text \contour{red}{\textcolor{green}{contour}} text.
\end{frame}
\end{document}

—it fails to compile, with the error

! Use of \\@contour doesn't match its definition.
\beamer@ifnextcharospec #1#2->\def \reserved@a {
                                                #1}\def \reserved@b {#2}\fut...
l.14 \end{frame}

? 

How can I use the outline effect in a Beamer presentation?

9

Prolog

Apparently, beamer redefines \textcolor in a way that makes it fragile.

If you \usepackage{beamerarticle} in your article MWE, you experience the same problems as with beamer.

Long answer

What is the difference between Fragile and Robust commands?

Short answer

Use

  • \contour{<color>}{\protect\textcolor{<color>}{<text>}} or
  • \textcolor{<color>}{\contour{<color>}{<text>}}.

Code

\documentclass{beamer}
\usepackage[outline]{contour}
\begin{document}
\begin{frame}{Example}
Text text text \contour{red}{\protect\textcolor{green}{contour}} text. \\
Text text text \textcolor{green}{\contour{red}{contour}} text.
\end{frame}
\end{document}

Output

Output

| improve this answer | |
  • That does work. Any idea why the error occurs though, and why only with Beamer? – Mechanical snail Oct 20 '12 at 1:28
  • @Mechanicalsnail I've updated my answer which now, hopefully, gives more insight. – Qrrbrbirlbel Oct 20 '12 at 1:38
  • Is there a way to change the contour size? – hkviktor Dec 24 '14 at 20:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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