label shifting behavior in tikz vs tikz-cd











up vote
1
down vote

favorite
1












I have a tikz picture that has labels, and the labels are in the correct place. However when I put the {tikzpicture} inside a {tikzcd} environment, the position of the labels shifts noticeably up, and they are no longer in the position I want. It would be easy enough to solve this by not using the {tikzcd} environment, but I want this picture to be part of a larger commuting diagram. So my question is,



How do I force the labels to stay in the same place when I place a {tikzpicture} inside a {tikzcd}?



I've included a stripped-down version of my code below.



documentclass[11pt]{amsart}
usepackage{fouriernc} % Fourier fonts instead of Computer Modern
usepackage{PageSetup} % general setup
usepackage{tikz, tikz-cd}

% art style for graphs
newcommand*{bigradius}{2.7em} % radius of a circle-shaped graph
newcommand*{biggerradius}{6.0em} % radius of a really big circle-shaped graph
newcommand*{dist}{4em} % separation between nodes of a line-shaped graph
newcommand*{distshort}{3.25em} % separation between nodes of a line-shaped graph
newcommand*{labeloffset}{1em} % spacing between the edges and their labels
newcommand*{vertexlabeloffset}{1.5em} % spacing between the vertices and their labels
newcommand*{littleradius}{.4em} % radius of the vertices
newcommand*{straightpathwidth}{.17em} % width of a straight path (needs to be slightly thicker than a curved path)
newcommand*{curvedpathwidth}{.14em}

begin{document}

Correct:

begin{tikzpicture}
% the BIG circle
draw[black, line width=curvedpathwidth] (0,0) circle (biggerradius);
% vertices
filldraw[fill=black, draw=black, line width=curvedpathwidth] ( 90:biggerradius) circle (littleradius);
filldraw[fill=white, draw=black, line width=curvedpathwidth] (120:biggerradius) circle (littleradius);
filldraw[fill=black, draw=black, line width=curvedpathwidth] (150:biggerradius) circle (littleradius);
filldraw[fill=white, draw=black, line width=curvedpathwidth] (180:biggerradius) circle (littleradius);
filldraw[fill=black, draw=black, line width=curvedpathwidth] (210:biggerradius) circle (littleradius);
filldraw[fill=white, draw=black, line width=curvedpathwidth] (240:biggerradius) circle (littleradius);
filldraw[fill=black, draw=black, line width=curvedpathwidth] (270:biggerradius) circle (littleradius);
filldraw[fill=white, draw=black, line width=curvedpathwidth] (300:biggerradius) circle (littleradius);
filldraw[fill=black, draw=black, line width=curvedpathwidth] (330:biggerradius) circle (littleradius);
filldraw[fill=white, draw=black, line width=curvedpathwidth] ( 0:biggerradius) circle (littleradius);
filldraw[fill=black, draw=black, line width=curvedpathwidth] ( 30:biggerradius) circle (littleradius);
filldraw[fill=white, draw=black, line width=curvedpathwidth] ( 60:biggerradius) circle (littleradius);
% labels
draw[line width=curvedpathwidth] ( 90:biggerradius - vertexlabeloffset) node {$P_1$};
draw[line width=curvedpathwidth] ( 75:biggerradius + vertexlabeloffset) node {$B_1$};
draw[line width=curvedpathwidth] ( 45:biggerradius + vertexlabeloffset) node {$B_1$};
draw[line width=curvedpathwidth] ( 30:biggerradius - vertexlabeloffset) node {$P_2$};
draw[line width=curvedpathwidth] ( 15:biggerradius + vertexlabeloffset) node {$B_2$};
draw[line width=curvedpathwidth] (345:biggerradius + vertexlabeloffset) node {$B_2$};
draw[line width=curvedpathwidth] (330:biggerradius - vertexlabeloffset) node {$P_3$};
draw[line width=curvedpathwidth] (315:biggerradius + vertexlabeloffset) node {$B_3$};
draw[line width=curvedpathwidth] (285:biggerradius + vertexlabeloffset) node {$B_3$};
draw[line width=curvedpathwidth] (270:biggerradius - vertexlabeloffset) node {$P_4$};
draw[line width=curvedpathwidth] (255:biggerradius + vertexlabeloffset) node {$B_4$};
draw[line width=curvedpathwidth] (225:biggerradius + vertexlabeloffset) node {$B_4$};
draw[line width=curvedpathwidth] (210:biggerradius - vertexlabeloffset) node {$P_5$};
draw[line width=curvedpathwidth] (195:biggerradius + vertexlabeloffset) node {$B_5$};
draw[line width=curvedpathwidth] (165:biggerradius + vertexlabeloffset) node {$B_5$};
draw[line width=curvedpathwidth] (150:biggerradius - vertexlabeloffset) node {$P_6$};
draw[line width=curvedpathwidth] (135:biggerradius + vertexlabeloffset) node {$B_6$};
draw[line width=curvedpathwidth] (105:biggerradius + vertexlabeloffset) node {$B_6$};
end{tikzpicture}

Incorrect:

begin{tikzcd}
begin{tikzpicture}
% the BIG circle
draw[black, line width=curvedpathwidth] (0,0) circle (biggerradius);
% vertices
filldraw[fill=black, draw=black, line width=curvedpathwidth] ( 90:biggerradius) circle (littleradius);
filldraw[fill=white, draw=black, line width=curvedpathwidth] (120:biggerradius) circle (littleradius);
filldraw[fill=black, draw=black, line width=curvedpathwidth] (150:biggerradius) circle (littleradius);
filldraw[fill=white, draw=black, line width=curvedpathwidth] (180:biggerradius) circle (littleradius);
filldraw[fill=black, draw=black, line width=curvedpathwidth] (210:biggerradius) circle (littleradius);
filldraw[fill=white, draw=black, line width=curvedpathwidth] (240:biggerradius) circle (littleradius);
filldraw[fill=black, draw=black, line width=curvedpathwidth] (270:biggerradius) circle (littleradius);
filldraw[fill=white, draw=black, line width=curvedpathwidth] (300:biggerradius) circle (littleradius);
filldraw[fill=black, draw=black, line width=curvedpathwidth] (330:biggerradius) circle (littleradius);
filldraw[fill=white, draw=black, line width=curvedpathwidth] ( 0:biggerradius) circle (littleradius);
filldraw[fill=black, draw=black, line width=curvedpathwidth] ( 30:biggerradius) circle (littleradius);
filldraw[fill=white, draw=black, line width=curvedpathwidth] ( 60:biggerradius) circle (littleradius);
% labels
draw[line width=curvedpathwidth] ( 90:biggerradius - vertexlabeloffset) node {$P_1$};
draw[line width=curvedpathwidth] ( 75:biggerradius + vertexlabeloffset) node {$B_1$};
draw[line width=curvedpathwidth] ( 45:biggerradius + vertexlabeloffset) node {$B_1$};
draw[line width=curvedpathwidth] ( 30:biggerradius - vertexlabeloffset) node {$P_2$};
draw[line width=curvedpathwidth] ( 15:biggerradius + vertexlabeloffset) node {$B_2$};
draw[line width=curvedpathwidth] (345:biggerradius + vertexlabeloffset) node {$B_2$};
draw[line width=curvedpathwidth] (330:biggerradius - vertexlabeloffset) node {$P_3$};
draw[line width=curvedpathwidth] (315:biggerradius + vertexlabeloffset) node {$B_3$};
draw[line width=curvedpathwidth] (285:biggerradius + vertexlabeloffset) node {$B_3$};
draw[line width=curvedpathwidth] (270:biggerradius - vertexlabeloffset) node {$P_4$};
draw[line width=curvedpathwidth] (255:biggerradius + vertexlabeloffset) node {$B_4$};
draw[line width=curvedpathwidth] (225:biggerradius + vertexlabeloffset) node {$B_4$};
draw[line width=curvedpathwidth] (210:biggerradius - vertexlabeloffset) node {$P_5$};
draw[line width=curvedpathwidth] (195:biggerradius + vertexlabeloffset) node {$B_5$};
draw[line width=curvedpathwidth] (165:biggerradius + vertexlabeloffset) node {$B_5$};
draw[line width=curvedpathwidth] (150:biggerradius - vertexlabeloffset) node {$P_6$};
draw[line width=curvedpathwidth] (135:biggerradius + vertexlabeloffset) node {$B_6$};
draw[line width=curvedpathwidth] (105:biggerradius + vertexlabeloffset) node {$B_6$};
end{tikzpicture}
end{tikzcd}



