cgnieder / acro

acronyms for LaTeX
LaTeX Project Public License v1.3c
40 stars 9 forks source link

bug: acro can't be used together with \include and \includeonly #229

Open FrankMittelbach opened 2 years ago

FrankMittelbach commented 2 years ago

One can argue that this feature but in my opinion it should be considered a bug. If you use acronyms across a large project (in case of TLC 1600+ pages) using \include and \includeonly the results depend on which files are included or excluded and as a result pagination and wording changes. The reason is the use of a separate file for storing the acro information instead of relying on the aux file mechanism. As a side effect that also blocks a precious file handle of which TeX is known to not have enough.

While on the outset it might seems nice to keep things separate I would strongly suggest to drop that approach and stick with the aux file mechanism so that data remains available even if only some chapters are processed.

cgnieder commented 2 years ago

This is something I obviously didn't think of… Thankfully it is easy to fix

FrankMittelbach commented 2 years ago

great, thanks. It it really a pain to run 1700 pages in one go only to get the acros right :-) looking forward to see the updated file

FrankMittelbach commented 2 years ago

Clemens, are you sure your solution works? From a glance at the patch I doubt it. I don't see anything that writes into the include aux files, but that would be needed to know that in a chapter \ac{foo} was called X times. Without that information the first usage would still depend on which files are included. But perhaps I'm missing something.

FrankMittelbach commented 2 years ago

@cgnieder my guess was unfortunately correct. The problem is not solved by the new code ashown in the following test:

\documentclass{article}

\usepackage{acro}

\begin{filecontents}[force]{\jobname-1.tex}
  \ac{abc}
\end{filecontents}
\begin{filecontents}[force]{\jobname-2.tex}
  \ac{abc}
\end{filecontents}
\begin{filecontents}[force]{\jobname-3.tex}
  \ac{abc}
\end{filecontents}

\DeclareAcronym{abc}{
  ,short = abc
  ,long  = AAAA BBB CCC
}

%\includeonly{\jobname-2,\jobname-3}

\begin{document}

\include{\jobname-1}
\include{\jobname-2}
\include{\jobname-3}

\end{document}

This means that formatting changes whenever you only run some includes even though everything else is correctly resolved and thenot included files are up-to-date

cgnieder commented 2 years ago

You're right. I realized that later, too. This isn't as easy as I initially thought…

FrankMittelbach commented 2 years ago

but I don't think it is that difficult either. What about this approach:

Thus if acro-test-1.tex is skipped your datastructure will still know that \ac{abc} was used once and thus uses the short entry in the later files

cgnieder commented 2 years ago

Yes, but the mechanism for any of acro's properties right now saves the information to some macro and only writes it to the aux file at end document. I need to revise this mechanism…

FrankMittelbach commented 2 years ago

maybe, haven't looked at the details of the mechanism. Revising it might also help with the code getting slower and slower if you have many acronyms. However, I don't think you must revise: A call to \ac{abc} does two things:

you say the second part is done by storing in a macro, okay. That doesn't prevent you when reading the include aux files that each record there does exactly this second step (but not doing the typesetting step). So if you put, say

\ACROupdate{\ac{abc}}

into the aux then at begin document \ACROupdate could be \@gobble but when reading the include aux file it could run \ac{abc} but without the typesetting part (assuming your data structure is global, simply by typesetting it in a box that this afterwards thrown away). So the definition could simply be

  \def\ACROupdate#1{\setbox\tmpbox\hbox{}}