Understanding what contour package does

Package contour sets the text many times: First the text is set in the specified color several times, slightly moved horizontally and vertically. Then the "inner" part is printed in black. The result is a "contour" in the specified color. Changing the background color makes it a little visible:

\documentclass{article}
\usepackage{contour}
\begin{document}
\colorbox{red}{This text is not visible
\contour{white}{but this is.}}
\end{document}

Result

The default of package contour is to put 16 copies in the specified color first. The star form uses 32 copies, or the number of copies can be specified in the optional argument of \contour.

Changing \rlap to \llap puts the first text prints to the left instead to the right. The final text in black is put to the right, invisible with black background. Again with changed background to red:

\documentclass{article}
\usepackage{contour}
\makeatletter
\renewcommand*\con@put[3]{%
  \llap{\hskip#1\raisebox{#2}[0pt]{#3}}%
}
\makeatother
\begin{document}
\colorbox{red}{This text is not visible
\contour{white}{but this is.}}
\end{document}

Result \llap


Just for fun: An alternative to contour is package pdfrender, which can set the contour using PDF features of vector fonts:

\documentclass{article}
\usepackage{pdfrender}
\usepackage{color}
\begin{document}
\colorbox{black}{This text is not visible
\textpdfrender{
  TextRenderingMode=Stroke,
  StrokeColor=white,
  LineWidth=.25pt,
}{but this is.}}

\colorbox{red}{This text is not visible
\textpdfrender{
  TextRenderingMode=FillStroke,
  FillColor=red,
  StrokeColor=white,
  LineWidth=.25pt,
}{but this is.}}
\end{document}

Result pdfrender

Also package contour can use this PDF feature, if option package option outlines is given. Then \con@put is not used.

Tags:

Contour

Color