Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Is there anybody out there, with an idea how to speed things up? I need to run pdflatex ~ 100 times because of unresolved cross references.

I use refcount to add a number to each row of a table (list of requirements) to refer to it later on (Req. 1, Req. 2, ...) . I wrapped it in the following module:

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{tabrowcounter}
\RequirePackage{etoolbox}
\RequirePackage{refcount}
\makeatletter
\let\rc@refused\refused
\makeatother
\preto\tabular{\setcounter{tab@rowcnt}{0}}
\preto\longtable{\setcounter{tab@rowcnt}{0}}
\newcounter{tab@rowcnt}
\newcommand{\tabrowno}[1]{
  \refstepcounter{tab@rowcnt}\label{#1}\setcounterref{tab@rowcnt}{#1}\arabic{tab@rowcnt}
}
\endinput

The number of requirements/rows is about 100. Everything works fine with one exception. I need to run pdflatex n - 1 times, where n is the number of requirements/rows in the table because of unresolved cross references.

I found out the following: On each run, refcount (or whatever component does it) adds +1 to the requirement number in file.aux until there are no references left (1, 2, ... , 100). I think about a workaround to solve my problem (parsing .aux file with a ruby script), but maybe there's a better way to do it.

Please see those the examples below:

Example 1 4 requirements

\documentclass{scrreprt}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{longtable}
\usepackage{float}
\usepackage{tabrowcounter}

\begin{document}

\chapter{Chapter}

%page 6 to distinguish between value of reference and page
\setcounter{page}{6}

\begin{table}[H]
  \centering
  \caption{First table}
  \label{tab:num1}
  \begin{tabular}{r|r}
    \# & value \tabularnewline
    \tabrowno{ref:row1} & blub \tabularnewline
    \tabrowno{ref:row2} & blub \tabularnewline
  \end{tabular}
\end{table}

\qquad
\qquad

\begin{longtable}{r|r}
  \caption{Second table}\label{tab:num2} \\
  \# & value \tabularnewline
  \tabrowno{ref:row3} & blub \tabularnewline
  \tabrowno{ref:row4} & blub \tabularnewline
\end{longtable}

Reference 1 in Table \ref{tab:num1}: value \ref{ref:row1}, page \pageref{ref:row1} \\
Reference 2 in Table \ref{tab:num1}: value \ref{ref:row2}, page \pageref{ref:row2} \\
Reference 3 in Table \ref{tab:num2}: value \ref{ref:row3}, page \pageref{ref:row3} \\
Reference 4 in Table \ref{tab:num2}: value \ref{ref:row4}, page \pageref{ref:row4} \\

\end{document}

Example 2 (5 requirements):

\documentclass{scrreprt}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{longtable}
\usepackage{float}
\usepackage{tabrowcounter}

\begin{document}

\chapter{Chapter}

%page 6 to distinguish between value of reference and page
\setcounter{page}{6}

\begin{table}[H]
  \centering
  \caption{First table}
  \label{tab:num1}
  \begin{tabular}{r|r}
    \# & value \tabularnewline
    \tabrowno{ref:row1} & blub \tabularnewline
    \tabrowno{ref:row2} & blub \tabularnewline
  \end{tabular}
\end{table}

\qquad
\qquad

\begin{longtable}{r|r}
  \caption{Second table}\label{tab:num2} \\
  \# & value \tabularnewline
  \tabrowno{ref:row3} & blub \tabularnewline
  \tabrowno{ref:row4} & blub \tabularnewline
  \tabrowno{ref:row5} & blub \tabularnewline
\end{longtable}

Reference 1 in Table \ref{tab:num1}: value \ref{ref:row1}, page \pageref{ref:row1} \\
Reference 2 in Table \ref{tab:num1}: value \ref{ref:row2}, page \pageref{ref:row2} \\
Reference 3 in Table \ref{tab:num2}: value \ref{ref:row3}, page \pageref{ref:row3} \\
Reference 4 in Table \ref{tab:num2}: value \ref{ref:row4}, page \pageref{ref:row4} \\
Reference 5 in Table \ref{tab:num2}: value \ref{ref:row5}, page \pageref{ref:row5} \\

\end{document}
share|improve this question

2 Answers 2

up vote 4 down vote accepted

But why do that \setcounterref{tab@rowcnt}{#1}? The number is already available as soon as you do \refstepcounter{tab@rowcnt}.

\newcommand{\tabrowno}[1]{%
  \refstepcounter{tab@rowcnt}\label{#1}\arabic{tab@rowcnt}%
}
share|improve this answer
    
Great! That did the trick. –  herbert_hurtig Feb 4 '12 at 12:48

If all your table rows end with \tabularnewline, you should be able to patch \tabularnewline to increment your counter, then \tabrowno can just read out its current value. That way, the number of references is computed in one pass, rather than incrementally through the .aux file.

share|improve this answer
    
I'm not sure how to do that. Any good documentation where I can find something about it? –  herbert_hurtig Feb 4 '12 at 12:52

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.