refcount + 未解析的交叉引用 + ~ 100 次 pdflatex 运行

refcount + 未解析的交叉引用 + ~ 100 次 pdflatex 运行

有谁知道如何加快速度吗?pdflatex由于未解决的交叉引用,我需要运行约 100 次。

我习惯refcount在表格(需求列表)的每一行添加一个数字,以便以后引用它(需求 1、需求 2,...)。我将其包装在以下模块中:

\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

需求/行数约为 100。除了一个例外,其他一切都正常。我需要运行pdflatexn - 1 次,其中 n 是表中的需求/行数,因为存在未解析的交叉引用。

我发现以下情况:每次运行时,refcount(或任何执行此操作的组件)都会将需求编号 +1 加到输入中,file.aux直到没有剩余引用(1、2、...、100)。我想到了一种解决方法来解决我的问题(使用.auxruby​​ 脚本解析文件),但也许有更好的方法。

请参阅以下示例:

Example 14个要求

\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 个要求):

\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}

答案1

但为什么要这么做呢\setcounterref{tab@rowcnt}{#1}?只要你这么做,号码就已经可用了\refstepcounter{tab@rowcnt}

\newcommand{\tabrowno}[1]{%
  \refstepcounter{tab@rowcnt}\label{#1}\arabic{tab@rowcnt}%
}

答案2

如果所有表格行都以 结尾\tabularnewline,则应该能够修补\tabularnewline以增加计数器,然后\tabrowno只需读出其当前值即可。这样,引用数就可以一次性计算出来,而不是通过 .aux 文件逐步计算。

相关内容