end{document}


It gives this result:



The correct and incorrect behavior










share|improve this question







New contributor




Cary is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 1




    Welcome to TeX.SX! Nesting a tikzpicture in another one is highly unrecommended.
    – egreg
    20 hours ago










  • Thanks for the pointer! I seem to be getting the same problem with the subfigure environment as well. Is there a good environment for positioning several pictures with arrows between them, or captions below, that doesn't come highly unrecommended?
    – Cary
    20 hours ago










  • Yes, subfigure is also deprecated, but the strange behavior is explained by nesting tikzpictures, as @egreg pointed out. If you put the ikzpicture into as savebox, the issues will disappear.
    – marmot
    19 hours ago















up vote
1
down vote

favorite
1












I have a tikz picture that has labels, and the labels are in the correct place. However when I put the {tikzpicture} inside a {tikzcd} environment, the position of the labels shifts noticeably up, and they are no longer in the position I want. It would be easy enough to solve this by not using the {tikzcd} environment, but I want this picture to be part of a larger commuting diagram. So my question is,



How do I force the labels to stay in the same place when I place a {tikzpicture} inside a {tikzcd}?



I've included a stripped-down version of my code below.



documentclass[11pt]{amsart}
usepackage{fouriernc} % Fourier fonts instead of Computer Modern
usepackage{PageSetup} % general setup
usepackage{tikz, tikz-cd}

% art style for graphs
newcommand*{bigradius}{2.7em} % radius of a circle-shaped graph
newcommand*{biggerradius}{6.0em} % radius of a really big circle-shaped graph
newcommand*{dist}{4em} % separation between nodes of a line-shaped graph
newcommand*{distshort}{3.25em} % separation between nodes of a line-shaped graph
newcommand*{labeloffset}{1em} % spacing between the edges and their labels
newcommand*{vertexlabeloffset}{1.5em} % spacing between the vertices and their labels
newcommand*{littleradius}{.4em} % radius of the vertices
newcommand*{straightpathwidth}{.17em} % width of a straight path (needs to be slightly thicker than a curved path)
newcommand*{curvedpathwidth}{.14em}

begin{document}

Correct:

begin{tikzpicture}
% the BIG circle
draw[black, line width=curvedpathwidth] (0,0) circle (biggerradius);
% vertices
filldraw[fill=black, draw=black, line width=curvedpathwidth] ( 90:biggerradius) circle (littleradius);
filldraw[fill=white, draw=black, line width=curvedpathwidth] (120:biggerradius) circle (littleradius);
filldraw[fill=black, draw=black, line width=curvedpathwidth] (150:biggerradius) circle (littleradius);
filldraw[fill=white, draw=black, line width=curvedpathwidth] (180:biggerradius) circle (littleradius);
filldraw[fill=black, draw=black, line width=curvedpathwidth] (210:biggerradius) circle (littleradius);
filldraw[fill=white, draw=black, line width=curvedpathwidth] (240:biggerradius) circle (littleradius);
filldraw[fill=black, draw=black, line width=curvedpathwidth] (270:biggerradius) circle (littleradius);
filldraw[fill=white, draw=black, line width=curvedpathwidth] (300:biggerradius) circle (littleradius);
filldraw[fill=black, draw=black, line width=curvedpathwidth] (330:biggerradius) circle (littleradius);
filldraw[fill=white, draw=black, line width=curvedpathwidth] ( 0:biggerradius) circle (littleradius);
filldraw[fill=black, draw=black, line width=curvedpathwidth] ( 30:biggerradius) circle (littleradius);
filldraw[fill=white, draw=black, line width=curvedpathwidth] ( 60:biggerradius) circle (littleradius);
% labels
draw[line width=curvedpathwidth] ( 90:biggerradius - vertexlabeloffset) node {$P_1$};
draw[line width=curvedpathwidth] ( 75:biggerradius + vertexlabeloffset) node {$B_1$};
draw[line width=curvedpathwidth] ( 45:biggerradius + vertexlabeloffset) node {$B_1$};
draw[line width=curvedpathwidth] ( 30:biggerradius - vertexlabeloffset) node {$P_2$};
draw[line width=curvedpathwidth] ( 15:biggerradius + vertexlabeloffset) node {$B_2$};
draw[line width=curvedpathwidth] (345:biggerradius + vertexlabeloffset) node {$B_2$};
draw[line width=curvedpathwidth] (330:biggerradius - vertexlabeloffset) node {$P_3$};
draw[line width=curvedpathwidth] (315:biggerradius + vertexlabeloffset) node {$B_3$};
draw[line width=curvedpathwidth] (285:biggerradius + vertexlabeloffset) node {$B_3$};
draw[line width=curvedpathwidth] (270:biggerradius - vertexlabeloffset) node {$P_4$};
draw[line width=curvedpathwidth] (255:biggerradius + vertexlabeloffset) node {$B_4$};
draw[line width=curvedpathwidth] (225:biggerradius + vertexlabeloffset) node {$B_4$};
draw[line width=curvedpathwidth] (210:biggerradius - vertexlabeloffset) node {$P_5$};
draw[line width=curvedpathwidth] (195:biggerradius + vertexlabeloffset) node {$B_5$};
draw[line width=curvedpathwidth] (165:biggerradius + vertexlabeloffset) node {$B_5$};
draw[line width=curvedpathwidth] (150:biggerradius - vertexlabeloffset) node {$P_6$};
draw[line width=curvedpathwidth] (135:biggerradius + vertexlabeloffset) node {$B_6$};
draw[line width=curvedpathwidth] (105:biggerradius + vertexlabeloffset) node {$B_6$};
end{tikzpicture}

Incorrect:

begin{tikzcd}
begin{tikzpicture}
% the BIG circle
draw[black, line width=curvedpathwidth] (0,0) circle (biggerradius);
% vertices
filldraw[fill=black, draw=black, line width=curvedpathwidth] ( 90:biggerradius) circle (littleradius);
filldraw[fill=white, draw=black, line width=curvedpathwidth] (120:biggerradius) circle (littleradius);
filldraw[fill=black, draw=black, line width=curvedpathwidth] (150:biggerradius) circle (littleradius);
filldraw[fill=white, draw=black, line width=curvedpathwidth] (180:biggerradius) circle (littleradius);
filldraw[fill=black, draw=black, line width=curvedpathwidth] (210:biggerradius) circle (littleradius);
filldraw[fill=white, draw=black, line width=curvedpathwidth] (240:biggerradius) circle (littleradius);
filldraw[fill=black, draw=black, line width=curvedpathwidth] (270:biggerradius) circle (littleradius);
filldraw[fill=white, draw=black, line width=curvedpathwidth] (300:biggerradius) circle (littleradius);
filldraw[fill=black, draw=black, line width=curvedpathwidth] (330:biggerradius) circle (littleradius);
filldraw[fill=white, draw=black, line width=curvedpathwidth] ( 0:biggerradius) circle (littleradius);
filldraw[fill=black, draw=black, line width=curvedpathwidth] ( 30:biggerradius) circle (littleradius);
filldraw[fill=white, draw=black, line width=curvedpathwidth] ( 60:biggerradius) circle (littleradius);
% labels
draw[line width=curvedpathwidth] ( 90:biggerradius - vertexlabeloffset) node {$P_1$};
draw[line width=curvedpathwidth] ( 75:biggerradius + vertexlabeloffset) node {$B_1$};
draw[line width=curvedpathwidth] ( 45:biggerradius + vertexlabeloffset) node {$B_1$};
draw[line width=curvedpathwidth] ( 30:biggerradius - vertexlabeloffset) node {$P_2$};
draw[line width=curvedpathwidth] ( 15:biggerradius + vertexlabeloffset) node {$B_2$};
draw[line width=curvedpathwidth] (345:biggerradius + vertexlabeloffset) node {$B_2$};
draw[line width=curvedpathwidth] (330:biggerradius - vertexlabeloffset) node {$P_3$};
draw[line width=curvedpathwidth] (315:biggerradius + vertexlabeloffset) node {$B_3$};
draw[line width=curvedpathwidth] (285:biggerradius + vertexlabeloffset) node {$B_3$};
draw[line width=curvedpathwidth] (270:biggerradius - vertexlabeloffset) node {$P_4$};
draw[line width=curvedpathwidth] (255:biggerradius + vertexlabeloffset) node {$B_4$};
draw[line width=curvedpathwidth] (225:biggerradius + vertexlabeloffset) node {$B_4$};
draw[line width=curvedpathwidth] (210:biggerradius - vertexlabeloffset) node {$P_5$};
draw[line width=curvedpathwidth] (195:biggerradius + vertexlabeloffset) node {$B_5$};
draw[line width=curvedpathwidth] (165:biggerradius + vertexlabeloffset) node {$B_5$};
draw[line width=curvedpathwidth] (150:biggerradius - vertexlabeloffset) node {$P_6$};
draw[line width=curvedpathwidth] (135:biggerradius + vertexlabeloffset) node {$B_6$};
draw[line width=curvedpathwidth] (105:biggerradius + vertexlabeloffset) node {$B_6$};
end{tikzpicture}
end{tikzcd}



