1

I am working on a table with a lot of formulas (Laplace Transforms of various functions). Using a standard command (\[2mm]), I am able to generate spacings for the denominators. But the numerators look cramped and the formulas do not read well. Is there a smart way to manage tables in LaTeX involving many mathematical fractions? Kindly help me on this! Thanks.

 \begin{table}
  \begin{center}
 \begin{tabular}{|c|c|c|} \hline 
No. & $f(t)$ & $F(s) = {\cal L}[f(t)]$ \\ \hline
  1 & $1$ & ${1 \over s}$ \\[2mm] \hline 
 2 & $t$ & ${1 \over s^2}$ \\[2mm] \hline 
  3 & $t^n$ & ${ n! \over s^{n + 1}}$ \\[2mm] \hline 
  4 & $e^{a t}$ & ${1 \over s - a}$ \\[2mm] \hline
  5 & $\sin \omega t$ & ${\omega \over s^2 + \omega^2}$ \\[2mm] \hline
  6 & $\cos \omega t$ & ${s \over s^2 + \omega^2}$ \\[2mm] \hline 
 \end{tabular}
  \end{center}
  \end{table}
2
  • 1
    Unless you give us some code to look at, aka a Minimal Working Example MWE, helping you is difficult since it involves guessing what you are trying to do.
    – Denis
    Commented Mar 10, 2022 at 8:28
  • 2
    Just out of curiosity: Why are you using PlainTeX \over notation instead of LaTeX \frac notation?
    – Mico
    Commented Mar 10, 2022 at 8:51

6 Answers 6

2

You can try \renewcommand{\arraystretch}{1.5} or \renewcommand{\arraystretch}{2.0} before the table. This should create more space around the objects in the table.

2
  • Thanks a lot! πŸ™πŸ™ It works beautifully! Great help!! πŸ™πŸ™
    – Sundar
    Commented Mar 10, 2022 at 9:03
  • You're welcome Dr. Sundar. Commented Mar 10, 2022 at 9:13
6

By far the most elegant way to avoid having to deal with math expressions, esp. expressions that contain fraction terms, coming too close to horizontal lines in a table is not to draw the horizontal lines in the first place.

Here's a solution which replaces most \hline directives with \addlinespace, a macro that's provided by the booktabs package. It further "opens up" the table by omitting all vertical lines. Finally, since virtually all of the table's contents are "math-y", I suggest you employ an array environment instead of a tabular environment.

Oh, and I'd replace all Plain-TeX syntax -- cf. \over and \cal -- with equivalent LaTeX syntax.

enter image description here

\documentclass{article} % or some other suitalbe document class
\usepackage{booktabs,array}
\newcolumntype{C}{>{$}c<{$}} % automatic text mode in an array env.
\begin{document}
\begin{table}
\[
\begin{array}{@{} C cc @{}} 
\toprule
No. & f(t) & F(s) = \mathcal{L}[f(t)] \\ 
\midrule
  1 & 1       & \frac{1}{s}   \\  \addlinespace
  2 & t       & \frac{1}{s^2} \\  \addlinespace
  3 & t^n     & \frac{n!}{s^{n + 1}} \\  \addlinespace
  4 & e^{a t} & \frac{1}{s - a}      \\  \addlinespace
  5 & \sin \omega t & \frac{\omega}{s^2 + \omega^2} \\  \addlinespace
  6 & \cos \omega t & \frac{s}{s^2 + \omega^2}      \\ 
\bottomrule 
\end{array}
\]
\end{table}
\end{document}
3

The simplest, in my opinion, consists in using the cellspace package, which enables you to define a minimal vertical spacing at the top & bottom of cells in columns with specifier prefixed with the letter S(or C if you load siunitx, or whatever letter you please with the column= some letter loading option).

\documentclass{article}
\usepackage{cellspace}
\setlength{\cellspacetoplimit}{4pt}
\setlength{\cellspacebottomlimit}{4pt}

\begin{document}

 \begin{table}
  \centering
 \begin{tabular}{|c|c|Sc|} \hline
No. & $f(t)$ & $F(s) = {\cal L}[f(t)]$ \\ \hline
  1 & $1$ & ${1 \over s}$ \\[2mm] \hline
 2 & $t$ & ${1 \over s^2}$ \\[2mm] \hline
  3 & $t^n$ & ${ n! \over s^{n + 1}}$ \\[2mm] \hline
  4 & $e^{a t}$ & ${1 \over s - a}$ \\[2mm] \hline
  5 & $\sin \omega t$ & ${\omega \over s^2 + \omega^2}$ \\[2mm] \hline
  6 & $\cos \omega t$ & ${s \over s^2 + \omega^2}$ \\[2mm] \hline
 \end{tabular}

  \end{table}

