cgnieder / acro

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

Missing support for pdflatex option output-directory #227

Closed Kaniee closed 2 years ago

Kaniee commented 2 years ago

When calling pdflatex with the option -output-directory all auxiliary files are created in a given folder. In the case where my acronyms.tex file is not in the root folder, a folder in the output directory needs to be created. For some reason this does not work with this package so the following error is thrown:

! I can't write on file `sub/acronyms.aux'.
\@include ...\immediate \openout \@partaux #1.aux 
                                                  \immediate \write \@partau...
l.187 \include{sub/acronyms}

To resolve this, I needed to create the folder in the output directory manually.

Example file structure, where the output directory is aux (after I created the sub folder):

.
├── aux
│   ├── sub
│   │   └── acronyms.aux
│   ├── main.acr
│   ├── main.aux
│   ├── main.bbl
│   ├── main.blg
│   ├── main.fdb_latexmk
│   ├── main.fls
│   ├── main.lof
│   ├── main.log
│   ├── main.lot
│   ├── main.out
│   ├── main.pdf
│   ├── main.synctex.gz
│   └── main.toc
├── sub
│   └── acronyms.tex
└── main.tex

I found the workaround for this solution on Stackexchange.

dbranford commented 2 years ago

I think your problem is independent of acro and probably due to a result of using \include rather than \input (see https://tex.stackexchange.com/a/250 for some of the distinction) which tries (and fails due to the attempt to mirror the root folder structure in the -output-directory) to create an independent aux file for the \included tex file. The same error occurs even with

\documentclass{article}
\begin{document}
\include{sub/acronyms}                                                                                             
\end{document}

where sub/acronyms.tex just contains plain text.

Probably your acronyms.tex file is a list of \DeclareAcronyms, in which case it should use \input and no additional aux file is created (this is not only simpler but likely desired). If acronyms.tex does contain section-like material it would be reasonable to not keep it in a subfolder in which case the manual creation of the aux/sub folder is unnecessary as the acronyms.aux file will go in the root of the -output-directory folder.

Kaniee commented 2 years ago

Sound reasonable. That would explain the issue. I'll try it with \input instead of \include.

Thanks for taking your time on this one and for the good explanation.