2

How can I make a chart like this in LaTeX?

Chart with lines between boxes

  • 2
    Please include title or class of diagram's in the Q Title instead of this for easy traceability/searchable for future users – texenthusiast Oct 20 '13 at 4:08
2

One possible solution is using tikz package. Minimal introduction can be found here. Another solution is MetaPost which may be though as prototype of tikz, they have much in common. But MetaPost is not package for TeX-file, it's external tool for creation of eps-images with back connection to TeX of LaTeX. It is included particularly in MiKTeX. Read manual here.

|improve this answer|||||
6

Here is a solution using Tikz matrix node

enter image description here

\documentclass[border=1mm,tikz]{standalone}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{tikz}
\usetikzlibrary{matrix}

\begin{document}
\begin{tikzpicture}[font=\footnotesize,%
        boxes/.style={draw, rectangle,%
                thick,minimum height=6mm,%
                text width=6mm, 
                align=center}]

    \matrix (A) [matrix of nodes, nodes=boxes,
             row sep=1cm,column sep=1cm]
    {
   |(A-3-1)|  & |(A-3-2)|   & |(A-3-3)|   & |(A-3-4)|  & |(A-3-5)| \\                              
   |(A-2-1)|  & |(A-2-2)|   & |(A-2-3)|   & |(A-2-4)|  & |(A-2-5)| \\                              
   |(A-1-1)|  & |(A-1-2)|   & |(A-1-3)|   & |(A-1-4)|  & |(A-1-5)| \\                                             
    };
    \foreach \i/\j in {3/2,2/1}
   {
        \draw  (A-\i-1)--(A-\j-1);        \draw  (A-\i-2)--(A-\j-2);
        \draw  (A-\i-3)--(A-\j-3);        \draw  (A-\i-5)--(A-\j-5);
    }
    \draw  (A-1-3)--(A-1-4)--(A-1-5);
    \draw  (A-3-3)--(A-3-4)--(A-3-5);
    \draw  (A-3-1.south east) -- (A-2-2.north west)      
       (A-2-2.south east) -- (A-1-3.north west);
    \draw  (A-3-2.south east) -- (A-2-3.north west)      
       (A-2-3.south east) -- (A-1-4.north west);
    \draw  (A-3-3.south east) -- (A-2-4.north west)      
       (A-2-4.south east) -- (A-1-5.north west);
    \node [red] at (A-3-5) {9}; 
    \node [red] at (A-1-3) {4}; 
    \end{tikzpicture}%
    \end{document} 
|improve this answer|||||
1

An example of similar diagram (with TikZ)

http://www.texample.net/tikz/examples/kalman-filter/

|improve this answer|||||
  • Thanks, though I already figured it out. – Jakob Weisblat Oct 20 '13 at 2:42
  • 1
    This is an interesting link. However, a link only "Answer" is usually better as a comment. Alternatively, you can expand your "Answer" to explain how to work with the code. – Andrew Swann Oct 20 '13 at 19:22
1

Just for fun, I did it with a stack...

\documentclass{article}
\usepackage[usestackEOL]{stackengine}[2013-10-15]
\usepackage{graphicx, xcolor}
\def\thk{.2pt}
\def\sz{1.3ex}
\def\sqt{1.40}
\def\hgap{.72ex}
\def\hrl{\rule{\ht\strutbox+\dp\strutbox-\thk}{\thk}}
\def\vrl{\rule{\thk}{\ht\strutbox+\dp\strutbox-\thk}}
\newcommand\drl{\rotatebox{135}{\rule{\sqt\ht\strutbox+\sqt\dp\strutbox}{\thk}}}
\def\nhrl{\rule{\ht\strutbox+\dp\strutbox}{0pt}}
\def\nvrl{\rule{0pt}{\ht\strutbox+\dp\strutbox}}
\def\nnrl{\rule{\thk}{\thk}}
\newcommand\ndrl{\rotatebox{45}{\rule{\sqt\ht\strutbox+\sqt\dp\strutbox}{0pt}}}
\newcommand\fsq[1]{\fboxsep=0pt\fboxrule=0.2pt\hspace{\hgap}%
  \stackinset{c}{}{c}{}{\tiny #1}{%
  \fbox{\colorbox{white}{\rule{\sz}{0ex}\rule{0ex}{\sz}}}}\hspace{\hgap}}
\begin{document}
\setstackgap{S}{-.15pt}
\def\stacktype{L}
\stackon[-2.7pt]{%
\Shortstack[l]{
\nnrl\nhrl\nnrl\nhrl\nnrl\hrl \nnrl\hrl\nnrl\\
\vrl \drl \vrl \drl \vrl \drl \nvrl\nhrl\vrl\\
\nnrl\nhrl\nnrl\nhrl\nnrl\nhrl\nnrl\nhrl\nnrl\\
\vrl \nhrl\vrl \drl \vrl \drl \nvrl\drl\vrl\\
\nnrl\nhrl\nnrl\nhrl\nnrl\hrl \nnrl\hrl\nnrl}
}{\kern-3.3pt\Longstack{%
\fsq{}\fsq{}\fsq{}\fsq{}\fsq{9}\\
\fsq{}\fsq{}\fsq{}\fsq{}\fsq{}\\
\fsq{}\fsq{}\fsq{4}\fsq{}\fsq{}}
}
\end{document}

enter image description here

|improve this answer|||||

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.