2

This question already has an answer here:

So I have a table with equations, below. It's a bit crunched up and I want to add vertical space in the rows. I'm using booktabs package for heavy lifting.

\begin{table}
\begin{tabular}{lcc}
  \toprule
  Name & Function & Derivative & \\
  \midrule
  Sigmoid & $\phi(x) = \ddfrac{1}{1+e^{-x}}$ &  $\phi'(x) = \phi(x)(1-\phi(x))$\\
  TanH    & $\phi(x) = \ddfrac{2}{1+e^{-2x}} - 1$ & $\phi'(x) = 1-\phi(x)^2$ \\
  ReLU    & $\phi(x) = \begin{cases}
                            0 & x \leq 0 \\
                            x & x > 0
                          \end{cases} $ 
                          & $\phi'(x) = \begin{cases}
                                            0 & x \leq 0 \\
                                            1 & x > 0 
                                          \end{cases} $ \\
  Leaky ReLU & $\phi(x) = \begin{cases}
                            \alpha x & x \leq 0 \\
                            x & x > 0
                          \end{cases} $ 
                          & $\phi'(x) = \begin{cases}
                                            \alpha & x \leq 0 \\
                                            1 & x > 0 
                                          \end{cases} $ \\
  \bottomrule
\end{tabular}
\caption{Activation functions and their derivatives.} 
\label{tab:activation-functions}
\end{table}

Here's the produced output. Bad table. Bad

I tried adding: \renewcommand{\arraystretch}{2} before I write the table but it messes up more. Here's the result.

Worse table. Worse.

So any idea how to make it look pretty with the equations? Looking for a relatively quick solution because this is the only table I'll have with equations. But open to anything that works.

marked as duplicate by leandriis, Community Apr 5 '18 at 20:25

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • The answers to this question contain a broad variety of possibilities on how to increase the height of table rows. – leandriis Apr 5 '18 at 19:25
  • 1
    IMHO, the table will look much better without the vertical lines and left-aligning the formula columns. Additional space between rows can be specified with booktabs' \addlinespace. – Heiko Oberdiek Apr 7 '18 at 15:01
1

You can use after \\ as \\[3ex] as your desire spacing by changing the value of the numeral.

 \documentclass[a4paper]{article}
 \usepackage{booktabs}
 \usepackage{amsmath}

 \begin{document}
 \begin{table}
 \begin{tabular}{l|cc|cc|}
   \toprule
   Name & Function & Derivative & \\
   \midrule
   Sigmoid & $\phi(x) = \dfrac{1}{1+e^{-x}}$ &  $\phi'(x) = \phi(x)(1-\phi(x))$\\[3ex]
   TanH    & $\phi(x) = \dfrac{2}{1+e^{-2x}} - 1$ & $\phi'(x) = 1-\phi(x)^2$ \\[3ex]
   ReLU    & $\phi(x) = \begin{cases}
                        0 & x \leq 0 \\
                        x & x > 0
                      \end{cases} $ 
                      & $\phi'(x) = \begin{cases}
                                        0 & x \leq 0 \\
                                        1 & x > 0 
                                      \end{cases} $ \\[4ex]
   Leaky ReLU & $\phi(x) = \begin{cases}
                        \alpha x & x \leq 0 \\
                        x & x > 0
                      \end{cases} $ 
                      & $\phi'(x) = \begin{cases}
                                        \alpha & x \leq 0 \\
                                        1 & x > 0 
                                      \end{cases} $ \\
   \bottomrule
 \end{tabular}
 \caption{Activation functions and their derivatives.} 
 \label{tab:activation-functions}
 \end{table}
 \end{document}

enter image description here

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