0

When creating a long table in my document, I add the automatic row number for each row. However, when I add the label for my table, it shows a blank row with the automatic row number, like this.

label row number

Here is the minimal example code:

\documentclass{article}

\usepackage{tabu,longtable}
\newcounter{rowno}

\begin{document}
    \begin{longtabu} {|c<{\stepcounter{rowno}\therowno}|X|X|X|}
        \caption{testtable} \\ 
        \hline
        \multicolumn{1}{|c|}{No.} & \multicolumn{1}{c|}{rule} & \multicolumn{1}{c|}{example} & \multicolumn{1}{c|}{src} \\ \hline
         & content & content2 & content3 \\ \hline
        \label{table:test} \\
    \end{longtabu}
\end{document}

It's really strange. Why does it add the auto rowno to the label row? And more incomprehensible to me, why would the label count as a row?

5
  • @ChristianHupfer Sorry. But I really don't think you have read my code carefully. The answer below has solved my problem.
    – PiggyZhu
    Mar 4, 2017 at 11:22
  • Well, your question was not really well stated, in my point of view
    – user31729
    Mar 4, 2017 at 11:23
  • @ChristianHupfer Maybe, but I've got the answer needed from another one.
    – PiggyZhu
    Mar 4, 2017 at 11:24
  • The [labels] tag is not meant for \label issues. You mean cross-referencing
    – user31729
    Mar 4, 2017 at 12:05
  • @ChristianHupfer I accepted the editing advice after checking the introduction of the tags. But I don't think it's quite polite to simply delete the tag (which is not appropriate as now you replace the tag instead of deleting it) without telling me and leave the comment that you have deleted, especially when some other guy have clearly caught my problem and solved it. To show your expertise is easy but to help others is difficult.
    – PiggyZhu
    Mar 4, 2017 at 12:19

1 Answer 1

1

If you put your \label{} after your caption (where it really ought to be), then the additional row disapears:

\documentclass{article}

\usepackage{tabu,longtable}
\newcounter{rowno}

\begin{document}
    \begin{longtabu} {|c<{\stepcounter{rowno}\therowno}|X|X|X|}
        \caption{testtable}\label{table:test} \\ 
        \hline
        \multicolumn{1}{|c|}{No.} & \multicolumn{1}{c|}{rule} & \multicolumn{1}{c|}{example} & \multicolumn{1}{c|}{src} \\ \hline
         & content & content2 & content3 \\ \hline
    \end{longtabu}
\end{document}
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .