3

I am creating the following table:

\begin{figure}[h!]
    \centering
    \begin{tabular}{|c|c|c|c|}
        \hline
        \text{sign of} c & f & i & \text{Resulting Matrix}\\
        \hline
        $\geq 0$ & $\geq 0$ & $\geq 0$ & 
        $
        \begin{bmatrix}
            -2c^2+1 & -2cf & 2ci\\
            -2cf & -2f^2+1 & 2fi\\
            -2ci & -2fi & 2i^2-1
        \end{bmatrix}$\\
        \hline
        $\geq 0$ & $\geq 0$ & $\leq 0$ & $ 
        \begin{bmatrix}
            -2c^2+1 & -2cf & -2ci\\
            -2cf & -2f^2+1 & -2fi\\
            2ci & 2fi & 2i^2-1
        \end{bmatrix}$
        \\
        \hline
        $\geq 0$ & $\leq 0$ & $\geq 0$ &
        $\begin{bmatrix}
            -2c^2+1 & 2cf & 2ci\\
            2cf & -2f^2+1 & -2fi\\
            -2ci & 2fi & 2i^2-1
        \end{bmatrix}$\\
        \hline
        $\geq 0$ & $\leq 0$ & $\leq 0$ & $
        \begin{bmatrix}
            -2c^2+1 & 2cf & -2ci\\
            2cf & -2f^2+1 & 2fi\\
            2ci & -2fi & 2i^2-1
        \end{bmatrix}$
        \\
        \hline
        $\leq 0$ & $\geq 0$ & $\geq 0$ & 
        $\begin{bmatrix}
            -2c^2+1 & 2cf & -2ci\\
            2cf & -2f^2+1 & 2fi\\
            2ci & -2fi & 2i^2-1
        \end{bmatrix}$\\
        \hline
        $\leq 0$ & $\geq 0$ & $\leq 0$ & 
        $\begin{bmatrix}
            -2c^2+1 & 2cf & 2ci\\
            2cf & -2f^2+1 & -2fi\\
            -2ci & 2fi & 2i^2-1
        \end{bmatrix}$
        \\
        \hline
        $\leq 0$ & $\leq 0$ & $\geq 0$ & 
        $\begin{bmatrix}
            -2c^2+1 & -2cf & -2ci\\
            -2cf & -2f^2+1 & -2fi\\
            2ci & 2fi & 2i^2-1
        \end{bmatrix}$
        \\
        \hline
        $\leq 0$ & $\leq 0$ & $\leq 0$ & 
        $\begin{bmatrix}
            -2c^2+1 & -2cf & 2ci\\
            -2cf & -2f^2+1 & 2fi\\
            -2ci & -2fi & 2i^2-1
        \end{bmatrix}$
        \\
        \hline
    \end{tabular}
    \caption{All the matrcies which yield from casework on $c,f,i = \pm \sqrt{c^2}, \pm \sqrt{f^2}, \pm \sqrt{i^2}$.}
    \label{fig:my_label}
\end{figure}

It ends up looking like this: Matricies are Cramped together on the right, compiled with Overleaf

As you can see, there is no vertical space between the top of the cell and the top of the matrix that is in it. Is there any way to fix that? Adding \vspace doesn't help as it creates blanks in the vertical bars. I also tried \renewcommand{\arraystretch}{<factor>}, but that simply stretches the matrices without adding any vertical padding within the cell.

3

Welcome to the TeX.SE. You can use \renewcommand{\arraystretch}{1.4} into the code near to tabular.

enter image description here

\documentclass[a4paper,12pt]{article}
\usepackage{amsmath,amssymb}

\begin{document}
\begin{figure}[h!]
    \centering
    {\renewcommand{\arraystretch}{1.4}\begin{tabular}{|c|c|c|c|}
        \hline
        \text{sign of} c & f & i & \text{Resulting Matrix}\\
        \hline
        $\geq 0$ & $\geq 0$ & $\geq 0$ & 
        $
        \begin{bmatrix}
            -2c^2+1 & -2cf & 2ci\\
            -2cf & -2f^2+1 & 2fi\\
            -2ci & -2fi & 2i^2-1
        \end{bmatrix}$\\
        \hline
        $\geq 0$ & $\geq 0$ & $\leq 0$ & $
        \begin{bmatrix}
            -2c^2+1 & -2cf & -2ci\\
            -2cf & -2f^2+1 & -2fi\\
            2ci & 2fi & 2i^2-1
        \end{bmatrix}$
        \\
        \hline
        $\geq 0$ & $\leq 0$ & $\geq 0$ &
        $\begin{bmatrix}
            -2c^2+1 & 2cf & 2ci\\
            2cf & -2f^2+1 & -2fi\\
            -2ci & 2fi & 2i^2-1
        \end{bmatrix}$\\
        \hline
        $\geq 0$ & $\leq 0$ & $\leq 0$ & $
        \begin{bmatrix}
            -2c^2+1 & 2cf & -2ci\\
            2cf & -2f^2+1 & 2fi\\
            2ci & -2fi & 2i^2-1
        \end{bmatrix}$
        \\
        \hline
        $\leq 0$ & $\geq 0$ & $\geq 0$ & 
        $\begin{bmatrix}
            -2c^2+1 & 2cf & -2ci\\
            2cf & -2f^2+1 & 2fi\\
            2ci & -2fi & 2i^2-1
        \end{bmatrix}$\\
        \hline
        $\leq 0$ & $\geq 0$ & $\leq 0$ & 
        $\begin{bmatrix}
            -2c^2+1 & 2cf & 2ci\\
            2cf & -2f^2+1 & -2fi\\
            -2ci & 2fi & 2i^2-1
        \end{bmatrix}$
        \\
        \hline
        $\leq 0$ & $\leq 0$ & $\geq 0$ & 
        $\begin{bmatrix}
            -2c^2+1 & -2cf & -2ci\\
            -2cf & -2f^2+1 & -2fi\\
            2ci & 2fi & 2i^2-1
        \end{bmatrix}$
        \\
        \hline
        $\leq 0$ & $\leq 0$ & $\leq 0$ & 
        $\begin{bmatrix}
            -2c^2+1 & -2cf & 2ci\\
            -2cf & -2f^2+1 & 2fi\\
            -2ci & -2fi & 2i^2-1
        \end{bmatrix}$
        \\
        \hline
    \end{tabular}}
    \caption{All the matrcies which yield from casework on $c,f,i = \pm \sqrt{c^2}, \pm \sqrt{f^2}, \pm \sqrt{i^2}$.}
    \label{fig:my_label}