end{document}


It gives this result:



The correct and incorrect behavior










share|improve this question







New contributor




Cary is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 1




    Welcome to TeX.SX! Nesting a tikzpicture in another one is highly unrecommended.
    – egreg
    20 hours ago










  • Thanks for the pointer! I seem to be getting the same problem with the subfigure environment as well. Is there a good environment for positioning several pictures with arrows between them, or captions below, that doesn't come highly unrecommended?
    – Cary
    20 hours ago










  • Yes, subfigure is also deprecated, but the strange behavior is explained by nesting tikzpictures, as @egreg pointed out. If you put the ikzpicture into as savebox, the issues will disappear.
    – marmot
    19 hours ago













up vote
1
down vote

favorite
1









up vote
1
down vote

favorite
1






1





I have a tikz picture that has labels, and the labels are in the correct place. However when I put the {tikzpicture} inside a {tikzcd} environment, the position of the labels shifts noticeably up, and they are no longer in the position I want. It would be easy enough to solve this by not using the {tikzcd} environment, but I want this picture to be part of a larger commuting diagram. So my question is,



How do I force the labels to stay in the same place when I place a {tikzpicture} inside a {tikzcd}?



I've included a stripped-down version of my code below.



documentclass[11pt]{amsart}
usepackage{fouriernc} % Fourier fonts instead of Computer Modern
usepackage{PageSetup} % general setup
usepackage{tikz, tikz-cd}

% art style for graphs
newcommand*{bigradius}{2.7em} % radius of a circle-shaped graph
newcommand*{biggerradius}{6.0em} % radius of a really big circle-shaped graph
newcommand*{dist}{4em} % separation between nodes of a line-shaped graph
newcommand*{distshort}{3.25em} % separation between nodes of a line-shaped graph
newcommand*{labeloffset}{1em} % spacing between the edges and their labels
newcommand*{vertexlabeloffset}{1.5em} % spacing between the vertices and their labels
newcommand*{littleradius}{.4em} % radius of the vertices
newcommand*{straightpathwidth}{.17em} % width of a straight path (needs to be slightly thicker than a curved path)
newcommand*{curvedpathwidth}{.14em}

begin{document}

Correct:

begin{tikzpicture}
% the BIG circle
draw[black, line width=curvedpathwidth] (0,0) circle (biggerradius);
% vertices
filldraw[fill=black, draw=black, line width=curvedpathwidth] ( 90:biggerradius) circle (littleradius);
filldraw[fill=white, draw=black, line width=curvedpathwidth] (120:biggerradius) circle (littleradius);
filldraw[fill=black, draw=black, line width=curvedpathwidth] (150:biggerradius) circle (littleradius);
filldraw[fill=white, draw=black, line width=curvedpathwidth] (180:biggerradius) circle (littleradius);
filldraw[fill=black, draw=black, line width=curvedpathwidth] (210:biggerradius) circle (littleradius);
filldraw[fill=white, draw=black, line width=curvedpathwidth] (240:biggerradius) circle (littleradius);
filldraw[fill=black, draw=black, line width=curvedpathwidth] (270:biggerradius) circle (littleradius);
filldraw[fill=white, draw=black, line width=curvedpathwidth] (300:biggerradius) circle (littleradius);
filldraw[fill=black, draw=black, line width=curvedpathwidth] (330:biggerradius) circle (littleradius);
filldraw[fill=white, draw=black, line width=curvedpathwidth] ( 0:biggerradius) circle (littleradius);
filldraw[fill=black, draw=black, line width=curvedpathwidth] ( 30:biggerradius) circle (littleradius);
filldraw[fill=white, draw=black, line width=curvedpathwidth] ( 60:biggerradius) circle (littleradius);
% labels
draw[line width=curvedpathwidth] ( 90:biggerradius - vertexlabeloffset) node {$P_1$};
draw[line width=curvedpathwidth] ( 75:biggerradius + vertexlabeloffset) node {$B_1$};
draw[line width=curvedpathwidth] ( 45:biggerradius + vertexlabeloffset) node {$B_1$};
draw[line width=curvedpathwidth] ( 30:biggerradius - vertexlabeloffset) node {$P_2$};
draw[line width=curvedpathwidth] ( 15:biggerradius + vertexlabeloffset) node {$B_2$};
draw[line width=curvedpathwidth] (345:biggerradius + vertexlabeloffset) node {$B_2$};
draw[line width=curvedpathwidth] (330:biggerradius - vertexlabeloffset) node {$P_3$};
draw[line width=curvedpathwidth] (315:biggerradius + vertexlabeloffset) node {$B_3$};
draw[line width=curvedpathwidth] (285:biggerradius + vertexlabeloffset) node {$B_3$};
draw[line width=curvedpathwidth] (270:biggerradius - vertexlabeloffset) node {$P_4$};
draw[line width=curvedpathwidth] (255:biggerradius + vertexlabeloffset) node {$B_4$};
draw[line width=curvedpathwidth] (225:biggerradius + vertexlabeloffset) node {$B_4$};
draw[line width=curvedpathwidth] (210:biggerradius - vertexlabeloffset) node {$P_5$};
draw[line width=curvedpathwidth] (195:biggerradius + vertexlabeloffset) node {$B_5$};
draw[line width=curvedpathwidth] (165:biggerradius + vertexlabeloffset) node {$B_5$};
draw[line width=curvedpathwidth] (150:biggerradius - vertexlabeloffset) node {$P_6$};
draw[line width=curvedpathwidth] (135:biggerradius + vertexlabeloffset) node {$B_6$};
draw[line width=curvedpathwidth] (105:biggerradius + vertexlabeloffset) node {$B_6$};
end{tikzpicture}

Incorrect:

