在上面的 Ti钾Z图片,我该如何
- 扩展边界框以包含文本装饰,而无需手动修改(我能找到的唯一解决方案是摆弄
border
或margin
类选项,请参阅这里)? Package inputenc Error: Unicode char
避免第 24 行的尖锐 s “ß” 的错误?
代码
\documentclass[tikz,svgnames]{standalone}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usetikzlibrary{positioning,decorations.text}
\renewcommand{\familydefault}{\sfdefault}
\tikzset{
entity/.style={fill=#1!70,text=white},
action/.style={->,postaction={decorate,decoration={raise=2pt,text along path,text align=center,text={|\scriptsize|#1}}}}
}
\begin{document}
\begin{tikzpicture}
% Entities
\node[entity=DarkGreen] (A) {A};
\node[entity=DarkBlue,right=2 of A] (B) {B};
% Actions
\draw[action=schließen] (A) to [bend left] (B);
\end{tikzpicture}
\end{document}
答案1
这会在装饰上方添加一条不可见的线。如果使该线可见,您将看到边界框比需要的略大。
我尝试了所有相关的建议\scriptsize
并得出结论 OP 解决方案是最好的。
\documentclass[tikz,svgnames]{standalone}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usetikzlibrary{positioning,decorations.text,calc}
\renewcommand{\familydefault}{\sfdefault}
\tikzset{
entity/.style={fill=#1!70,text=white},
action/.style={->,postaction={decorate,decoration={raise=2pt,text along path,
text align=center,text={|\scriptsize|#1}
}}}}
\newlength{\mybuffer}
\sbox0{\scriptsize\strut}
\setlength{\mybuffer}{\dimexpr 2pt+\ht0+\dp0}
\begin{document}
\begin{tikzpicture}
% Entities
\node[entity=DarkGreen] (A) {A};
\node[entity=DarkBlue,right=2 of A] (B) {B};
% Actions
\draw[action={schlie{ß}en}] (A) to [bend left] (B);
\path ($(A)+(0pt,\mybuffer)$) to [bend left] ($(B)+(0pt,\mybuffer)$);
%\draw[red] ($(A)+(0pt,\mybuffer)$) to [bend left] ($(B)+(0pt,\mybuffer)$);
\end{tikzpicture}
\end{document}