0

I'm trying to write a custom environment, but I keep running into a strange error..

This is my setup

\documentclass{article}

\usepackage{environ}
\usepackage{longtable}
\usepackage[utf8]{inputenc}
\usepackage{fancyhdr}
\usepackage{advdate}
\usepackage{varwidth}

\environbodyname\scenarioBODY
\NewEnviron{scenario}
{
  \renewcommand{\tabcolsep}{0.8ex}
    \setlength\LTleft{0pt}
    \setlength\LTright{0pt}
    \longtable{@{\extracolsep{\fill}}ll@{}}
    \hline
    {\bf Scenario name} & \multicolumn{1}{l}{Some scenario} \\
    \hline
    \endhead 

    body & \scenarioBODY \\

    {\bf Total} & {\bf 100 DKK} \\
    \hline
    \endlongtable
}

It works with

\begin{document}
    \begin{scenario}
        Some body
    \end{scenario}
\end{document}

but not with

\begin{document}
    \begin{scenario}
        \begin{enumerate}
            \item Some body
        \end{enumerate}
    \end{scenario}
\end{document}

What am I doing wrong?

  • \longtable{@{\extracolsep{\fill}}lp{3cm}@{}} rather then \longtable{@{\extracolsep{\fill}}ll@{}} – Salim Bou Sep 10 '16 at 17:18
  • Thanks; that worked. But why? – cholewa1992 Sep 10 '16 at 17:33
  • Don't use l column type to insert paragraph or list, instead you can use p{<width>} tables-wiki – Salim Bou Sep 10 '16 at 17:54
  • @cholewa1992 - Use \bseries intead of \bf, those old commands will cause errors, depending of the documentclass. Read the manual of the array package to learn about different kinds of columns (texdoc array) on the command line. The l-type throws an error, if there is a \par in the content, the p-type not. The enumerate env. and such end an item with a paragraph. – Keks Dose Sep 12 '16 at 11:59
  • Thanks @KeksDose. I managed to solve the problem; it was as you say due to the use of l-type instead of p-types. But also the latex compiler made i really hard to figure out that that was the error ;-) – cholewa1992 Sep 13 '16 at 17:45
2

From the comments: You can't insert paragraphs or lists in l columns. Use a p column instead, e.g.

\longtable{@{\extracolsep{\fill}}lp{3cm}@{}}

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.