Can I renew the table counter to use my own counter similarly to renewing, for instance, the \tablename? What is the keyword or where could I look for it?
This will be used within a newenvironment based on tabu (in order to have a separate counter from the table environment).
This is for the environment created in this question. When we click in a hyperlink in the PDF, we are always sent to the first Interface or last Table in the document. I believe the reason may be that hyperref relies on the table counter to work properly; if we comment out the counter decrease, \addtocounter{table}{-1}, in the environment definition then: hyperlinks work well, but table numbering is incorrect.
\documentclass{article}
\usepackage{array, booktabs, longtable, tabu}
\usepackage{hyperref}
\newcommand{\ListOfInterfacesName}{List of Interfaces}
\newcommand{\InterfaceName}{Interface}
% Define list of interfaces command
\makeatletter%
\newcommand{\listofinterfaces}{%
\section*{\ListOfInterfacesName}%
\@starttoc{int} % New toc with extension *.int%
\clearpage%
}%
\makeatother%
% Usage: {}{<label>}{<ifNum>}{<caption>}
\newenvironment{ryetable}[4]{%
\renewcommand{\tablename}{\InterfaceName} % Safe to renew table because it is inside a group
\renewcommand{\thetable}{#3} % Explicitly set table number to given argument (safe because redifinition also occurs inside a group)
\addtocounter{table}{-1} % Reduce counter number since using table increases it automatically
\addcontentsline{int}{subsection}{\protect{\numberline{#3}{#4}}} % Define entry subsection akin to normal tables
\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 ---> drop the entry to the table list
\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 nifty new environment check Interface~\ref{if:myinterface}.
\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}
\newpage
\begin{ryetable}{}{if:myif2}{35}{This is the other 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}
Go to Interface~\ref{if:myif2}. % Incorrectly links to first environment
\end{document}
\documentclass{...}and ending with\end{document}. – Jun 16 '14 at 16:41