begin{tikzcd}
begin{tikzpicture}
% the BIG circle
draw[black, line width=curvedpathwidth] (0,0) circle (biggerradius);
% vertices
filldraw[fill=black, draw=black, line width=curvedpathwidth] ( 90:biggerradius) circle (littleradius);
filldraw[fill=white, draw=black, line width=curvedpathwidth] (120:biggerradius) circle (littleradius);
filldraw[fill=black, draw=black, line width=curvedpathwidth] (150:biggerradius) circle (littleradius);
filldraw[fill=white, draw=black, line width=curvedpathwidth] (180:biggerradius) circle (littleradius);
filldraw[fill=black, draw=black, line width=curvedpathwidth] (210:biggerradius) circle (littleradius);
filldraw[fill=white, draw=black, line width=curvedpathwidth] (240:biggerradius) circle (littleradius);
filldraw[fill=black, draw=black, line width=curvedpathwidth] (270:biggerradius) circle (littleradius);
filldraw[fill=white, draw=black, line width=curvedpathwidth] (300:biggerradius) circle (littleradius);
filldraw[fill=black, draw=black, line width=curvedpathwidth] (330:biggerradius) circle (littleradius);
filldraw[fill=white, draw=black, line width=curvedpathwidth] ( 0:biggerradius) circle (littleradius);
filldraw[fill=black, draw=black, line width=curvedpathwidth] ( 30:biggerradius) circle (littleradius);
filldraw[fill=white, draw=black, line width=curvedpathwidth] ( 60:biggerradius) circle (littleradius);
% labels
draw[line width=curvedpathwidth] ( 90:biggerradius - vertexlabeloffset) node {$P_1$};
draw[line width=curvedpathwidth] ( 75:biggerradius + vertexlabeloffset) node {$B_1$};
draw[line width=curvedpathwidth] ( 45:biggerradius + vertexlabeloffset) node {$B_1$};
draw[line width=curvedpathwidth] ( 30:biggerradius - vertexlabeloffset) node {$P_2$};
draw[line width=curvedpathwidth] ( 15:biggerradius + vertexlabeloffset) node {$B_2$};
draw[line width=curvedpathwidth] (345:biggerradius + vertexlabeloffset) node {$B_2$};
draw[line width=curvedpathwidth] (330:biggerradius - vertexlabeloffset) node {$P_3$};
draw[line width=curvedpathwidth] (315:biggerradius + vertexlabeloffset) node {$B_3$};
draw[line width=curvedpathwidth] (285:biggerradius + vertexlabeloffset) node {$B_3$};
draw[line width=curvedpathwidth] (270:biggerradius - vertexlabeloffset) node {$P_4$};
draw[line width=curvedpathwidth] (255:biggerradius + vertexlabeloffset) node {$B_4$};
draw[line width=curvedpathwidth] (225:biggerradius + vertexlabeloffset) node {$B_4$};
draw[line width=curvedpathwidth] (210:biggerradius - vertexlabeloffset) node {$P_5$};
draw[line width=curvedpathwidth] (195:biggerradius + vertexlabeloffset) node {$B_5$};
draw[line width=curvedpathwidth] (165:biggerradius + vertexlabeloffset) node {$B_5$};
draw[line width=curvedpathwidth] (150:biggerradius - vertexlabeloffset) node {$P_6$};
draw[line width=curvedpathwidth] (135:biggerradius + vertexlabeloffset) node {$B_6$};
draw[line width=curvedpathwidth] (105:biggerradius + vertexlabeloffset) node {$B_6$};
end{tikzpicture}
end{tikzcd}



end{document}


It gives this result:



The correct and incorrect behavior










share|improve this question







New contributor




Cary is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











I have a tikz picture that has labels, and the labels are in the correct place. However when I put the {tikzpicture} inside a {tikzcd} environment, the position of the labels shifts noticeably up, and they are no longer in the position I want. It would be easy enough to solve this by not using the {tikzcd} environment, but I want this picture to be part of a larger commuting diagram. So my question is,



How do I force the labels to stay in the same place when I place a {tikzpicture} inside a {tikzcd}?



I've included a stripped-down version of my code below.



documentclass[11pt]{amsart}
usepackage{fouriernc} % Fourier fonts instead of Computer Modern
usepackage{PageSetup} % general setup
usepackage{tikz, tikz-cd}

% art style for graphs
newcommand*{bigradius}{2.7em} % radius of a circle-shaped graph
newcommand*{biggerradius}{6.0em} % radius of a really big circle-shaped graph
newcommand*{dist}{4em} % separation between nodes of a line-shaped graph
newcommand*{distshort}{3.25em} % separation between nodes of a line-shaped graph
newcommand*{labeloffset}{1em} % spacing between the edges and their labels
newcommand*{vertexlabeloffset}{1.5em} % spacing between the vertices and their labels
newcommand*{littleradius}{.4em} % radius of the vertices
newcommand*{straightpathwidth}{.17em} % width of a straight path (needs to be slightly thicker than a curved path)
newcommand*{curvedpathwidth}{.14em}

begin{document}

Correct:

begin{tikzpicture}
% the BIG circle
draw[black, line width=curvedpathwidth] (0,0) circle (biggerradius);
% vertices
filldraw[fill=black, draw=black, line width=curvedpathwidth] ( 90:biggerradius) circle (littleradius);
filldraw[fill=white, draw=black, line width=curvedpathwidth] (120:biggerradius) circle (littleradius);
filldraw[fill=black, draw=black, line width=curvedpathwidth] (150:biggerradius) circle (littleradius);
filldraw[fill=white, draw=black, line width=curvedpathwidth] (180:biggerradius) circle (littleradius);
filldraw[fill=black, draw=black, line width=curvedpathwidth] (210:biggerradius) circle (littleradius);
filldraw[fill=white, draw=black, line width=curvedpathwidth] (240:biggerradius) circle (littleradius);
filldraw[fill=black, draw=black, line width=curvedpathwidth] (270:biggerradius) circle (littleradius);
filldraw[fill=white, draw=black, line width=curvedpathwidth] (300:biggerradius) circle (littleradius);
filldraw[fill=black, draw=black, line width=curvedpathwidth] (330:biggerradius) circle (littleradius);
filldraw[fill=white, draw=black, line width=curvedpathwidth] ( 0:biggerradius) circle (littleradius);
filldraw[fill=black, draw=black, line width=curvedpathwidth] ( 30:biggerradius) circle (littleradius);
filldraw[fill=white, draw=black, line width=curvedpathwidth] ( 60:biggerradius) circle (littleradius);
% labels
draw[line width=curvedpathwidth] ( 90:biggerradius - vertexlabeloffset) node {$P_1$};
draw[line width=curvedpathwidth] ( 75:biggerradius + vertexlabeloffset) node {$B_1$};
draw[line width=curvedpathwidth] ( 45:biggerradius + vertexlabeloffset) node {$B_1$};
draw[line width=curvedpathwidth] ( 30:biggerradius - vertexlabeloffset) node {$P_2$};
draw[line width=curvedpathwidth] ( 15:biggerradius + vertexlabeloffset) node {$B_2$};
draw[line width=curvedpathwidth] (345:biggerradius + vertexlabeloffset) node {$B_2$};
draw[line width=curvedpathwidth] (330:biggerradius - vertexlabeloffset) node {$P_3$};
draw[line width=curvedpathwidth] (315:biggerradius + vertexlabeloffset) node {$B_3$};
draw[line width=curvedpathwidth] (285:biggerradius + vertexlabeloffset) node {$B_3$};
draw[line width=curvedpathwidth] (270:biggerradius - vertexlabeloffset) node {$P_4$};
draw[line width=curvedpathwidth] (255:biggerradius + vertexlabeloffset) node {$B_4$};
draw[line width=curvedpathwidth] (225:biggerradius + vertexlabeloffset) node {$B_4$};
draw[line width=curvedpathwidth] (210:biggerradius - vertexlabeloffset) node {$P_5$};
draw[line width=curvedpathwidth] (195:biggerradius + vertexlabeloffset) node {$B_5$};
draw[line width=curvedpathwidth] (165:biggerradius + vertexlabeloffset) node {$B_5$};
draw[line width=curvedpathwidth] (150:biggerradius - vertexlabeloffset) node {$P_6$};
draw[line width=curvedpathwidth] (135:biggerradius + vertexlabeloffset) node {$B_6$};
draw[line width=curvedpathwidth] (105:biggerradius + vertexlabeloffset) node {$B_6$};
end{tikzpicture}

Incorrect:

