绘制文档编号系统格式

绘制文档编号系统格式

我怎样才能画出类似的东西:

在此处输入图片描述

我尝试过这样做,但是 tikz 对我来说有点难。

\documentclass[a4paper,12pt,final]{article}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}

\foreach \x in {0,1,2,3}
 \draw (.75*\x,-2) node 
 [rectangle, draw, align=center, inner sep=1ex] {A};
\draw[ultra thick]  --(0,0);

\end{tikzpicture}

\end{document}

答案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}

输出

在此处输入图片描述

相关内容