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?

  • 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? – David Carlisle Jun 3 '18 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 '18 at 23:47
  • I wouldn't use tabularx for such invoices. It doesn't allow pagebreaks. – Ulrike Fischer Jun 4 '18 at 7:53
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
}

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.