I need to display fractions within a table and it requires to set
\renewcommand{\arraystretch}{2.3}
The problem is that not all rows contain fractions, and in this cases the white space below and above is too big. I can tweak it manually with something like \\[-2ex]
. This works for the middle cases, though its a little inconvenient, but I have no idea how to reduce the absolute top space.
Something like
\vspace{-2ex}
has no effect.
The best would be to be able to change the arraystretch for a single table row, but the command has no effect after \begin{tabular}
. How can I solve this issue?
MWE
\documentclass{article}
\usepackage{amsmath}
\usepackage{booktabs}
\begin{document}
\begin{table}
\renewcommand{\arraystretch}{2.3}
\begin{tabular}{@{}c|l@{}}
\bfseries $R_x$ & Symbol\\
\hline\hline
$\dfrac{a}{b}$ & $ \dfrac{A}{B} $\\
$\dfrac{a}{b}$ & $ \dfrac{A}{B} $\\
$\dfrac{a}{b}$ & $ \dfrac{A}{B} $\\
\hline
\end{tabular}
\end{table}
\end{document}
MWE with siunitx
\documentclass{article}
\usepackage{amsmath}
\usepackage{booktabs}
%\usepackage{siunitx}
\usepackage{wrapfig}
\usepackage{cellspace}
\setlength\cellspacetoplimit{4pt}
\setlength\cellspacebottomlimit{4pt}
\begin{document}
\begin{wrapfigure}[14]{R}{8.5cm}
\renewcommand{\arraystretch}{2.3}
\begin{tabular}{@{}Sc|Sl@{}}
\bfseries $R_x$ & Symbol\\
\hline\hline
$\dfrac{a}{b}$ & $ \dfrac{A}{B} $\\
some text & some other text \\
$\dfrac{a}{b}$ & $ \dfrac{A}{B} $\\
$\dfrac{a}{b}$ & $ \dfrac{A}{B} $\\
\hline
\end{tabular}
\end{wrapfigure}
\end{document}
Best Answer
The best solution is to use the
cellspace
package: it defines an adjustable minimal vertical padding around a cell. For this, you have to prefix the column specifier with the letterS
(orC
if you loadsiunitx
).With
\arraystretch
, there are two drawbacks: first the cell contents is no more vertically centred, and second, you have to determine, by trial and error, the stretch value – any modification of the contents may result in a new value, as is demonstrated in the following, where I modified one fraction, keeping the value you gave: