# \hline problem, get all kind of error

\begin{table}

\centering

\begin{tabular}{|l|l|}

\hline

Period & Expected yearly rate of return %\\

\hline

Renaissance & $6.1$\\\\

Neoclassicism & $5.0$\\\\

Romanticism & $4.1$\\\\

Modern art & $3.3$\\\\

Contemporary art & $2.4$

\hline

\end{tabular}

\end{table}


Hi guys, I have this entered in TeXstudio and I have a problem. I get the same error at every \hline I entered:

• misplaced no \align.
• you cant use \hrule here except with leaders
• Missing number treated as zero
• illegal unit of measure

I also get an error in the line with Renaissance & $6.15$\\, namely:

Extra alignment tab has been changed to \cr

I don't understand how to solve this.

Only first \hline can be without preceeded \\. Next \hlines need to be written as \\ \hline.

Edit: Sorry, my answer was only "LaTeX-like" answer to the LaTeX question. It means "do this and don't think about it". I try to improve this now. You can ask why there is the error message "Misplaced \noalign". The \hline macro is implemented by \noalign TeX primitive. This primitive enables to put a material between lines of the table and it can be used only after \cr. This is another primitve which ends the current line in the table or it ends the tab declaration data before the first line of the table. The \cr is equivalent with \\ in LaTeX tabular environment.

This is the reason, why I knew your problem without any trying or running LaTeX. The error message was sufficient for me. But the knowledge about such error messages cannot be found in LaTeX manuals. You need to know the TeX itself. This is the reason why LaTeX with TeX error messages is very inhospitable for LaTeX users.

What does mean the message "Extra alignment tab has been changed to \cr?" You are using & separator between columns but the number of such columns in the current line of table is greater than is allowed by tab declaration data. The \cr means the end of line in the table as mentioned above.

The other mentioned error messages are only spread errors.

• Thanks, that worked. However for some reason the table only shows at the top of the page, how do i get it down to where i am with the text? – Pim Dec 3 '14 at 17:04
• – LaRiFaRi Dec 3 '14 at 17:08
• "cannot be found in latex manuals"? I can only assume you have never looked? the standard latex2e reference is the latex companion which lists every error message issued by tex or commands in the latex format. In this case it says Misplaced \noalign The TEX primitive \noalign is internally used to place "nonaligned" material between rows of alignment displays. It is therefore allowed only directly following the command that finishes a row. For example, you get this error when you use \hline outside of array or tabular, or not directly after \\ within these environments. – David Carlisle Dec 3 '14 at 21:47
• @DavidCarlisle OK, you are right and I am wrong in this topic. My idea was that if somebody knows TeX then (s)he needn't such dictionaries because (s)he understand such error messages natively. And knowledge about TeX is missing in LaTeX manuals. LaTeX user needs to use the dictionary from LaTeX to TeX terminology: for example LaTeX command = TeX control sequence with meaning macro or with meaning character constant etc. We are witnesses of frequent misunderstanding of common error message "missing control sequence" because it is not in LaTeX terminology. – wipet Dec 4 '14 at 7:08

the immediate cause of the error is that % is the comment character in TeX so your line ending %\\ does not end with a typeset % it comments out the \\. Using \% fixes that. Then there is one row missing a \\. Fixing those two errors allows the document to run without error but the spacing is poor and the vertical lines are broken as the \\\\ construct puts an incomplete line every other row. Never use consecutive \\. To increase the row spacing, don't double \\ instead increase the \arraystretch parameter.

\documentclass{article}

\begin{document}
\begin{table}

\centering
\renewcommand\arraystretch{1.5}
\begin{tabular}{|l|l|}

\hline

Period & Expected yearly rate of return \%\\
\hline

Renaissance & $6.1$\\

Neoclassicism & $5.0$\\

Romanticism & $4.1$\\

Modern art & $3.3$\\

Contemporary art & $2.4$\\
\hline

\end{tabular}

\end{table}
\end{document}