# Prevent empty line after tabular environment

I have a question related to Empty line after a tabular environment.

I have a document using package lineno to enumerate lines. The rendered document enumerates a line exactly after any tabular environment. Is there an empty line after the tabular environment? If there is one, how can I erase it?

Example:

\documentclass[10pt,english,final,a4paper]{book}
\usepackage{lineno} % Line numbers

\begin{document}
\linenumbers
1st Para: Bablabla...
\begin{table}[htpb]
\begin{flushleft}
\begin{tabular}{|l|c|c|}
\hline
Mass & $m_1$ & 2.18 \\
Length & $l_1$ & 0.335\\
Center of mass (fraction of length) & $f_1$ & 0.39\\
Joint limits (relative angles) & elbow, shoulder & $[-7,100]$, $[0,160]$\\
\hline
\end{tabular}
\caption{\label{tab:} Parameters.}
\end{flushleft}
\end{table}

2nd Para: blablabla
\end{document}


The rendered document shows a 2 after the table. Erasing the new line in the second paragraph does not solve the "problem".

• Can you please add to your question a minimal working example illustrating the problem? – Gonzalo Medina Mar 27 '12 at 14:49
• Adding an empty line above the table between Bablabla... and \begin{table} should solve it. – cgnieder Mar 27 '12 at 15:06
• Leave an empty line before \begin{table} – egreg Mar 27 '12 at 15:09

To remove the empty line, go without flushleft environment and use \raggedright.

To correct the line number placement:

• either put an empty line before \begin{table};
• or remove the [h] specifier from the table.

Without one of these changes, the paragraph breaking algorithm (and whence the line numbering algorithm) for the first paragraph is run after the table is typeset. And when the table is placed "here", the line number shows below the table, which is incorrect.

Remark: Try to avoid [h] specifier, it is considered incorrect from the typographical point of view (it usually doesn't look well in the final document).

Corrected MWE:

\documentclass[10pt,english,final,a4paper]{book}
\usepackage{lineno} % Line numbers

\begin{document}
\linenumbers
1st Para: Bablabla...

\begin{table}[tpb]
\raggedright
\begin{tabular}{|l|c|c|}
\hline
Mass & $m_1$ & 2.18 \\
Length & $l_1$ & 0.335\\
Center of mass (fraction of length) & $f_1$ & 0.39\\
Joint limits (relative angles) & elbow, shoulder & $[-7,100]$, $[0,160]$\\
\hline
\end{tabular}
\caption{\label{tab:} Parameters.}
\end{table}

2nd Para: blablabla
\end{document}

• I wouldn't place the \label inside the \caption in the “corrected MWE” :) – cgnieder Mar 27 '12 at 17:38
• @cgnieder Why not? It's not a bad practice. See Label in caption. – Alan Munn Mar 27 '12 at 17:44
• @AlanMunn Damn! Learned something new again... ;) Seriously: I didn't know that. – cgnieder Mar 27 '12 at 17:53
• @cgnieder IMHO it's just a matter of habit, some people do it, some don't. Me personally, I usually put \caption as the before-last line of float and \label as a last line of float. However, I didn't want to modify what need not to be. – yo' Mar 27 '12 at 17:53
• I always believed it to be bad practice but apparently I was wrong... – cgnieder Mar 27 '12 at 17:56