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

Compilation errors when using \includeonly #10

Open
plescornet opened this issue Feb 20, 2023 · 14 comments
Open

Compilation errors when using \includeonly #10

plescornet opened this issue Feb 20, 2023 · 14 comments

Comments

@plescornet
Copy link

plescornet commented Feb 20, 2023

Hi !

I have a compilation error when using algorithmic environment when using \includeonly{...} to compile my chapters separately. I'm using an up-to-date texlive install with algpseudocodex v1.1.0.

Here is a MWE showing the issue :

\documentclass{scrreprt}

\usepackage{algpseudocodex}

\includeonly{mwe2.tex}

\begin{document}
\include{mwe1.tex}
\include{mwe2.tex}
\end{document}

And mwe1/2.tex contain :

\begin{algorithmic}[1]
  \Function{f}{$G$}
    \State $G$
  \EndFunction
\end{algorithmic}

The first error is :

! LaTeX Error: No counter 'algpx@indentEndPage-0' defined.

Deleting the .aux files removes the error. According to some colleagues, there was no error in the previous version of algpseudocodex.

@chrmatt
Copy link
Owner

chrmatt commented Feb 20, 2023

Hi! The code compiles without errors for me. Maybe you have some leftovers from old versions of the package in the aux file. Do you still get an error after cleaning up all auxiliary files?

@plescornet
Copy link
Author

Just tried it : cleaned up the aux files, compiled it one time without the includeonly and compiled it another time with it. I still get the error.

@chrmatt
Copy link
Owner

chrmatt commented Feb 20, 2023

Hmm, I see. So the reproduce the error, one first needs to compile without the includeonly, and then (without cleaning the aux files) add the includeonly and compile again. I can try to look into it, but an easy fix is to clean up again before compiling...

@plescornet
Copy link
Author

plescornet commented Feb 20, 2023

Seems a good fix for now, I tested several situations where I thought the lack of auxiliairy files would raise an issue, but it doesn't in my project. Should I close the issue or leave it for now ?

@chrmatt
Copy link
Owner

chrmatt commented Feb 20, 2023

If you are happy, feel free to close it. I played a bit around and don't see an easy fix for this. The error is caused by trying to access a reference defined in mwe1.tex, which then does not exist. There may be some ways to work around this, but I have no experience with \includeonly and this particular order of compilations seems to start the execution in an incosistent state...

@plescornet
Copy link
Author

Thanks for your work !

@leolavaur
Copy link

leolavaur commented Jun 24, 2024

Hi @chrmatt, sorry for digging out this issue. I am having the same problem, although deleting .aux files between compilations is not a satisfactory solution for my use case. In fact, I need these files to allow cross-referencing in my document (a big thesis manuscript), but without compiling the concerned chapters. Would you mind taking another look at it and reopening the issue so that others might see it as unresolved?

I looked around, and it does not seem that this issue is that common, although using \includeonly and packages that rely on counters is. Maybe there is inspiration to take there?
Another thing that surprises me, is why the counter wouldn't exist in the first place? I would assume that since the .aux files are preserved, any counter defined when writing an algorithm in an excluded chapter would be preserved too.

Anyway, I really like this package, but it currently becomes really frustrating! I hope we can find a solution. Thanks again!

@chrmatt
Copy link
Owner

chrmatt commented Jun 24, 2024

Hi @phdcybersec! I'm glad you like the package and I'm sorry for your frustration. I'll try to take a look soon, but I can't promise a quick fix. If anybody has an idea how to fix this, please let me know and I'll try to make it work.

@chrmatt chrmatt reopened this Jun 24, 2024
@tobast
Copy link

tobast commented Aug 15, 2024

If this might help, I've encountered the exact same error message (! LaTeX Error: No counter 'algpx@indentEndPage-0' defined.) in a document where I mistakenly \usepackage'd both algpseudocodex and \algpseudocode.

@plescornet
Copy link
Author

I don't know how but it seems that my MWE compiles now. If no one opposes, I can close this issue.
Thanks for the package !

@chrmatt
Copy link
Owner

chrmatt commented Oct 7, 2024

I still get the error following the instructions discussed before:

So the reproduce the error, one first needs to compile without the includeonly, and then (without cleaning the aux files) add the includeonly and compile again.

@plescornet
Copy link
Author

Sorry, I forgot I changed the system-wide algpseudocodex.sty file. Problem's still there.

@leolavaur
Copy link

Yeah, this is still true today, and like discussed, recompiling the whole document is not always feasible. Please keep the issue open in case someone with more time and/or knowledge comes across it!

@alephpiece
Copy link

I'm not familiar with package development, but I believe that the error is caused by This line.

My MWE goes here:

main.tex

\documentclass{article}

\usepackage{algpseudocodex}

% \includeonly{plaintext.tex}

\begin{document}
\include{algorithms.tex}
\include{plaintext.tex} % without algorithmic
\end{document}

algorithms.tex

% error with includeonly
\begin{algorithmic}[1]
    \Require{$x$}
    \If{$x \geq 0$}
        \State \Return $x$
    \Else
        \State \Return $-x$
    \EndIf
\end{algorithmic}

% ok with includeonly
\begin{algorithmic}[1]
    \Require{$x$}
    \State \Return $|x|$
\end{algorithmic}

According to the documentation of the package totcount, it uses the main auxiliary file (main.aux here) to keep its counter definitions. However, \includeonly updates main.aux without compiling algorithms.tex, which means definitions generated by \newtotcounter are discarded but never re-generated.

Without \includeonly:

% main.aux
\relax 
\@input{algorithms.aux}
% ...
\@input{plaintext.aux}
\expandafter\ifx\csname c@algpx@indentEndPage-0@totc\endcsname\relax\newcounter{algpx@indentEndPage-0@totc}\fi\setcounter{algpx@indentEndPage-0@totc}{0}
\expandafter\ifx\csname c@algpx@indentEndPage-1@totc\endcsname\relax\newcounter{algpx@indentEndPage-1@totc}\fi\setcounter{algpx@indentEndPage-1@totc}{0}
\gdef \@abspage@last{2}

With \includeonly:

% main.aux
\relax 
\@input{algorithms.aux}
\@input{plaintext.aux}
\gdef \@abspage@last{1}

Maybe we could use \newtotcounter[auxfile=<file>]{<counter>} to get around this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants