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?

6
  • \longtable{@{\extracolsep{\fill}}lp{3cm}@{}} rather then \longtable{@{\extracolsep{\fill}}ll@{}}
    – Salim Bou
    Commented Sep 10, 2016 at 17:18
  • Thanks; that worked. But why? Commented Sep 10, 2016 at 17:33
  • Don't use l column type to insert paragraph or list, instead you can use p{<width>} tables-wiki
    – Salim Bou
    Commented Sep 10, 2016 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
    Commented Sep 12, 2016 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 ;-) Commented Sep 13, 2016 at 17:45

1 Answer 1

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}@{}}

You must log in to answer this question.

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