How to get the width for a math symbol to align the rows of a table?
\hphantom{\neg}
will insert a horizontal space exactly the same as \neg
\documentclass{article}
\usepackage{amsmath, booktabs}
\begin{document}
\begin{tabular}{@{}ll@{}}
\toprule
combination & example \\ \midrule
$(b,\hphantom{\neg} d,\hphantom{\neg} t)$ & \\
$(b,\hphantom{\neg} d,\neg t)$ & \\
$(b,\neg d,\hphantom{\neg} t)$ & double auction \\
$(b,\neg d,\neg t)$ & \\ \bottomrule
\end{tabular}
\end{document}
This makes all components the same width, specified here as 2.1ex
, plus an added inter-column gap of \,\,
.
This allows some flexibility if the array content changes and allows for the presence of \neg
in the first column.
\documentclass{article}
\usepackage{amsmath, booktabs}
\newcommand\cw{2.1ex}
\def\z(#1,#2,#3){%
(\makebox[\cw][r]{$#1$},\,\,\makebox[\cw][r]{$#2$},\,\,\makebox[\cw][r]{$#3$})}
\begin{document}
\begin{tabular}{@{}ll@{}}
\toprule
combination & example \\ \midrule
$\z(b,d,t)$ & \\
$\z(b,d,\neg t)$ & \\
$\z(b,\neg d,t)$ & double auction \\
$\z(b,\neg d,\neg t)$ & \\ \bottomrule
\end{tabular}
\end{document}
But if you wanted the output tailored to this particular set of arrays, then
\documentclass{article}
\usepackage{amsmath, booktabs}
\setbox0=\hbox{$b$}
\edef\cwA{\the\wd0}
\setbox0=\hbox{$\neg d$}
\edef\cwB{\the\wd0}
\setbox0=\hbox{$\neg t$}
\edef\cwC{\the\wd0}
\def\z(#1,#2,#3){%
(\makebox[\cwA][r]{$#1$},\,\,\makebox[\cwB][r]{$#2$},\,\,\makebox[\cwC][r]{$#3$})}
\begin{document}
\begin{tabular}{@{}ll@{}}
\toprule
combination & example \\ \midrule
$\z(b,d,t)$ & \\
$\z(b,d,\neg t)$ & \\
$\z(b,\neg d,t)$ & double auction \\
$\z(b,\neg d,\neg t)$ & \\ \bottomrule
\end{tabular}
\end{document}
Another way uses the \eqparbox
package, which defines a system of tags for the standard box commands: all boxes sharing the same tag have as width of the natural width of the widest box in the series.
\documentclass{article}
\usepackage{amsmath, booktabs}
\usepackage{eqparbox}
\newcommand{\eqmathbox}[2][T]{\eqmakebox[#1][r]{$#2$}}
\begin{document}
\begin{tabular}{@{}ll@{}}
\toprule
combination & example \\ \midrule
$(b, \eqmathbox[D]{d},\eqmathbox{ t})$ & \\
$(b,\eqmathbox[D]{d}, \eqmathbox{t})$ & \\
$(b,\eqmathbox[D]{\neg d}, \eqmathbox{t})$ & double auction \\
$(b,\eqmathbox[D]{\neg d},\eqmathbox{\neg t})$ & \\ \bottomrule
\end{tabular}
\end{document}