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.

In contour package, the macro \con@put is defined as:

\newcommand*\con@put[3]{%
  \rlap{\hskip#1\raisebox{#2}[0pt]{#3}}%
}

But if one changes that \rlap to \llap, then you no longer get contour. For instance, try

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

This is what you get:

enter image description here

Why this does not work? What is the special effect of that \rlap that makes contour? and if one decides to go with \llap instead \rlap in the example above, what changes are required so you still get contour?

share|improve this question
    
\llap would print the box on the wrong side. –  egreg Jul 12 at 15:25
add comment

2 Answers 2

up vote 5 down vote accepted

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.

share|improve this answer
    
pdfrender does not work with xetex. If you are using \pdfliteral primitive of PDFTeX for this, then you can use \special{pdf:code ...} for dvipdfmx driver. –  user56799 Jul 13 at 12:51
add comment

Using Heiko's explanation, the answer to my last question would be:

\documentclass{article}
\usepackage{contour}
\makeatletter
\renewcommand*\con@put[3]{%
  \llap{\raisebox{#2}[0pt]{#3}\hskip-\dimexpr\wd0+#1\relax}%
}
\makeatother
\begin{document}
\setbox0\hbox{but this is.}

\colorbox{black}{This text is not visible
\contour{white}{but this is.}}
\end{document}
share|improve this answer
    
What would be the advantage of so doing? –  egreg Jul 12 at 16:43
    
Did you see this answer? tex.stackexchange.com/a/64759/4427 If you're interested into understanding \rlap and \llap it's very good. –  egreg Jul 12 at 17:03
    
@egreq: I know what \rlap and \llap does. I was just confused because of the strange behavior of e-tex; please see tex.stackexchange.com/questions/191222/… –  user56799 Jul 13 at 3:41
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.