I am using the blochsphere package (see 1) and I want to nest it in another tikzpicture, to work with several blochspheres. The manual tells one to put "nested=true" in the settings for \begin{tikzpicture}
. Unfortunately there are many errors, even when using the blochsphere example, given in the manual - which I use to provide a MWE:
\documentclass[10pt,a4paper]{article}
\usepackage{tikz}
\usepackage{blochsphere}
\begin{document}
\begin{figure}
\begin{tikzpicture}
\draw (0,0) node []{
\begin{blochsphere}[nested=false,radius=1.5 cm,tilt=15,rotation=-20]
\drawBallGrid[style={opacity=0.3}]{30}{30}
\drawGreatCircle[style={dashed}]{-60}{0}{0}
\drawGreatCircle[style={dashed}]{60}{0}{0}
\drawRotationLeft[scale=1.3,style={red}]{-60}{0}{0}{15}
\drawRotationRight[scale=1.3,style={red}]{60}{0}{0}{15}
\node at (-0.8,1.9) {\textcolor{red}{\tiny $J_{12}(t)$}};
\node at (1.1,1.8) {\textcolor{red}{\tiny $J_{23}(t)$}};
\labelLatLon{up}{90}{0};
\labelLatLon{down}{-90}{90};
\node[above] at (up) {{\tiny $\left|1\right>$ }};
\node[below] at (down) {{\tiny $\left|0\right>$}};
\labelLatLon[labelmark=false]{d}{15}{90};
\node at (d) {\color{gray}\fontsize{0.15cm}{1em}\selectfont $60^\circ$};
\labelLatLon[labelmark=false]{d2}{5}{78};
\end{blochsphere}
}
\end{tikzpicture}
\end{figure}
\end{document}
The code above is the MWE. The following code gives the example from the manual (that works, but is not nested):
\documentclass[10pt,a4paper]{article}
\usepackage{tikz}
\usepackage{blochsphere}
\begin{document}
\begin{figure}
\begin{blochsphere}[nested=false,radius=1.5 cm,tilt=15,rotation=-20]
\drawBallGrid[style={opacity=0.3}]{30}{30}
\drawGreatCircle[style={dashed}]{-60}{0}{0}
\drawGreatCircle[style={dashed}]{60}{0}{0}
\drawRotationLeft[scale=1.3,style={red}]{-60}{0}{0}{15}
\drawRotationRight[scale=1.3,style={red}]{60}{0}{0}{15}
\node at (-0.8,1.9) {\textcolor{red}{\tiny $J_{12}(t)$}};
\node at (1.1,1.8) {\textcolor{red}{\tiny $J_{23}(t)$}};
\labelLatLon{up}{90}{0};
\labelLatLon{down}{-90}{90};
\node[above] at (up) {{\tiny $\left|1\right>$ }};
\node[below] at (down) {{\tiny $\left|0\right>$}};
\labelLatLon[labelmark=false]{d}{15}{90};
\node at (d) {\color{gray}\fontsize{0.15cm}{1em}\selectfont $60^\circ$};
\labelLatLon[labelmark=false]{d2}{5}{78};
\end{blochsphere}
\end{figure}
\end{document}
One error e.g. is the following (but there are a lot):
! Undefined control sequence.\tmp ->\endgroup \draw[current plane,on layer=back,opacity=0.3] (\agamma -\... \drawBallGrid[style={opacity=0.3}]{30}{30}
In the case of my personal blochsphere I get those as well as other errors like missing number treated as zero
etc.
Could someone help me make the blochsphere package work to nest in another tikzpicture?
Thank you!
The ;
at the end of the path is missing.
That being said, nesting tikz pictures in nodes is usually not a good idea - surprising things can happen...
\documentclass[10pt,a4paper]{article}
\usepackage{tikz}
\usepackage{blochsphere}
\begin{document}
\begin{figure}
\begin{tikzpicture}
\draw (0,0) node []{
\begin{blochsphere}[nested=false,radius=1.5 cm,tilt=15,rotation=-20]
\drawBallGrid[style={opacity=0.3}]{30}{30}
\drawGreatCircle[style={dashed}]{-60}{0}{0}
\drawGreatCircle[style={dashed}]{60}{0}{0}
\drawRotationLeft[scale=1.3,style={red}]{-60}{0}{0}{15}
\drawRotationRight[scale=1.3,style={red}]{60}{0}{0}{15}
\node at (-0.8,1.9) {\textcolor{red}{\tiny $J_{12}(t)$}};
\node at (1.1,1.8) {\textcolor{red}{\tiny $J_{23}(t)$}};
\labelLatLon{up}{90}{0};
\labelLatLon{down}{-90}{90};
\node[above] at (up) {{\tiny $\left|1\right>$ }};
\node[below] at (down) {{\tiny $\left|0\right>$}};
\labelLatLon[labelmark=false]{d}{15}{90};
\node at (d) {\color{gray}\fontsize{0.15cm}{1em}\selectfont $60^\circ$};
\labelLatLon[labelmark=false]{d2}{5}{78};
\end{blochsphere}
};
\end{tikzpicture}
\end{figure}
\end{document}
The nested=false
option is for when you use the blochsphere
environment directly in a tikzpicture, e.g.
\begin{tikzpicture}
\begin{blochsphere}[nested=true]
\drawBall
\end{blochsphere}
\end{tikzpicture}
because it will switch off the tikzpicture
which is normally automatically added to the blochsphere
environment (... I think there is some problem with expansion going on if used like this, not everything is drawn...).
The easy way out would be to ditch your tikz picture and place everything you wanted to draw in your tikz picture inside the blochsphere
environment.