0

so I am writing my own LaTex class so that I can use it to automatically generate invoices with information provided from the user. As such, I have encountered an issue with tabularx and new environments and I am looking for a way around the issue that it presents. If one defines a new environment as such:

\newenvironment{test}[1]
{
    #1\\
    \begin{tabularx}{\textwidth}{X r}
}
{
    \end{tabularx}
}

The parser complains about reading past EOF or something similar, however; if I were to use tabular or tabular* the parser allows this, and one is allowed to add entries to the table as normal. Is there a way around this, if not, is there a way to get a dynamic column that can fill up a size so that the table takes up for example \textwidth amount of horizontal space?

3
  • see the tabularx documentation, you need to use \tabularx not \begin{tabularx} but I can't think of any cases when you would want \\ before a table? Jun 3, 2018 at 23:45
  • I mean.. the \\ is just there so that it doesn't seem like I am just making an environment of an existing environment
    – Ohunter
    Jun 3, 2018 at 23:47
  • I wouldn't use tabularx for such invoices. It doesn't allow pagebreaks. Jun 4, 2018 at 7:53

1 Answer 1

3

As it states in the package documentation, you need the \tabularx form in an environment definition.

\newenvironment{test}[1]
{%%
    #1%%

    \noindent\tabularx{\textwidth}{X r}%%
}
{%%
    \endtabularx
}

You must log in to answer this question.

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