I am part of a large project working with big documents (>100 chapters and ~1000 pages per document).
As it stands, we input our partial files into the main document via \input.
The project would greatly benefit from switching to \include, because \includeonly in conjunction with the partial .aux files allows to speed up compilation AND preserve the cross-references.
However, a pesky comma stands in the way. As of now, all our file paths contain a comma in one of the folder names (as in: volume8,4/section1.tex). \include is fine with that, but \includeonly of course has a huge parsing problem, as the comma is needed to separate the names of the files that are to be included.
I am aware that commas in file names are a bad idea, full stop. Changing the folder names once and for all would be clearly much better.
However, given that it's a long-running, multi-volume project with several collaborators, the change is not too likely to happen.
Add to this that the occurrences of commas in our file structure, while predictable, are very pervasive – they show up in the main document as well as the individual chapters, which \input graphics or other files in the tree.
In the spirit of trying to work around the comma issue, here are my questions:
1. Is there a way to teach \includeonly to parse the path correctly? That is,
\includeonly{volume8,4/section1}
should include volume8,4/section1.tex rather than the (nonexistent) files volume8.tex and 4/section1.tex.
I have researched and tried different approaches to escape or quote the comma (",", \string, additional braces), and also tried changing the catcode of comma as suggested here;
all to no avail. Some of these approaches work great with spaces in the path, but commas seem hopeless.
EDIT: double braces, as in \includeonly{{volume8,4/section1}}, don't do the trick either.
1.a. How would a solution be able to handle multi-file inclusion? For instance:
\includeonly{volume8,4/section1, volume8,4/section2}
should include section1.tex and section2.tex.
2. Would it help to specify a path for \include(only)? The path should take care of the (suitably processed/escaped/quoted) comma, which wouldn't need to show up explicitly in the argument. I would then write:
\includeonly{section1,section2}
Is there some internal macro that specifies the path for all inclusions, the way that \input@path does for \input – and would it be any help here?
Here's a MWE:
\documentclass{article}
%\usepackage{shellesc} % Some code to generate the appropriate folders and files
%\ShellEscape{mkdir volume8,4}
%
%\begin{filecontents}[overwrite]{volume8,4/section1.tex}
%\section{First section}
%Hello
%\end{filecontents}
%\begin{filecontents}[overwrite]{volume8,4/section2.tex}
%\section{Second section}
%Bye
%\end{filecontents} % End of code for folders and files
%\includeonly{volume8,4/section1} % How to make this work?
\begin{document}
\include{volume8,4/section1}
\include{volume8,4/section2}
\end{document}
\includeonly{{with,comma},without_comma,{with,comma,again}}(just guessing; may not be possible at all) – Phelype Oleinik Nov 19 '21 at 16:16\includeonly{{file}}still allows to includefile. Files with comma in their names are just ignored. – Jasper Habicht Nov 19 '21 at 16:22\includeonly{{volume8,4/section1}}, but it doesn't work. – marquinho Nov 19 '21 at 16:30\includeonly{{volume8,4/section1},}– Phelype Oleinik Nov 19 '21 at 16:33\@forinside\include– David Carlisle Nov 19 '21 at 16:37mv 'volume8,4/section1' 'volume8.4/section1'should work smoothly :) – Phelype Oleinik Nov 19 '21 at 16:41\@forto loop over comma separated lists, it is hard to trick it into accepting a comma – Phelype Oleinik Nov 19 '21 at 16:43ln -smight be the simplest solution – David Carlisle Nov 19 '21 at 16:43mvfor batch renaming the folders as suggested by Phelype + some text editor to batch edit the file contents should work. – marquinho Nov 19 '21 at 16:52volume8,4from the tex then run withTEXINPUTS=volumne8,4:so that directory gets searched but it fails, perhaps kpathse also has problems with commas not just tex... – David Carlisle Nov 19 '21 at 16:53