begin{tikzcd}
begin{tikzpicture}
% the BIG circle
draw[black, line width=curvedpathwidth] (0,0) circle (biggerradius);
% vertices
filldraw[fill=black, draw=black, line width=curvedpathwidth] ( 90:biggerradius) circle (littleradius);
filldraw[fill=white, draw=black, line width=curvedpathwidth] (120:biggerradius) circle (littleradius);
filldraw[fill=black, draw=black, line width=curvedpathwidth] (150:biggerradius) circle (littleradius);
filldraw[fill=white, draw=black, line width=curvedpathwidth] (180:biggerradius) circle (littleradius);
filldraw[fill=black, draw=black, line width=curvedpathwidth] (210:biggerradius) circle (littleradius);
filldraw[fill=white, draw=black, line width=curvedpathwidth] (240:biggerradius) circle (littleradius);
filldraw[fill=black, draw=black, line width=curvedpathwidth] (270:biggerradius) circle (littleradius);
filldraw[fill=white, draw=black, line width=curvedpathwidth] (300:biggerradius) circle (littleradius);
filldraw[fill=black, draw=black, line width=curvedpathwidth] (330:biggerradius) circle (littleradius);
filldraw[fill=white, draw=black, line width=curvedpathwidth] ( 0:biggerradius) circle (littleradius);
filldraw[fill=black, draw=black, line width=curvedpathwidth] ( 30:biggerradius) circle (littleradius);
filldraw[fill=white, draw=black, line width=curvedpathwidth] ( 60:biggerradius) circle (littleradius);
% labels
draw[line width=curvedpathwidth] ( 90:biggerradius - vertexlabeloffset) node {$P_1$};
draw[line width=curvedpathwidth] ( 75:biggerradius + vertexlabeloffset) node {$B_1$};
draw[line width=curvedpathwidth] ( 45:biggerradius + vertexlabeloffset) node {$B_1$};
draw[line width=curvedpathwidth] ( 30:biggerradius - vertexlabeloffset) node {$P_2$};
draw[line width=curvedpathwidth] ( 15:biggerradius + vertexlabeloffset) node {$B_2$};
draw[line width=curvedpathwidth] (345:biggerradius + vertexlabeloffset) node {$B_2$};
draw[line width=curvedpathwidth] (330:biggerradius - vertexlabeloffset) node {$P_3$};
draw[line width=curvedpathwidth] (315:biggerradius + vertexlabeloffset) node {$B_3$};
draw[line width=curvedpathwidth] (285:biggerradius + vertexlabeloffset) node {$B_3$};
draw[line width=curvedpathwidth] (270:biggerradius - vertexlabeloffset) node {$P_4$};
draw[line width=curvedpathwidth] (255:biggerradius + vertexlabeloffset) node {$B_4$};
draw[line width=curvedpathwidth] (225:biggerradius + vertexlabeloffset) node {$B_4$};
draw[line width=curvedpathwidth] (210:biggerradius - vertexlabeloffset) node {$P_5$};
draw[line width=curvedpathwidth] (195:biggerradius + vertexlabeloffset) node {$B_5$};
draw[line width=curvedpathwidth] (165:biggerradius + vertexlabeloffset) node {$B_5$};
draw[line width=curvedpathwidth] (150:biggerradius - vertexlabeloffset) node {$P_6$};
draw[line width=curvedpathwidth] (135:biggerradius + vertexlabeloffset) node {$B_6$};
draw[line width=curvedpathwidth] (105:biggerradius + vertexlabeloffset) node {$B_6$};
end{tikzpicture}
end{tikzcd}



end{document}


It gives this result:



The correct and incorrect behavior







tikz-pgf labels tikz-cd






share|improve this question







New contributor




Cary is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question







New contributor




Cary is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question






New contributor




Cary is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 20 hours ago









Cary

1062




1062




New contributor




Cary is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Cary is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Cary is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








  • 1




    Welcome to TeX.SX! Nesting a tikzpicture in another one is highly unrecommended.
    – egreg
    20 hours ago










  • Thanks for the pointer! I seem to be getting the same problem with the subfigure environment as well. Is there a good environment for positioning several pictures with arrows between them, or captions below, that doesn't come highly unrecommended?
    – Cary
    20 hours ago










  • Yes, subfigure is also deprecated, but the strange behavior is explained by nesting tikzpictures, as @egreg pointed out. If you put the ikzpicture into as savebox, the issues will disappear.
    – marmot
    19 hours ago














  • 1




    Welcome to TeX.SX! Nesting a tikzpicture in another one is highly unrecommended.
    – egreg
    20 hours ago










  • Thanks for the pointer! I seem to be getting the same problem with the subfigure environment as well. Is there a good environment for positioning several pictures with arrows between them, or captions below, that doesn't come highly unrecommended?
    – Cary
    20 hours ago










  • Yes, subfigure is also deprecated, but the strange behavior is explained by nesting tikzpictures, as @egreg pointed out. If you put the ikzpicture into as savebox, the issues will disappear.
    – marmot
    19 hours ago








1




1




Welcome to TeX.SX! Nesting a tikzpicture in another one is highly unrecommended.
– egreg
20 hours ago




Welcome to TeX.SX! Nesting a tikzpicture in another one is highly unrecommended.
– egreg
20 hours ago












Thanks for the pointer! I seem to be getting the same problem with the subfigure environment as well. Is there a good environment for positioning several pictures with arrows between them, or captions below, that doesn't come highly unrecommended?
– Cary
20 hours ago




Thanks for the pointer! I seem to be getting the same problem with the subfigure environment as well. Is there a good environment for positioning several pictures with arrows between them, or captions below, that doesn't come highly unrecommended?
– Cary
20 hours ago












Yes, subfigure is also deprecated, but the strange behavior is explained by nesting tikzpictures, as @egreg pointed out. If you put the ikzpicture into as savebox, the issues will disappear.
– marmot
19 hours ago




Yes, subfigure is also deprecated, but the strange behavior is explained by nesting tikzpictures, as @egreg pointed out. If you put the ikzpicture into as savebox, the issues will disappear.
– marmot
19 hours ago










1 Answer
1






active

oldest

votes

















up vote
1
down vote













Welcome to TeX.SE! As pointed out by @egreg, and as is explained in more detail in this thread, you should try to avoid nesting tikzpictures.



I am assuming now that you want to make the tikzpicture part of a commutative diagram. Then, as suggested here, you may want to put the tikzpicture into a savebox, such that is safe from the pgf keys of the ambient tikzpicture.



documentclass[11pt]{amsart}
% usepackage{fouriernc} % Fourier fonts instead of Computer Modern
% usepackage{PageSetup} % general setup
usepackage{tikz, tikz-cd}

% art style for graphs
newcommand*{bigradius}{2.7em} % radius of a circle-shaped graph
newcommand*{biggerradius}{6.0em} % radius of a really big circle-shaped graph
newcommand*{dist}{4em} % separation between nodes of a line-shaped graph
newcommand*{distshort}{3.25em} % separation between nodes of a line-shaped graph
newcommand*{labeloffset}{1em} % spacing between the edges and their labels
newcommand*{vertexlabeloffset}{1.5em} % spacing between the vertices and their labels
newcommand*{littleradius}{.4em} % radius of the vertices
newcommand*{straightpathwidth}{.17em} % width of a straight path (needs to be slightly thicker than a curved path)
newcommand*{curvedpathwidth}{.14em}

newsaveboxIshouldNeveNestTikzPics
begin{document}

Correct:

saveboxIshouldNeveNestTikzPics{begin{tikzpicture}
% the BIG circle
draw[black, line width=curvedpathwidth] (0,0) circle (biggerradius);
% vertices
filldraw[fill=black, draw=black, line width=curvedpathwidth] ( 90:biggerradius) circle (littleradius);
filldraw[fill=white, draw=black, line width=curvedpathwidth] (120:biggerradius) circle (littleradius);
filldraw[fill=black, draw=black, line width=curvedpathwidth] (150:biggerradius) circle (littleradius);
filldraw[fill=white, draw=black, line width=curvedpathwidth] (180:biggerradius) circle (littleradius);
filldraw[fill=black, draw=black, line width=curvedpathwidth] (210:biggerradius) circle (littleradius);
filldraw[fill=white, draw=black, line width=curvedpathwidth] (240:biggerradius) circle (littleradius);
filldraw[fill=black, draw=black, line width=curvedpathwidth] (270:biggerradius) circle (littleradius);
filldraw[fill=white, draw=black, line width=curvedpathwidth] (300:biggerradius) circle (littleradius);
filldraw[fill=black, draw=black, line width=curvedpathwidth] (330:biggerradius) circle (littleradius);
filldraw[fill=white, draw=black, line width=curvedpathwidth] ( 0:biggerradius) circle (littleradius);
filldraw[fill=black, draw=black, line width=curvedpathwidth] ( 30:biggerradius) circle (littleradius);
filldraw[fill=white, draw=black, line width=curvedpathwidth] ( 60:biggerradius) circle (littleradius);
% labels
draw[line width=curvedpathwidth] ( 90:biggerradius - vertexlabeloffset) node {$P_1$};
draw[line width=curvedpathwidth] ( 75:biggerradius + vertexlabeloffset) node {$B_1$};
draw[line width=curvedpathwidth] ( 45:biggerradius + vertexlabeloffset) node {$B_1$};
draw[line width=curvedpathwidth] ( 30:biggerradius - vertexlabeloffset) node {$P_2$};
draw[line width=curvedpathwidth] ( 15:biggerradius + vertexlabeloffset) node {$B_2$};
draw[line width=curvedpathwidth] (345:biggerradius + vertexlabeloffset) node {$B_2$};
draw[line width=curvedpathwidth] (330:biggerradius - vertexlabeloffset) node {$P_3$};
draw[line width=curvedpathwidth] (315:biggerradius + vertexlabeloffset) node {$B_3$};
draw[line width=curvedpathwidth] (285:biggerradius + vertexlabeloffset) node {$B_3$};
draw[line width=curvedpathwidth] (270:biggerradius - vertexlabeloffset) node {$P_4$};
draw[line width=curvedpathwidth] (255:biggerradius + vertexlabeloffset) node {$B_4$};
draw[line width=curvedpathwidth] (225:biggerradius + vertexlabeloffset) node {$B_4$};
draw[line width=curvedpathwidth] (210:biggerradius - vertexlabeloffset) node {$P_5$};
draw[line width=curvedpathwidth] (195:biggerradius + vertexlabeloffset) node {$B_5$};
draw[line width=curvedpathwidth] (165:biggerradius + vertexlabeloffset) node {$B_5$};
draw[line width=curvedpathwidth] (150:biggerradius - vertexlabeloffset) node {$P_6$};
draw[line width=curvedpathwidth] (135:biggerradius + vertexlabeloffset) node {$B_6$};
draw[line width=curvedpathwidth] (105:biggerradius + vertexlabeloffset) node {$B_6$};
end{tikzpicture}}
useboxIshouldNeveNestTikzPics

