1

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".

JuanPi
  • 273

1 Answers1

2

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} 
David Carlisle
  • 757,742
yo'
  • 51,322