QuickLaTeX: Hackenbush diagram

Today I stumbled across Tikz Diagrams in Math Mode topic on tex.SE. Here is how QuickLaTeX solves the task (example is taken from one of the answers in the thread):

Rendered by QuickLaTeX.com

Since we want to display several TikZ drawings on one image, we need to use [latex] ... [/latex] tags to mark raw region with LaTeX commands:

[latex]
[+preamble]
\usepackage{tikz}
\usetikzlibrary{calc}

\tikzstyle{hackennode}=[draw,circle,fill=white,inner sep=0,minimum size=4pt]
\tikzstyle{hackenline}=[line width=3pt]
[/preamble]

{\Large
\[
\begin{tikzpicture}[baseline=-0.65ex,scale=0.5]
    \draw[densely dashed] (-1,-1) -- (1,-1);
    \node[hackennode] (middle) at ( 0,   0) {};
    \node[hackennode] (left)   at (-0.5,-1) {};
    \node[hackennode] (right)  at ( 0.5,-1) {};
    \node[hackennode] (top)    at ( 0,   1) {};

    \draw[hackenline,blue]
        (left) -- (middle) -- (right);
    \draw[hackenline,red]
        (middle) -- (top);
\end{tikzpicture}
=
\left\{
\begin{tikzpicture}[baseline=-0.65ex,scale=0.5]
    \draw[densely dashed] (-0.5,-1) -- (1,-1);
    \node[hackennode] (middle) at ( 0,   0) {};
    \node[hackennode] (right)  at ( 0.5,-1) {};
    \node[hackennode] (top)    at ( 0,   1) {};

    \draw[hackenline,blue]
        (middle) -- (right);
    \draw[hackenline,red]
        (middle) -- (top);
\end{tikzpicture}
\tikz[baseline=-0.65ex,scale=0.5] \node[inner sep=0] at (0,-1) {,\,};
\begin{tikzpicture}[baseline=-0.65ex,scale=0.5]
    \draw[densely dashed] (-1,-1) -- (0.5,-1);
    \node[hackennode] (middle) at ( 0,   0) {};
    \node[hackennode] (left)   at (-0.5,-1) {};
    \node[hackennode] (top)    at ( 0,   1) {};

    \draw[hackenline,blue]
        (middle) -- (left);
    \draw[hackenline,red]
        (middle) -- (top);
\end{tikzpicture}
\middle|
\begin{tikzpicture}[baseline=-0.65ex,scale=0.5]
    \draw[densely dashed] (-1,-1) -- (1,-1);
    \node[hackennode] (middle) at ( 0,   0) {};
    \node[hackennode] (left)   at (-0.5,-1) {};
    \node[hackennode] (right)  at ( 0.5,-1) {};

    \draw[hackenline,blue]
        (left) -- (middle) -- (right);
\end{tikzpicture}
\right\}
\]
[/latex]
1 Star2 Stars3 Stars4 Stars5 Stars (4 votes, average: 4.75)
Loading ... Loading ...

Post a Comment

Your email is never published nor shared.

Use native LaTeX syntax to include formulas: $ ... $, \[ ... \], etc. Do not forget to preview comment before posting.

Also you may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Subscribe without commenting