# Tables side by side

I am trying to create the tables in the picture, it is my first time using LaTeX and I've managed to handle more type of tables using the tabularx or the tabular ways. But I am struggling with 4 tables 2 and 2 side by side and also with how do you write text next to the line of the tables.

Any help is well appreciated, thank you a lot!!

Later edit: I did not manage to do a lot by far, I know how to do a little table and how to insert the grey box, but as I've mentioned I do not know how to place 4 tables like that and how to write next to it between the rows. This is how i do a small one: (is inside a bigger document,I've added all the packages needed)

\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}


What it should look like:

• Welcome to TeX.SX! In order for people to be able to help you, please provide a MWE of what you have tried so far and showing exactly what you are struggling with. – KersouMan May 7 '20 at 18:17
• I've edited it now with more details. Thank you!! – Diana Catalina May 7 '20 at 18:26
• Do you have math formulæ next to the tables? – Bernard May 7 '20 at 19:05
• yes but I know how to write them, an example with random text next to it would be more than enough – Diana Catalina May 7 '20 at 19:13

I could reproduce the model you posted with a simple align* environment, and tabular s in it. If you want to control the spacing between column, use alignat*:

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

\begin{document}

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

\end{document}


Here is a simple(-minded) proposal: use an array in which you put smaller arrays.

\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}


• Maybe I should have added that, of course, I designed this answer in such a way that it is rather robust. That is, the table is still centered if you use fleqn, say. (But of course when writing the answer I could not know that another answer will show up, in which these point get neglected.) – user194703 May 8 '20 at 16:56
• Thank you a lot! – Diana Catalina May 8 '20 at 20:24

Both the above answers mentioned the word simple. This TikZ code is also simple (maybe just) in my opinion. I hope the code is self-explained, even for first-time-TikZ-users.

\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}