1

How can I draw something like:

enter image description here

I tried to do it but tikz kinda hard for me.

\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}
4

Here's a quite automatic version. It goes though a lot of loops, so performance for very long constructs will be terrible. It has 4 parameters:

  • Length of the individual groups
  • Separators between the groups
  • Text to display as individual chars; empty groups a simply a comma
  • Explanantions to be displayed; empty groups a simply a comma

Code

\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}

Output

enter image description here

  • Wow. Thaaaaank you. My jaw hit the table :). Niiiice – OOzy Pal Dec 9 '15 at 18:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.