Add "just a little more" padding to my table?
The possibility of changing the multiplicative parameter \arraystretch
has already been mentioned in another answer. For the sake of completeness, I think it's useful to also mention the additive parameter \extrarowheight
, which one would use as follows:
\usepackage{array}
\setlength\extrarowheight{2pt} % or whatever amount is appropriate
If you include these commands in the document's preamble, all array
and tabular
-like environments (such as tabular
, tabular*
, tabularx
, longtable
, etc.) will be affected by them.
I can't help but comment on some additional aspects of your table. First, all those horizontal and vertical lines make it look very busy; howevr, the multitude of lines probably doesn't add all that much to the table's readability. I'd therefore suggest getting rid of all single-vertical and single-horizontal lines and changing all double lines to single lines. Second, when you have numerical information in the table, it's really important to align the numbers in ways that makes reading them easy. For instance, numbers with decimal points should be aligned on the decimal point; and if some numbers are negative and some are positive, it's helpful to align them in ways that emphasizes that fact.
Here, then, is how I'd suggest you render the table:
\documentclass{article}
\usepackage{dcolumn} % automatically loads the 'array' package
\newcolumntype{d}[1]{D{.}{.}{#1}}
\setlength{\extrarowheight}{2pt}
\begin{document}
$ \begin{array}{c | c c c | r c c d{2.3} | d{4.1} r @{}}
& x_1 & x_2 & x_3 & x_4 & x_5 & x_6
& \multicolumn{1}{c|}{x_7} & \multicolumn{1}{c}{RS} & Q \\
\hline
x_2 & 0 & 1 & \frac{1}{3} & \frac{1}{3} & 0 & 0 & 0 & 50 & 150\\
x_5 & 0 & 0 & \frac{5}{6} & -\frac{2}{3} & 1 & 0 & -0.5 & 20 & 24 \\
x_6 & 0 & 0 & \frac{1}{12} & -\frac{2}{3} & 0 & 1 & -0.25 & 25 & 300\\
x_1 & 1 & 0 & 0.25 & 0 & 0 & 0 & 0.25 & 25 & 100\\
\hline
-z & 0 & 0 & \frac{79}{120} & \frac{23}{30} & 0 & 0 & -0.575 & -172.5 &
\end{array} $
\end{document}
If you use the \arraystretch
parameter in the preamble then all tables are going to obey that setting as follows
\documentclass{article}
\renewcommand{\arraystretch}{1.5}
\begin{document}
\begin{table}%
\centering
\begin{tabular}{c||c|c|c||c|c|c|c||c|c}
& $x_1$ & $x_2$ & $x_3$ & $x_4$ & $x_5$ & $x_6$ & $x_7$ & RS & Q \\ \hline \hline
$x_2$ & 0 & 1 & $\frac{1}{3}$ & $\frac{1}{3}$ & 0 & 0 & 0 & 50 & 150 \\ \hline
$x_5$ & 0 & 0 & $\frac{5}{6}$ & $-\frac{2}{3}$ & 1 & 0 & -0.5 & 20 & 24 \\ \hline
$x_6$ & 0 & 0 & $\frac{1}{12}$ & $-\frac{2}{3}$ & 0 & 1 & -0.25 & 25 & 300 \\ \hline
$x_1$ & 1 & 0 & 0.25 & 0 & 0 & 0 & 0.25 & 25 & 100 \\ \hline \hline
$-z$ & 0 & 0 & $\frac{79}{120}$ & $\frac{23}{30}$ & 0 & 0 & -0.575& -172.5 &
\end{tabular}
\caption{Some table}
\label{tab:1}
\end{table}
\end{document}
To keep this change local, you can simply place it in the table
environment instead of the preamble, say, just after the \centering
command. This would cause a temporary change in the global settings.
As mentioned in a related answer, arraystretch
introduces problems with vertical alignment of cell contents.
The solution with cellspace
is to:
Put the following in the preamble:
% Add vertical padding within each tabular cell. \usepackage[math]{cellspace} \cellspacetoplimit 4pt \cellspacebottomlimit 4pt
Use column specifiers
Sl, Sc, Sr, Sp{...}
instead ofl, c, r, p
.(Unless you are using the
siunitx
package, in which case useCl, Cc, Cr,
. This is because theCp{...}
siunitx
package has its ownS
column type, and takes care to renamecellspace
's column types toC
. Though something seems to be wrong with theCp{...}
, it seems.)
Compare:
Code for the above:
\documentclass{article}
% Add vertical padding within each tabular cell.
\usepackage[math]{cellspace}
\cellspacetoplimit 4pt
\cellspacebottomlimit 4pt
\begin{document}
Default:
\begin{tabular}{|l|l|} \hline
$\Upsilon_3$ & Description [Units] \\\hline
$\Pi_i$ & Description [Units] \\\hline
\end{tabular}
\vspace{2em}
Arraystretch:
{\renewcommand{\arraystretch}{2}
\begin{tabular}{|l|l|} \hline
$\Upsilon_3$ & Description [Units] \\\hline
$\Pi_i$ & Description [Units] \rule{1em}{1em} \\\hline
$\Pi_i$ & Description [Units] \rule{1em}{2em} \\\hline
$\Pi_i$ & Description [Units] \rule{1em}{3em} \\\hline
$\Pi_i$ & Description [Units] \rule{1em}{4em} \\\hline
$\Pi_i$ & Description [Units] \rule{1em}{5em} \\\hline
\end{tabular}}
With \verb|cellspace| (don't forget the \verb|Sl| cell specifiers):
\begin{tabular}{|Sl|Sl|} \hline
$\Upsilon_3$ & Description [Units] \\\hline
$\Pi_i$ & Description [Units] \\\hline
\end{tabular}
\vspace{2em}
\begin{tabular}{|Sl|Sl|} \hline
$\Upsilon_3$ & Description [Units] \\\hline
$\Pi_i$ & Description [Units] \rule{1em}{1em} \\\hline
$\Pi_i$ & Description [Units] \rule{1em}{2em} \\\hline
$\Pi_i$ & Description [Units] \rule{1em}{3em} \\\hline
$\Pi_i$ & Description [Units] \rule{1em}{4em} \\\hline
$\Pi_i$ & Description [Units] \rule{1em}{5em} \\\hline
\end{tabular}
\end{document}