Как можно отцентрировать tikzpicture, не центрируя \item, который его содержит?

Как можно отцентрировать tikzpicture, не центрируя \item, который его содержит?

У меня есть конкретное упражнение, в котором я хочу, чтобы диаграмма, которую я создал, tikzpictureбыла центрирована, но я также хочу, чтобы метка для , \itemкоторая ее содержит, была оставлена ​​в покое и оставалась на одной линии с другими перечислителями на своем уровне. Мне удалось найти решения для множества других проблем, с которыми я сталкивался (это мой первый документ LaTeX), но какой бы ответ я ни пробовал, метка \item(в данном случае a (b)) как будто тянется за собой, вот так:

![центральный тег itemnapping

Вот несколько примеров того, что я попробовал:

\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}

...и так далее. Я получаю "лучшие" результаты с первыми двумя, которые кажутся мне идентичными. (b) смещается к центру, и между tikzpictureи текстом под ним нет надлежащего вертикального интервала. Однако последующие диаграммы (которые все находятся под тем же, \itemчто и первая) не имеют этой проблемы с интервалом. Мне кажется странным, что \begin{center}втягивается что-то, что должно быть за пределами его области действия, но я уверен, что есть простое объяснение. Вот минимальный (почти) рабочий пример (я собираюсь реорганизовать его, чтобы минимизировать повторения):

\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

Так:

введите описание изображения здесь

Решение довольно простое. После \itemfor bпросто добавьте ~или \mbox{}. Полная MWE (после небольших изменений) выглядит так:

\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}

Связанный контент