0

I've created a table and I want the text to be centered and aligned vertically in the middle so I used this code

\documentclass[a4paper]{article}

\usepackage[french]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{array}
    \begin{document}

    \begin{tabular}{|>{\centering}m{1in}|>{\centering}m{0.3in}|>{\centering}m{0.3in}|}
    \hline
    \textbf{Phase de propulsion}&\textbf{$\phi$}&\textbf{$\Delta h$}\tabularnewline \hline
    Avant 'tumble'&-14& \tabularnewline \cline{2-3}
     &-6& \tabularnewline \cline{2-3}
     &-7& \tabularnewline \cline{2-3}
     &*& \tabularnewline \cline{2-3}
     &*& \tabularnewline \cline{2-3}
     &*& \\ \cline{2-3}
     &-20& \\ \cline{2-3}
     &-11& \\ \cline{2-3}
     &-26& \\ \cline{2-3}
     &-41& \\ \cline{2-3}
     &-22& \\ \cline{2-3}
     &-34& \\ \cline{2-3}
     &*& \\ \hline
    Après 'tumble'& & \\ \cline{2-3}
     &-11& \\ \cline{2-3}
     &*&\\ \cline{2-3}
     &31& \\ \cline{2-3}
     &-8& \\ \cline{2-3}
     &17& \\ \cline{2-3}
     &4& \\ \cline{2-3}
     &*& \\ \cline{2-3}
     &*& \\ \cline{2-3}
     &-37& \\ \cline{2-3}
     &20& \\ \cline{2-3}
     &*& \\ \cline{2-3}
     &9& \\ \cline{2-3}
     &-10& \\ \cline{2-3}
     & & \\ \hline
    \end{tabular}
    \end{document}

My problem is except for the first line, all of my numbers seem to be stick to the top of the box. Help me, please :D

enter image description here

16
  • Do you have a redefinition of \arraystretch somewhere in your document?
    – Werner
    Jun 19, 2014 at 14:22
  • @Werner no, sorry, I actually don't know what's that
    – pomxipum
    Jun 19, 2014 at 14:23
  • Welcome to TeX.SE. While code snippets are useful in explanations, it is always best to compose a fully compilable MWE that illustrates the problem including the \documentclass and the appropriate packages so that those trying to help don't have to recreate it. Jun 19, 2014 at 14:41
  • sorry, added the packages i used
    – pomxipum
    Jun 19, 2014 at 14:52
  • not necessarily relevant to the question, but those aren't real minus signs on the negative values in the second column of the table. Jun 19, 2014 at 15:22

1 Answer 1

2

The vertical centering in the cells gets much better with help of the package booktabs. If you really need that many horizontal lines, you may uncomment the line commands after each line.

If you want the text in the first column vertically centered, please rephrase your question. This wasn't that clear.

The minus sign for numbers has to be typeset using $-14$. However, it is easier to use the S column of the package siunitx. Please adapt the [table-format=...] to your needs. The biggest number in each column tells you the format. E.g. -12,345 yields [table-format=-2.3].

% arara: pdflatex

\documentclass[a4paper]{article}
\usepackage[french]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{mathtools}
\usepackage{booktabs}
\usepackage[locale=FR]{siunitx}
\usepackage[style=french,french=quotes]{csquotes}

\begin{document}
\begin{tabular}{cS[table-format=-2.0]S[table-format=-2.3]}
\toprule
\textbf{Phase de propulsion}&{$\phi$}&{$\Delta h$}\\ \midrule
Avant \enquote*{tumble} & -14 & -12.345\\% \cmidrule{2-3}
&-6&\\  %\cmidrule{2-3}
&-7& \\ %\cmidrule{2-3}
&*& \\ %\cmidrule{2-3}
&*& \\ %\cmidrule{2-3}
&*& \\ %\cmidrule{2-3}
&-20& \\ %\cmidrule{2-3}
&-11& \\ %\cmidrule{2-3}
&-26& \\ %\cmidrule{2-3}
&-41& \\ %\cmidrule{2-3}
&-22& \\ %\cmidrule{2-3}
&-34& \\ %\cmidrule{2-3}
&*& \\ \midrule
Après \enquote*{tumble}& & \\ %\cmidrule{2-3}
&-11& \\ %\cmidrule{2-3}
&*&\\ %\cmidrule{2-3}
&31& \\ %\cmidrule{2-3}
&-8& \\ %\cmidrule{2-3}
&17& \\ %\cmidrule{2-3}
&4& \\ %\cmidrule{2-3}
&*& \\ %\cmidrule{2-3}
&*& \\ %\cmidrule{2-3}
&-37& \\ %\cmidrule{2-3}
&20& \\ %\cmidrule{2-3}
&*& \\ %\cmidrule{2-3}
&9& \\ %\cmidrule{2-3}
&-10& \\ %\cmidrule{2-3}
& & \\
\bottomrule
\end{tabular}
\end{document}

enter image description here

You must log in to answer this question.

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