我想引用方程式的“表格”,但我希望每个“单元格”都有编号。我见过的所有类似答案都涉及编号行,但我也想对单个单元格进行编号。这是最基本的代码:
\begin{align*}
\begin{array}{c|c|c}
p & q & p\wedge q\\\hline
1 & 1 & 1\\\hline
1 & 0 & 0\\\hline
0 & 1 & 0\\\hline
0 & 0 & 0 \\
\end{array} &&&
\begin{array}{c|c|c}
p & q & p\vee q\\\hline
1 & 1 & 1\\\hline
1 & 0 & 1\\\hline
0 & 1 & 1\\\hline
0 & 0 & 0 \\
\end{array}\\[1.3ex]
\begin{array}{c|c|c}
p & q & p\veebar q\\\hline
1 & 1 & 0\\\hline
1 & 0 & 1\\\hline
0 & 1 & 1\\\hline
0 & 0 & 0 \\
\end{array}&&&
\begin{array}{c|c}
p & \neg p\\\hline
1 & 0 \\\hline
0 & 1\\
\end{array}
\end{align*}
下面是输出的屏幕截图;我想要的是每个真值表都有自己的标签(不一定是数字,只是能够\tag
在每个真值表上使用),以便我以后可以参考它们。
答案1
这是一个解决方案tabularx
:
\documentclass[12pt]{report}
\usepackage{amsmath, amssymb}
\usepackage{tabularx}
\begin{document}
Some text. Some more text.
{\centering \renewcommand{\tabularxcolumn}[1]{m{#1}}
\begin{tabularx}{\textwidth}{@{}XX@{}}
\begin{equation}\label{TT:AND}
\begin{array}{c|c|c}
p & q & p\wedge q\\\hline
1 & 1 & 1\\\hline
1 & 0 & 0\\\hline
0 & 1 & 0\\\hline
0 & 0 & 0
\end{array}
\end{equation} &
\begin{equation}\label{TT:OR}
\begin{array}{c|c|c}
p & q & p\vee q\\\hline
1 & 1 & 1\\\hline
1 & 0 & 1\\\hline
0 & 1 & 1\\\hline
0 & 0 & 0
\end{array}
\end{equation} \\[-2ex]
%
\begin{equation}
\begin{array}{c|c|c}\label{TT:XOR}
p & q & p\veebar q\\\hline
1 & 1 & 0\\\hline
1 & 0 & 1\\\hline
0 & 1 & 1\\\hline
0 & 0 & 0
\end{array}
\end{equation}&
\begin{equation}\label{TT:NEG}
\begin{array}{c|c}
p & \neg p\\\hline
1 & 0 \\\hline
0 & 1
\end{array}
\end{equation}
\end{tabularx}\vskip -1ex
}
Text continuation.
\end{document}
答案2
解决方案如下:(a) 将每个array
环境放在一个equation
环境中,(b) 将每个equation
环境放在一个minipage
宽度为 的环境中0.5\linewidth
,(c) 将四个minipage
环境放在一个环境中center
。将minipage
环境嵌入一个环境中center
可确保四个数组组的上方和下方会有少量空白。
\documentclass{article}
\usepackage{array} % for '\extrarowheight' macro
\usepackage{amssymb} % for '\veebar' macro
\begin{document}
\begin{center}
\setlength\extrarowheight{1pt} % for a less "cramped" look
\begin{minipage}{0.5\linewidth}\begin{equation}\begin{array}{c|c|c}
p & q & p\wedge q \\ \hline
1 & 1 & 1 \\ \hline
1 & 0 & 0 \\ \hline
0 & 1 & 0 \\ \hline
0 & 0 & 0
\end{array}\end{equation}\end{minipage}%
\begin{minipage}{0.5\linewidth}\begin{equation}\begin{array}{c|c|c}
p & q & p\vee q \\ \hline
1 & 1 & 1 \\ \hline
1 & 0 & 1 \\ \hline
0 & 1 & 1 \\ \hline
0 & 0 & 0
\end{array}\end{equation}\end{minipage}
\vspace{5mm} % or whatever amount of vertical spacing you prefer
\begin{minipage}{0.5\linewidth}\begin{equation}\begin{array}{c|c|c}
p & q & p\veebar q \\ \hline
1 & 1 & 0 \\ \hline
1 & 0 & 1 \\ \hline
0 & 1 & 1 \\ \hline
0 & 0 & 0
\end{array}\end{equation}\end{minipage}%
\begin{minipage}{0.5\linewidth}\begin{equation}\begin{array}{c|c}
p & \neg p \\ \hline
1 & 0 \\ \hline
0 & 1 \\
\end{array}\end{equation}\end{minipage}
\end{center}
\end{document}