5

I'm trying to get more white halo around text. I'm using tikz and contour package. I know that I should use \contournumber{X} to change the numbers of copies. But I can't figure out how to use the command.

\documentclass{standalone}
\usepackage{tikz}
\usepackage{contour}

\begin{document}
    \begin{tikzpicture}
    \filldraw[fill=blue!40!white, draw=black] (-5,-5) rectangle (5,5);
    \draw (0, 0) node[]     {\contour{white} {I CAN FEEL YOUR HALO HALO HALO!!}};
    \end{tikzpicture}
\end{document}

%   \contournumber{64}

1 Answer 1

6

The number of copies does not make the white halo larger, but smoother. The larger white area can be achieved by increasing the contour length. The following example sets both:

\documentclass{standalone}
\usepackage{tikz}
\usepackage{contour}
\contournumber{64}% default is 16, star form uses 32
\contourlength{.06em}% default is 0.03em

\begin{document}
    \begin{tikzpicture}
    \filldraw[fill=blue!40!white, draw=black] (-5,-5) rectangle (5,5);
    \draw (0, 0) node[] {\contour{white} {I CAN FEEL YOUR HALO HALO HALO!!}};
    \end{tikzpicture}
\end{document}

Result contour

Implementation via package pdfrender that uses a PDF feature for vector fonts. Therefore, it is limited to PDF mode of pdfTeX and LuaTeX (recent LuaTeX also requires package luatex85). The advantage is that the text is drawn twice only. The first time it is stroked with a thick line width in white, then it is overprinted in black.

\documentclass{standalone}
\usepackage{tikz}
\usepackage{pdfrender}
\newcommand*{\contour}[2]{%
  \leavevmode
  \rlap{%
    \textpdfrender{
      TextRenderingMode=Stroke,
      StrokeColor=white,
      LineWidth=.12em,
    }{#2}%
  }%
  \mbox{#2}%
}
\begin{document}
    \begin{tikzpicture}
    \filldraw[fill=blue!40!white, draw=black] (-5,-5) rectangle (5,5);
    \draw (0, 0) node[] {\contour{white} {I CAN FEEL YOUR HALO HALO HALO!!}};
    \end{tikzpicture}
\end{document}

Result pdfrender

The width of the white halo in comparison: 2 * contour length = 1 * line width of pdfrender.

4
  • Oooh, I didn't think of putting the command in the pre-maple. I was trying to put with the sentence. - Great, I like the pdf render method. Thanks!
    – Bjartmar
    Apr 8, 2017 at 18:41
  • Dear Heiko, would you mind to print the link to this answer into the manual of pdfrender.sty? Because from reading the manual I didn't get any idea what the whole package was good for.
    – Keks Dose
    Apr 8, 2017 at 19:53
  • After several days diagnosing various \contour issues as part of my conversion from pdflatex to lualatex, I found this little gem of a comment regarding how "recent LuaTeX also requires package luatex85". As the \contour documentation makes no mention of the luatex85 requirement when using lualatex that I could see (and no mention of luatex or lualatex either), perhaps an update to the 2004/11/18 \contour documentation is in order. Feb 18 at 0:02
  • @RosesBouquet I could compile the example above with package contour using LuaLaTeX of TeX Live 2024 without problems. yesterday

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .