TransWikia.com

Table (or similar) of numbered displayed math

TeX - LaTeX Asked by Óscar Guajardo on November 26, 2020

I want to refer to a "table" of equations, but I want every "cell" to be numbered. All answers I have seen of anything similar deal with numbering lines, but I’d like to number individual cells as well. Here’s the minimal code:

begin{align*}
begin{array}{c|c|c}
p & q & pwedge qhline
1 & 1 & 1hline
1 & 0 & 0hline
0 & 1 & 0hline
0 & 0 & 0 
end{array} &&&
begin{array}{c|c|c}
p & q & pvee qhline
1 & 1 & 1hline
1 & 0 & 1hline
0 & 1 & 1hline
0 & 0 & 0 
end{array}[1.3ex]
begin{array}{c|c|c}
p & q & pveebar qhline
1 & 1 & 0hline
1 & 0 & 1hline
0 & 1 & 1hline
0 & 0 & 0 
end{array}&&&
begin{array}{c|c}
p & neg phline
1 & 0 hline
0 & 1
end{array}
end{align*}

A screencap of the output is below; what I want is for every truth table to have its own tag (not necessesarily a number, just to be able to use tag on each one) so I can later refer to them.

enter image description here

2 Answers

Here is a solution with 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 & pwedge qhline
1 & 1 & 1hline
1 & 0 & 0hline
0 & 1 & 0hline
0 & 0 & 0
end{array}
end{equation} &
begin{equation}label{TT:OR}
begin{array}{c|c|c}
p & q & pvee qhline
1 & 1 & 1hline
1 & 0 & 1hline
0 & 1 & 1hline
0 & 0 & 0
end{array}
end{equation} [-2ex]
%
begin{equation}
begin{array}{c|c|c}label{TT:XOR}
p & q & pveebar qhline
1 & 1 & 0hline
1 & 0 & 1hline
0 & 1 & 1hline
0 & 0 & 0
end{array}
end{equation}&
begin{equation}label{TT:NEG}
begin{array}{c|c}
p & neg phline
1 & 0 hline
0 & 1
end{array}
end{equation}
end{tabularx}vskip -1ex
}

Text continuation.

end{document} 

enter image description here

Correct answer by Bernard on November 26, 2020

Here's a solution that (a) places each array environment in an equation environment, (b) places each equation environment in a minipage environment of width 0.5linewidth, and (c) places the four minipage environments in a center environment. Embedding the minipage environments in a center environment assures that there will be bit of whitespace above and below the group of four arrays.

enter image description here

documentclass{article}
usepackage{array}    % for 'extrarowheight' macro
usepackage{amssymb}  % for 'veebar' macro
begin{document}

begin{center}
setlengthextrarowheight{1pt} % for a less "cramped" look

begin{minipage}{0.5linewidth}begin{equation}begin{array}{c|c|c}
p & q & pwedge 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.5linewidth}begin{equation}begin{array}{c|c|c}
p & q & pvee 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.5linewidth}begin{equation}begin{array}{c|c|c}
p & q & pveebar 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.5linewidth}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}

Answered by Mico on November 26, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP