并排的桌子

并排的桌子

我正在尝试创建图片中的表格,这是我第一次使用 LaTeX,我已经设法使用 tabularx 或 tabular 方式处理更多类型的表格。但我正在努力处理 4 个表格 2 和 2 并排,以及如何在表格行旁边写文本。

任何帮助都将不胜感激,非常感谢!!

后来的编辑:到目前为止,我还没有做很多事情,我知道如何做一个小表格以及如何插入灰色框,但正如我提到的,我不知道如何放置 4 个这样的表格以及如何在行之间写字。这是我做一个小表格的方法:(在一个更大的文档中,我已经添加了所有需要的包)

\begin{center}
\begin{tabular}{l|c|r|}
  & $b_1$ & $b_1'$ \\
\hline
$b_2$ & \cellcolor{gray!100} &  \\
\hline
$b_2'$ &  &   \\
\hline
\end{tabular}
\end{center}

它看起来应该是这样的:

在此处输入图片描述

答案1

align*我可以用一个简单的环境重现您发布的模型,并tabular在其中。如果您想控制列之间的间距,请使用alignat*

\documentclass{article}
\usepackage{amsmath}
\usepackage[table, svgnames]{xcolor}

\begin{document}

\begin{align*}
  x'_1 + x'_2: \:&
\begin{tabular}{|c| >{\columncolor{LightGrey}}c|}
\hline
\quad &\quad \\
\hline
\rowcolor{LightGrey} & \\
\hline
\end{tabular}
 & x'_1 x'_2: \:&
\begin{tabular}{|c|c|}
\hline
\quad &\quad \\
\hline
 & \cellcolor{LightGrey} \\
\hline
\end{tabular}\\[1ex]
  x_1x_2 + x'_1 x'_2: \:&
\begin{tabular}{|c| c|}
\hline
 \cellcolor{LightGrey}&\quad \\
\hline
\quad & \cellcolor{LightGrey}\\
\hline
\end{tabular}
 & x'_1 x_2 + x_1x'_2: \:&
\begin{tabular}{|c|c|}
\hline
\quad & \cellcolor{LightGrey} \\
\hline
  \cellcolor{LightGrey} & \quad \\
\hline
\end{tabular}
\end{align*}

\end{document} 

在此处输入图片描述

答案2

这是一个简单的建议:使用一个放置较小数组的数组。

\documentclass{article}
\usepackage[table]{xcolor}
\usepackage{colortbl}
\begin{document}
\begin{table}
\centering
$\begin{array}{r@{\,\colon\,}lp{1em}r@{\,\colon\,}l}
x_1'+x_2'&
\begin{array}{|*2{p{1ex}|}}
\hline
 & \cellcolor{gray!100}\\
\hline
\cellcolor{gray!100} & \cellcolor{gray!100}\\
\hline
\end{array} & &
x_1'x_2'&
\begin{array}{|*2{p{1ex}|}}
\hline
 & \\
\hline
  & \cellcolor{gray!100}\\
\hline
\end{array} \\[1.2em]  
x_1x_2+x_1'x_2'&
\begin{array}{|*2{p{1ex}|}}
\hline
 \cellcolor{gray!100} & \\
\hline
 & \cellcolor{gray!100}\\
\hline
\end{array} & &
x_1'x_2+x_1x_2'&
\begin{array}{|*2{p{1ex}|}}
\hline
 & \cellcolor{gray!100}\\
\hline
 \cellcolor{gray!100} & \\
\hline
\end{array} \\
\end{array}$
\caption{A table.}
\end{table}
\end{document}

在此处输入图片描述

答案3

以上两个答案都提到了这个词simple。在我看来,这个 TikZ 代码也很简单(也许只是)。我希望代码是自我解释的,即使对于第一次使用 TikZ 的用户也是如此。

在此处输入图片描述

\documentclass{article}
\usepackage{tikz}
\usepackage{lipsum}   % <<< for dummy texts only
\begin{document}
\lipsum[5] % dummy texts
\begin{center}
\begin{tikzpicture}[scale=.6] % as you think fit
\def\a{7.5} % distance to the right
\def\b{2.5} % distance to the bottom

\begin{scope}
\fill[yellow] (0,0)-|(2,2)-|(1,1)-|cycle;
\draw 
(0,0) grid (2,2)
(0,1) node[left]{$x'_1+x'_2 : $};
\end{scope} 

\begin{scope}[shift={(\a,0)}]
\fill[yellow] (1,0) rectangle (2,1);
\draw 
(0,0) grid (2,2)
(0,1) node[left]{$x'_1x'_2 : $};
\end{scope} 

\begin{scope}[shift={(0,-\b)}]
\fill[yellow] 
(2,0) rectangle (1,1) rectangle (0,2);
\draw 
(0,0) grid (2,2)
(0,1) node[left]{$x_1x_2+x'_1x'_2 : $};
\end{scope} 

\begin{scope}[shift={(\a,-\b)}]
\fill[yellow] 
(0,0) rectangle (1,1) rectangle (2,2);
\draw 
(0,0) grid (2,2)
(0,1) node[left]{$x'_1x_2+x_1x'_2 : $};
\end{scope} 

\end{tikzpicture}   
\end{center}
\lipsum[2] % dummy texts
\end{document}

相关内容