Der folgende Code ermöglicht, zeilenweise Auszüge aus Tabellen als neue Tabelle zu erstellen. Die Kommentare (comment) sollen in der Auszugstabelle erscheinen, aber nicht in den Ursprungstabellen. Open in writeLaTeX
\documentclass[a4paper]{article} \usepackage[ngerman]{babel} \usepackage[utf8]{inputenc} \usepackage{longtable} \newcommand{\extract}[1]{#1\immediate\write\extracttable{Tabelle \thetable\noexpand& #1\noexpand\\}} \begin{document} \newwrite\extracttable \def\mytable{mytable} \immediate\openout\extracttable=\mytable.ext \begin{longtable}{p{1cm}p{1cm}p{1cm}}\caption{Erste}\\ \extract{ATest&ATest&comment}\\ BTest&BTest&comment\\ \extract{CTest&CTest&comment}\\ \extract{DTest&DTest&comment}\\ \end{longtable} \begin{longtable}{p{1cm}p{1cm}p{1cm}}\caption{Zweite}\\ \extract{VTest&VTest&comment}\\ WTest&WTest&comment\\ \extract{XTest&XTest&comment}\\ \extract{YTest&YTest&comment}\\ \end{longtable} \immediate\closeout\extracttable \begin{longtable}{p{3cm}p{2cm}p{2cm}p{2cm}}\caption{Extract Erste \& Zweite}\\ \textbf{fromtable}& \textbf{value}& \textbf{value}&\textbf{comment}\\\endfirsthead \textbf{table}& \textbf{value}& \textbf{val}&comment\\\endhead \input \mytable.ext \end{longtable} \end{document} gefragt 20 Okt '14, 01:41 ctansearch |
Open in writeLaTeX
\documentclass[a4paper]{article} \usepackage[utf8]{inputenc} \usepackage{longtable} \newwrite\extracttable \immediate\openout\extracttable=extract.ext \newcommand{\extracttables}{ \begin{longtable}[l]{p{3cm}p{2cm}p{2cm}p{2cm}}\caption{Extract}\\ \textbf{fromtable}& \textbf{value}& \textbf{value}&\textbf{comment}\\\endfirsthead \textbf{table}& \textbf{value}& \textbf{val}&comment\\\endhead \immediate\closeout\extracttable \input extract.ext \end{longtable}} \newcommand{\extract}[2]{#1 \immediate\write\extracttable{Tabelle \thetable \noexpand\noexpand\noexpand\\}} \begin{document} \begin{longtable}[l]{p{1cm}p{1cm}p{1cm}}\caption{Erste}\\ \extract{ATest&ATest}{comment}\\ BTest&BTest\\ \extract{CTest&CTest}{comment}\\ \extract{DTest&DTest}{comment}\\ \end{longtable} \begin{longtable}[l]{p{1cm}p{1cm}p{1cm}}\caption{Zweite}\\ \extract{VTest&VTest}{}\\ WTest&WTest\\ \extract{XTest&XTest}{}\\ \extract{YTest&YTest}{}\\ \end{longtable} \extracttables \end{document} beantwortet 20 Okt '14, 22:39 ctansearch |