20

This is the Latex code I have to create a table:

\documentclass{article}

\usepackage{amsmath}
\usepackage{tabularx}
\usepackage[top=0.5cm, bottom=0.5cm, left=0.5cm, right=0.5cm, columnsep=0.75cm]{geometry}

\begin{document}

\subsubsection*{Fourier Transform properties}
\begin{tabular}{l@\quad|@\quad l@\quad|@\quad l@\quad|@\quad l}
    Property & Time domain & Frequency domain & Condition \\
    \hline
    Time-shift & $f(t - \tau)$ & $\hat{f}(\omega)e^{-i \omega \tau}$ \\
    Frequency-shift & $f(t) e^{i \omega_0 t}$ & $\hat{f}(\omega - \omega_0)$ \\
    Modulation Thm. & $f(t)\cos(\omega_0 t)$ & $\cfrac{\hat{f}(\omega-\omega_0)+\hat{f}(\omega+\omega_0)}{2}$ \\
    Differentiation (time) & $f^{(n)}(t)$ & $(i\omega)^n \hat{f}(\omega)$ & $\lim_{t \to \pm \infty} f(t) = 0$
\end{tabular}

\end{document}

With this code there is no space between the rows in the table. How can I add some space (let's say 0.3 cm) between the rows? I've tried a few things, but they don't work as expected.

When using \setlength{\extrarowheight}{0.3cm}, the table looks like this: extrarowheight

As you can see, no space is added between the third and the fourth row. Also, the text in the header row is aligned at the bottom, which does not look nice.

When using \renewcommand{\arraystretch}{1.8}, the table looks like this: arraystretch

This looks better, but the space between the second and third row is twice as big as the space between the third and fourth row.

Which command can I use that always puts the same amount of spacing between two rows?

31
+50
\documentclass{article}

\usepackage{mathtools}

\begin{document}

\subsubsection*{Fourier Transform properties}
{\def\arraystretch{2}\tabcolsep=10pt
\begin{tabular}{@{}l | l | l | l @{}}
    Property & Time domain & Frequency domain & Condition \\
    \hline
    Time-shift & $f(t - \tau)$ & $\hat{f}(\omega)e^{-i \omega \tau}$ \\
    Frequency-shift & $f(t) e^{i \omega_0 t}$ & $\hat{f}(\omega - \omega_0)$ \\
\rule{0pt}{5ex}%  EXTRA vertical height  
    Modulation Thm. & $f(t)\cos(\omega_0 t)$ & $\dfrac{ \hat{f}(\omega-\omega_0)+\hat{f}(\omega+\omega_0) }{2}$ \\
    Differentiation (time) & $f^{(n)}(t)$ & $(i\omega)^n \hat{f}(\omega)$ & $\displaystyle\lim_{\mathclap{t \to \pm \infty}} f(t) = 0$
\end{tabular}%
}
\end{document}

enter image description here

another possibility is to use package tabls. But this may cause problems when using other tabular packages. Try it and maybe the possible optional arguments are of interest, as minimal distance between tabulkar lines.

\documentclass{article}

\usepackage{mathtools}
\usepackage{tabls}

\begin{document}

\subsubsection*{Fourier Transform properties}
{\tablinesep=2ex\tabcolsep=10pt
\begin{tabular}{@{}l | l | l | l @{}}
    Property & Time domain & Frequency domain & Condition \\
    \hline
    Time-shift & $f(t - \tau)$ & $\hat{f}(\omega)e^{-i \omega \tau}$ \\
    Frequency-shift & $f(t) e^{i \omega_0 t}$ & $\hat{f}(\omega - \omega_0)$ \\   
    Modulation Thm. & $f(t)\cos(\omega_0 t)$ & $\dfrac{ \hat{f}(\omega-\omega_0)+\hat{f}(\omega+\omega_0) }{2}$ \\
    Differentiation (time) & $f^{(n)}(t)$ & $(i\omega)^n \hat{f}(\omega)$ & $\displaystyle\lim_{\mathclap{t \to \pm \infty}} f(t) = 0$
\end{tabular}%
}
\end{document}

enter image description here

  • 1
    This works, but I still hope someone has a solution that doesn't involve doing something special for one row (like the \rule{0pt}{5ex}). And thanks for correcting my ugly way of doing horizontal spacing. – Paul Mar 20 '13 at 9:22
  • @Paul: see my edit and the 2nd example – user2478 Mar 20 '13 at 9:29
  • All right, one last request: It looks like that in the horizontal direction sort-of the same problem occurs now. The "t → ±∞" in the formula in the fourth column is ignored in determining the position of the formula. Would it be possible to move that formula a bit to the right. Again, with a command for the table, not for the specific column or cell. – Paul Mar 20 '13 at 12:17
  • for the last column specifier: .. @{\kern2\tabcolsep}l @{}} or any other length. You can also use as an alternative \mathrlap{t ...} instead of \mathclap – user2478 Mar 20 '13 at 12:37
  • Thanks Herbert! I've I discovered that simply removing \mathclap solves the second problem. – Paul Mar 20 '13 at 18:28
14

\extrarowheight does add the same amount of space to each row, but the fraction \frac{\hat{f}(\omega-\omega_0)+\hat{f}(\omega+\omega_0)}{2} makes for a rather unappealing table. For better appearance, you might prefer something like that:

\documentclass{article}

\usepackage{amsmath}
\usepackage{tabularx}
\usepackage{array}
\usepackage[top=0.5cm, bottom=0.5cm, left=0.5cm, right=0.5cm, columnsep=0.75cm]{geometry}

\begin{document}

\subsubsection*{Fourier Transform properties}
{
\setlength{\extrarowheight}{.5em}
\begin{tabular}{l@\quad|@\quad l@\quad|@\quad l@\quad|@\quad l}
    Property & Time domain & Frequency domain & Condition \\
    \hline
    Time-shift & $f(t - \tau)$ & $\hat{f}(\omega)e^{-i \omega \tau}$ \\
    Frequency-shift & $f(t) e^{i \omega_0 t}$ & $\hat{f}(\omega - \omega_0)$ \\
    Modulation Thm. & $f(t)\cos(\omega_0 t)$ &
        $\left[\hat{f}(\omega-\omega_0)+\hat{f}(\omega+\omega_0)\right]/\,2$ \\
    Differentiation (time) & $f^{(n)}(t)$ &
        $(i\omega)^n \hat{f}(\omega)$ & $\lim_{t \to \pm \infty} f(t) = 0$
\end{tabular}

\end{document}

EDIT: thanks to those users who posted constructive suggestions below. enter image description here

  • 5
    I would much rather go with (...)/2. – Werner Mar 18 '13 at 4:38
  • I added an image to show the problem with extrarowheight. Maybe writing the fraction differently works for this case, but I want a solution that works in every case. I don't want a workaround. – Paul Mar 18 '13 at 4:41
  • 1
    I agree with @Werner. You could also consider $[...]/2$ (brackets as delimeters without scaling). – user10274 Mar 20 '13 at 9:55
  • 2
    $\left[...\right]$ makes more sense – user2478 Mar 20 '13 at 10:12
  • 3
    Seriously, people, this is not an answer to my question. Removing the \frac obviously causes the spacing problem to disappear, you don't have to tell me that. My code is just an example of a lot of tables I'm going to make, and in some of those tables I really want a \frac. – Paul Mar 20 '13 at 19:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.