tikzpicture がドキュメントに収まりません

tikzpicture がドキュメントに収まりません

いくつかのスコープを使用して 3D 図形を描画するコードがあります。
しかし、出力はスタンドアロン ドキュメントに収まりません。役に立ちません
\hbox{*}\vbox{*}

何をすればいいですか?

ここに画像の説明を入力してください

次のようになります:

ここに画像の説明を入力してください

\documentclass[margin=5pt]{standalone}
%\documentclass{article}
%\usepackage[margin=15mm]{geometry} 
\usepackage{tikz} 

\begin{document}

\def\a{1}
\def\h{0.2}
%%%%%%%%%%%%%%%%%%%%%%%%%%
\hbox{\vbox{%%%%%%%%%%%%%%%%%%%% 
%%%%%%%%%%%%%%%%%%%%%%%%%% 

\begin{tikzpicture}[font=\footnotesize,
very thin,
%line cap=round,
x={(1,0,0)}, z={(0,1,0)}, y={(0.5,0.5)}, 
every label/.style={text=black!1},
]

\coordinate[label=below:A] (A1) at (0,0,0);
\coordinate[label=below:B] (B1) at (\a,0,0);
\coordinate[label=below:C] (C1) at (\a,\a,0);
\coordinate[label=below:D] (D1) at (0,\a,0);
\coordinate[label=below:A] (A2) at (0,0,\h);
\coordinate[label=below:B] (B2) at (\a,0,\h);
\coordinate[label=below:C] (C2) at (\a,\a,\h);
\coordinate[label=below:D] (D2) at (0,\a,\h);

%% straight %%%%%%%%%%%%%%%%%%%%%
\foreach \n in {0,...,9}{%%
\begin{scope}[transform canvas={shift={(0,0,\n*\h)}}]
\draw[] (A1) -- (B1) -- (C1); 

\ifnum\n=9 \draw[fill=white] (A2) -- (B2) -- (C2) -- (D2) --cycle; 
\else \draw[fill=white] (A2) -- (B2) -- (C2);  \fi
\foreach \P in {A,B,C} \draw[] (\P1) -- (\P2);
\end{scope}
}%%

%% skew  %%%%%%%%%%%%%%%%%%%%%
\begin{scope}[transform canvas={shift={(12*\h+\a,0,0)}}]
\foreach \n in {0,...,9}{%%
\begin{scope}[transform canvas={shift={(-\n*\h,0,\n*\h)}}]
\draw[] (A1) -- (B1) -- (C1); 

\ifnum\n=9 \draw[fill=white] (A2) -- (B2) -- (C2) -- (D2) --cycle; 
\else \draw[fill=white] (A2) -- (B2) -- (C2) -- (D2);  \fi
\foreach \P in {A,B,C}{  \draw[] (\P1) -- (\P2);  }
\draw[fill=white] (B1) -- (C1) -- (C2) -- (B2) --cycle;
\end{scope}
}%%
\end{scope}
\end{tikzpicture}

%%%%%%%%%%%%%%%%%%%%%%%%%% 
}}%%%%%%%%%%%%%%%%%%%%%%%%% 
%%%%%%%%%%%%%%%%%%%%%%%%%% 
\end{document}

答え1

transform canvas座標を使用するたびに変換を追加して回避する方法を次に示します。

\documentclass[margin=5pt]{standalone}
\usepackage{tikz} 
% ateb: https://tex.stackexchange.com/a/707241/ addaswyd o gwestiwn cis: https://tex.stackexchange.com/q/707215/
\begin{document}

\begin{tikzpicture}[font=\footnotesize,
    very thin,
    x={(1,0,0)}, z={(0,1,0)}, y={(0.5,0.5)}, 
  ]
  \def\a{1}
  \def\h{0.2}
  \def\makecoords{%
    \coordinate (A1) at (0,0,0);
    \coordinate (B1) at (\a,0,0);
    \coordinate (C1) at (\a,\a,0);
    \coordinate (D1) at (0,\a,0);
    \coordinate (A2) at (0,0,\h);
    \coordinate (B2) at (\a,0,\h);
    \coordinate (C2) at (\a,\a,\h);
    \coordinate (D2) at (0,\a,\h);}
  %% straight %%%%%%%%%%%%%%%%%%%%%
  \foreach \n in {0,...,9}{%%
    \begin{scope}[shift={(0,0,\n*\h)}]
      \makecoords
      \draw (A1) -- (B1) -- (C1);
      \ifnum\n=9 \draw[fill=white] (A2) -- (B2) -- (C2) -- (D2) -- cycle; 
      \else \draw[fill=white] (A2) -- (B2) -- (C2);  \fi
      \foreach \P in {A,B,C} \draw[] (\P1) -- (\P2);
    \end{scope}
  }  
  %% skew  %%%%%%%%%%%%%%%%%%%%%
  \begin{scope}[shift={(12*\h+\a,0,0)}]
    \foreach \n in {0,...,9}{%%
      \begin{scope}[shift={(-\n*\h,0,\n*\h)}]
        \makecoords
        \draw[] (A1) -- (B1) -- (C1); 
        \ifnum\n=9 \draw[fill=white] (A2) -- (B2) -- (C2) -- (D2) --cycle; 
        \else \draw[fill=white] (A2) -- (B2) -- (C2) -- (D2);  \fi
        \foreach \P in {A,B,C}{  \draw[] (\P1) -- (\P2);  }
        \draw[fill=white] (B1) -- (C1) -- (C2) -- (B2) --cycle;
      \end{scope}
    }
  \end{scope}
\end{tikzpicture}
\end{document}

積み重ねて段を作った

\vboxin anが何のためにあるのかわからなかった\hboxので、何の機能も果たしていないように思えたので削除しました。

関連情報