![数组行中的元素垂直居中](https://linux22.com/image/318647/%E6%95%B0%E7%BB%84%E8%A1%8C%E4%B8%AD%E7%9A%84%E5%85%83%E7%B4%A0%E5%9E%82%E7%9B%B4%E5%B1%85%E4%B8%AD.png)
在下表中,我想将维恩图垂直居中。以下是 MWE,显示我的图表“顶部对齐”:
\documentclass[letterpaper,10pt,american]{article}
\usepackage[left=1 in, right=1 in, top=1 in, bottom=1 in]{geometry}
\usepackage{amsmath,amsfonts,amssymb,amsthm,color,srcltx,hyperref,enumitem,bm,cancel,thmtools}
\usepackage[scr=boondoxo,scrscaled=1.05]{mathalfa}
\usepackage{centernot}
\usepackage{pgf,tikz}
\usetikzlibrary{automata,arrows,positioning,calc,decorations.pathreplacing}
%Command for creating Venn diagrams (from https://tex.stackexchange.com/questions/266326/generate-all-16-possible-2-variable-shaded-venn-diagrams-in-tikz):
\makeatletter
\def\venn@strip#1#2\venn@STOP{\def\venn@next{#1}\gdef\venn@rest{#2}}
\newcommand{\venn}[1]{%
\begin{tikzpicture}[scale=0.15]
\coordinate (A) at (2,0);
\coordinate (B) at (0,0);
\coordinate (E) at (5,-3);
\coordinate (W) at (-3,{sqrt(3)+1.5});
\edef\venn@rest{#10000}%
\foreach \i in {0,...,3} {
\begin{scope}[even odd rule]
\expandafter\venn@strip\venn@rest\venn@STOP
\ifnum\venn@next=1\relax
\pgfmathparse{Mod(\i,2) == 1 ? "(E) rectangle (W)" : ""}
\path[clip] \pgfmathresult (A) circle[radius=2];
\pgfmathparse{Mod(floor(\i/2),2) == 1 ? "(E) rectangle (W)" : ""}
\path[clip] \pgfmathresult (B) circle[radius=2];
\pgfmathparse{Mod(floor(\i/4),2) == 1 ? "(E) rectangle (W)" : ""}
\fill[gray] (E) rectangle (W);
\fi
\end{scope}
}
\draw[thick] (A) circle[radius=2];
\draw[thick] (B) circle[radius=2];
\draw[thick] (E) rectangle (W);
\end{tikzpicture}
}
\makeatother
\begin{document}
\begin{displaymath}
\begin{array}{|c|c|c|c|}
\hline
\textrm{Truth Table} & \textrm{Venn Diagram} & \textrm{Connective} & \textrm{Connective Name} \\
\hline
FFFF & \venn{0000} & \mathscr{P} \perp \mathscr{Q} & \textrm{Contradiction} \\
FFFT & \venn{0001} & \mathscr{P} \overline{\lor} \mathscr{Q} & \textrm{Nondisjunction (Nor)} \\
FFTF & \venn{0010} & \mathscr{P} \centernot\impliedby \mathscr{Q} & \textrm{Converse Nonimplication} \\
\hline
\end{array}
\end{displaymath}
\end{document}
我尝试过raisebox
建议的方法这个问题,其 MWE 如下:
\documentclass[letterpaper,10pt,american]{article}
\usepackage[left=1 in, right=1 in, top=1 in, bottom=1 in]{geometry}
\usepackage{amsmath,amsfonts,amssymb,amsthm,color,srcltx,hyperref,enumitem,bm,cancel,thmtools}
\usepackage[scr=boondoxo,scrscaled=1.05]{mathalfa}
\usepackage{centernot}
\usepackage{pgf,tikz}
\usetikzlibrary{automata,arrows,positioning,calc,decorations.pathreplacing}
%Command for creating Venn diagrams (from https://tex.stackexchange.com/questions/266326/generate-all-16-possible-2-variable-shaded-venn-diagrams-in-tikz):
\makeatletter
\def\venn@strip#1#2\venn@STOP{\def\venn@next{#1}\gdef\venn@rest{#2}}
\newcommand{\venn}[1]{%
\begin{tikzpicture}[scale=0.15]
\coordinate (A) at (2,0);
\coordinate (B) at (0,0);
\coordinate (E) at (5,-3);
\coordinate (W) at (-3,{sqrt(3)+1.5});
\edef\venn@rest{#10000}%
\foreach \i in {0,...,3} {
\begin{scope}[even odd rule]
\expandafter\venn@strip\venn@rest\venn@STOP
\ifnum\venn@next=1\relax
\pgfmathparse{Mod(\i,2) == 1 ? "(E) rectangle (W)" : ""}
\path[clip] \pgfmathresult (A) circle[radius=2];
\pgfmathparse{Mod(floor(\i/2),2) == 1 ? "(E) rectangle (W)" : ""}
\path[clip] \pgfmathresult (B) circle[radius=2];
\pgfmathparse{Mod(floor(\i/4),2) == 1 ? "(E) rectangle (W)" : ""}
\fill[gray] (E) rectangle (W);
\fi
\end{scope}
}
\draw[thick] (A) circle[radius=2];
\draw[thick] (B) circle[radius=2];
\draw[thick] (E) rectangle (W);
\end{tikzpicture}
}
\makeatother
\begin{document}
\begin{displaymath}
\begin{array}{|c|c|c|c|}
\hline
\textrm{Truth Table} & \textrm{Venn Diagram} & \textrm{Connective} & \textrm{Connective Name} \\
\hline
FFFF & \raisebox{-.35\height}{\venn{0000} } & \mathscr{P} \perp \mathscr{Q} & \textrm{Contradiction} \\
FFFT & \raisebox{-.35\height}{\venn{0001} } & \mathscr{P} \overline{\lor} \mathscr{Q} & \textrm{Nondisjunction (Nor)} \\
FFTF & \raisebox{-.35\height}{\venn{0010} } & \mathscr{P} \centernot\impliedby \mathscr{Q} & \textrm{Converse Nonimplication} \\
\hline
\end{array}
\end{displaymath}
\end{document}
然而,这似乎导致我的图表向左滑动,失去水平对齐!因此,我正在寻找一种可以改善视觉效果的替代方法。
顺便说一句,我绝不承诺array
,所以如果您有不同的建议(例如使用tabular
或tabularx
或其他东西),我绝对愿意接受您的想法!
答案1
您可以使用baseline
选项tikzpicture
\newcommand{\venn}[1]{%
\begin{tikzpicture}[scale=0.15,baseline={(current bounding box.center)}]
这将使
在您使用的方法中\raisebox
,在右括号之前有一个额外的空格:
\raisebox{-.35\height}{\venn{0010} }
应该是
\raisebox{-.35\height}{\venn{0010}} %<-- no space here before }
代码:
\documentclass[letterpaper,10pt,american]{article}
\usepackage[left=1 in, right=1 in, top=1 in, bottom=1 in]{geometry}
\usepackage{amsmath,amsfonts,amssymb,amsthm,color,srcltx,hyperref,enumitem,bm,cancel,thmtools}
\usepackage[scr=boondoxo,scrscaled=1.05]{mathalfa}
\usepackage{centernot}
\usepackage{pgf,tikz}
\usetikzlibrary{automata,arrows,positioning,calc,decorations.pathreplacing}
%Command for creating Venn diagrams (from http://tex.stackexchange.com/questions/266326/generate-all-16-possible-2-variable-shaded-venn-diagrams-in-tikz):
\makeatletter
\def\venn@strip#1#2\venn@STOP{\def\venn@next{#1}\gdef\venn@rest{#2}}
\newcommand{\venn}[1]{%
\begin{tikzpicture}[scale=0.15]
\coordinate (A) at (2,0);
\coordinate (B) at (0,0);
\coordinate (E) at (5,-3);
\coordinate (W) at (-3,{sqrt(3)+1.5});
\edef\venn@rest{#10000}%
\foreach \i in {0,...,3} {
\begin{scope}[even odd rule]
\expandafter\venn@strip\venn@rest\venn@STOP
\ifnum\venn@next=1\relax
\pgfmathparse{Mod(\i,2) == 1 ? "(E) rectangle (W)" : ""}
\path[clip] \pgfmathresult (A) circle[radius=2];
\pgfmathparse{Mod(floor(\i/2),2) == 1 ? "(E) rectangle (W)" : ""}
\path[clip] \pgfmathresult (B) circle[radius=2];
\pgfmathparse{Mod(floor(\i/4),2) == 1 ? "(E) rectangle (W)" : ""}
\fill[gray] (E) rectangle (W);
\fi
\end{scope}
}
\draw[thick] (A) circle[radius=2];
\draw[thick] (B) circle[radius=2];
\draw[thick] (E) rectangle (W);
\end{tikzpicture}%
}
\makeatother
\begin{document}
\begin{displaymath}
\begin{array}{|c|c|c|c|}
\hline
\textrm{Truth Table} & \textrm{Venn Diagram} & \textrm{Connective} & \textrm{Connective Name} \\
\hline
FFFF & \raisebox{-.35\height}{\venn{0000}} & \mathscr{P} \perp \mathscr{Q} & \textrm{Contradiction} \\
FFFT & \raisebox{-.35\height}{\venn{0001}} & \mathscr{P} \overline{\lor} \mathscr{Q} & \textrm{Nondisjunction (Nor)} \\
FFTF & \raisebox{-.35\height}{\venn{0010}} & \mathscr{P} \centernot\impliedby \mathscr{Q} & \textrm{Converse Nonimplication} \\
\hline
\end{array}
\end{displaymath}
\end{document}