I defined a new environment for some custom tables (to not have to repeat the header and column definitions etc. again and again).
\newenvironment{mytable}{
\noindent\tabularx{\textwidth}{|c|c|X|}
\hline
\bf Col 1 & \bf Col 2 & \bf Col 3 \\
\hline
}{%
\endtabularx
}
It's based on tabularx (for the variable size X
column) and should be able to span multiple pages. There's the package ltablex
which can do this for a tabularx environment. (See the tabularx
in my example below, you can comment out the mytable
).
However, I am receiving the error:
! LaTeX Error: \begin{mytable} on input line 26 ended by \end{tabularx}.
I assume this comes from the redefinition of \TX@endtabularx
in ltablex.sty
where it has the following code snippet:
\ifnum0=`{\fi}%
\end{tabularx}
Is it possible to use a "longtable tabularx" as a new environment?
Example to try out:
\documentclass{article}
% filling table with for, relentlessy copied from
% http://tex.stackexchange.com/a/183756/51583
% extremely shortened, see address for more explanations
\def\addto#1#2{\expandafter\def\expandafter#1\expandafter{#1#2}}\def\tabledata{}
\newcount\n\n=1\loop\advance\n by1\addto\tabledata{Lorem&Ipsum&XCell\\}
\ifnum\n<100\repeat
% package and new environment
\usepackage{ltablex}
\newenvironment{mytable}{%
\noindent\tabularx{\textwidth}{|c|c|X|}
\hline
\bf Col 1 & \bf Col 2 & \bf Col 3 \\
\hline
}{%
\endtabularx
}
\begin{document}
% working tabularx
\begin{tabularx}{\textwidth}{|c|c|X|}
\tabledata
\end{tabularx}
% not working mytable
\begin{mytable}
\tabledata
\hline
\end{mytable}
\end{document}