0

I'm trying to make two Tikzpictures side by side, but I am not sure why it is going off the page in Tikzpicture...

Image showing one tikzpicture going off the page

Here is my code:

\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{amsmath}

\newcommand{\knodel}[2]{
\pgfmathtruncatemacro{\mymod}{#1+1}
  \foreach \X in {0,...,#1}
   {\node[bullet,label={right:$\boldsymbol{(2,\X)}$}] (v2\X) at 
   (4,{1.2*(\X-(#1+0)/2)}){};
   \node[bullet,label={left:$\boldsymbol{(1,\X)}$}] (v1\X) at 
   (1.5,{1.2*(\X-(#1+0)/2)}){};}
  \foreach \X [evaluate=\X as \NextX using {int(mod(\X+3,\mymod))},
  evaluate=\X as \AnotherX using {int(mod(\X+1,\mymod))},] in {0,...,#1}
  {\draw[thick] (v1\X) -- (v2\NextX);
  \draw[dashed] (v1\X) -- (v2\AnotherX);
  \draw (v1\X) -- (v2\X);} 
}

\begin{document}
\begin{tikzpicture}[bullet/.style={circle,inner sep=2pt,fill}]

\knodel{8}{3}
\hspace{5cm}
\knodel{16}{3}

\end{tikzpicture}
\end{document}
2
  • 4
    Don't use \hspace in a TikZ picture. Try \begin{scope}[xshift=5cm] ... \end{scope} instead.
    – user156344
    Mar 3, 2019 at 4:15
  • 3
    Notice also that in the pic version, i.e. in the lower code, of tex.stackexchange.com/a/477179/121799 you can just shift the corresponding pic and do not have to add a scope environment. That is, you can simply say \pic[xshift=5cm]{<name of the pic>};.
    – user121799
    Mar 3, 2019 at 4:38

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.