Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
FrankMittelbach opened this issue Nov 16, 2021 · 8 comments
Open
Assignees
Labels
bug Something isn't working

Comments

@FrankMittelbach
Copy link

FrankMittelbach commented Nov 16, 2021

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
Copy link
Owner

cgnieder commented Jan 4, 2022

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

@cgnieder cgnieder self-assigned this Jan 4, 2022
@cgnieder cgnieder added the bug Something isn't working label Jan 4, 2022
cgnieder added a commit that referenced this issue Jan 4, 2022
@cgnieder cgnieder closed this as completed Jan 4, 2022
@FrankMittelbach
Copy link
Author

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
Copy link
Author

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
Copy link
Author

@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}
  • Run this document so that all \ac calls resolve (full form on page 1).
  • Then uncomment the include only and the full form will appear on page 2.

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
Copy link
Owner

cgnieder commented Jan 5, 2022

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

@cgnieder cgnieder reopened this Jan 5, 2022
@FrankMittelbach
Copy link
Author

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

  • when executing \ac put a record in the current aux file
  • at aux file reading at begin document ignore those
  • but when reading an include aux file instead of processing the file use those records to mimic the use of \ac with respect to your data structures.

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
Copy link
Owner

cgnieder commented Jan 5, 2022

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
Copy link
Author

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:

  • check what should be typeset (long/short/full) and do the typesetting
  • update the data structure so that you know something was typeset

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

cgnieder added a commit that referenced this issue Feb 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants