I want to achieve the same result as for the question: Tikz animated figure in Beamer
The difference in my case is, that I use labels in my nodes. For nodes there is already a solution in the comment by @kmundnic: Tikz animated figure in Beamer
But in my special case I have newlines in the labels, which results in the error:
! 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.16 \end{frame}
?
My MWE to reproduce the error is:
\documentclass[tikz]{beamer}
\usepackage{tikz}
\tikzset{
invisible/.style={opacity=0,prefix after command={\pgfextra{\tikzset{every label/.style={opacity=0}}}}},
visible on/.style={alt={#1{}{invisible}}},
alt/.code args={<#1>#2#3}{%
\alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}} % \pgfkeysalso doesn't change the path
},
}
\begin{document}
\begin{frame}
\begin{tikzpicture}[every label/.style={align=center}]
\path (1,1) node[draw, shape=circle, text width=2.2cm, visible on=<2->, label=center:{Label\new Line}] (LODL2) {};
\end{tikzpicture}
\end{frame}
\end{document}
If you just leave out the \\ it will compile.
Edit:* added every label/.style={align=center} to tikzpicture which is needed to compile the MWE without the animation part.
Edit2:* putting the label into the node, so far is no solution, as the amount of text make the node bigger:
\path (1,1) node[draw, shape=circle, text width=2.2cm, align=center, label=center:{Label\\new Line}] (LODL1) {};
\path (4,1) node[draw, shape=circle, text width=2.2cm, visible on=<2->, align=center, label=center:{}] (LODL2) {Label\\new Line};
\path (1,1) node[draw, shape=circle, text width=2.2cm, visible on=<3->, align=center, label=center:{}] (LODL2) {Label\\new Line};
In this image, first the node is drawn as I want it at (1,1), then two nodes are drawn at (4,1) and (1,1) with the label in the node. As one can see the second and third node is bigger than the first node. The more text, the bigger the circle.


text width=2.2cmparameter you added to the code. – AndréC Jun 27 '20 at 22:10