tikzpicture を、それを含む \item を中央に配置せずに中央に配置するにはどうすればよいですか?

tikzpicture を、それを含む \item を中央に配置せずに中央に配置するにはどうすればよいですか?

特定の演習で、 で作成した図をtikzpicture中央に配置したいのですが、\itemそれを含む のラベルはそのままにして、そのレベルの他の列挙子と一列に並べておきたいと思っています。これまでに経験したさまざまな問題 (これは初めての LaTeX ドキュメントです) の解決策を見つけることに成功しましたが、どのような解決策を試しても、ラベル\item(この場合は a (b)) が、次のように、一緒に移動されてしまうようです。

![センタータグアイテムナッピング

私が試したことのいくつかの例を以下に示します。

\begin{center}
  \begin{tikzpicture}
  ....
  \end{tikzpicture}
\end{center}

{\centering

  \begin{tikzpicture}
  ....
  \end{tikzpicture}

}

\begin{figure}
   \begin{center}
     \begin{tikzpicture}
      ....
     \end{tikzpicture}
   \end{center}
\end{figure}

\begin{tikzpicture}
  \centering

  ....
\end{tikzpicture}

...などなど。最初の 2 つで「最善」の結果が得られました。私には同じに見えます。(b) は中央に引っ張られ、tikzpictureその下のテキストとの間に適切な垂直間隔がありません。ただし、後続の図 (すべて\item最初の図と同じ) にはこの間隔の問題はありません。\begin{center}本来の範囲外にあるはずのものを引っ張ってくるのは奇妙に思えますが、簡単な説明があるはずです。最小限の (ish) 動作例を以下に示します (繰り返しを最小限に抑えるためにリファクタリングするつもりです)。

\documentclass[12pt]{article}

\usepackage[margin=1in]{geometry} 
\usepackage{amsmath,amsthm,amssymb,bm,enumitem,tikz}

\usetikzlibrary{calc,positioning,shapes}

\tikzset{
    between/.style args={#1 and #2}{
         at = ($(#1)!0.5!(#2)$)
    }
}

\tikzstyle{mydot}=[circle,fill,inner sep=2pt]
\tikzstyle{myellipse}=[ellipse,draw=cyan,thick,minimum width=60pt,minimum height=110pt,inner sep=0pt]
\tikzstyle{every edge}=[draw=cyan,thick]
\tikzstyle{relarrow}=[->, shorten >= 0pt, shorten <= 0pt, out=25, in=155]

\begin{document}

\begin{enumerate}
    \item
    \begin{enumerate}
        \item $R=\{(5,5),(6,5),(6,6)\}$,\\
              $S=\{(4,6),(5,5),(5,7),(6,6)\}$

        \item % Relation R
             \begin{center}
             \begin{tikzpicture}[
             >=latex,
             shorten >= 3pt,
             shorten <= 3pt,
             baseline={([yshift=-1em] current bounding box.north)}
             ]

             \node[mydot,label={left:4}] (a1) {}; 
             \node[mydot,below=of a1,label={left:5}] (a2) {}; 
             \node[mydot,below=of a2,label={left:6}] (a3) {}; 

             \node[mydot,right=5cm of a1,label={right:5}] (b1) {}; 
             \node[mydot,below=of b1,label={right:6}] (b2) {}; 
             \node[mydot,below=of b2,label={right:7}] (b3) {}; 

             \path[->] (a2) edge (b1);
             \path[->] (a3) edge (b1)
                 edge(b2);

             \node[myellipse,label={above:A}] at (a2.center) (c1) {};
             \node[myellipse,label={above:B}] at (b2.center) (c2) {};

             \node at (2.5, 0.75) (r1) {$R$};
             \path[relarrow] (2.1, 0.4) edge (2.95, 0.35);

             \end{tikzpicture}
             \end{center}

             $R$ is not a function because it fails both 
             properties (1) and (2) of the definition of a function.
             $4\in A$, but there is no $(4,y)\in R$ for any 
             $y\in B$.
             Also, \mbox{$(6,5)\in R$} and $(6,6)\in R\text{, but }
             5\neq6$.

             % Relation S
             \begin{center}
             \begin{tikzpicture}[
             >=latex,
             shorten >= 3pt,
             shorten <= 3pt,
             baseline={([yshift=-1em] current bounding box.north)}
             ]

             \node[mydot,label={left:4}] (a1) {}; 
             \node[mydot,below=of a1,label={left:5}] (a2) {}; 
             \node[mydot,below=of a2,label={left:6}] (a3) {}; 

             \node[mydot,right=5cm of a1,label={right:5}] (b1) {}; 
             \node[mydot,below=of b1,label={right:6}] (b2) {}; 
             \node[mydot,below=of b2,label={right:7}] (b3) {}; 

             \path[->] (a1) edge (b2);
             \path[->] (a2) edge (b1)
                 edge (b3);
             \path[->] (a3) edge (b2);

             \node[myellipse,label={above:A}] at (a2.center) (c1) {};
             \node[myellipse,label={above:B}] at (b2.center) (c2) {};

             \node at (2.5, 0.75) (r1) {$S$};
             \path[relarrow] (2.1, 0.4) edge (2.95, 0.35);

             \end{tikzpicture}
             \end{center}

             $S$ is not a function because it fails property 
             (2) of the definition of a function.
             $(5,5)\in S\text{ and }(5,7)\in S\text{, but }
             5\neq7$.

    \end{enumerate}
\end{enumerate}

\end{document}

答え1

このような図は数学の表示として考えますが、導入文を追加した方が良いでしょう。

\documentclass[12pt]{article}

\usepackage[margin=1in]{geometry} 
\usepackage{amsmath,amsthm,amssymb,bm,enumitem,tikz}

\usetikzlibrary{calc,positioning,shapes}

\tikzset{
  between/.style args={#1 and #2}{at = ($(#1)!0.5!(#2)$)},
  mydot/.style={circle,fill,inner sep=2pt},
  myellipse/.style={
    ellipse,
    draw=cyan,
    thick,
    minimum width=60pt,
    minimum height=110pt,
    inner sep=0pt
  },
  every edge/.style={draw=cyan,thick},
  relarrow/.style={->, shorten >= 0pt, shorten <= 0pt, out=25, in=155},
}

\begin{document}

\begin{enumerate}
\item
  \begin{enumerate}
  \item $R=\{(5,5),(6,5),(6,6)\}$,\\
        $S=\{(4,6),(5,5),(5,7),(6,6)\}$

  \item % Relation R
    \[
    \begin{tikzpicture}[
      >=latex,
      shorten >= 3pt,
      shorten <= 3pt,
      baseline={([yshift=-1em] current bounding box.north)}
    ]

    \node[mydot,label={left:4}] (a1) {}; 
    \node[mydot,below=of a1,label={left:5}] (a2) {}; 
    \node[mydot,below=of a2,label={left:6}] (a3) {}; 

    \node[mydot,right=5cm of a1,label={right:5}] (b1) {}; 
    \node[mydot,below=of b1,label={right:6}] (b2) {}; 
    \node[mydot,below=of b2,label={right:7}] (b3) {}; 

    \path[->] (a2) edge (b1);
    \path[->] (a3) edge (b1) edge(b2);

    \node[myellipse,label={above:$A$}] at (a2.center) (c1) {};
    \node[myellipse,label={above:$B$}] at (b2.center) (c2) {};

    \node at (2.5, 0.75) (r1) {$R$};
    \path[relarrow] (2.1, 0.4) edge (2.95, 0.35);

    \end{tikzpicture}
    \]
    $R$ is not a function because it fails both 
    properties (1) and (2) of the definition of a function.
    $4\in A$, but there is no $(4,y)\in R$ for any $y\in B$.
    Also, $(6,5)\in R$ and $(6,6)\in R$, but~$5\neq6$.

  \item % Relation S
    \[
    \begin{tikzpicture}[
      >=latex,
      shorten >= 3pt,
      shorten <= 3pt,
      baseline={([yshift=-1em] current bounding box.north)}
    ]

    \node[mydot,label={left:4}] (a1) {}; 
    \node[mydot,below=of a1,label={left:5}] (a2) {}; 
    \node[mydot,below=of a2,label={left:6}] (a3) {}; 

    \node[mydot,right=5cm of a1,label={right:5}] (b1) {}; 
    \node[mydot,below=of b1,label={right:6}] (b2) {}; 
    \node[mydot,below=of b2,label={right:7}] (b3) {}; 

    \path[->] (a1) edge (b2);
    \path[->] (a2) edge (b1) edge (b3);
    \path[->] (a3) edge (b2);

    \node[myellipse,label={above:$A$}] at (a2.center) (c1) {};
    \node[myellipse,label={above:$B$}] at (b2.center) (c2) {};

    \node at (2.5, 0.75) (r1) {$S$};
    \path[relarrow] (2.1, 0.4) edge (2.95, 0.35);

    \end{tikzpicture}
    \]
    $S$ is not a function because it fails property (2) of
    the definition of a function.
    $(5,5)\in S$ and $(5,7)\in S$, but~$5\neq7$.

  \end{enumerate}
\end{enumerate}

\end{document}

注意すべき点がいくつかあります:

  1. \tikzstyle非推奨です

  2. セット名は数式モードにする必要があります。label={above:$A$}これで動作します

  3. テキスト

    Also, \mbox{$(6,5)\in R$} and $(6,6)\in R\text{, but } 5\neq6$.
    

    すべきである

    Also, $(6,5)\in R$ and $(6,6)\in R$, but~$5\neq6$.
    
  4. 同様に、テキスト

    $(5,5)\in S\text{ and }(5,7)\in S\text{, but } 5\neq7$.
    

    すべきである

    $(5,5)\in S$ and $(5,7)\in S$, but~$5\neq7$.
    
  5. \]と次のテキストの間に空行を入れないでください。

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

答え2

\mbox{}アイテムラベルにテキストを追加するだけです

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

\begin{document}

\begin{enumerate}
    \item
    \begin{enumerate}
        \item $R=\{(5,5),(6,5),(6,6)\}$,\\
              $S=\{(4,6),(5,5),(5,7),(6,6)\}$

        \item \mbox{}
             \begin{center}
             \begin{tikzpicture}[

答え3

このような:

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

解決法はかなり簡単です。 の後に\itemまたはをb追加するだけです。 完全な MWE は (小さな変更後) 次のようになります。~\mbox{}

\documentclass[12pt]{article}

\usepackage[margin=1in]{geometry}
\usepackage{amsmath,amsthm,amssymb,bm}
\usepackage{enumitem,tikz}
\usepackage{tikz}
\usetikzlibrary{calc,positioning,shapes}

\tikzset{          >=latex,
           shorten >=3pt,
           shorten <=3pt,
between/.style args ={#1 and #2}{at = ($(#1)!0.5!(#2)$)},
      mydot/.style  ={circle,fill,inner sep=2pt},
  myellipse/.style  ={ellipse,draw=cyan,thick,
                      minimum width=60pt,minimum height=110pt,
                      inner sep=0pt},
 every edge/.style  ={draw=cyan,thick},
   relarrow/.style  ={->, out=25, in=155}
        }

\begin{document}

\begin{enumerate}
    \item
    \begin{enumerate}
        \item $R=\{(5,5),(6,5),(6,6)\}$,\\
              $S=\{(4,6),(5,5),(5,7),(6,6)\}$

        \item \mbox{}% <-- added      (Relation R  )
             \begin{center}
             \begin{tikzpicture}[
             baseline={([yshift=-1em] current bounding box.north)}
                                ]
             \node[mydot,label={left:4}] (a1) {};
             \node[mydot,below=of a1,label={left:5}] (a2) {};
             \node[mydot,below=of a2,label={left:6}] (a3) {};

             \node[mydot,right=5cm of a1,label={right:5}] (b1) {};
             \node[mydot,below=of b1,label={right:6}] (b2) {};
             \node[mydot,below=of b2,label={right:7}] (b3) {};

             \path[->] (a2) edge (b1);
             \path[->] (a3) edge (b1) edge (b2);

             \node[myellipse,label={above:A}] at (a2.center) (c1) {};
             \node[myellipse,label={above:B}] at (b2.center) (c2) {};

             \node at (2.5, 0.75) (r1) {$R$};
             \path[relarrow] (2.1, 0.4) edge (2.95, 0.35);
             \end{tikzpicture}
             \end{center}

     $R$ is not a function because it fails both properties (1) and (2) of the definition of a function. $4\in A$, but there is no $(4,y)\in R$ for any $y\in B$. Also, $(6,5)\in R$ and $(6,6)\in R$, but $5\neq6$.

             % Relation S
             \begin{center}
             \begin{tikzpicture}[
             baseline={([yshift=-1em] current bounding box.north)}
                                ]
             \node[mydot,label=left:4] (a1) {};
             \node[mydot,below=of a1,label=left:5] (a2) {};
             \node[mydot,below=of a2,label=left:6] (a3) {};

             \node[mydot,right=5cm of a1,label=right:5] (b1) {};
             \node[mydot,below=of b1,label=right:6] (b2) {};
             \node[mydot,below=of b2,label=right:7] (b3) {};

             \path[->] (a1) edge (b2);
             \path[->] (a2) edge (b1)
                 edge (b3);
             \path[->] (a3) edge (b2);

             \node[myellipse,label=above:A] at (a2.center) (c1) {};
             \node[myellipse,label=above:B] at (b2.center) (c2) {};

             \node at (2.5, 0.75) (r1) {$S$};
             \path[relarrow] (2.1, 0.4) edge (2.95, 0.35);
             \end{tikzpicture}
             \end{center}

             $S$ is not a function because it fails property (2) of the definition of a function. $(5,5)\in S$ and $(5,7)\in S$, but $5\neq7$.
    \end{enumerate}
\end{enumerate}
\end{document}

関連情報