I'm trying do define a new environment using tabu
as a building block. The reason to use tabu
is that it will break nicely across pages for long tables. I would like to have some help on doing the following:
- Create a new type of environment that appears in
\listofinterfaces
instead of\listoftables
; - The caption should read
Interface X: text
instead ofTable X: text
; and - There is no need for automatic numbering, since I would prefer to use my own number provided with each table (it's currently the 3rd argument of
ryetable
); this also means that when I reference the new environment, the number provided is shown and not some automatic counter.
I understand you may need some serious latex voodoo to achieve this but even some pointers on the right direction would be helpful.
\documentclass{article}
\usepackage{array, booktabs, longtable, tabu}
% Usage: {}{<label>}{<ifNum>}{<caption>}
\newenvironment{ryetable}[4]{%
\gdef\tmpheaders{#1} % Not currently used
\gdef\tmplabel{\label{#2}} % Save label for later use
\gdef\tmpifnum{#3} % Save interface number
\gdef\tmpcaption{\caption{#4}} % Save caption for later use
\renewcommand{\arraystretch}{1.3} % More space between rows
\begin{longtabu} to \textwidth {@{} X[1,l] X[1,l] X[1,l] >{\raggedright}X[1,l] @{}}
\\\toprule\rowfont\bfseries
Header1 & Header2 & Header3 & Description \\
\midrule
\endfirsthead
\multicolumn{4}{@{}c@{}}{\small\textit{(continued)}}\\
\toprule\rowfont\bfseries
Header1 & Header2 & Header3 & Description \\
\midrule
\endhead
\bottomrule
\multicolumn{4}{@{}r@{}}{\small\textit{(continues)}}\\
\endfoot
\bottomrule
\tmpcaption
\tmplabel
\endlastfoot
}{%
\end{longtabu}
}
\begin{document}
\listoftables
%\listofinterfaces %TODO
\section{MySection}
For a simple table see Table~\ref{tab:somelabel} and for a nifty new environment check Interface~\ref{if:myinterface}.
%TODO: 31 here should be the environment's number
\begin{ryetable}{}{if:myinterface}{31}{This is my pretty interface.}
a & b & c & d\\
e & f & g & h\\
i & j & k & l\\
m & n & o & p\\
q & r & s & t\\
u & v & w & x\\
y & z & -- & --\\
\end{ryetable}
% Some other table to show on list
\begin{table}[h]
\centering
\begin{tabular}{c|c}
a&b\\
c&d\\
\end{tabular}
\caption{Caption of tabular table.}
\label{tab:somelabel}
\end{table}
\end{document}