绘制文件编号系统格式(更新)

绘制文件编号系统格式(更新)

继续https://tex.stackexchange.com/questions/282262/draw-document-numbering-system-format

我怎样才能画出没有(什么)胡须的图表(见附件)?另外我怎样才能修复重叠部分?

我的代码是:

在此处输入图片描述

    \documentclass[tikz, border=2mm]{standalone}
\usepackage{xifthen}
\usepackage{tikz}

\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*3em, align=center, below] (dummy) at ({(\XPos+\L/2)*1em},-1) {\small\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};
                        }{}
                    }
                }{}
            }
        }
        %   \hspace{5.5mm}
        \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{6,4,8,1,3}%
    {,,,}%
    {{B,O,E,I,N,G},{B,7,3,8},{B,7,3,7,-,3,0,0},{M},{L,2,J}}%
    {Manufacturer,ICAO Designation,Aircraft,Medium,Landplane 2 Jet Engines}
\end{tikzpicture}

\end{document}

答案1

如果将每个单词(Boing,B738,...)放入各自的矩阵中,则可以使用该矩阵来放置整个构造,从而可以轻松修复重叠。

从技术上讲,你可以把所有的事情都放到自己的列中矩阵,但需要采用非常不同的方法。

我不太清楚该,,,列表的规则是什么。

代码

\documentclass[tikz]{standalone}
\usetikzlibrary{arrows.meta, chains}
\usepackage{xifthen}
\newcommand*\DNSF[3]{
  \coordinate(start);
  \foreach[count=\groupI] \GROUP in {#2} {
    \matrix[matrix anchor=north west] at (start.north east) (start) {
      \tikzset{
        node distance=+0mm,
        start chain={ch\groupI} going base right}
      \foreach \LETTER in \GROUP
        \node[letter node, on chain=ch\groupI] {\LETTER};
      \draw (ch\groupI-begin.south west) 
         |- ([yshift=-2pt]ch\groupI-end.south east) coordinate (@)
         -- (ch\groupI-end.south east);
      \foreach[count=\labelI] \LABEL in {#3} {
        \ifthenelse{\groupI = \labelI}{
          \pgfmathtruncatemacro\nodenumber{(\tikzchaincount+1)/2}
          \ifthenelse{\isodd{\tikzchaincount}}{
            \coordinate (startarrow) at (ch\groupI-\nodenumber.south|-@);
          }{
            \coordinate (startarrow) at (ch\groupI-\nodenumber.south east|-@);
          }
          \draw[arrow style] (startarrow) -- ++(down:1) node[label node]{\LABEL};
        }{}
      }
     \\};
  }
}
\begin{document}
\begin{tikzpicture}[
  letter node/.style={
    text depth=+0pt,
    text height=+.7\ht\strutbox,
    text width=width("M"), align=center,
    inner sep=+.15em,
  },
  label node/.style={
    below,
    align=center,
    font=\small
  },
  arrow style/.style={
    Latex-,
    shorten <=1mm,
  },
]
\DNSF{,,,}
  {{B,O,E,I,N,G},{B,7,3,8},{B,7,3,7,-,3,0,0},{M},{L,2,J}}
  {Manufacturer,ICAO Designation,Aircraft,Medium,Landplane 2\\Jet Engines}
\end{tikzpicture}
\end{document}

输出

在此处输入图片描述


使用上面的一个矩阵思想,我们可以使用 TikZ-CD 和一些有用的设置来做到这一点。

设置row sep为改变垂直箭头的长度。

我已将第一行节点的内间距和外间距最小化,以使它们尽可能靠近。然而,width("M")仍然意味着每个字母都为字母保留了空间M,很可能是字体中最宽的字母。

如果不需要这个,你可以使用单词本身和一个节点。这就是第二个示例所做word explainer*的。

代码

\documentclass[tikz]{standalone}
\usetikzlibrary{cd, chains}
\tikzcdset{
  word explainer/.style={
    math mode=false,  column sep=+.6666em, arrows=-Latex,
    /tikz/node letter/.style={
      text width=width("M"), inner sep=+.0em, outer sep=+0pt, align=center},
    /tikz/row 2/.append style={
      /utils/exec=\pgfpointdiff
        {\pgfpointanchor{\tikzmatrixname-\the\pgfmatrixcurrentcolumn'-begin}{center}}
        {\pgfpointanchor{\tikzmatrixname-\the\pgfmatrixcurrentcolumn'-end}{center}}%
        \pgftransformxshift{.5*\csname pgf@x\endcsname},
      execute at end node={\uar[shorten >=1mm]}, align=center, anchor=north},
    /utils/exec=%
      \expandafter\let\expandafter\nl\csname tikz@align@newline\endcsname
      \def\letters##1{%
        \draw[node distance=+0mm,
             /utils/exec=\edef\groupname{\tikzmatrixname-\the\pgfmatrixcurrentcolumn'},
             start chain={\groupname} going base right] foreach \l in {##1}{
          node[node letter/.try, on chain=\groupname]{\l}}
           (\groupname-begin.south west) |- ([yshift=-2pt]\groupname-end.south east)
        coordinate[near end] (\tikzmatrixname-\the\pgfmatrixcurrentrow-\the\pgfmatrixcurrentcolumn)
        -- (\groupname-end.south east);}},
  word explainer*/.style={
    math mode=false, column sep=+.6666em, arrows=-Latex,
    /utils/exec=%
      \expandafter\let\expandafter\nl\csname tikz@align@newline\endcsname,
    /tikz/row 1/.append style={ nodes={
       inner xsep=+.1em, inner ysep=+0pt, outer sep=+0pt,
        append after command={[insert path/.expanded={
            (\tikzlastnode.south west) edge[to path={
              |- ([yshift=+-2pt]\noexpand\tikztotarget)
              -- (\noexpand\tikztotarget)}] (\tikzlastnode.south east)}]}}},
    /tikz/row 2/.append style={align=center, anchor=north},
    /tikz/row 2/.append code={\uar[shorten >=1mm+2pt]}}}
\begin{document}
\begin{tikzcd}[word explainer]
  \letters{B, O, E, I, N, G}       & \letters{B, 7, 3, 8}
& \letters{B, 7, 3, 7, -, 3, 0, 0} & \letters{M}
& \letters{L, 2, J} \\
  Manufacturer                     & ICAO Designation
& Aircraft                         & Medium
& Landplane 2\nl Jet Engined
\end{tikzcd}

\begin{tikzcd}[word explainer*]
  BOEING       & B738 & B737-300 & M & L2J \\
  Manufacturer & ICAO Designation
& Aircraft     & Medium
& Landplane 2\nl Jet Engined
\end{tikzcd}
\end{document}

输出

在此处输入图片描述

在此处输入图片描述

相关内容