# Bad vertical alignment in latex \tabular

I've got a little question about my tabular vertical aligment. I've a two-column tabular with letter and text :

\begin{tabular}{p{0.1\textwidth} p{0.8\textwidth} }

Hypothèse   &   Description\\
\hline


But in my pdf file, the first and second column is not aligned. I tried to align everything to the top, to insert space with \\[1ex], but nothing seems to work!

In fact, the problem seems to come from the counter I use to enumerate the letters :

\newcounter{hypothese}
\renewcommand\thehypothese{\Alph{hypothese}}
\newcommand{\newhypothese}[1]{\refstepcounter{hypothese}\label{#1} \ref{#1}}

\footnotesize

\begin{tabular}{p{0.1\textwidth} p{0.8\textwidth} }

Hypothèse   &   Description\\
\hline
\hspace{1pc}&\

\multicolumn{2}{p{\textwidth}}{\textbf{Multimodalité}} \\
A & Bla bla Bla blaBla blaBla blaBla blaBla blaBla blaBla blaBla blaBla blaBla bla Bla bla Bla bla\\
B &Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla \\
C& Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla  \\
D& Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla \\
% Upon here, everything looks right... below here, first column are not aligned right.
\newhypothese{hypo:cla_ver} &Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla \\
\newhypothese{hypo:com_acc_recoup} & Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla \\
\newhypothese{hypo:reg_negoc} & Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla \\
\newhypothese{hypo:reg_croise} & LBla bla Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla \\
\newhypothese{hypo:gest_reg_part} & Bla bla Bla bla Bla bla \\
\newhypothese{hypo:gest_verba} & Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla \\
\newhypothese{hypo:trace_graph_verba} & Bla bla Bla bla Bla bla \


But I don't know how to fix it

• meta.tex.stackexchange.com/questions/1436/welcome-to-tex-sx. Can you provide a complete MWE. – cacamailg May 6 '13 at 17:48
• @cacamailg : Here's part of my code that mess things up : pastebin.com/6hzpwNhv – Loic Coenen May 6 '13 at 17:56
• It would be better if you build a MWE herein, for us to test your code. Nevertheless, why are you using \hspace{1pc} after the tabular. – cacamailg May 6 '13 at 18:02
• Also you are using a multicolumn of \textwidth after you have defined two columns, one of 0.1\textwidth and other of 0.8\textwidth. Which is not a good practice. – cacamailg May 6 '13 at 18:07
• I used it \hspace to add vertical space below my \hline. – Loic Coenen May 6 '13 at 18:28

You can profit from the tabularx package, so you don't have to fiddle with the subtle points of the interaction between issuing \label and printing \thehypothese

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[french]{babel}
\usepackage{tabularx,booktabs}

\newcounter{hypothese}
\renewcommand\thehypothese{\Alph{hypothese}}
\newcommand{\newhypothese}[1]{%
\refstepcounter{hypothese}\label{#1}\thehypothese}

\begin{document}

\noindent
\begin{tabularx}{\textwidth}{lX}
Hypothèse   &   Description\\
\midrule
\multicolumn{2}{l}{\textbf{Multimodalité}} \\
\newhypothese{hypo:cla_ver} &New hypothese: Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla \\
\newhypothese{hypo:com_acc_recoup} & Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla \\
\newhypothese{hypo:reg_negoc} & Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla \\
\newhypothese{hypo:reg_croise} & LBla bla Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla \\
\newhypothese{hypo:gest_reg_part} & Bla bla Bla bla Bla bla \\
\newhypothese{hypo:gest_verba} & Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla \\
\newhypothese{hypo:trace_graph_verba} & Bla bla Bla bla Bla bla \\
\end{tabularx}

\end{document}


The problem seems to come from this command not starting with any printing material. In particular, \label uses internal commands \@bsphack and \@espack which successfully gobble the correct number of spaces before and after when the command is in ordinary text, i.e. horizontal mode, but which do not necessarily do the right thing in between paragraphs, i.e. in vertical mode. (See source2e pages 52--53 for a discussion of possible modifications of these commands.) In many situtations, including your case, you can fix this simply by forcing horizontal mode via \leavevmode:

\documentclass{article}

\begin{document}
\newcounter{hypothese}
\renewcommand\thehypothese{\Alph{hypothese}}
\newcommand{\newhypothese}[1]{\leavevmode\refstepcounter{hypothese}\label{#1}\ref{#1}}

\begin{tabular}{p{0.1\textwidth} p{0.8\textwidth} }
Hypothèse   &   Description\\
\hline
\hspace{1pc}&\\
\multicolumn{2}{p{\textwidth}}{\textbf{Multimodalité}} \\
A &Ordinary label: Bla bla Bla blaBla blaBla blaBla blaBla blaBla blaBla blaBla blaBla blaBla bla Bla bla Bla bla\\
B &Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla \\
\newhypothese{hypo:cla_ver} &New hypothese: Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla \\
\newhypothese{hypo:com_acc_recoup} & Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla \\
\newhypothese{hypo:reg_negoc} & Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla \\
\newhypothese{hypo:reg_croise} & LBla bla Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla \\
\newhypothese{hypo:gest_reg_part} & Bla bla Bla bla Bla bla \\
\newhypothese{hypo:gest_verba} & Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla Bla bla \\
\newhypothese{hypo:trace_graph_verba} & Bla bla Bla bla Bla bla \\
\end{tabular}
\end{document}

• Thanks for the answers. The solution I found below seems to work for now, but i'll look at yours if it turns out it doesn't. – Loic Coenen May 6 '13 at 23:37

I found the solution. By juste replacing

\newcommand{\newhypothese}[1]{\refstepcounter{hypothese}\label{#1} \ref{#1}}


by

\newcommand{\newhypothese}[1]{\refstepcounter{hypothese}\thehypothese\label{#1}}


It looks perfect... I don't know why. Thanks anyway

• That doesn't work, as your labels are no longer defined, and your label is now doubled. Deleting the .aux file and compiling again will give you problems... – Andrew Swann May 6 '13 at 19:37
• Oh, sorry, my bad... I replaced the line by \newcommand{\newhypothese}[1]{\refstepcounter{hypothese}\thehypothese \label{#1}} – Loic Coenen May 6 '13 at 23:35
• OK - I have updated my answer accordingly with some explanation. Your rewriting introduces printed material before the \label so the \label command is now in horizontal mode. – Andrew Swann May 7 '13 at 7:00