答案1
这是一个相当自动化的版本。它经过很多循环,因此非常长的构造的性能会很糟糕。它有 4 个参数:
- 各组的长度
- 组间分隔符
- 文本显示为单个字符;空组只是一个逗号
- 要显示的解释;空组只是一个逗号
代码
\documentclass[tikz, border=2mm]{standalone}
\usepackage{xifthen}
\begin{document}
\xdef\XPos{0}
\newcommand{\DNSF}[4]%
% lengths, separators, fillings, explainers
{ \foreach \L [count=\CountL] in {#1}
{ \foreach \E [count=\CountE] in {#4}
{ \ifthenelse{\CountL = \CountE}
{ \ifthenelse{\equal{\E}{}}
{}
{ \node[text width=\L*1em, align=left, below] (dummy) at ({(\XPos+\L/2)*1em},-1) {\E};
\draw[-latex] (dummy.north) -- (dummy.north |- 0,0);
}
}{}
}
\foreach \D [count=\CountD] in {1,...,\L}
{\draw (\XPos*1em,0.1) -- (\XPos*1em,0) -- ({(\XPos+1)*1em},0) -- ({(\XPos+1)*1em},0.1);
\pgfmathparse{int(\XPos+1)}
\xdef\XPos{\pgfmathresult}
\foreach \F [count=\CountF] in {#3}
{ \ifthenelse{\CountL = \CountF}
{ \foreach \FF [count=\CountFF] in \F
{ \ifthenelse{\CountD = \CountFF}
{ \node[above] at (\XPos*1em-0.5em,0) {\FF};
}{}
}
}{}
}
}
\foreach \S [count=\CountS] in {#2}
{ \ifthenelse{\CountL = \CountS}
{ \node at (\XPos*1em+0.5em,0.2) {\S};
\pgfmathparse{int(\XPos+1)}
\xdef\XPos{\pgfmathresult}
}{}
}
}
}
\begin{tikzpicture}
\DNSF{3,4,5,2,7}%
{-,-,-,-,$\bullet$}%
{,{A,S,D,F},,{1,$\varphi$}}%
{Bla,Bla Bla Bla Bla,Bla Bla Bla Bla,,Bla Bla Bla Bla Bla Bla Bla Bla Bla}
\end{tikzpicture}
\end{document}