1

How to change vertical cell spacing with tabular in the first row of the next table?

\documentclass{article}
\usepackage{siunitx}
\usepackage{cellspace}
\setlength\cellspacetoplimit{25pt}
\setlength\cellspacebottomlimit{25pt}
\addparagraphcolumntypes{X}
\usepackage{tabularx}
\usepackage{amsmath}

\begin{document}

\begin{center} \setlength{\arrayrulewidth}{1.0pt} \begin{tabular}{c>{\centering\arraybackslash}m{2.0cm}}\hline $c$ & $\dfrac{a}{b}$ \ \hline $1$ & $1$ \ $1$ & $1$ \ $1$ & $1$ \end{tabular} \end{center}

\end{document}

With thanks,

Charles

Charles
  • 11

2 Answers2

1
  • solution using tabularray package is simple:
\documentclass{article}
\usepackage{tabularray}

\begin{document} [ \begin{tblr}{c c} \hline c & a/b \
\hline 1 & 1 \ 1 & 1 \ 1 & 1 \end{tblr} ]
\end{document}

which produce:

enter image description here

  • What you mean with your comment below question is unclear. It works out of box, however, you need to have installed tabularray package. The recent version (2022A) is available on CTAN, however, Overleaf support a older version which in your case works fine too.

  • Anyway, with "classic" tables package as are makecell package for additional vertical space in cells, array for table and if you liked nccmath for medium sized fraction in second column header:

\documentclass{article}
\usepackage{nccmath}
\usepackage{makecell}
    \setcellgapes{3pt}

\begin{document} [ \makegapedcells \begin{array}{c c} \hline c & a/b \ % or if you prefer c & \dfrac{a}{b} \hline 1 & 1 \ 1 & 1 \ 1 & 1 \end{array} ] or if you prefer
[ \makegapedcells \begin{array}{c c} \hline c & \mfrac{a}{b} \ \hline 1 & 1 \ 1 & 1 \ 1 & 1 \end{array} ] \end{document}

enter image description here

Zarko
  • 296,517
0

I have another solution if you have booktabs package.

\documentclass{article}
\usepackage{siunitx}
\usepackage{cellspace}
\setlength\cellspacetoplimit{25pt}
\setlength\cellspacebottomlimit{25pt}
\addparagraphcolumntypes{X}
\usepackage{tabularx}
\usepackage{amsmath}
\usepackage{booktabs} % <-- new

\begin{document}

\begin{center} \setlength{\arrayrulewidth}{1.0pt} \begin{tabular}{c>{\centering\arraybackslash}m{2.0cm}}\hline \specialrule{0em}{2pt}{2pt} % <-- new $c$ & $\dfrac{a}{b}$ \ \specialrule{0em}{2pt}{2pt} % <-- new \hline $1$ & $1$ \ $1$ & $1$ \ $1$ & $1$ \end{tabular} \end{center}

\end{document}

The specialrule adds the additional space here (a rule without width itself but has space above and below it) which is defined as (according to the manual)

\specialrule{<wd>}{<abovespace>}{<belowspace>}

result