使用 tikz 拉直对立正方形中的倾斜线

使用 tikz 拉直对立正方形中的倾斜线

我正在尝试绘制一个对立的正方形(一种旧的逻辑结构),并在一些边缘处添加两行文本。当我运行下面的代码时,“一些”和“并非全部”之间的线会以非常烦人的方式倾斜。我不确定如何解决这个问题。

我尝试在“Every”下方添加一行,\vspace*{1\baselineskip}但不起作用。而且看起来很奇怪。我还尝试将 I(“Some”)的位置指定为“left of=O”,其中 O 表示“并非全部”,但它将“some”向中心倾斜。

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{positioning,arrows,calc}

\pagestyle{empty}
\begin{document}

% based on code in http://www.actual.world/resources/tex/doc/TikZ.pdf

\begin{tikzpicture}[node distance=4cm]

    \node (A) {\begin{tabular}{c} \textbf{Every} \\ \end{tabular}};
    \node (E) [right=of A, xshift=2cm] {\begin{tabular}{c} \textbf{No} \\ every(not(...)) \end{tabular}};
    \node (O) [below=of E] {\begin{tabular}{c}  \textbf{Not every}  \\ not(every(...))\end{tabular}};
    \node (I) [below=of A] {\begin{tabular}{c}  \textbf{Some} \\ not(every(not(...)) \end{tabular}};

    \coordinate (CENTER) at ($(A)!0.5!(O)$);

    \node (contra) at (CENTER) {\begin{tabular}{c}Contradictories\\ \tiny{cannot both be true and cannot both be false} \end{tabular}};
    \path[<->] (A) edge node[] {\begin{tabular}{c}Contraries\\ \tiny{cannot both be true but can both be false} \end{tabular}} (E);
    \path[<->] (I) edge node[] {\begin{tabular}{c}Subcontraries\\ \tiny{cannot both be false but can both be true}\end{tabular}} (O);
    \path[->] (A) edge node[rotate=90] {\begin{tabular}{c}Subalterns\\ \tiny{must be true if superaltern is true}\end{tabular}} (I);
    \path[->] (E) edge node[rotate=-90] {\begin{tabular}{c}Subalterns\\ \tiny{must be true if superaltern is true}\end{tabular}} (O);

    \path[->] (contra) edge (A);
    \path[->] (contra) edge (E);
    \path[->] (contra) edge (I);
    \path[->] (contra) edge (O);

\end{tikzpicture}


\end{document}

在此处输入图片描述

答案1

节点AE不具有相同的高度,则定位OIbelow=of ...产生下部节点的错位。

我建议先放置Ibelow=of A然后再放置Oat (I-|E)这样所有节点将水平和垂直对齐。

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{positioning,arrows,calc}

\pagestyle{empty}
\begin{document}

% based on code in http://www.actual.world/resources/tex/doc/TikZ.pdf

\begin{tikzpicture}[node distance=4cm]

    \node (A) {\begin{tabular}{c} \textbf{Every} \\ \end{tabular}};
    \node (E) [right=of A, xshift=2cm] {\begin{tabular}{c} \textbf{No} \\ every(not(...)) \end{tabular}};
    \node (I) [below=of A] {\begin{tabular}{c}  \textbf{Some} \\ not(every(not(...)) \end{tabular}};
    \node (O) at (I-|E) {\begin{tabular}{c}  \textbf{Not every}  \\ not(every(...))\end{tabular}};

    \coordinate (CENTER) at ($(A)!0.5!(O)$);

    \node (contra) at (CENTER) {\begin{tabular}{c}Contradictories\\ \tiny{cannot both be true and cannot both be false} \end{tabular}};
    \path[<->] (A) edge node[] {\begin{tabular}{c}Contraries\\ \tiny{cannot both be true but can both be false} \end{tabular}} (E);
    \path[<->] (I) edge node[] {\begin{tabular}{c}Subcontraries\\ \tiny{cannot both be false but can both be true}\end{tabular}} (O);
    \path[->] (A) edge node[rotate=90] {\begin{tabular}{c}Subalterns\\ \tiny{must be true if superaltern is true}\end{tabular}} (I);
    \path[->] (E) edge node[rotate=-90] {\begin{tabular}{c}Subalterns\\ \tiny{must be true if superaltern is true}\end{tabular}} (O);

    \path[->] (contra) edge (A);
    \path[->] (contra) edge (E);
    \path[->] (contra) edge (I);
    \path[->] (contra) edge (O);

\end{tikzpicture}


\end{document}

在此处输入图片描述

答案2

在此处输入图片描述

与您的 MWE 相比的变化:

  • 定义新的节点距离(并消除xshift节点E
  • 主节点已定义minimum height=3em,因此水平线是直的
  • 增加字体大小,以便\tiny\scriptsize阅读
  • 删除了\tabular节点中的环境,而是使用align=center每个节点的选项
  • 对于箭头使用库arrows.meta(个人喜好问题)

上述变化的结果是 MWE 更加简洁,具有所需的功能 :-) :

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{arrows.meta, calc, positioning}

\begin{document}
\pagestyle{empty}

% based on code in http://www.actual.world/resources/tex/doc/TikZ.pdf
    \begin{tikzpicture}[
    > = {Straight Barb[length=1mm]},
node distance = 5cm and 7cm,
mn/.style = {minimum height=3em}, % mn: main nodes
every node/.style = {align=center},
every edge quotes/.style={auto}
                        ]
\node (A) [mn]              {\textbf{Every}};
\node (E) [mn,right=of A]   {\textbf{No} \\ every(not(...))};
\node (O) [mn,below=of E]   {\textbf{Not every}\\ not(every(...))};
\node (I) [mn,below=of A]   {\textbf{Some}\\ not(every(not(...))};

\coordinate (CENTER) at ($(A)!0.5!(O)$);

\node (contra) [mn] at (CENTER) {Contradictories\\
                            \scriptsize cannot both be true and
                                        cannot both be false};
\draw[<->]  (A) edge node {Contraries\\
                            \scriptsize cannot both be true
                            and cannot both be false}   (E)
            (I) edge node {Subcontraries\\
                            \scriptsize cannot both be false
                            but can both be true}       (O);
\draw[->]   (A) edge node[rotate=90]
                      {Subalterns\\
                       \scriptsize must be true if
                       superaltern is true}             (I)
            (E) edge node[align=center, rotate=-90]
                      {Subalterns\\
                       \scriptsize must be true if
                       superaltern is true}             (O);

\draw[->]   (contra) edge (A)
            (contra) edge (E)
            (contra) edge (I)
            (contra) edge (O);
    \end{tikzpicture}
\end{document}

相关内容