From 49d9179875d59455e16d8ccadb93e061493e212f Mon Sep 17 00:00:00 2001 From: Michael Wiebusch Date: Thu, 3 Jul 2014 16:14:55 +0200 Subject: [PATCH] got a working version of longtable code in my perl script --- mvdsensorcontrol/appendix.tex | 5 +++++ mvdsensorcontrol/documentation.tex | 3 ++- mvdsensorcontrol/tables/maketable.pl | 33 ++++++++++++++++++++++------ 3 files changed, 33 insertions(+), 8 deletions(-) diff --git a/mvdsensorcontrol/appendix.tex b/mvdsensorcontrol/appendix.tex index 3dfef9f..b0e56b4 100644 --- a/mvdsensorcontrol/appendix.tex +++ b/mvdsensorcontrol/appendix.tex @@ -288,6 +288,8 @@ call JTAG programmer, program and initialize the sensors \input{tables/table} +\newpage +\begin{table} \begin{tabular}{ l | c || r } \hline 1 & 2 & 3 \\ @@ -295,6 +297,9 @@ call JTAG programmer, program and initialize the sensors 7 & 8 & 9 \\ \hline \end{tabular} +\caption{this is a simple table} +\label{tab:simple} +\end{table} diff --git a/mvdsensorcontrol/documentation.tex b/mvdsensorcontrol/documentation.tex index 0850d4a..229ece7 100644 --- a/mvdsensorcontrol/documentation.tex +++ b/mvdsensorcontrol/documentation.tex @@ -22,7 +22,8 @@ \usepackage{colortbl} \usepackage{xcolor} \usepackage{booktabs} - +\usepackage{longtable} +% \usepackage[singlelinecheck=off]{caption} % my macros diff --git a/mvdsensorcontrol/tables/maketable.pl b/mvdsensorcontrol/tables/maketable.pl index 5f962a9..7981c57 100755 --- a/mvdsensorcontrol/tables/maketable.pl +++ b/mvdsensorcontrol/tables/maketable.pl @@ -92,6 +92,7 @@ $table->addData(%$item); $table->{dataKeys} = [ 'name', 'addr', 'bits', 'description' ]; $table->{format} = '@{} l l l p{8cm} @{}'; +$table->{caption} = 'registers, maan'; my $tablefile = FileHandle->new("./table.tex", 'w'); print $tablefile $table->generateString(); @@ -202,19 +203,32 @@ sub generateString { my $self = shift; my $str = ""; - $str.='\begin{table}[tbp] - \centering'; +# $str.='\begin{table}[tbp] +# \centering'; +# $str .= '\begin{center}'; - $str .= '\begin{tabular}'."\n"; + $str .= '\begin{longtable}'."\n"; $str .="{".($self->{format}||"")."}\n"; + +# $str.='\caption{'.$self->{caption}.'}' if defined $self->{caption}."\n"; + $str .= '\\\\'; $str.='\toprule'."\n"; +# $str.='\hline'."\n"; if ( @{$self->{header}} ){ # if no header list ... $str.= " ".join(" & ",@{$self->{header}}).' \\\\'."\n"; } else { # print the keys instead $str.= " ".join(" & ",@{$self->{dataKeys}}).' \\\\'."\n"; } $str.='\midrule'."\n"; + $str.='\hline'."\n"; + $str.='\endfirsthead'; + + + $str.='\hline \multicolumn{'.scalar(@{$self->{dataKeys}}).'}{r}{\textit{Continued on next page}} \\\\ + \endfoot + \hline + \endlastfoot'; for my $data (@{$self->{data}}){ my @line; @@ -226,10 +240,15 @@ sub generateString { $str.=$line; } $str.='\bottomrule'."\n"; - $str.='\end{tabular}'."\n"; +# $str.='\hline'."\n"; + + $str .='\caption{aoeiaeoi}'."\n"; + $str .='\label{tab:long}'."\n"; + + $str.='\end{longtable}'."\n"; - $str.='\caption{'.$self->{caption}.'}' if defined $self->{caption}."\n"; - $str.='\label{'.$self->{label}.'}' if defined $self->{label}."\n"; - $str.='\end{table}'."\n"; +# $str.='\label{'.$self->{label}.'}' if defined $self->{label}."\n"; +# $str.='\end{table}'."\n"; +# $str .= '\end{center}'; return $str; } \ No newline at end of file -- 2.43.0