我正在尝试在具有轮廓的节点内生成文本。问题是:使用轮廓时,文本宽度似乎被忽略,因此我无法使用自动多行文本。
我发现了轮廓tikz 文本周围的光晕,我可以正确使用它,如下所示:
\draw (0, 0) node {\contour{white}{A very long title that we mean to split on multiple lines}};
但添加时text width
它不是多行的:
\draw (0, 0) node[text width=5cm] {\contour{white}{A very long title that we mean to split on multiple lines}};
没有轮廓它也能正常工作:
\draw (0, 0) node[text width=5cm] {A very long title that we mean to split on multiple lines};
我怎样才能解决这个问题?
答案1
从输出来看pdfrender
包裹,它似乎与以下 TikZ 代码(其编码为与最优相反)具有相同的功能和作为contour
包裹。
代码
\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}