4

Both of these seem like a valid tabular definition:

\begin{tabular}{ll}
    a & A \\
    b & B
\end{tabular} 

\begin{tabular}{ll}
    a & A \\
    b & B \\
\end{tabular} 

The only difference is the line break \\ after the last row. What is the recommended way? Should I leave out the last line break or should I always finish with a line break.

  • 1
    Imho: leave it out as it gives inconsistent spacing. – Skillmon Nov 11 '17 at 18:25
  • Try to put a bottom horizontal line in the first table. – Fran Nov 11 '17 at 18:39
  • 1
    @Skillmon no, it gives identical results – David Carlisle Nov 11 '17 at 18:50
  • 3
    @Skillmon are you thinking about amsmath? align and friends don't like a final \\ – David Carlisle Nov 11 '17 at 20:09
  • 2
    @TimHoffmann yes I'm afraid so, generally you can make \\ optional (as TeX has a \crcr primitive that is a conditional \cr for exactly this use) but some environments, align, blockarray, ... try to pre-process rows in various ways so the rules vary – David Carlisle Nov 11 '17 at 20:30
10

By design these give identical output, generally I leave off the \\ unless there is a final \hline (when it is required) but it really doesn't matter.

0

I would prefer your second version:

\begin{tabular}{ll}
    a & A \\
    b & B \\
\end{tabular} 

Not because of the rendered result but because of ease of future editing. Some day you may want to add another row to the table like this:

\begin{tabular}{ll}
    a & A \\
    b & B \\
    c & C \\
\end{tabular} 

Here it was enough to simply add another line. Had the last line not ended with \\, I would have had to first add \\ and then add another line. However when the last line ends with \\, I could simply copy the last line and change the b's to c's. The same would apply if you'd want to reorder the rows.

This also makes it easier to read diffs between versions if you are keeping any sort of revision history.

I haven't found any context where the rendering is any different with or without the final \\.

  • 1
    A trailing \\ is definitely out of place in align, alignat and gather. – egreg Nov 19 '17 at 17:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.