1

I have the following code:

\begin{table}[h]
\begin{tabularx}{\textwidth}{ m{4cm}  X }
                            & Derivations \\
    $v=v_0+at$              & test \newline test \newline test \\
    $x=x_0+v_0t+½at^2$      & a\\
    $v^2-v_0^2=2a(x-x_0)$   & a\\
    $x-x_0=½t(v_0-v)$       & a  
\end{tabularx}
\end{table}

The m{4cm} will make a 4cm wide column with vertically centered content according to this answer to another question. I have added the array package. But no vertical centering happens; the result is:

enter image description here

How can I make the content in the left column (which consists of $..$ equations) vertically align to the center.

  • 1
    your image shows that the vertical centring specified by m is happening. It makes the reference point of the first column its vertical centre rather than its baseline, and that reference point aligns with the reference point of the second column which is the baseline of its top row. – David Carlisle May 1 '15 at 16:02
1

The code with the makecell package, is very simple: it allows for line breaks in the \makecell and \thead commands. Note the default alignment is vertically and horizontally aligned.

\documentclass{article}
\usepackage{tabularx}
\usepackage{makecell}
\renewcommand\cellalign{lc}

\begin{document}

\begin{table}[h]
  \begin{tabularx}{\linewidth}{ m{4cm} X}
                          & Derivations \\
    $v=v_0+at$ & \makecell{test \\ test \\ test }\\
    $x=x_0+v_0t+½at^2$ & a \\
    $v^2-v_0^2=2a(x-x_0)$ & a \\
    $x-x_0=½t(v_0-v)$ & a \\
  \end{tabularx}
\end{table}

\end{document} 

enter image description here

2

I wouldn't use \newline the way you did to create the larger cell to center in. I'd use three separate rows with multirow:

\documentclass{article}
\usepackage{tabularx}
\usepackage{multirow}
\begin{document}
\begin{table}[h]
\begin{tabularx}{\textwidth}{ m{4cm}  X }
                                  & Derivations \\
    \multirow{3}{4cm}{$v=v_0+at$} & test \\
                                  & test \\
                                  & test \\
    $x=x_0+v_0t+½at^2$            & a \\
    $v^2-v_0^2=2a(x-x_0)$         & a \\
    $x-x_0=½t(v_0-v)$             & a \\
\end{tabularx}
\end{table}
\end{document}

which gives:

multirowResult

and means you don't necessarily need m{4cm} but you can keep that if you want your other content vertically centered in their cells.

In the future, please post your preamble with your MWE : ).

-1

One solution is to use \hfil to both sides of the equation

\documentclass{article}
\usepackage{tabularx}
\begin{document}
\begin{table}[h]
\begin{tabularx}{\textwidth}{ m{4cm}  X }
                        & Derivations \\
\hfil$v=v_0+at$\hfil             & test \newline test \newline test \\
\hfil$x=x_0+v_0t+½at^2$\hfil     & a\\
\hfil$v^2-v_0^2=2a(x-x_0)$\hfil  & a\\
\hfil$x-x_0=½t(v_0-v)$\hfil     & a  
\end{tabularx}
\end{table}
\end{document}

enter image description here

  • doesn't that give horizontal centering? the op asks for vertical centering. – aeroNotAuto May 1 '15 at 15:51

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.