I'm trying to put a boxed itemize
list inside my TikZ figure:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\begin{document}
\begin{tikzpicture}
\node at (1.7, 10) {\texttt{q1}};
\node at (1.7, 8) {\texttt{q2}};
\draw [-{>[length=3mm,width=3mm]},line width=1pt] (2, 10) -- (5, 10);
\draw [-{>[length=3mm,width=3mm]},line width=1pt] (2, 9) -- (5, 8.8);
\node at (5, 10) {\framebox{\Large
{\begin{itemize}
\item \texttt{[0]}
\item \texttt{[1]}
\item \texttt{[2]}
\end{itemize}}
}};
\end{tikzpicture}
\end{document}
But I get
! LaTeX Error: Something's wrong--perhaps a missing \item.` at the line `}};
and I don't understand why (since I have fed \itemize
three \item
s.) Can anyone help?
Best Answer
You need to use a
\parbox
, but since you probably want it to be the natural width of the text I usedvarwidth
in the example below:but I would recommend you use
\nodes
instead for each of the bulleted items, which makes it easier to connect them. To draw the box around the nodes you can use thefit
library:You can adjust the value of
inner sep=
to control the spacing between the text and the box.Code:
Code: Suggested Solution