Itemize list inside a tikzpicture node
You need to use a \parbox
, but since you probably want it to be the natural width of the text I used varwidth
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 the fit
library:
You can adjust the value of inner sep=
to control the spacing between the text and the box.
Code:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\usepackage{varwidth}
\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{varwidth}{\linewidth}\begin{itemize}
\item \texttt{[0]}
\item \texttt{[1]}
\item \texttt{[2]}
\end{itemize}\end{varwidth}}
}};
\end{tikzpicture}
\end{document}
Code: Suggested Solution
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\usetikzlibrary{fit}
\begin{document}
\begin{tikzpicture}
\node (Q1) at (1.7, 10) {\texttt{q1}};
\node (Q2) at (1.7, 8) {\texttt{q2}};
\node [font=\Large] (top) at (5,10) {$\bullet$ [0]};
\node [font=\Large] (middle) at (5,9) {$\bullet$ [1]};
\node [font=\Large] (bottom) at (5,8) {$\bullet$ [2]};
\node[draw=brown, thick,fit={(top) (middle) (bottom)}, inner sep=10pt] (box) {};
\draw [-{>[length=3mm,width=3mm]}, red, line width=1pt] (Q1) -- (top);
\draw [-{>[length=3mm,width=3mm]}, blue,line width=1pt] (Q2) -- (middle);
\end{tikzpicture}
\end{document}
Do you want like this?
\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 [draw] at (5, 10) {\vbox {\Large
{\begin{itemize}
\item \texttt{[0]}
\item \texttt{[1]}
\item \texttt{[2]}
\end{itemize}}
}};
\end{tikzpicture}
\end{document}