\end{document} 

enter image description here

3

With use of the tabularray package:

\documentclass{article}
\usepackage{tabularray}
\UseTblrLibrary{booktabs}   % load booktabs package

\begin{document}
\[
    \begin{tblr}{hlines, vlines, 
                 colspec = {ccc}
                 }          
\SetCell{mode=text} No.
    & f(t)            & F(s) = \cal{L}[f(t)]            \\
  1 & 1               & \frac{1}{s}                     \\
  2 & t               & \frac{1}{s^2}                   \\
  3 & t^n             & \frac{n!}{s^{n + 1}}            \\
  4 & e^{a t}         & \frac{1}{s - a}                 \\
  5 & \sin\omega t    & \frac{\omega}{s^2 + \omega^2}   \\
  6 & \cos\omega t    & \frac{s}{s^2 + \omega^2}        \\
    \end{tblr}
\]
or
\[
    \begin{tblr}{colspec = {ccc} }
    \toprule
\SetCell{mode=text} No.
    & f(t)            & F(s) = \cal{L}[f(t)]            \\
    \midrule
  1 & 1               & \frac{1}{s}                     \\
  2 & t               & \frac{1}{s^2}                   \\
  3 & t^n             & \frac{n!}{s^{n + 1}}            \\
  4 & e^{a t}         & \frac{1}{s - a}                 \\
  5 & \sin\omega t    & \frac{\omega}{s^2 + \omega^2}   \\
  6 & \cos\omega t    & \frac{s}{s^2 + \omega^2}        \\
  \bottomrule
    \end{tblr}
\]
\end{document}

enter image description here

1

Trivial working solution:

\documentclass[10pt,a4paper]{book}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amssymb}

\begin{document}
     \begin{table}
        \begin{center}
            \begin{tabular}{ccc} \hline 
                &&\\
                No. & $f(t)$ & $F(s) = {\cal L}[f(t)]$ \\ \hline
                &&\\
                
                1 & $1$ & ${1 \over s}$ \\[2mm] \hline 
                &&\\
                2 & $t$ & ${1 \over s^2}$ \\[2mm] \hline 
                &&\\
                3 & $t^n$ & ${ n! \over s^{n + 1}}$ \\[2mm] \hline 
                &&\\
                4 & $e^{a t}$ & ${1 \over s - a}$ \\[2mm] \hline
                &&\\
                5 & $\sin \omega t$ & ${\omega \over s^2 + \omega^2}$ \\[2mm] \hline
                &&\\
                6 & $\cos \omega t$ & ${s \over s^2 + \omega^2}$ \\[2mm] \hline 
                &&\\
            \end{tabular}
        \end{center}
    \end{table}
\end{document}

Output:

enter image description here

3
  • 3
    Suggestion: use \dfrac (instead of \over, which is plain TeX, not LaTeX, and should be avoided).
    – Rmano
    Commented Mar 10, 2022 at 8:56
  • Sorry, I got used to using \over for many years.. It is very easy to use compared to \frac{}{}.. I feel you will also like using \over when you start using it. Thanks!
    – Sundar
    Commented Mar 10, 2022 at 9:05
  • 2
    @Dr.Sundar - You wrote, "I feel you will also like using \over when you start using it." Not a chance on my part. See What is the difference between \over and \frac? for a general discussion of the subject.
    – Mico
    Commented Mar 10, 2022 at 9:08
1

With {NiceArray} of nicematrix.

\documentclass{article}
\usepackage{nicematrix}

\begin{document}

\[\begin{NiceArray}{ccc}[hvlines,cell-space-limits=4pt] 
\text{No.} & f(t) & F(s) = {\cal L}[f(t)] \\ 
  1 & 1 & \frac{1}{s} \\ 
  2 & t & \frac{1}{s^2} \\ 
  3 & t^n & \frac{n!}{s^{n + 1}} \\ 
  4 & e^{a t} & \frac{1}{s-a} \\ 
  5 & \sin \omega t & \frac{\omega}{s^2 + \omega^2} \\ 
  6 & \cos \omega t & \frac{s}{s^2 + \omega^2} \\ 
\end{NiceArray}\]

\end{document}

You need several compilations (because nicematrix uses PGF/Tikz nodes under the hood).

Output of the above code

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .