使用 \include 时输入堆栈大小=5000 错误

Input stack size=5000 error when using \include

我正在“包含”一个 .tex 文件。我收到错误消息“超出 TeX 容量,抱歉 [输入堆栈大小 = 5000]。@nomath ...e@font@warning 等。” 该错误由 latex 在

行中找到

\pic[current plane, draw,fill=orange!50,fill opacity=.5, text opacity=1,"\footnotesize $\phi$", angle eccentricity=2.2]{angle=ketplus--origin--psiProjectedEquat}; %je nachdem, ob der Psi Pfeil links oder rechts von der z-Achse ist, muss man die Reihenfolge bei "angle=" umkehren }

我应该指出,“包含”的文件在单独编译时有效(其中序言不在主文件中,而是在文件本身中。似乎 \usepackage[ngerman]{babel} 在masterfile 导致问题。

MWE:

"file.tex":

\documentclass{article}
\usepackage[ngerman]{babel}

\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsfonts}
\usepackage{tikz}
\usetikzlibrary{positioning,arrows,calc,math,angles,quotes}
\usepackage{blochsphere}
\usepackage{braket}
\usetikzlibrary{arrows.meta}

\begin{document}
\include{file1}
\end{document}

"file1.tex":

\def\rotationSphere{-10} %Drehung im Uhrzeigersinn aus der Standardposition "x-Achse aus Bildebene heraus, y-Achse nach rechts"; 89.9 statt 90 (sonst Division von 0 durch 0)
\def\tiltSphere{10} %0.01 statt 0 da bei 0 Fehler bei der im Paket hinterlegten Rechnung mit Sinus/Cosinus kommen
\def\radiusSphere{2cm}
\def\psiTheta{70} %Winkel Theta
\def\psiPhi{65} %Winkel Phi

 %Farbeinstellung als Hinweis für sämtliche color= Befehle
  %draw={rgb,255:red,199; green,199; blue,199}

\begin{blochsphere}
[ball=none,radius=\radiusSphere,opacity=1,rotation=\rotationSphere,tilt=\tiltSphere,color=white]
    
\newcommand\drawLatitudeCircleNew[2][]{
\begingroup
\pgfmathsetmacro\yshift{sin(#2)*\blochsphere@radius}
\pgfmathsetmacro\radius{\blochsphere@radius*cos(#2)}
\drawCircleNew[#1,shift={{0,0,\yshift}},radius=\radius]{0}{0}
\endgroup
}%

\newcommand\drawLongitudeCircleNew[2][]{
\begingroup
\drawCircleNew[#1]{90}{#2+90}
\endgroup
}

\newcommand\drawCircleNew[3][]{
\begingroup
%\setkeys{blochsphere}{#1}
\setDrawingPlane{#2}{#3}
\computeVisibility{#2}{#3}{agamma}{abeta}
\begingroup\edef\tmp{\endgroup%
\noexpand\draw[opacity=0.2,line width=0.8,current plane,on layer=front,\unexpanded\expandafter{\blochsphere@style}] \unexpanded\expandafter{(\agamma-\abeta-0.2:\blochsphere@radius+\the\pgflinewidth*0.5) arc (\agamma-\abeta-0.2:\agamma+\abeta+0.2:\blochsphere@radius+\the\pgflinewidth*0.5)};
\noexpand\draw[current plane,opacity=0.5,line width=0.8,on layer=front,\unexpanded\expandafter{\blochsphere@style}] \unexpanded\expandafter{(\agamma+\abeta:\blochsphere@radius+\the\pgflinewidth*0.5) arc (\agamma+\abeta:\agamma-\abeta+360:\blochsphere@radius+\the\pgflinewidth*0.5)};
} \tmp
\endgroup
}%hier Dicke, Form und Farbe von Longitude/Latitude Circle einstellen
    
\pgfdeclareradialshading[tikz@ball]{ball}{\pgfqpoint{-10bp}{10bp}}{
color(0bp)=(tikz@ball!90!white);
color(9bp)=(tikz@ball!90!white);
color(18bp)=(tikz@ball!90!white);
color(25bp)=(tikz@ball!90!black);
color(50bp)=(black)
}
\drawBall[ball=3d,radius=\radiusSphere,opacity=1,rotation=\rotationSphere,tilt=\tiltSphere,color=white]
     
      %\drawBallGrid[style={opacity=.3}]{30}{30}
  %Vertikale Ebene (als Kreis) zeichnen
  %\drawLongitudeCircle[]{\rotationSphere} 
  \drawLongitudeCircleNew[style={opacity=0.3,line width=0.8}]{-90-0} %Schreibe bei Befehle, die Latitude und Longitude verwenden immer {90-phiTheta} und {-90-phi)}
  %Horizontale Ebene (als Kreis) zeichnen
  \drawLatitudeCircleNew[style={opacity=0.3,line width=0.8}]{90-90} %style={dashed} falls Linie gestrichelt haben will

  %Punkte auf der Kugel definieren (für Achsen)
  \labelLatLon[radius=\radiusSphere*1.3]{ket0}{90-0}{-90-0}; %Schreibe bei LatLon Befehl immer {90-phiTheta} und {-90-phi)} wegen Definition von LabelLatLon
  \labelLatLon[radius=\radiusSphere]{ket1}{90-180}{-90-0};
  
  \labelLatLon[radius=\radiusSphere]{ketminus}{90-90}{-90-0+180};
  \labelLatLon[radius=\radiusSphere*2.2]{ketplus}{90-90}{-90-0};
  
  \labelLatLon[radius=\radiusSphere*1.25]{ketpluspi2}{90-90}{-90-90}; 
  \labelLatLon[radius=\radiusSphere]{ketplus3pi2}{90-90}{-90-90+180};
  \labelLatLon{psi}{90-\psiTheta}{-90-\psiPhi};
  
  %Achen zeichnen und markieren
  %z-Achse
  \draw[-latex,opacity=0.5,line width=0.8] (0,0,0) -- (ket0) node[below right,inner sep=.5mm,opacity=0.5] at (ket0) {\footnotesize $z$};
  %Bemerkung: 0,0,0 karthesische Koordinaten; ket0 in 2D Koordinaten auf der Kugeloberfläche
  %gepunkteter Teil der z-Achse
   \draw[-latex,opacity=0.3,line width=0.8,-] (0,0,0) -- (ketplus3pi2) node[below right,inner sep=.5mm,opacity=0.5] at (ketplus3pi2) {};
   %usw.
   \draw[-latex,opacity=0.3,line width=0.8,-] (0,0,0) -- (ket1) node[below right,inner sep=.5mm,opacity=0.5] at (ket1) {};
   \draw[-latex,opacity=0.3,line width=0.8,-] (0,0,0) -- (ketminus) node[below right,inner sep=.5mm,opacity=0.5] at (ket1) {};
  \draw[-latex,opacity=0.5,line width=0.8] (0,0,0) -- (ketplus) node[above left,inner sep=.5mm,opacity=0.5] at (ketplus) {\footnotesize$x$};
  \draw[-latex,opacity=0.5,line width=0.8] (0,0,0) -- (ketpluspi2) node[below left,inner sep=0.5mm,opacity=0.5] at (ketpluspi2) {\footnotesize $y$};
  %|psi> zeichnen
  \draw[-latex,color=orange,line width=2] (0,0,0) -- (psi) node[above]{\footnotesize $\ket{\psi}$};
  \def\phitest{65}
     \labelLatLon{test}{90-90}{-90-65};
  \draw[-latex,color=orange,line width=2] (0,0,0) -- (test) node[above]{\footnotesize $\ket{test}$};
  %Winkel zeichnen
  \coordinate (origin) at (0,0,0);
  {
     %Projektion zeichnen - cosinus verwendet
    \setDrawingPlane{0}{0}
    \draw[current plane,dashed] (0,0,0) -- (180+\psiPhi:{cos(90-\psiTheta)*\radiusSphere}) coordinate (psiProjectedEquat) -- (psi); %Winkel:Länge Polarkoordinaten
    %Winkel schattieren (phi)
    \pic[current plane, draw,fill=orange!50,fill opacity=.5, text opacity=1,"\footnotesize $\phi$", angle eccentricity=2.2]{angle=ketplus--origin--psiProjectedEquat}; %je nachdem, ob der Psi Pfeil links oder rechts von der z-Achse ist, muss man die Reihenfolge bei "angle=" umkehren
  }
  { \setLongitudinalDrawingPlane{-90-\psiPhi}
    %Winkel schattieren (theta)
    \pic[current plane, draw,fill=orange!50,fill opacity=.5, text opacity=1,"\footnotesize $\theta$", angle eccentricity=1.5]{angle=ket0--origin--psi}; %je nachdem, ob der Psi Pfeil links oder rechts von der z-Achse ist, muss man die Reihenfolge bei "angle=" umkehren
  }  
\end{blochsphere}

正如您所注意到的,您的 tikz 图片和 babel 的组合导致了问题。您可以通过加载 babel tikz 库来解决此问题:

\documentclass{article}
\usepackage[ngerman]{babel}

\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsfonts}
\usepackage{tikz}
\usetikzlibrary{positioning,arrows,calc,math,angles,quotes}
\usepackage{blochsphere}
\usepackage{braket}
\usetikzlibrary{arrows.meta,babel}

\begin{document}
\include{file1}
\end{document}