Probleme mit sortierter Tabelle
Verfasst: Di 14. Jun 2016, 13:13
Hallo Leute, ich habe ein Problem mit einem Skript für eine Tabelle welches ich aus dem Internet kopiert habe. Die Tabelle sortiert sich automatisch alphabetisch. Hier mal das Minimalbeispiel:
Nun habe ich die folgenden 2 Probleme: Die Tabelle hat zu viele Einträge und passt nicht mehr auf eine Seite, sie erweitert sich aber nicht automatisch auf 2 Seiten, sondern schneidet den Rest einfach ab. Das andere Problem ist, dass ich keine automatischen Zeilenumbrüche habe, falls z.B. die Bedeutung der Variable einen zu langen Namen hat. Für Hilfe wäre ich sehr dankbar 
\documentclass{article} \usepackage{etoolbox} \usepackage{booktabs} \makeatletter % #1 - comparator % #2 - token list to sort \newcommand\sort[2]{% \ifstrempty{#2} {}% else {% \sort@begin#1{}#2\sort@s\sort@begin }% } % helpers \def\sort@s{\sort@s} \def\ifsort@s#1{% \ifx\sort@s#1% \expandafter\@firstoftwo \else \expandafter\@secondoftwo \fi } % #1 - comparator % #2 - tokens processed so far % #3 - smallest token so far % #4 - rest of the list \def\sort@begin#1#2#3#4\sort@begin{% \ifsort@s{#4} {% \sortend{#3}% \sort#1{#2}% }% else {% \sort@go#1{#2}{#3}#4\sort@go }% } % #1 - comparator % #2 - tokens processed so far % #3 - smallest token so far % #4 - token under consideration % #5 - rest of the list \def\sort@go#1#2#3#4#5\sort@go{% #1{#3}{#4}{\sort@output#1{#2}{#5}}% } % #1 - comparator % #2 - tokens processed so far % #3 - rest of the list % #4 - smaller of the two tokens % #5 - larger of the two tokens \def\sort@output#1#2#3#4#5{% \ifsort@s{#3} {% \sortoutput{#4}% \sort#1{#2{#5}}% }% else {% \sort@begin#1{#2{#5}}{#4}#3\sort@begin }% } \def\sort@numlt#1#2#3{% \ifnumcomp{#1}<{#2} {#3{#1}{#2}}% else {#3{#2}{#1}}% } \def\sort@numgt#1#2#3{% \ifnumcomp{#1}>{#2} {#3{#1}{#2}}% else {#3{#2}{#1}}% } \def\sort@alpha#1#2#3{% \ifnumcomp{\pdfstrcmp{#1}{#2}}<{0} {#3{#1}{#2}}% else {#3{#2}{#1}}% } \def\sort@firstcol#1#2{% \expandafter\expandafter\expandafter \sort@fc@helper\expandafter#1#2#1#2% } \def\sort@fc@helper#1\\#3\\#5#6#7{% \ifnumcomp{\pdfstrcmp{#1}{#3}}<{0} {#7{#5}{#6}}% else {#7{#6}{#5}}% } \newcommand*\sortnumlt{\sort\sort@numlt} \newcommand*\sortnumgt{\sort\sort@numgt} \newcommand*\sortalpha{\sort\sort@alpha} \newcommand*\sortfirstcol{\sort\sort@firstcol} \makeatother % Change these to change out the sort outputs. \newcommand*\sortoutput[1]{#1} \newcommand*\sortend[1]{#1} \begin{document} \def\rowa {$m$ & $kg$ & Masse \\} \def\rowb {$F$ & $N$ & Kraft \\} \def\rowc {$h$ & $m$ & Höhe \\} \begin{tabular}{ccc} \toprule \textbf{Variable} & \textbf{SI-Einheit} & \textbf{Bedeutung}\\ \midrule \sortfirstcol{\rowa\rowb\rowc} \bottomrule \end{tabular} \end{document}
