
如何按照建議使用輪廓包在文字周圍添加光環在這個答案中透過定義樣式在許多節點中?
微量元素:
\documentclass[tikz]{standalone}
\usepackage[outline]{contour} %halo around text
%https://tex.stackexchange.com/questions/18472/tikz-halo-around-text
\contourlength{1.2pt}
\usetikzlibrary{patterns}
\begin{document}
\begin{tikzpicture}[halo text node/.style={circle, draw, pattern=north east lines}]
\node [halo text node] {\contour{white}A};
\end{tikzpicture}
\end{document}
結果:
我想要的是以tikzpicture
類似的形式包含一個選項halo text node/.style{...,text=\contour{white}}
,而不是\contour{white}{...}
在每個節點內使用。
答案1
這並不能回答您的問題(因為我不知道如何應用於\contour
節點內容),而是為您提供了定義contour text
樣式的替代方法,該方法將節點內容作為參數。
\documentclass[tikz]{standalone}
\usetikzlibrary{patterns}
\usepackage[outline]{contour}
\contourlength{1.2pt}
\tikzset{
contour text/.style={node contents={\contour{white}{#1}}},
halo text node/.style={circle, draw, pattern=north east lines}
}
\begin{document}
\tikz\node[halo text node, contour text=ABC];
\end{document}
筆記:
- 這對我來說不適用於 XeLaTeX。
- 另一種可能性是不使用
contour
包但pdfrender
,或在純 TikZ 中重新定義輪廓的動作(在列印之前用不同的顏色多次移動文字)。