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 trying to produce a text inside a node which has a contour. Problem is: when using contour, text width seems to be ignored, so I can not use auto multi-line text.

I discovered contours in tikz halo around text, and I can use it correctly as in:

\draw (0, 0) node {\contour{white}{A very long title that we mean to split on multiple lines}};

but when adding text width it is not multi-lined:

\draw (0, 0) node[text width=5cm] {\contour{white}{A very long title that we mean to split on multiple lines}};

And without contour it works correctly:

\draw (0, 0) node[text width=5cm] {A very long title that we mean to split on multiple lines};

How can I fix this?

share|improve this question
    
Apparently contour puts everything in a box. Just try this, out of TikZ picture. \contour{red}{A very long text that hopefully breaks at the end of the this line otherwise I need to write more stuff}. So I think, the pragmatic approach is to break manually. –  percusse Mar 25 '13 at 13:59
    
Same problem with shadowtext package. Very annoying. It seems there is no way of getting wrapping contour or shaded multiline text inside a TikZ node. –  mmj Apr 15 '13 at 14:08

1 Answer 1

up vote 5 down vote accepted

Judging from the output of the pdfrender package, it seems that it does the same as the following TikZ code (which is coded as the opposite of optimal) and as the contour package.

Code

\documentclass[tikz]{standalone}
\usetikzlibrary{shadows}
\tikzset{
    text shadow/.code args={[#1]#2at#3(#4)#5}{
        \pgfkeysalso{/tikz/.cd,#1}%
        \foreach \angle in {0,5,...,359}{
                \node[#1,text=white] at ([shift={(\angle:.5pt)}] #4){#5};
        }
    }
}
\begin{document}
    \begin{tikzpicture}
    \fill[gray, step=.5mm] (-1.6,-1) rectangle (1.6,1);
    \node[
        text shadow={[align=center,text width=3cm] at (0,0) {A very long title that we mean to split on multiple lines \ldots}}]
                                      at (0,0) {A very long title that we mean to split on multiple lines \ldots};
    \end{tikzpicture}
\end{document}

Output

enter image description here

share|improve this answer

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.