Here are two LaTeX templates, one for drawing automata, the other for drawing quantum circuits.

Automata

This templates uses pgf/tikz.

Note. On Arch Linux, you can install the texlive-pictures package, which contains pgf/tikz.

\documentclass[a4paper]{article}

\usepackage{amsmath,amsfonts,amsthm,amssymb}
\usepackage{pgf,tikz}
\usetikzlibrary{shapes,arrows,automata,positioning}

\begin{document}
\thispagestyle{empty}

\begin{tikzpicture}[shorten >= 1pt,node distance=2.4cm,on grid,>=stealth',every state/.style={draw=blue!50,very thick,fill=blue!20}]
    \draw[help lines] (0,0) grid (8,6);

%   Node format:
    \node[state,initial,accepting]  (q_0)   at (0,3)                {$q_0$};
    \node[state]                    (q_1)   [above right=of q_0]    {$q_1$};
    \node[state,accepting]          (q_2)   at (4,0)                {$q_2$};

%   Path format:
    \path[->]
    (q_0)   edge [loop right]   node                {\parbox[t]{48pt}{$0,\epsilon \rightarrow 0 \\ 1, \epsilon \rightarrow 1$}} ()
            edge                node [above left]   {\parbox[t]{48pt}{$0,\epsilon \rightarrow 0 \\ 1, \epsilon \rightarrow 1$}} (q_1)
            edge                node [below left]   {\parbox[t]{48pt}{$0,\epsilon \rightarrow 0 \\ 1, \epsilon \rightarrow 1$}} (q_2);

\end{tikzpicture}

\end{document}

Here are some explanations.

\draw[help lines] (0,0) grid (8,6);

This line draws a grid to help you put nodes. You can comment this line after you’re content with your drawing.

\node[state,initial,accepting]  (q_0)   at (0,3)                {$q_0$};
\node[state]                    (q_1)   [above right=of q_0]    {$q_1$};

These two lines defines two nodes. q_0 is a node marked as state, initial, and accepting, and is placed at coordinate (0,3). The second part (q_0) sets its name, while last part $q_0$ sets the text inside it.

q_1 is similarly defined, but uses a relative positioning.

\path[->]
    (q_0)   edge [loop right]   node                {\parbox[t]{48pt}{$0,\epsilon \rightarrow 0 \\ 1, \epsilon \rightarrow 1$}} ()
            edge                node [above left]   {\parbox[t]{48pt}{$0,\epsilon \rightarrow 0 \\ 1, \epsilon \rightarrow 1$}} (q_1)
            edge                node [below left]   {\parbox[t]{48pt}{$0,\epsilon \rightarrow 0 \\ 1, \epsilon \rightarrow 1$}} (q_2);

This line defines a path starting at (q_0), which consists of three lines. If a line is a loop, point out the loop direction as indicated by [loop right]. The positioning option [above left] after node puts the text at the ‘above left’ of the line. Finally, if the text contains line break, you should enclose it inside \parbox.

Download the .tex file: link1 link2.

Quantum circuits

Actually the template here is nothing but a figure environment:

\begin{figure}[H]
    \begin{center}
        \includegraphics[width=0.2\textwidth]{a.png}
    \end{center}
\end{figure}

But the importance is how to generate the picture of the quantum circuit. I recommend the qasm2circ package written by Prof. Issac L. Chuang.

You can download this package at http://www.media.mit.edu/quanta/qasm2circ/, extract it at ${TEXMFLOCAL}/tex/latex/qasm2circ, then run texhash.

We’ll use qasm2png to generate png files we want. qasm2png will call qasm2tex.py, so add the full path to it in qasm2png if qasm2png complains not being able to find it.

Now you can describe your quantum circuit using the QASM language. You can view the homepage above, or read README.

To generate png files, run

qasm2png a.qasm

You’ll get a.png, which you need in the .tex file.

qasm2png supports batch operation. So you can process several .qasm files at one time, like

qasm2png a.qasm b.qasm c.qasm