gsalzer / subfiles

class and package for multi-file projects in LaTeX
LaTeX Project Public License v1.3c
25 stars 1 forks source link

.out file corrupted if there is an error in compiling main.tex #35

Open MRoth1910 opened 2 weeks ago

MRoth1910 commented 2 weeks ago

If I compile main.tex and some error arises (e.g. when I change a file name when working on and compiling subfile_2.tex but subfile_1.tex is left untouched by accident, obviously main.tex cannot compile), the .out file is seemingly unable to delete itself and start over (deleting the aux file doesn't always work and is even more annoying, as I needed a first pass to account for EVERYTHING as if I'd never compiled before).

The second compilation after seemingly fixing an error gives me File ended while scanning use of \@@BOOKMARK

Also, on that note, sometimes compiling main.tex will not work and I get an error if I try to add a yet-uncompiled subfile.tex (in order to have defined references and, then in the subfile PDF, the right pagination carried over from main.tex. In my preamble, I have

%%%SUBFILES%%%
\usepackage{xr} %%to allow cross-references between documents%%%
  \usepackage{subfiles}

  %% When we start a new subfile (new chapter or at least section), 
%% we start on a new page (with blank filling on the previous page) and create a corresponding label.

\newcommand{\customsubfile}[1]{\newpage\label{#1}\thispagestyle{empty}\subfile{#1}}

and at the top of each document

\ifcsname preamble@file\endcsname
  \setcounter{page}{\getpagerefnumber{M-subfile_N}}
\fi

%%this code when \customsubfiles is used should allow for continuous pagination when subfiles are compiled individually.

so it's not quite the basic stuff, but I wasn't having this problem, as far as I can tell, before (when I didn't have my TOC set up, and now I do)

gsalzer commented 2 weeks ago

@MRoth1910 Not sure I understand the problem. Out-files are auxiliary files like aux-files, generated by the hyperref package. If they get corrupted, you have to remove them. No file removes itself, files are passive objects. Maybe you use a TeX-platform that clears aux-files for you, but doesn't do the same with out-files. In this case search its documentation or forums for advice on how to let it also clear out files.

Otherwise, please provide a complete minimal (non-)working example that illustrates your problem, with a descriptions of the steps that lead to the problem, such that I can reproduce your problem.

Last remark: Do you know the Standard-LaTeX command \include and \includeonly? Maybe you don't really need the subfiles package.

MRoth1910 commented 2 weeks ago

Hmm. Yes, I know that sometimes the files become corrupted: but a file should not be corrupted every time that there is an error. So maybe it's a hyperref problem, but I came here first because one of the problems causing a corrupted .out file is this strange issue with the argument of \subfile.

So all I can say for now is that these packages aren't working correctly together— as adding a new subfile to main.tex should compile without an error, right?

That is, compiling main.tex that already includes subfile_N.tex when subfile_Nplusone.tex is built but not yet independently compiled seems to produce an error — it is as if subfile_Nplusone.tex doesn't exist in the directory when it goes to read \subfile{subfile_N}. And then it compiles without an issue when I replace the file name (with the exact same string copied and pasted from the file name in the directory) so long as I delete the .out file.

I don't even know what a MWE could possibly look like for this, quite honestly.

Yes I know about \include and \includeonly. That is NOT what I want. Independently usable and printable PDFs that can also have the pagination derived from the main document are essential.

gsalzer commented 2 weeks ago

@MRoth1910 At the moment, I find it hard to understand which steps will lead to the bad thing that you are worrying about. An MWE would be a collection of initial files and a sequence of instructions that, when applied to the files, will result in the bad thing. I'm afraid that without such an MWE, I can't really help. You may try at tex.stackexchange.com, but the people there also want to see such an MWE.

MRoth1910 commented 2 weeks ago

I know what an MWE is. But what MWE will be minimal given the scope (this is a 500+ page work at the moment with a dozen+ subfiles being called).

I have described the problem and while I realize that I'm asking for help for free, I don't know what you don't understand other than that apparently I'm not describing something in a way that makes sense.

Also please don't tag me. I turned off notifications because I'm trying to get work done. A simple reply will do.

mrpiggi commented 2 weeks ago

I know what an MWE is. But what MWE will be minimal given the scope (this is a 500+ page work at the moment with a dozen+ subfiles being called).

That's exactly why it's necessary to strip down to something which still reproduces the error. This often also points out, which packages are exactly involved causing this error.

I have described the problem and while I realize that I'm asking for help for free, I don't know what you don't understand other than that apparently I'm not describing something in a way that makes sense.

Some input is required in order to reproduce the error. What is a package maintainer supposed to do in your eyes? As you error obviously is not something which can be reproduced straightforward but involves several steps, it's up to you providing some input on which a maintainer can work with.

If this is something, which you can not provide or are not willing to do so, well then just delete the *.out files manually or with a custom script.

gsalzer commented 2 weeks ago

Don't worry about using my time. If I can help with my knowledge of LaTeX or the subfiles package, I will. The problem is just that at the moment, the problem is not clear to me. You say that sometimes files written by the hyperref package get corrupted when you add a new subfile. There is nothing I can test, because the problem may lie with any of your packages, and I have no idea what your setup looks like. To obtain a minimal (or rather, a small) example, either start from a copy of the full document and remove parts as long as the error still appears. Or start from an empty document and add just the elements that you think are relevant until the error appears. But now I have to stop, as I'm also trying to get work done.