I'm trying to create a new environment for longtable
enclosed by a filecontents
environment. But I'm stuck and don't know exactly how to solve my problem.
\documentclass[a4paper,parskip]{scrartcl}
\usepackage{polyglossia}
\usepackage{longtable, ltxtable, filecontents, colortbl}
\newenvironment{tbl}{%
\begin{filecontents}{\jobname-ltxtable.tex}%
\begin{longtable}{|p{2cm}|p{2cm}|p{2cm}|p{2cm}|}%
\hline\rowcolor[gray]{.8}%
Column 1 & Column 2 & Column 3 & Column 4\\\hline%
\endhead%
}{%
%\caption{#1} %
\end{longtable}%
\end{filecontents}%
\LTXtable{\textwidth}{\jobname-ltxtable.tex}%
}
\begin{document}
\begin{tbl}
1 & 2 & 3 & 4 \\\hline
1 & 2 & 3 & 4 \\\hline
1 & 2 & 3 & 4 \\\hline
\end{tbl}
\end{document}
I found out that using filecontents
inside a macro leads to problems but I need something like filecontents
to write out the longtable. The table shall later consist X
columns. I reduced all the complexity to generate a minimal (non-working) example.
I hope someone can help me with this.
Thx + Bye!