如何让放置在两个图形之间的文本居中?

如何让放置在两个图形之间的文本居中?

我尝试了使用 minipages 和 tabular 的几种不同方法,但结果如下:

阴谋

代码如下:

    \begin{tabular}{lcr}
    \begin{tikzpicture}[scale=1.1]
    \def\x{1} % replace 1 with desired value here
    \def\x{1} % replace 1 with desired value here
    \draw[<->] (-2.6,0) -- (2.6,0) node[right] {$\Psi_1$};
    \draw[<->] (0,-2.6) -- (0,2.6) node[above left] {$\Psi_2$};
      
    \foreach \Point in {(-1.5,1.5), (-1.5,-1.5), (1.5,1.5), (1.5,-1.5), (0,2.12) , (0,-2.12), (2.12,0),      (-2.12,0)}{
    \node at \Point {\textbullet};}

    \draw[dashed,draw=blue!60] (0,0) ++(0:2.12) arc (0:360:2.12);
    \end{tikzpicture}& \textbf{\Large OR}&

    \begin{tikzpicture}[scale=1.1]
    \def\x{1} % replace 1 with desired value here
    \def\x{1} % replace 1 with desired value here
    \draw[<->] (-2.6,0) -- (2.6,0) node[right] {$\Psi_1$};
    \draw[<->] (0,-2.6) -- (0,2.6) node[above left] {$\Psi_2$};
      
    \foreach \Point in {(-0.5,0.5), (-0.5,-0.5), (0.5,0.5), (0.5,-0.5), (0,2.12) , (0,-2.12), (2.12,0), (-2.12,0)}{
    \node at \Point {\textbullet};}

    \draw[dashed,draw=blue!60] (0,0) ++(0:2.12) arc (0:360:2.12);
    \draw[dashed,draw=blue!60] (0,0) ++(0:0.707) arc (0:360:0.707);
    \end{tikzpicture}
    \end{tabular}

问题是我希望 OR 与 x 轴对齐。有办法吗?我尝试了 minipages、center 和 tabular,但似乎都没有与 tabular 配合使用,到目前为止效果最好。有什么帮助吗?

答案1

请注意,(current bounding box.center)由于标签的原因, 略微偏离轴,因此我在原点添加了一个命名坐标。此外, 的基线or不在中心,因此\raisebox

\documentclass{article}
\usepackage{tikz}

\begin{document}

\begin{tabular}{lcr}
    \begin{tikzpicture}[scale=1.1, baseline=(origin)]
    \def\x{1} % replace 1 with desired value here
    \def\x{1} % replace 1 with desired value here
    \draw[<->] (-2.6,0) -- (2.6,0) node[right] {$\Psi_1$};
    \draw[<->] (0,-2.6) -- (0,2.6) node[above left] {$\Psi_2$};
      
    \foreach \Point in {(-1.5,1.5), (-1.5,-1.5), (1.5,1.5), (1.5,-1.5), (0,2.12) , (0,-2.12), (2.12,0),      (-2.12,0)}{
    \node at \Point {\textbullet};}

    \draw[dashed,draw=blue!60] (0,0) ++(0:2.12) arc (0:360:2.12);
    \coordinate (origin) at (0,0);
    \end{tikzpicture}& 
    \textbf{\Large \raisebox{\dimexpr 0.5\dp\strutbox-0.5\ht\strutbox}{OR}}&

    \begin{tikzpicture}[scale=1.1, baseline=(origin)]
    \def\x{1} % replace 1 with desired value here
    \def\x{1} % replace 1 with desired value here
    \draw[<->] (-2.6,0) -- (2.6,0) node[right] {$\Psi_1$};
    \draw[<->] (0,-2.6) -- (0,2.6) node[above left] {$\Psi_2$};
      
    \foreach \Point in {(-0.5,0.5), (-0.5,-0.5), (0.5,0.5), (0.5,-0.5), (0,2.12) , (0,-2.12), (2.12,0), (-2.12,0)}{
    \node at \Point {\textbullet};}

    \draw[dashed,draw=blue!60] (0,0) ++(0:2.12) arc (0:360:2.12);
    \draw[dashed,draw=blue!60] (0,0) ++(0:0.707) arc (0:360:0.707);
    \coordinate (origin) at (0,0);
    \end{tikzpicture}
    \end{tabular}

\end{document}

我突然意识到,表格除了将您推到右边距之外,实际上什么也没做。有很多方法可以避免这种情况,但为了简单起见,我只是加宽了文本区域。

\documentclass{article}
\usepackage[textwidth=6in, showframe]{geometry}
\usepackage{tikz}

\begin{document}

\noindent
    \begin{tikzpicture}[scale=1.1, baseline=(origin)]
    \def\x{1} % replace 1 with desired value here
    \def\x{1} % replace 1 with desired value here
    \draw[<->] (-2.6,0) -- (2.6,0) node[right] {$\Psi_1$};
    \draw[<->] (0,-2.6) -- (0,2.6) node[above left] {$\Psi_2$};
      
    \foreach \Point in {(-1.5,1.5), (-1.5,-1.5), (1.5,1.5), (1.5,-1.5), (0,2.12) , (0,-2.12), (2.12,0),      (-2.12,0)}{
    \node at \Point {\textbullet};}

    \draw[dashed,draw=blue!60] (0,0) ++(0:2.12) arc (0:360:2.12);
    \coordinate (origin) at (0,0);
    \end{tikzpicture}\hfill
    \textbf{\Large \raisebox{-0.2\baselineskip}{OR}}\hfill
    \begin{tikzpicture}[scale=1.1, baseline=(origin)]
    \def\x{1} % replace 1 with desired value here
    \def\x{1} % replace 1 with desired value here
    \draw[<->] (-2.6,0) -- (2.6,0) node[right] {$\Psi_1$};
    \draw[<->] (0,-2.6) -- (0,2.6) node[above left] {$\Psi_2$};
      
    \foreach \Point in {(-0.5,0.5), (-0.5,-0.5), (0.5,0.5), (0.5,-0.5), (0,2.12) , (0,-2.12), (2.12,0), (-2.12,0)}{
    \node at \Point {\textbullet};}

    \draw[dashed,draw=blue!60] (0,0) ++(0:2.12) arc (0:360:2.12);
    \draw[dashed,draw=blue!60] (0,0) ++(0:0.707) arc (0:360:0.707);
    \coordinate (origin) at (0,0);
    \end{tikzpicture}

\end{document}

相关内容