1

I am making a table with displaystyle inline math, and am having trouble getting a consistent vertical spacing between each row.

enter image description here

To be clear, I want the vertical padding for the fraction to be the same as that of the gobbledygook. I have tried using \def\arraystretch{...}, but it doesn't produce a consistent spacing.

The solutions in How to set the space between rows in a table don't really seem to solve this problem generally.

MWE:

\documentclass{article}
\begin{document}
\begin{tabular}{|c|}
\hline
Gobbledygook\\
\hline
$\displaystyle\frac{a}{b}$\\
\hline
\end{tabular}
\end{document}

2 Answers2

2

You can pad the cell contents, eg

enter image description here

\documentclass{article}
\newcommand\pad[1]{{\fboxsep=.5em \fboxrule=0pt \fbox{#1}}}
\begin{document}
\begin{tabular}{|c|}
\hline
\pad{Gobbledygook}\\
\hline
\pad{$\displaystyle\frac{a}{b}$}\\
\hline
\end{tabular}
\end{document}
David Carlisle
  • 757,742
  • Thank you very much! –  Nov 30 '23 at 21:32
  • It seems that the command does not preserve line wrapping, is there a way to overcome this? –  Dec 01 '23 at 17:29
  • @Pseudonym123 you had a c column which has no line wrapping, so there is nothing to preserve. – David Carlisle Dec 01 '23 at 17:39
  • I was actually using tabularx with an X column, but simplified it to just a tabular environment for the question because I thought they'd behave the same. Should I ask another question? –  Dec 01 '23 at 17:44
  • 1
    Zarko's answer probably covers that (mine doesn't it can't be fixed it would be a completely different answer) @Pseudonym123 – David Carlisle Dec 01 '23 at 17:46
0

With use of the tabularray package:

\documentclass{article}
\usepackage{tabularray}

\begin{document} \begin{tblr}{hlines, vlines, colspec={Q[c,mode=dmath]}, row{1} = {mode=text}, rowsep = {3pt} } Gobbledygook \ \frac{a}{b} \ \end{tblr} \end{document}

enter image description here

Zarko
  • 296,517