Take the following MWE:
I made this node with tikz
using the normal font:
However, I need to use a monospaced font to get the following result:
Since the node has two lines of text, I would normally do \texttt{line1\\line2}
. However when I compile it I get lots of errors.
If I do \texttt{line1}\\\texttt{line2}
it compiles with no errors.
Why can't I use \\
inside \texttt{}
? Is there a solution to avoid putting \texttt{}
on every line of text?
\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\node[draw,rectangle,align=center] {line1\\line2};
\end{tikzpicture}
\end{document}
{\ttfamily text1\\ text2}
\node[draw,rectangle,align=center,font=\ttfamily] {line1\\line2};
?