Now correct:

begin{tikzcd}
vcenter{hbox{useboxIshouldNeveNestTikzPics}} arrow[r]
arrow[d]
& vcenter{hbox{useboxIshouldNeveNestTikzPics}} arrow[d]
\
vcenter{hbox{useboxIshouldNeveNestTikzPics}} arrow[r]
& vcenter{hbox{useboxIshouldNeveNestTikzPics}}
end{tikzcd}
end{document}


enter image description here






share|improve this answer





















    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "85"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });






    Cary is a new contributor. Be nice, and check out our Code of Conduct.










     

    draft saved


    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f461666%2flabel-shifting-behavior-in-tikz-vs-tikz-cd%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    1
    down vote













    Welcome to TeX.SE! As pointed out by @egreg, and as is explained in more detail in this thread, you should try to avoid nesting tikzpictures.



    I am assuming now that you want to make the tikzpicture part of a commutative diagram. Then, as suggested here, you may want to put the tikzpicture into a savebox, such that is safe from the pgf keys of the ambient tikzpicture.



    documentclass[11pt]{amsart}
    % usepackage{fouriernc} % Fourier fonts instead of Computer Modern
    % usepackage{PageSetup} % general setup
    usepackage{tikz, tikz-cd}

    % art style for graphs
    newcommand*{bigradius}{2.7em} % radius of a circle-shaped graph
    newcommand*{biggerradius}{6.0em} % radius of a really big circle-shaped graph
    newcommand*{dist}{4em} % separation between nodes of a line-shaped graph
    newcommand*{distshort}{3.25em} % separation between nodes of a line-shaped graph
    newcommand*{labeloffset}{1em} % spacing between the edges and their labels
    newcommand*{vertexlabeloffset}{1.5em} % spacing between the vertices and their labels
    newcommand*{littleradius}{.4em} % radius of the vertices
    newcommand*{straightpathwidth}{.17em} % width of a straight path (needs to be slightly thicker than a curved path)
    newcommand*{curvedpathwidth}{.14em}

    newsaveboxIshouldNeveNestTikzPics
    begin{document}

    Correct:

    saveboxIshouldNeveNestTikzPics{begin{tikzpicture}
    % the BIG circle
    draw[black, line width=curvedpathwidth] (0,0) circle (biggerradius);
    % vertices
    filldraw[fill=black, draw=black, line width=curvedpathwidth] ( 90:biggerradius) circle (littleradius);
    filldraw[fill=white, draw=black, line width=curvedpathwidth] (120:biggerradius) circle (littleradius);
    filldraw[fill=black, draw=black, line width=curvedpathwidth] (150:biggerradius) circle (littleradius);
    filldraw[fill=white, draw=black, line width=curvedpathwidth] (180:biggerradius) circle (littleradius);
    filldraw[fill=black, draw=black, line width=curvedpathwidth] (210:biggerradius) circle (littleradius);
    filldraw[fill=white, draw=black, line width=curvedpathwidth] (240:biggerradius) circle (littleradius);
    filldraw[fill=black, draw=black, line width=curvedpathwidth] (270:biggerradius) circle (littleradius);
    filldraw[fill=white, draw=black, line width=curvedpathwidth] (300:biggerradius) circle (littleradius);
    filldraw[fill=black, draw=black, line width=curvedpathwidth] (330:biggerradius) circle (littleradius);
    filldraw[fill=white, draw=black, line width=curvedpathwidth] ( 0:biggerradius) circle (littleradius);
    filldraw[fill=black, draw=black, line width=curvedpathwidth] ( 30:biggerradius) circle (littleradius);
    filldraw[fill=white, draw=black, line width=curvedpathwidth] ( 60:biggerradius) circle (littleradius);
    % labels
    draw[line width=curvedpathwidth] ( 90:biggerradius - vertexlabeloffset) node {$P_1$};
    draw[line width=curvedpathwidth] ( 75:biggerradius + vertexlabeloffset) node {$B_1$};
    draw[line width=curvedpathwidth] ( 45:biggerradius + vertexlabeloffset) node {$B_1$};
    draw[line width=curvedpathwidth] ( 30:biggerradius - vertexlabeloffset) node {$P_2$};
    draw[line width=curvedpathwidth] ( 15:biggerradius + vertexlabeloffset) node {$B_2$};
    draw[line width=curvedpathwidth] (345:biggerradius + vertexlabeloffset) node {$B_2$};
    draw[line width=curvedpathwidth] (330:biggerradius - vertexlabeloffset) node {$P_3$};
    draw[line width=curvedpathwidth] (315:biggerradius + vertexlabeloffset) node {$B_3$};
    draw[line width=curvedpathwidth] (285:biggerradius + vertexlabeloffset) node {$B_3$};
    draw[line width=curvedpathwidth] (270:biggerradius - vertexlabeloffset) node {$P_4$};
    draw[line width=curvedpathwidth] (255:biggerradius + vertexlabeloffset) node {$B_4$};
    draw[line width=curvedpathwidth] (225:biggerradius + vertexlabeloffset) node {$B_4$};
    draw[line width=curvedpathwidth] (210:biggerradius - vertexlabeloffset) node {$P_5$};
    draw[line width=curvedpathwidth] (195:biggerradius + vertexlabeloffset) node {$B_5$};
    draw[line width=curvedpathwidth] (165:biggerradius + vertexlabeloffset) node {$B_5$};
    draw[line width=curvedpathwidth] (150:biggerradius - vertexlabeloffset) node {$P_6$};
    draw[line width=curvedpathwidth] (135:biggerradius + vertexlabeloffset) node {$B_6$};
    draw[line width=curvedpathwidth] (105:biggerradius + vertexlabeloffset) node {$B_6$};
    end{tikzpicture}}
    useboxIshouldNeveNestTikzPics

    Now correct:

    begin{tikzcd}
    vcenter{hbox{useboxIshouldNeveNestTikzPics}} arrow[r]
    arrow[d]
    & vcenter{hbox{useboxIshouldNeveNestTikzPics}} arrow[d]
    \
    vcenter{hbox{useboxIshouldNeveNestTikzPics}} arrow[r]
    & vcenter{hbox{useboxIshouldNeveNestTikzPics}}
    end{tikzcd}
    end{document}


    enter image description here






    share|improve this answer

























      up vote
      1
      down vote













      Welcome to TeX.SE! As pointed out by @egreg, and as is explained in more detail in this thread, you should try to avoid nesting tikzpictures.



      I am assuming now that you want to make the tikzpicture part of a commutative diagram. Then, as suggested here, you may want to put the tikzpicture into a savebox, such that is safe from the pgf keys of the ambient tikzpicture.



      documentclass[11pt]{amsart}
      % usepackage{fouriernc} % Fourier fonts instead of Computer Modern
      % usepackage{PageSetup} % general setup
      usepackage{tikz, tikz-cd}

      % art style for graphs
      newcommand*{bigradius}{2.7em} % radius of a circle-shaped graph
      newcommand*{biggerradius}{6.0em} % radius of a really big circle-shaped graph
      newcommand*{dist}{4em} % separation between nodes of a line-shaped graph
      newcommand*{distshort}{3.25em} % separation between nodes of a line-shaped graph
      newcommand*{labeloffset}{1em} % spacing between the edges and their labels
      newcommand*{vertexlabeloffset}{1.5em} % spacing between the vertices and their labels
      newcommand*{littleradius}{.4em} % radius of the vertices
      newcommand*{straightpathwidth}{.17em} % width of a straight path (needs to be slightly thicker than a curved path)
      newcommand*{curvedpathwidth}{.14em}

      newsaveboxIshouldNeveNestTikzPics
      begin{document}

      Correct:

      saveboxIshouldNeveNestTikzPics{begin{tikzpicture}
      % the BIG circle
      draw[black, line width=curvedpathwidth] (0,0) circle (biggerradius);
      % vertices
      filldraw[fill=black, draw=black, line width=curvedpathwidth] ( 90:biggerradius) circle (littleradius);
      filldraw[fill=white, draw=black, line width=curvedpathwidth] (120:biggerradius) circle (littleradius);
      filldraw[fill=black, draw=black, line width=curvedpathwidth] (150:biggerradius) circle (littleradius);
      filldraw[fill=white, draw=black, line width=curvedpathwidth] (180:biggerradius) circle (littleradius);
      filldraw[fill=black, draw=black, line width=curvedpathwidth] (210:biggerradius) circle (littleradius);
      filldraw[fill=white, draw=black, line width=curvedpathwidth] (240:biggerradius) circle (littleradius);
      filldraw[fill=black, draw=black, line width=curvedpathwidth] (270:biggerradius) circle (littleradius);
      filldraw[fill=white, draw=black, line width=curvedpathwidth] (300:biggerradius) circle (littleradius);
      filldraw[fill=black, draw=black, line width=curvedpathwidth] (330:biggerradius) circle (littleradius);
      filldraw[fill=white, draw=black, line width=curvedpathwidth] ( 0:biggerradius) circle (littleradius);
      filldraw[fill=black, draw=black, line width=curvedpathwidth] ( 30:biggerradius) circle (littleradius);
      filldraw[fill=white, draw=black, line width=curvedpathwidth] ( 60:biggerradius) circle (littleradius);
      % labels
      draw[line width=curvedpathwidth] ( 90:biggerradius - vertexlabeloffset) node {$P_1$};
      draw[line width=curvedpathwidth] ( 75:biggerradius + vertexlabeloffset) node {$B_1$};
      draw[line width=curvedpathwidth] ( 45:biggerradius + vertexlabeloffset) node {$B_1$};
      draw[line width=curvedpathwidth] ( 30:biggerradius - vertexlabeloffset) node {$P_2$};
      draw[line width=curvedpathwidth] ( 15:biggerradius + vertexlabeloffset) node {$B_2$};
      draw[line width=curvedpathwidth] (345:biggerradius + vertexlabeloffset) node {$B_2$};
      draw[line width=curvedpathwidth] (330:biggerradius - vertexlabeloffset) node {$P_3$};
      draw[line width=curvedpathwidth] (315:biggerradius + vertexlabeloffset) node {$B_3$};
      draw[line width=curvedpathwidth] (285:biggerradius + vertexlabeloffset) node {$B_3$};
      draw[line width=curvedpathwidth] (270:biggerradius - vertexlabeloffset) node {$P_4$};
      draw[line width=curvedpathwidth] (255:biggerradius + vertexlabeloffset) node {$B_4$};
      draw[line width=curvedpathwidth] (225:biggerradius + vertexlabeloffset) node {$B_4$};
      draw[line width=curvedpathwidth] (210:biggerradius - vertexlabeloffset) node {$P_5$};
      draw[line width=curvedpathwidth] (195:biggerradius + vertexlabeloffset) node {$B_5$};
      draw[line width=curvedpathwidth] (165:biggerradius + vertexlabeloffset) node {$B_5$};
      draw[line width=curvedpathwidth] (150:biggerradius - vertexlabeloffset) node {$P_6$};
      draw[line width=curvedpathwidth] (135:biggerradius + vertexlabeloffset) node {$B_6$};
      draw[line width=curvedpathwidth] (105:biggerradius + vertexlabeloffset) node {$B_6$};
      end{tikzpicture}}
      useboxIshouldNeveNestTikzPics

      Now correct:

      begin{tikzcd}
      vcenter{hbox{useboxIshouldNeveNestTikzPics}} arrow[r]
      arrow[d]
      & vcenter{hbox{useboxIshouldNeveNestTikzPics}} arrow[d]
      \
      vcenter{hbox{useboxIshouldNeveNestTikzPics}} arrow[r]
      & vcenter{hbox{useboxIshouldNeveNestTikzPics}}
      end{tikzcd}
      end{document}


      enter image description here






      share|improve this answer























        up vote
        1
        down vote










        up vote
        1
        down vote









        Welcome to TeX.SE! As pointed out by @egreg, and as is explained in more detail in this thread, you should try to avoid nesting tikzpictures.



        I am assuming now that you want to make the tikzpicture part of a commutative diagram. Then, as suggested here, you may want to put the tikzpicture into a savebox, such that is safe from the pgf keys of the ambient tikzpicture.



        documentclass[11pt]{amsart}
        % usepackage{fouriernc} % Fourier fonts instead of Computer Modern
        % usepackage{PageSetup} % general setup
        usepackage{tikz, tikz-cd}

        % art style for graphs
        newcommand*{bigradius}{2.7em} % radius of a circle-shaped graph
        newcommand*{biggerradius}{6.0em} % radius of a really big circle-shaped graph
        newcommand*{dist}{4em} % separation between nodes of a line-shaped graph
        newcommand*{distshort}{3.25em} % separation between nodes of a line-shaped graph
        newcommand*{labeloffset}{1em} % spacing between the edges and their labels
        newcommand*{vertexlabeloffset}{1.5em} % spacing between the vertices and their labels
        newcommand*{littleradius}{.4em} % radius of the vertices
        newcommand*{straightpathwidth}{.17em} % width of a straight path (needs to be slightly thicker than a curved path)
        newcommand*{curvedpathwidth}{.14em}

        newsaveboxIshouldNeveNestTikzPics
        begin{document}

        Correct:

        saveboxIshouldNeveNestTikzPics{begin{tikzpicture}
        % the BIG circle
        draw[black, line width=curvedpathwidth] (0,0) circle (biggerradius);
        % vertices
        filldraw[fill=black, draw=black, line width=curvedpathwidth] ( 90:biggerradius) circle (littleradius);
        filldraw[fill=white, draw=black, line width=curvedpathwidth] (120:biggerradius) circle (littleradius);
        filldraw[fill=black, draw=black, line width=curvedpathwidth] (150:biggerradius) circle (littleradius);
        filldraw[fill=white, draw=black, line width=curvedpathwidth] (180:biggerradius) circle (littleradius);
        filldraw[fill=black, draw=black, line width=curvedpathwidth] (210:biggerradius) circle (littleradius);
        filldraw[fill=white, draw=black, line width=curvedpathwidth] (240:biggerradius) circle (littleradius);
        filldraw[fill=black, draw=black, line width=curvedpathwidth] (270:biggerradius) circle (littleradius);
        filldraw[fill=white, draw=black, line width=curvedpathwidth] (300:biggerradius) circle (littleradius);
        filldraw[fill=black, draw=black, line width=curvedpathwidth] (330:biggerradius) circle (littleradius);
        filldraw[fill=white, draw=black, line width=curvedpathwidth] ( 0:biggerradius) circle (littleradius);
        filldraw[fill=black, draw=black, line width=curvedpathwidth] ( 30:biggerradius) circle (littleradius);
        filldraw[fill=white, draw=black, line width=curvedpathwidth] ( 60:biggerradius) circle (littleradius);
        % labels
        draw[line width=curvedpathwidth] ( 90:biggerradius - vertexlabeloffset) node {$P_1$};
        draw[line width=curvedpathwidth] ( 75:biggerradius + vertexlabeloffset) node {$B_1$};
        draw[line width=curvedpathwidth] ( 45:biggerradius + vertexlabeloffset) node {$B_1$};
        draw[line width=curvedpathwidth] ( 30:biggerradius - vertexlabeloffset) node {$P_2$};
        draw[line width=curvedpathwidth] ( 15:biggerradius + vertexlabeloffset) node {$B_2$};
        draw[line width=curvedpathwidth] (345:biggerradius + vertexlabeloffset) node {$B_2$};
        draw[line width=curvedpathwidth] (330:biggerradius - vertexlabeloffset) node {$P_3$};
        draw[line width=curvedpathwidth] (315:biggerradius + vertexlabeloffset) node {$B_3$};
        draw[line width=curvedpathwidth] (285:biggerradius + vertexlabeloffset) node {$B_3$};
        draw[line width=curvedpathwidth] (270:biggerradius - vertexlabeloffset) node {$P_4$};
        draw[line width=curvedpathwidth] (255:biggerradius + vertexlabeloffset) node {$B_4$};
        draw[line width=curvedpathwidth] (225:biggerradius + vertexlabeloffset) node {$B_4$};
        draw[line width=curvedpathwidth] (210:biggerradius - vertexlabeloffset) node {$P_5$};
        draw[line width=curvedpathwidth] (195:biggerradius + vertexlabeloffset) node {$B_5$};
        draw[line width=curvedpathwidth] (165:biggerradius + vertexlabeloffset) node {$B_5$};
        draw[line width=curvedpathwidth] (150:biggerradius - vertexlabeloffset) node {$P_6$};
        draw[line width=curvedpathwidth] (135:biggerradius + vertexlabeloffset) node {$B_6$};
        draw[line width=curvedpathwidth] (105:biggerradius + vertexlabeloffset) node {$B_6$};
        end{tikzpicture}}
        useboxIshouldNeveNestTikzPics

        Now correct:

        begin{tikzcd}
        vcenter{hbox{useboxIshouldNeveNestTikzPics}} arrow[r]
        arrow[d]
        & vcenter{hbox{useboxIshouldNeveNestTikzPics}} arrow[d]
        \
        vcenter{hbox{useboxIshouldNeveNestTikzPics}} arrow[r]
        & vcenter{hbox{useboxIshouldNeveNestTikzPics}}
        end{tikzcd}
        end{document}


        enter image description here






        share|improve this answer












        Welcome to TeX.SE! As pointed out by @egreg, and as is explained in more detail in this thread, you should try to avoid nesting tikzpictures.



        I am assuming now that you want to make the tikzpicture part of a commutative diagram. Then, as suggested here, you may want to put the tikzpicture into a savebox, such that is safe from the pgf keys of the ambient tikzpicture.



        documentclass[11pt]{amsart}
        % usepackage{fouriernc} % Fourier fonts instead of Computer Modern
        % usepackage{PageSetup} % general setup
        usepackage{tikz, tikz-cd}

        % art style for graphs
        newcommand*{bigradius}{2.7em} % radius of a circle-shaped graph
        newcommand*{biggerradius}{6.0em} % radius of a really big circle-shaped graph
        newcommand*{dist}{4em} % separation between nodes of a line-shaped graph
        newcommand*{distshort}{3.25em} % separation between nodes of a line-shaped graph
        newcommand*{labeloffset}{1em} % spacing between the edges and their labels
        newcommand*{vertexlabeloffset}{1.5em} % spacing between the vertices and their labels
        newcommand*{littleradius}{.4em} % radius of the vertices
        newcommand*{straightpathwidth}{.17em} % width of a straight path (needs to be slightly thicker than a curved path)
        newcommand*{curvedpathwidth}{.14em}

        newsaveboxIshouldNeveNestTikzPics
        begin{document}

        Correct:

        saveboxIshouldNeveNestTikzPics{begin{tikzpicture}
        % the BIG circle
        draw[black, line width=curvedpathwidth] (0,0) circle (biggerradius);
        % vertices
        filldraw[fill=black, draw=black, line width=curvedpathwidth] ( 90:biggerradius) circle (littleradius);
        filldraw[fill=white, draw=black, line width=curvedpathwidth] (120:biggerradius) circle (littleradius);
        filldraw[fill=black, draw=black, line width=curvedpathwidth] (150:biggerradius) circle (littleradius);
        filldraw[fill=white, draw=black, line width=curvedpathwidth] (180:biggerradius) circle (littleradius);
        filldraw[fill=black, draw=black, line width=curvedpathwidth] (210:biggerradius) circle (littleradius);
        filldraw[fill=white, draw=black, line width=curvedpathwidth] (240:biggerradius) circle (littleradius);
        filldraw[fill=black, draw=black, line width=curvedpathwidth] (270:biggerradius) circle (littleradius);
        filldraw[fill=white, draw=black, line width=curvedpathwidth] (300:biggerradius) circle (littleradius);
        filldraw[fill=black, draw=black, line width=curvedpathwidth] (330:biggerradius) circle (littleradius);
        filldraw[fill=white, draw=black, line width=curvedpathwidth] ( 0:biggerradius) circle (littleradius);
        filldraw[fill=black, draw=black, line width=curvedpathwidth] ( 30:biggerradius) circle (littleradius);
        filldraw[fill=white, draw=black, line width=curvedpathwidth] ( 60:biggerradius) circle (littleradius);
        % labels
        draw[line width=curvedpathwidth] ( 90:biggerradius - vertexlabeloffset) node {$P_1$};
        draw[line width=curvedpathwidth] ( 75:biggerradius + vertexlabeloffset) node {$B_1$};
        draw[line width=curvedpathwidth] ( 45:biggerradius + vertexlabeloffset) node {$B_1$};
        draw[line width=curvedpathwidth] ( 30:biggerradius - vertexlabeloffset) node {$P_2$};
        draw[line width=curvedpathwidth] ( 15:biggerradius + vertexlabeloffset) node {$B_2$};
        draw[line width=curvedpathwidth] (345:biggerradius + vertexlabeloffset) node {$B_2$};
        draw[line width=curvedpathwidth] (330:biggerradius - vertexlabeloffset) node {$P_3$};
        draw[line width=curvedpathwidth] (315:biggerradius + vertexlabeloffset) node {$B_3$};
        draw[line width=curvedpathwidth] (285:biggerradius + vertexlabeloffset) node {$B_3$};
        draw[line width=curvedpathwidth] (270:biggerradius - vertexlabeloffset) node {$P_4$};
        draw[line width=curvedpathwidth] (255:biggerradius + vertexlabeloffset) node {$B_4$};
        draw[line width=curvedpathwidth] (225:biggerradius + vertexlabeloffset) node {$B_4$};
        draw[line width=curvedpathwidth] (210:biggerradius - vertexlabeloffset) node {$P_5$};
        draw[line width=curvedpathwidth] (195:biggerradius + vertexlabeloffset) node {$B_5$};
        draw[line width=curvedpathwidth] (165:biggerradius + vertexlabeloffset) node {$B_5$};
        draw[line width=curvedpathwidth] (150:biggerradius - vertexlabeloffset) node {$P_6$};
        draw[line width=curvedpathwidth] (135:biggerradius + vertexlabeloffset) node {$B_6$};
        draw[line width=curvedpathwidth] (105:biggerradius + vertexlabeloffset) node {$B_6$};
        end{tikzpicture}}
        useboxIshouldNeveNestTikzPics

        Now correct:

        begin{tikzcd}
        vcenter{hbox{useboxIshouldNeveNestTikzPics}} arrow[r]
        arrow[d]
        & vcenter{hbox{useboxIshouldNeveNestTikzPics}} arrow[d]
        \
        vcenter{hbox{useboxIshouldNeveNestTikzPics}} arrow[r]
        & vcenter{hbox{useboxIshouldNeveNestTikzPics}}
        end{tikzcd}
        end{document}


        enter image description here







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 12 hours ago









        marmot

        78k487166




        78k487166






















            Cary is a new contributor. Be nice, and check out our Code of Conduct.










             

            draft saved


            draft discarded


















            Cary is a new contributor. Be nice, and check out our Code of Conduct.













            Cary is a new contributor. Be nice, and check out our Code of Conduct.












            Cary is a new contributor. Be nice, and check out our Code of Conduct.















             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f461666%2flabel-shifting-behavior-in-tikz-vs-tikz-cd%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            サソリ

            広島県道265号伴広島線

            Setup Asymptote in Texstudio