我并不tikz
经常使用。当我使用时,我通常对结果非常满意(以及手册的实用性)。但我总是认为代码我为此制作的程序可以进行优化,因为最终它充满了冗余,这是由于我笨拙的复制粘贴方法造成的。这是我在手册中尚未找到的一件事,但这\pgfsetarrows,
是一个进步。
接下来是一个很好的例子。如果我现在决定更改影响整个元素组的参数,则需要进行大量的搜索和替换。例如,考虑文本元素的字体和颜色设置,或锚点设置。有哪些方法可以消除这些冗余,例如通过为某组元素定义样式“全局”?——一种方法当然是保存,比如说,将其保存\bfseries\color{hks15k}
在自己的宏中,然后直接调用它。但首先我想找出是否tikz
提供了更正式的方式来做这些事情。
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{tikz,sourcesanspro,textcomp}
\definecolor{hks89k}{cmyk}{0,.1,.3,.35}%
\definecolor{hks15k}{cmyk}{0.1,1,.8,0}
\begin{document}
\begin{figure}\footnotesize\sffamily
\begin{tikzpicture}[x=\textwidth,y=5\baselineskip, text height=.75em, text depth=.15em]
\useasboundingbox (0,-0.65) rectangle (1,1.65);
\draw (0,1)
node[anchor=south west] {\color{hks89k}15\rlap{\textrightarrow}}
node[anchor=north west] {IV\rlap{\enskip\textbf{Klöden 1824}}}
rectangle (11/46,0.65)
+(0.25em,0.35)
node[anchor=south west] {\color{hks89k}26\rlap{\textrightarrow}}
node[anchor=north west] {III}
rectangle (0.5\textwidth-0.25em,0.65)
+(0.25em,0.35)
node[anchor=south west] {\color{hks89k}38\rlap{\textrightarrow}}
node[anchor=north west] {II}
rectangle (34/46,0.65)
+(0.25em,0.35)
node[anchor=south west] {\color{hks89k}50\rlap{\textrightarrow}}
node[anchor=north west] {I}
rectangle (46/46,0.65);
\draw (0,0)
node[anchor=north west] {\color{hks89k}11x\rlap{\textrightarrow}}
node[anchor=south west] {IV\rlap{\enskip\textbf{Köhler 1856}}}
rectangle (.5\textwidth-0.25em,0.35)
+(0.25em,-0.35)
node[anchor=north west] {\color{hks89k}7x\rlap{\textrightarrow}}
node[anchor=south west] {III}
rectangle (10/16,0.35)
+(0.25em,-0.35)
node[anchor=north west] {\color{hks89k}6x\rlap{\textrightarrow}}
node[anchor=south west] {IIb}
rectangle (12/16,0.35)
+(0.25em,-0.35)
node[anchor=north west] {\color{hks89k}5x\rlap{\textrightarrow}}
node[anchor=south west] {IIa}
rectangle (14/16,0.35)
+(0.25em,-0.35)
node[anchor=north west] {\color{hks89k}4x\rlap{\textrightarrow}}
node[anchor=south west] {Ib}
rectangle (15/16,0.35)
+(0.25em,-0.35)
node[anchor=north west] {\color{hks89k}3,5x\rlap{\textrightarrow}}
node[anchor=south west] {Ia}
rectangle (16/16,0.35);
\draw (0,0.5) node {0\%\rlap{\quad \color{hks89k}schlechter}}
(20/100,0.5) node {20\%}
(40/100,0.5) node {40\%}
(60/100,0.5) node {60\%}
(80/100,0.5) node {80\%}
(100/100,0.5) node {\llap{\color{hks89k}besser\quad}100\%};
\pgfsetarrows{-latex}
\draw (20/100,0.61) .. controls +(2/200,0.19) and +(3/200,-0.23) .. +(up:0.8) node[anchor=south] {\bfseries\color{hks15k}IV};
\draw (40/100,0.61) .. controls +(1/200,0.38) and +(2/200,-0.28).. +(up:0.8) node[anchor=south] {\bfseries\color{hks15k}III};
\draw (60/100,0.61) .. controls +(4/200,0.4) and +(1.5/200,-0.2) .. +(up:0.8) node[anchor=south] {\bfseries\color{hks15k}II};
\draw (80/100,0.61) .. controls +(3/200,0.30) and +(1/200,-0.1) .. +(up:0.8) node[anchor=south] {\bfseries\color{hks15k}I};
\draw (20/100,0.39) .. controls +(-1.2/200,-0.32) and +(-3.5/200,0.23) .. +(down:0.8) node[anchor=north] {\bfseries\color{hks15k}IV};
\draw (40/100,0.39) .. controls +(-2.4/200,-0.3) and +(-1.5/200,0.2) .. +(down:0.8) node[anchor=north] {\bfseries\color{hks15k}IV};
\draw (60/100,0.39) .. controls +(-1.5/200,-0.24) and +(-1/200,0.21) .. +(down:0.8) node[anchor=north] {\bfseries\color{hks15k}III};
\draw (80/100,0.39) .. controls +(1/200,-0.23) and +(2/200,0.42) .. +(down:0.8) node[anchor=north] {\bfseries\color{hks15k}IIa};
\end{tikzpicture}
\end{figure}
\end{document}