7

Using the code

\documentclass{article}
\usepackage{amsmath}
\usepackage{array}
\newcolumntype{C}{>$c<$}
\begin{document}
\[
\begin{array}{C|C|C|C|C|C}
$p$ & $q$ & $p\land q$ & $\overbrace{(p\land q)\to p}^{\textbf{(a)}}$ & $p\lor q$ & $\overbrace{p\to (p\lor q)}^{\textbf{(b)}}$\\
\hline
T & T & T & T & T & T\\
T & F & F & T & T & T\\
F & T & F & T & T & T\\
F & F & F & T & F & T
\end{array}
\]
\end{document}

I get the following: enter image description here

I can also use

\begin{array}{C|C|C|C|C|C}
$p$ & $q$ & $p\land q$ & $(p\land q)\to p$ & $p\lor q$ & $p\to (p\lor q)$\\
\hline
T & T & T & T & T & T\\
T & F & F & T & T & T\\
F & T & F & T & T & T\\
F & F & F & $\underbrace{\text{T}}_{\textbf{(a)}}$ & F & $\underbrace{\text{T}}_{\textbf{(b)}}$
\end{array}

to get enter image description here

The only problem, in both cases, is that I want the over/underbrace usage, but I do not want the vertical lines to extend for all of the columns. Is there a way to accomplish the overbrace effect without having the vertical bars scale with it?

Note: If someone can think of a better title for this post and/or more appropriate tags, then please change for whatever works best.

2 Answers 2

6

You could use the \smash macro to encase the expressions with \overbrace and \underbrace material.

Since the tables are mostly set in text mode (except for the header row), I suggest you use tabular instead of array environments. Furthermore, consider using center environments instead of encasing the tables in \[ and \] statements. Finally, you should contemplate getting rid of all vertical bars in the tables and using \midrule (from the booktabs package) instead of \hline. This will give you a much more open look.

Actually, without the vertical bars, using \smash isn't strictly necessary. However, I suggest you keep the \smash directives, just in case you do decide to retain (or bring back) the vertical bars in the tables.

enter image description here

\documentclass{article}
\usepackage{amsmath}
\usepackage{booktabs} % for "\midrule" macro
\usepackage{lipsum} % for filler text
\begin{document}
\lipsum[2]
\bigskip % some extra vertical space *above* the first "center" env.
\begin{center}
\begin{tabular}{cccccc}
$p$ & $q$ & $p\land q$ & $\smash{\overbrace{(p\land q)\to p}^{\textbf{(a)}}}$ & $p\lor q$ & $\smash{\overbrace{p\to (p\lor q)}^{\textbf{(b)}}}$\\
\midrule
T & T & T & T & T & T\\
T & F & F & T & T & T\\
F & T & F & T & T & T\\
F & F & F & T & F & T\\
\end{tabular}
\end{center}

\lipsum[2]

\begin{center}
\begin{tabular}{cccccc}
$p$ & $q$ & $p\land q$ & $(p\land q)\to p$ & $p\lor q$ & $p\to (p\lor q)$\\
\midrule
T & T & T & T & T & T\\
T & F & F & T & T & T\\
F & T & F & T & T & T\\
F & F & F & $\smash{\underbrace{\text{T}}_{\textbf{(a)}}}$ & F & $\smash{\underbrace{\text{T}}_{\textbf{(b)}}}$\\
\end{tabular}
\end{center}

\bigskip  % some extra vertical space *below* the second "center" env.
\lipsum[2]
\end{document}
1
  • That's awesome--thank you for your in-depth answer, especially correcting some bad practices I've apparently developed. Much appreciated! Commented Sep 22, 2015 at 19:38
5

In order to remove the division lines (vertical rules) in the “overbrace” zone you need to detach the overbraces from the cells they refer to, which is possible with a phantom. Unfortunately the cell width is not available for inspection or usage.

I define also the command \lto that makes the arrow into a binary operation symbol, so with the same spacings as \land and \lor.

\documentclass{article}
\usepackage{amsmath}
\usepackage{lipsum}

\newcommand{\lto}{\mathbin{\to}}

\begin{document}

\lipsum*[2]
\[
\begin{tabular}{c*{5}{|c}}
\multicolumn{3}{c}{}&
\multicolumn{1}{c}{%
  $\overbrace{\hphantom{(p\land q)\lto p}}^{\textbf{(a)}}$%
}
&\multicolumn{1}{c}{}&
\multicolumn{1}{c}{%
  $\overbrace{\hphantom{p\lto (p\lor q)}}^{\textbf{(b)}}$%
}\\[-1ex]
$p$ & $q$ & $p\land q$ & $(p\land q)\lto p$ & $p\lor q$ & $p\to (p\lor q)$\\
\hline
T & T & T & T & T & T\\
T & F & F & T & T & T\\
F & T & F & T & T & T\\
F & F & F & T & F & T
\end{tabular}
\]
\lipsum[3]

\end{document}

enter image description here

You can use a similar trick for the underbrace.

A different realization with the truth value for the complex formulas under the connectives:

\documentclass{article}
\usepackage{amsmath}
\usepackage{booktabs}
\usepackage{lipsum}

\newcommand{\lto}{\mathbin{\to}}

\begin{document}

\lipsum*[2]
\[
\begin{tabular}{*{5}{c}}
\toprule
\multicolumn{5}{c}{\textbf{(a)}} \\
\midrule
$\llap{(}p$ & $\land$ & $q\rlap{)}$ & $\lto$ & $p$ \\
\midrule
% (p  AND  q)  -->  p
   T & T & T  & T & T \\
   T & F & F  & T & T \\
   F & F & T  & T & F \\
   F & F & F  & T & F \\
\bottomrule
\end{tabular}
\]
\lipsum[3]

\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .