# Drawing a diagram in LaTeX How can I draw this diagram in LaTeX?

## migrated from writing.stackexchange.comDec 9 '18 at 15:25

This question came from our site for the craft of professional writing, including fiction, non-fiction, technical, scholarly, and commercial writing.

• Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass{...} and ending with \end{document}. • Note this is a Q&A site, not a please do this for me service. What do you have so far. – albert Dec 9 '18 at 15:38
• For the future, you should provide a MWE, I answered only because you're a new user and I think JouleV's answer, as is, doesn't work for multiline nodes. – CarLaTeX Dec 9 '18 at 21:07
• Joule updated his answer, now it's ok, even if it still requires some manual work. – CarLaTeX Dec 10 '18 at 5:31

I was using tikz-cd with smallmatrix. Obviously you can change the numbers and set a macro to replace each time the small matrix. \documentclass[a4paper,12pt]{article}

\usepackage{tikz-cd}
\usepackage{mathtools}

\begin{document}

\begin{tikzcd}
& \begin{smallmatrix}     0 & 0 & 0 \\      & 0 &            \end{smallmatrix}  \arrow[rd] &  & \begin{smallmatrix}     1 & 0 & 0 \\      & 0 &            \end{smallmatrix}  \arrow[rd] &  &  \\
&  & \begin{smallmatrix}     1 & 1 & 0 \\      & 1 &            \end{smallmatrix}  \arrow[rd] \arrow[ru] &  & \begin{smallmatrix}     0 & 0 & 0 \\      & 1 &            \end{smallmatrix}  \arrow[rd] &  \\
& \begin{smallmatrix}     0 & 0 & 0 \\      & 1 &            \end{smallmatrix}  \arrow[ru] \arrow[rd] &  & \begin{smallmatrix}     0 & 0 & 0 \\      & 1 &            \end{smallmatrix}  \arrow[ru] \arrow[rd] &  & \begin{smallmatrix}     1 & 0 & 0 \\      & 1 &            \end{smallmatrix}  \\
\begin{smallmatrix}     1 & 1 & 1 \\      & 1 &            \end{smallmatrix}  \arrow[ru] &  & \begin{smallmatrix}     0 & 0 & 0 \\      & 1 &            \end{smallmatrix}  \arrow[ru] &  & \begin{smallmatrix}     0 & 0 & 0 \\      & 0 &            \end{smallmatrix}  \arrow[ru] &
\end{tikzcd}

\end{document}


Welcome to TeX.SX! This is an attempt using simple TikZ.

\documentclass{article}
\usepackage{tikz}
\tikzset{every node/.style={align=center}}
% To align all nodes as centered (Thank you, CarLaTeX, for showing me this)
\begin{document}
\begin{tikzpicture}[x=1cm,y=0.8cm]
\node at (0,0) (a) {1};
\node at (1,-1) (b) {2};
\node at (0,-2) (c) {3};
\node at (-1,-3) (d) {4};
\node at (1,-3) (e) {5};
\node at (2,-2) (f) {6};
\node at (2,0) (g) {7};
\node at (3,-1) (h) {8};
\node at (3,-3) (i) {9};
\node at (4,-2) (j) {10};
\draw [->] (a)--(b);
\draw [->] (c)--(b);
\draw [->] (d)--(c);
\draw [->] (c)--(e);
\draw [->] (e)--(f);
\draw [->] (b)--(f);
\draw [->] (b)--(g);
\draw [->] (f)--(h);
\draw [->] (g)--(h);
\draw [->] (f)--(i);
\draw [->] (i)--(j);
\draw [->] (h)--(j);
\end{tikzpicture}
\end{document} You now only have to substitute the numbers with appropriate content.

• You should add align=center as a general node style. Otherwise, your solution won't work with multiline nodes. – CarLaTeX Dec 9 '18 at 21:09
• @CarLaTeX Thank you very much! I didn't notice that :) – user156344 Dec 10 '18 at 5:17

This is a job for tikz-cd:

\documentclass{article}
\usepackage{tikz-cd}
\usepackage{array}
\newcommand{\mycell}{\begin{array}{c}
#1
\end{array}}
\begin{document}
$\begin{tikzcd} &\mycell{000 \\ 1}\ar[dr] & & \mycell{111 \\ 0}\ar[dr]\\ &&\mycell{111 \\ 1}\ar[dr]\ar[ur] & & \mycell{110 \\ 0}\ar[dr]\\ &\mycell{011 \\ 0}\ar[dr]\ar[ur] & & \mycell{110 \\ 1}\ar[dr]\ar[ur] & & \mycell{100\\0}\\ \mycell{001 \\ 0}\ar[ur] & &\mycell{101 \\ 1}\ar[ur] & & \mycell{110 \\ 0}\ar[ur]\\ \end{tikzcd}$
\end{document} • Wow, nice answer, quack! Is it possible to pass as parameter the number of columns i.e. something like \begon{array}{#2}#1...? – manooooh Mar 1 at 17:19
• @manooooh Yes, just modify the definition of \mycell :) – CarLaTeX Mar 1 at 17:25