tikzpicture 中不需要的空间

tikzpicture 中不需要的空间

我在这里得到了一些明显不需要的空间:

不需要的空格

这与用于绘制弧线的不可见控制点有关吗?

以下是有问题的代码:

\begin{tabular}{|c|c|}
\hline
\begin{tikzpicture} [main/.style = {draw, circle},node distance = 2cm,on grid,auto]
 \node[main] (1) {$1$};
 \node[main] (2) [right of=1] {$2$};
 \node[main] (3) [below of =2] {$3$};
 \node[main] (4) [left of =3] {$4$};
 \draw (1) -- (2);
 \draw (2) -- (3);
 \draw (3) -- (4);
 \draw (4) -- (1);
 \draw (1) -- (3);
 \draw (2) to [out=135,in=180,looseness=2.5] (4);
\end{tikzpicture}
&
\begin{tikzpicture} [main/.style = {draw, circle},node distance = 2cm,on grid,auto]
 \node[main] (1) {$1$};
 \node[main] (2) [below right of= 1] {$2$};
 \node[main] (3) [below left of =1] {$3$};
 \node[main] (4) [below of =3] {$4$};
 \node[main] (5) [below of =2] {$5$};
 \draw (1) -- (2);
 \draw (1) -- (3);
 \draw (1) -- (4);
 \draw (1) -- (5);
 \draw (2) to [out=90,in=90,looseness=2.5] (3);
 \draw (2) to [out=-50,in=-50,looseness=2.5] (4);
 \draw (2) -- (5);
 \draw (3) -- (4);
 \draw (3) -- (5);
 \draw (4) -- (5);
\end{tikzpicture}
 \\ \hline
$K_{4}$ drawn without crossing     & Attempted drawing of $K_{5}$ without crossings \\ \hline
\end{tabular}

答案1

考虑到@Rmano 评论,您可以得到:

在此处输入图片描述

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{automata,
                positioning}

\begin{document}
    \begin{tabular}{|c|c|}
    \hline
    \begin{tikzpicture}[baseline=(4),   % <---
node distance = 2cm and 2cm, on grid,
every node/.append style = {state}
                        ]
\clip(-2,-3) rectangle (3,2);           % <---
\node (1) at (0,0) {$1$};
\node (2) [right=of 1] {$2$};
\node (3) [below=of 2] {$3$};
\node (4) [left =of 3] {$4$};
%
\draw   (1) -- (2) -- (3) -- (4) -- (1) -- (3) 
        (4) to [out=135,in=135,looseness=2.5] (2);
\end{tikzpicture}
&
    \begin{tikzpicture}[baseline=(4),   % <---
node distance = 2cm and 2cm, on grid,
every node/.append style = {state}
                        ]
\clip(-0.5,-4) rectangle (5.1,4);       % <---
\node  (1) at (2,2) {$1$};
\node  (2) [below right=of  1] {$2$};
\node  (3) [below left =of 1] {$3$};
\node  (4) [below=of 3] {$4$};
\node  (5) [below=of 2] {$5$};
%
\draw   (1) -- (2) -- (5) -- (4) -- (3) -- (1) -- (5)  -- (3)
        (4) -- (1) 
        (3) to [out= 90,in= 90,looseness=2.5] (2) 
        (2) to [out=-60,in=-30,looseness=2.5] (4); 
\end{tikzpicture}       \\ \hline
$K_{4}$ drawn without crossing     & Attempted drawing of $K_{5}$ without crossings \\ \hline
\end{tabular}
\end{document}

相关内容