\end{figure}
\end{document}
| improve this answer | |
3

The tool of choice for vertical padding in tabular is cellspace, which defines a minimal padding in cells of columns with specifier prefixed with the letter S (or C if you load siunitx, which defines an S column type).

I also propose a different layout, with only horizontal rules from booktabs, and the use of the measuredfigure environment from threeparttable. Also, a a code simplification with the use of array in the place of tabular, and a fine suggestion from @BarbaraBeeton for ‘normalising‘ the square roots in the caption:

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

\begin{document}

\begin{figure}[!ht]
 \centering
    \begin{measuredfigure}%[h!]

    $ \begin{array}{ccc!{\quad}Sc}
        \toprule
        \text{sign of } c & f & i & \text{Resulting Matrix}\\
        \midrule
 \geq 0 & \geq 0 & \geq 0 &
 $ \begin{bmatrix}
 -2c^2+1 & -2cf & 2ci \\
 -2cf & -2f^2+1 & 2fi \\
 -2ci & -2fi & 2i^2-1
 \end{bmatrix} $\\
 \cmidrule(r){1-3}
   \geq 0 & \geq 0 & \leq 0 &
 $ \begin{bmatrix}
 -2c^2+1 & -2cf & -2ci\\
 -2cf & -2f^2+1 & -2fi\\
 2ci & 2fi & 2i^2-1
 \end{bmatrix} $ \\
 \cmidrule(r){1-3}
 \geq 0 & \leq 0 & \geq 0 &
 $ \begin{bmatrix}
 -2c^2+1 & 2cf & 2ci\\
 2cf & -2f^2+1 & -2fi\\
 -2ci & 2fi & 2i^2-1
 \end{bmatrix} $ \\
 \cmidrule(r){1-3}
 \geq 0 & \leq 0 & \leq 0 &
 $ \begin{bmatrix}
 -2c^2+1 & 2cf & -2ci\\
 2cf & -2f^2+1 & 2fi\\
 2ci & -2fi & 2i^2-1
 \end{bmatrix} $ \\
 \cmidrule(r){1-3}
 \leq 0 & \geq 0 & \geq 0 &
$ \begin{bmatrix}
 -2c^2+1 & 2cf & -2ci\\
 2cf & -2f^2+1 & 2fi\\
 2ci & -2fi & 2i^2-1
 \end{bmatrix} $ \\
 \cmidrule(r){1-3}
 \leq 0 & \geq 0 & \leq 0 &
$ \begin{bmatrix}
 -2c^2+1 & 2cf & 2ci\\
 2cf & -2f^2+1 & -2fi\\
 -2ci & 2fi & 2i^2-1
 \end{bmatrix} $ \\
 \cmidrule(r){1-3}
 \leq 0 & \leq 0 & \geq 0 &
 $ \begin{bmatrix}
 -2c^2+1 & -2cf & -2ci\\
 -2cf & -2f^2+1 & -2fi\\
 2ci & 2fi & 2i^2-1
 \end{bmatrix} $ \\
 \cmidrule(r){1-3}
 \leq 0 & \leq 0 & \leq 0 &
$ \begin{bmatrix}
 -2c^2+1 & -2cf & 2ci\\
 -2cf & -2f^2+1 & 2fi\\
 -2ci & -2fi & 2i^2-1
 \end{bmatrix} $\\
 \bottomrule
    \end{array} $
  \caption{All the matrices which yield from casework on $c,f,i = \pm \sqrt{c^2}, \pm \sqrt{\smash[b]{f^2}}, \pm \sqrt{i^2}$.}
 \label{fig:my_label}
\end{measuredfigure}
\end{figure}

\end{document} 

enter image description here

| improve this answer | |
  • Very kind Bernard improved the whole MWE: there is a part out of {} – Sebastiano Jun 2 at 20:56
  • 1
    Thank you for warning me, @Sebastiano! – Bernard Jun 2 at 20:58
  • Looks nice. Now, it might be nice to "normalize" the radicals in the caption. Either smashing the bottom of the f or adding \mathstrut to the other two would do it. – barbara beeton Jun 2 at 21:12
  • @barbarabeeton: Excellent suggestion! What do you think, semantically, of ‘compressing’ the three square roots, under a single symbol (I mean something like \sqrt{c^2, \smash[b]{f^2}, i^2})? – Bernard Jun 2 at 21:19
  • I'm not sure enough mathematically that compressing them is equivalent. I'm inclined to be conservative and leave them separate. – barbara beeton Jun 2 at 21:31

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.