I want to draw the following tree in a question. But, I don't want to upload a picture. Can anyone tell me how to do it using MathJax?The Tree

up vote 19 down vote accepted

It can be done in MathJax, but it is painful and a complete hack. Here is one way:

\hskip 1em

which produces

$$ \require{enclose} \def\uline#1#2{\enclose{updiagonalstrike}{\phantom{\Rule{#1em}{#2em}{0em}}}} \def\dline#1#2{\enclose{downdiagonalstrike}{\phantom{\Rule{#1em}{#2em}{0em}}}} % \def\place#1#2#3{\smash{\rlap{\hskip{#1em}\raise{#2em}{#3}}}} % \hskip 1em % \place{0}{12}{\bullet} \place{2}{0}{\bullet} \place{4}{4}{\bullet} \place{6}{0}{\bullet} \place{8}{8}{\bullet} \place{10}{0}{\bullet} \place{12}{4}{\bullet} \place{14}{0}{\bullet} \place{16}{12}{\bullet} % \place{.3}{4.4}{\dline{3.6}{7.6}} \place{2.3}{.5}{\uline{1.6}{3.6}} \place{4.3}{.4}{\dline{1.6}{3.6}} \place{4.3}{4.4}{\uline{3.6}{3.7}} \place{8.3}{4.4}{\dline{3.6}{3.6}} \place{10.3}{.5}{\uline{1.6}{3.6}} \place{12.3}{.4}{\dline{1.6}{3.6}} \place{12.2}{4.4}{\uline{3.7}{7.6}} % \place{-1}{12.5}{\frac01} \place{1}{-.5}{\frac13} \place{2.75}{4}{\frac12} \place{6.5}{-.5}{\frac23} \place{7.75}{9.5}{\frac11} \place{9}{-.5}{\frac32} \place{12.75}{4}{\frac21} \place{14.5}{-.5}{\frac31} \place{16.5}{12.5}{\frac10} % \hskip18em\Rule{0em}{14em}{1.5em} $$

It allows you to define an abstract grid on which you place the items you want (bullets for dots, fractions, and diagonal lines created using the enclose package). I also use \hskip and \Rule to define the size of the complete diagram, and an \hskip at the front to compensate for the use of -1 for the left-most labels.

Anyway, you can make these kinds of diagrams with some effort.

  • 3
    I'd like to mention this doesn't work on the iOS app – KoA Apr 22 '16 at 5:28
  • The numbers after place, for example \place{2}{0} are relative coordinates with respect to previous position? Or are they absolute coordinates? – Martin Sleziak Apr 22 '16 at 7:54
  • 1
    @shieldbug1 And I can confirm that it does not render correctly on the mobile version of the site, using iOS's Safari (but switching to the "full site" in Safari still, it does work). Very interesting answer, either way! – pjs36 Apr 22 '16 at 12:29
  • 1
    @MartinSleziak, they are absolute with respect to the lower left-hand corner of the graph. – Davide Cervone Apr 22 '16 at 13:10
  • Thx for this great hack. $+1$ The diagram flooted on the code out of the screen though. – GNUSupporter 8964民主女神 地下教會 Dec 4 at 5:05
  • Here's what it looks like on an Android phone; viz., a ZTE Blade V8. – Shaun Dec 9 at 2:13
  • Here's what it looks like on the same phone but using the desktop site. – Shaun Dec 9 at 2:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .