1

I'm trying to use a longtabu environment as a replacement for a tabularx environment that I was using. When I try to compile this example, I get the error:

! LaTeX Error: There's no line here to end.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.26       \end{steplist}

The example that I'm trying to compile:

\documentclass{article}
\usepackage{tabu}
\usepackage{longtable}

\newcounter{StepListCounter}
\newenvironment{steplist} {
    \renewcommand\item[2]{%
        \\[\medskipamount]
        \noindent
        \stepcounter{StepListCounter}
        {\textbf{\arabic{StepListCounter}}} & ##1 & &
        \parbox[c]{1em}{##2} \\
    }

    \setcounter{StepListCounter}{0}
    \longtabu to \linewidth {l X c X}
    %\tabularx{\linewidth}{l X c X}
} {
    \endlongtabu
    %\endtabularx
    \\[\medskipamount]
}

\begin{document}
  \begin{steplist}
  \end{steplist}
\end{document}

What am I doing wrong here? When I swap tabu in for longtabu, it works perfect.

  • Why \renewcommand{\item}? – user31729 Mar 3 '15 at 23:11
  • @SoundsOfSilence the OP wants a list-like markup with a table based implementation – David Carlisle Mar 3 '15 at 23:38
2

tabularx is a horizontal mode construct so you can have \\after it but longtable is a vertical mode construct so you can not follow it by \\.

\documentclass{article}
\usepackage{tabu}
\usepackage{longtable}

\newcounter{StepListCounter}
\newenvironment{steplist} {
    \renewcommand\item[2]{%
        \\[\medskipamount]
        \noindent
        \stepcounter{StepListCounter}
        {\textbf{\arabic{StepListCounter}}} & ##1 & &
        \parbox[c]{1em}{##2} \\
    }

    \setcounter{StepListCounter}{0}
    \longtabu to \linewidth {l X c X}
    %\tabularx{\linewidth}{l X c X}
} {
    \endlongtabu
    %\endtabularx
    \medskip
}

\begin{document}
  \begin{steplist}
  \end{steplist}
\end{document}

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.