1

I would like to explain a diagram created in TikZ by creating a description environment with small parts of the diagram as item labels.

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{positioning,arrows}
\begin{document}
\begin{frame}{Notation}
  \begin{description}
  \item[This works]%
    Temporary vertex \begin{minipage}[h]{2em}\begin{tikzpicture} \node[draw, circle] at (-4,0) (n1) {1}; \end{tikzpicture}\end{minipage} and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on
  \item[But
    % This line leads to an error:
    %% \begin{tikzpicture} \node[draw, circle] at (-4,0) (n1) {1}; \end{tikzpicture}
    ]%
    This does not work.
  \end{description}
\end{frame}
\end{document}

However, uncommenting the line starting with %% leads not to Desired output: a (1) inside the second description item label

but instead to a long chain of error messages, the cause of which I don't understand. In my ignorance, I tried to wrap it inside a minipage, like in the previous line. That did not help. What should I do?

./minimal_exapmle.tex:15: Argument of \tikz@fig@scan@options has an extra }.
<inserted text> 
                \par 
l.15 \end{frame}

Runaway argument? draw, circle ./minimal_exapmle.tex:15: Paragraph ended before \tikz@fig@scan@options was complete. <to be read again> \par l.15 \end{frame}

./minimal_exapmle.tex:15: Extra }, or forgotten \endgroup. <recently read> }

l.15 \end{frame}

./minimal_exapmle.tex:15: Extra }, or forgotten \endgroup. \beamer@usebeamertemplatedoss ...l@#1\endcsname }}

l.15 \end{frame}

./minimal_exapmle.tex:15: Extra }, or forgotten \endgroup. \NRorg@beamer@descriptionitem ...escription item}}

l.15 \end{frame}

./minimal_exapmle.tex:15: Extra }, or forgotten \endgroup. \sbox ...box {\color@setgroup #2\color@endgroup }

l.15 \end{frame}

./minimal_exapmle.tex:15: Extra }, or forgotten \endgroup. \endpgfpicture ...globally \endgroup \hss \egroup \pgf@restore@layerlist@fro...l.15 \end{frame}

./minimal_exapmle.tex:15: Missing } inserted. <inserted text> } l.15 \end{frame}

./minimal_exapmle.tex:15: Extra }, or forgotten \endgroup. \endpgfpicture ...dpicture \endgroup \hss \egroup \pgfsys@typesetpicturebox ...l.15 \end{frame}

./minimal_exapmle.tex:15: Missing } inserted. <inserted text> } l.15 \end{frame}

./minimal_exapmle.tex:15: LaTeX Error: Something's wrong--perhaps a missing \item.

See the LaTeX manual or LaTeX Companion for explanation. Type H <return> for immediate help. ...

l.15 \end{frame}

./minimal_exapmle.tex:15: LaTeX Error: Something's wrong--perhaps a missing \item.

See the LaTeX manual or LaTeX Companion for explanation. Type H <return> for immediate help. ...

l.15 \end{frame}

./minimal_exapmle.tex:15: LaTeX Error: \begin{tikzpicture} on input line 15 ended by \end{description}.

See the LaTeX manual or LaTeX Companion for explanation. Type H <return> for immediate help. ...

l.15 \end{frame}

./minimal_exapmle.tex:15: LaTeX Error: \begin{tikzpicture} on input line 15 ended by \end{beamer@framepauses}.

See the LaTeX manual or LaTeX Companion for explanation. Type H <return> for immediate help. ...

l.15 \end{frame}

./minimal_exapmle.tex:15: LaTeX Error: \begin{description} on input line 15 ended by \end{beamer@frameslide}.

See the LaTeX manual or LaTeX Companion for explanation. Type H <return> for immediate help. ...

l.15 \end{frame}

./minimal_exapmle.tex:15: Missing } inserted. <inserted text> } l.15 \end{frame}

./minimal_exapmle.tex:15: Missing } inserted. <inserted text> } l.15 \end{frame}

./minimal_exapmle.tex:15: Improper \prevdepth. \newpage ...everypar {}\fi \par \ifdim \prevdepth >\z@ \vskip -\ifdim \prevd...l.15 \end{frame}

./minimal_exapmle.tex:15: Missing } inserted. <inserted text> } l.15 \end{frame}

./minimal_exapmle.tex:16: LaTeX Error: \begin{description} on input line 15 ended by \end{document}.

See the LaTeX manual or LaTeX Companion for explanation. Type H <return> for immediate help. ...

l.16 \end{document}

(./minimal_exapmle.aux) ./minimal_exapmle.tex:16: You can't use `\end' in internal vertical mode. \enddocument ...cumenthook \deadcycles \z@ @@end

l.16 \end{document}

./minimal_exapmle.tex:16: LaTeX Error: \begin{description} on input line 15 ended by \end{document}.

See the LaTeX manual or LaTeX Companion for explanation. Type H <return> for immediate help. ...

l.16 \end{document}

) ! Emergency stop. <*> minimal_exapmle.tex

! ==> Fatal error occurred, no output PDF file produced! Transcript written on minimal_exapmle.log.

TeX Output exited abnormally with code 1 at Tue Oct 20 12:45:48

Anaphory
  • 440
  • 2
  • 10
  • 1
    Wrap it in braces: {\begin{tikzpicture} \node[draw, circle] at (-4,0) (n1) {1}; \end{tikzpicture}}. There's an explanation in the linked post below – Phelype Oleinik Oct 20 '20 at 10:59
  • Oh, i did actuarlly try to wrap it in \begin{group}…\end{group} suspecting it was some bit of the argument expansion. No idea why I didn't try it with brackets first, and the fact that commas matter makes a lot of sense to me, yes. – Anaphory Oct 20 '20 at 11:04
  • 1
    In this case it's not the comma that is misinterpreted, but the ] in \node[draw, circle] that is seen as the delimiter for the optional argument to \item, so it sees \item[\begin{tikzpicture} \node[draw, circle], and it goes downhill from there – Phelype Oleinik Oct 20 '20 at 11:06
  • I see. Reading the except from The TeXbook which you quote there, that makes sense. I'll keep that in mind for the future. – Anaphory Oct 20 '20 at 11:12

0 Answers0