1

This question already has an answer here:

I want to make an environment for my tables. See the following example:

\documentclass[a4paper,10pt]{scrartcl}

\usepackage{longtable}
\usepackage{booktabs}           % \toprule, \bottomrule
\usepackage{tabu}

\begin{document}

  \newenvironment{kpTable}
  {
    \begin{longtabu}{X[1,c] X[1,c]}
        \toprule \rowfont{\bfseries}
        Foo & Bar\\
        \midrule
        \everyrow{\tabucline[on 3 pt off 3pt]-}
  }
  {
        \everyrow{}\\
        \bottomrule
        \caption{}  % ERROR: Missing number, treated as zero.
    \end{longtabu}
  }

  \begin{kpTable}
    1 & 2 \\
    1 & 2 \\
    1 & 2
  \end{kpTable}

\end{document}

my table

The caption statement generates the error: "Missing number, treated as zero. \tabu@0.H6"

How can I fix?

marked as duplicate by egreg, Heiko Oberdiek, Guido, Christoph, Joseph Wright May 3 '14 at 21:12

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Try \bottomrule%. – Sigur May 3 '14 at 20:25
  • @Sigur, same error – sergej May 3 '14 at 20:27
1

Fixed it using the environ package:

\documentclass[a4paper,10pt]{scrartcl}

\usepackage{longtable}
\usepackage{booktabs}           % \toprule, \bottomrule
\usepackage{tabu}
\usepackage{environ}

\begin{document}

  \NewEnviron{kpTable}
  {
    \begin{longtabu}{X[1,c] X[1,c]}
        \toprule \rowfont{\bfseries}
        Foo & Bar\\
        \midrule
        \everyrow{\tabucline[on 3 pt off 3pt]-}
        \BODY
        \everyrow{}\\
        \bottomrule
        \caption{}
    \end{longtabu}
  }

  \begin{kpTable}
    1 & 2 \\
    1 & 2 \\
    1 & 2
  \end{kpTable}

\end{document}

As mentioned in Ch'en Meng's answer here

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