# Two questions: Math mode and tree diagrams for probability in LaTeX

I am trying to print a worksheet for the math class I'm teaching and I was wondering if anyone can specifically help me out in two areas.

a) How do I get the output BAL1L2 without the slant?

     $BAL_{1}L_{2}$


b) And is there is an easier code out there to create tree diagrams for probability?

• You need to register first to make you have some privileges. – kiss my armpit Nov 17 '13 at 3:31
• It sounds like you need to read a good introduction to math typesetting. I recommend the mathmode document (available via texdoc). For regular text in math mode, load the amsmath package, and use \text{foo}, unless the element has a specific semantics in which case there are other ways. As for your second question, easier than what? There are plenty of examples already on the site: Probability tree using TikZ for Bernoulli experiments? and What is a more efficient way to draw this tree?. – Alan Munn Nov 17 '13 at 3:32
• Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. – Heiko Oberdiek Nov 17 '13 at 3:45

You can use $$\mathrm{BAL_{1}L_{2}$$ to remove the slant.

The best tree-diagram program out there is pgf-tkiz, but you could also hack out something with dirtree.

More on probability trees with pgf at this link: Example: Probability tree

Some dirtree stuff here: (Semi-)automatic directory-tree in LaTeX

• Small (but crucial) typo: should be \mathrm, not mathrm. Also,  is recommended over . – ChrisS Nov 17 '13 at 7:55
• Huh, so I learned something today. I had it backwards, I thought  was the LaTeX one, and  was the old TeX one. Edited. – NictraSavios Nov 17 '13 at 7:59
• And, to be fussy, $$\mathtrm{BAL}_{1}\mathrm{L}_{2}$$ should be preferred. – egreg Nov 17 '13 at 11:02
• Too much typing, I'm a c++ programmer at heart haha. – NictraSavios Nov 17 '13 at 13:12

A recommended tree with PSTricks.

\documentclass[preview,border=12pt]{standalone}
\usepackage{pst-tree}

\psset{treemode=R,edge=\ncline}

\def\ABCD{%
\psTree{\Tcircle{A}}
\psTree{\Tcircle{B}}
\pstree[edge={\ncline[linecolor=red]}]{\Tcircle{C}}{\Tcircle{D}}\taput{\tiny an example}
\pstree{\Tcircle{D}}{\Tcircle{C}}
\endpsTree
\psTree{\Tcircle{C}}
\pstree{\Tcircle{B}}{\Tcircle{D}}
\pstree{\Tcircle{D}}{\Tcircle{B}}
\endpsTree
\psTree{\Tcircle{D}}
\pstree{\Tcircle{B}}{\Tcircle{C}}
\pstree{\Tcircle{C}}{\Tcircle{B}}
\endpsTree
\endpsTree
}

\def\BACD{%
\psTree{\Tcircle{B}}
\psTree{\Tcircle{A}}
\pstree{\Tcircle{C}}{\Tcircle{D}}
\pstree{\Tcircle{D}}{\Tcircle{C}}
\endpsTree
\psTree{\Tcircle{C}}
\pstree{\Tcircle{A}}{\Tcircle{D}}
\pstree{\Tcircle{D}}{\Tcircle{A}}
\endpsTree
\psTree{\Tcircle{D}}
\pstree{\Tcircle{A}}{\Tcircle{C}}
\pstree{\Tcircle{C}}{\Tcircle{A}}
\endpsTree
\endpsTree
}

\def\CABD{%
\psTree{\Tcircle{C}}
\psTree{\Tcircle{A}}
\pstree{\Tcircle{B}}{\Tcircle{D}}
\pstree{\Tcircle{D}}{\Tcircle{B}}
\endpsTree
\psTree{\Tcircle{B}}
\pstree{\Tcircle{A}}{\Tcircle{D}}
\pstree{\Tcircle{D}}{\Tcircle{A}}
\endpsTree
\psTree{\Tcircle{D}}
\pstree{\Tcircle{A}}{\Tcircle{B}}
\pstree{\Tcircle{B}}{\Tcircle{A}}
\endpsTree
\endpsTree
}

\def\DABC{%
\psTree{\Tcircle{D}}
\psTree{\Tcircle{A}}
\pstree{\Tcircle{B}}{\Tcircle{C}}
\pstree{\Tcircle{C}}{\Tcircle{B}}
\endpsTree
\psTree{\Tcircle{B}}
\pstree{\Tcircle{A}}{\Tcircle{C}}
\pstree{\Tcircle{C}}{\Tcircle{A}}
\endpsTree
\psTree{\Tcircle{C}}
\pstree{\Tcircle{A}}{\Tcircle{B}}
\pstree{\Tcircle{B}}{\Tcircle{A}}
\endpsTree
\endpsTree
}

\begin{document}
\psTree[thislevelsep=0]{\Tn}
\ABCD
\BACD
\CABD
\DABC
\endpsTree
\end{document}