TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Possible Duplicate:
Problem with TikZ, beamer and verbatim

Is it possible to use verbatim-like environments inside a tikz node? This MWE gives an error:

\documentclass{article}
\usepackage{tikz}

\begin{document}
\tikz{
  \node{\begin{verbatim}a_b\end{verbatim}};
}
\end{document}
share|improve this question

marked as duplicate by JLDiaz, Harish Kumar, Marco Daniel, Thorsten, Martin Schröder Dec 9 '12 at 13:12

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
I saw that, but the answer notes 'if another document class (article, for example) ...' -- so that looks beamer-specific, no? – Mohan Dec 9 '12 at 12:16
    
Do you really need \begin{verbatim}...\end{verbatim}? – hpesoj626 Dec 9 '12 at 12:38
    
I need an environment constructed for me in other answers that is like verbatim... – Mohan Dec 9 '12 at 12:41

This other command works for me:

\documentclass{article}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
\node[draw] at (0,0) {\verb+a_b+};
\end{tikzpicture}
\end{document}
share|improve this answer

I get missing item error with your MWE. However, it seems to work with listings package. If you would allow it, then try the code below.

\documentclass{article}
\usepackage{tikz}
\usepackage{listings}
\lstset{basicstyle=\ttfamily}
\begin{document}

\tikz
\node at (0,0) {
\begin{lstlisting}
a_b
\end{lstlisting}
};

\end{document}
share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.