I am an undergrad math major learning latex so I can optimize my notes. I would appreciate if someone can help recreate a diagram like this one:
3 Answers
The hardest aspect is persuading tikz-cd
that the top object can overlap the bottom ones.
\documentclass{article}
\usepackage{tikz-cd}
\begin{document}
\begin{tikzcd}[column sep=-1em,row sep=2.5ex]
& \mbox{13 Total} \arrow[dl] \arrow[d] \arrow[dr] & \\
3C \arrow[d] & 6B \arrow[d] & 4E \arrow[d] \\
1C & 2B & 2E
\end{tikzcd}
\end{document}
You can play with the lengths until the result is what you like best.
Since your image resembles a tree diagram, try drawing it with the forest
specialized for such drawings:
\documentclass[margin=3mm]{standalone}
\usepackage{forest}
\begin{document}
\begin{forest}
for tree = {math content,
s sep=3mm,
l sep=6mm,
edge={->}}
[\mbox{13 Total}
[3C [1C]]
[6B [2B]]
[4E [2E]]
]
\end{forest}
\end{document}
Addendum: Well, we all have different tastes. While I prefer the original answer (special its simple code), it looks like you like something similar to the picture below:
\documentclass[margin=3mm]{standalone}
\usepackage{forest}
\begin{document}
\begin{forest}
for tree = {math content,
s sep=3mm,
l sep=6mm,
edge={->}}
[\mbox{13 Total}, name=r
[3C, name=c,no edge [1C]]
[6B [2B]]
[4E, name=e,no edge [2E]]
]
\draw[->] ([xshift=+1ex] r.south west) -- (c);
\draw[->] ([xshift=-1ex] r.south east) -- (e);
\end{forest}
\end{document}
-
Does the arrow need to come from under the 1 of 13 instead of the T or Total?– SimdOct 23, 2020 at 12:48
-
@fomin, I do not know from where you like to have, that comes. Now are comes from middle of root node, however, the part to node borders is not visible. The same are at all other answers.– ZarkoOct 23, 2020 at 13:21
-
I think the suggestion is just because of the difference to OP's diagram.– SimdOct 24, 2020 at 15:09
-
@Anush, I see, but accepted answer has the same source of lines. For it in the first (s)he say Oh wow this is perfect!, it seem that now (s)he changed the mind. See addendum to answer (unfortunately, now the code is not so simple as before :-( ). And to my taste looks awful ...– ZarkoOct 24, 2020 at 16:29
-
1@Anush, thank you to help me understanding, what OP like to have. So, I was able to do new example (for which I express my personal opinion).– ZarkoOct 24, 2020 at 18:43
egreg
already gave the best answer, but able to meet the OP
's requirement without using additional packages like tikz
, and the code is:
\documentclass{book}
\usepackage{mathtools}
\begin{document}
\[
\begin{array}{ccc}
\multicolumn{3}{c}{\text{13 Total}}\\
\swarrow &\downarrow &\searrow\\
3C &6B &4E\\
\downarrow &\downarrow &\downarrow\\
1C &2B &2E
\end{array}
\]
\end{document}
Output
-
I had no idea you could do this with just array! But does the arrow going down and left from the 1 of 13 needs to point at the C of 3C and not the 3? Similarly for 4E.– SimdOct 23, 2020 at 12:50
tikz
ortikz-cd
which is a diagram setup build on top oftikz