I have a large document in which I use and reuse pieces of data. Such a piece of data consists of a number, a short and long description and a value. For example. I want to declare all those pieces of data in advance like this:
\begin{datasnippets}
\datasnippet{licenseplate}{A licenseplate}{A valid licenseplate for Belgium}{1BEL500}
\datasnippet{building}{An expensive house}{The address of a building costing more than 1 million}{1 Google Drive CA}
\end{datasnippets}
I then want this environment to (a) generate a table with all datasnippets, and (b) generate a set of commands which allow me to refer to the different parts of those snippets.
So, the above snippet followed by following sentence:
I found a license plate (\licenseplateValue ). The car was located at \buildingValue .
Will look like this.
Currently I implemented this as follows:
\newcounter{datasnippets}
\newcommand{\thedatasnippetcounter}{\arabic{datasnippets}}
\newenvironment{datasnippets}
{
\small\\
\hspace{-2cm}\begin{longtable}{p{0.4cm} p{4cm}p{3cm}p{10cm} }
\ & \textbf{Naam} & \textbf{Waarde} & \textbf{Beschrijving} \\
\ & \ & \ & \\
\hline
\newcommand{\datasnippet}[4]{%
\refstepcounter{datasnippets}
\label{data:##1}
\global\expandafter\def\csname ##1\endcsname{##2}
\global\expandafter\def\csname ##1Description\endcsname{##3}%
\global\expandafter\def\csname ##1Value\endcsname{##4}%
\global\expandafter\def\csname ##1Full\endcsname{##3 (waarde: ##4)}%
\hspace{-2cm}
\begin{tabular}{p{0.2cm}p{4cm}p{3cm}p{10cm} }
\thedatasnippetcounter . & ##2 & ##4 & ##3 \\
\ & \ & \ & \\
\end{tabular}
}
}
{
\end{longtable}
}
The result somewhat behaves the way I want it to, but the table behaves very badly when it gets too long as it doesn't break over pages. Also, the fact that I use tabulars inside a tabular is a poor mans solution, since I didn't get it to work without the inner tabular (and I have no idea why - the outer tabular is open and only closed at the very end?).
So my question is: how do I get this working without the second tabular and how do I get the table to break nicely over multiple pages?
Thanks,