In LaTeX2e, one can write to the standard auxiliary file via the \@auxout
file handle. Are there dedicated LaTeX3 functions (planned) that facilitate writing to \jobname.aux
or is there an equivalent \@auxout
file handle in LaTeX3 we can use with the functions from the l3file
package?
2 Answers
At present the answer here is 'no', as we do not have structures for the higher-level idea of 'an auxiliary file'. Clearly we will need to address this along with a number of other file-related areas (for example a native mechanism for loading files, akin to \usepackage
).
-
If you have a clear need and a sensible proposal, send something to LaTeX-L!– Joseph Wright ♦Jan 11, 2013 at 13:46
-
Thanks for your answer. LaTeX package authors may always open and write to their own, package-specific auxiliary files, but they will have to explicitly read them in
\AtBeginDocument
. Moreover, the file extension one has to invent may already be in use by another package, giving rise to conflict. Thus, it is a good idea to use\@auxout
in contributed packages and many L2e authors do this, I guess. For now, I will stick to private aux-files, since\@auxout
is LaTeX2e and may be subject to change.– AlexGJan 11, 2013 at 14:02 -
1@AlexG: LaTeX package author don't want to deal with aux files but want some kind of data storage that persists across LaTeX runs (and don't care if the data is stored in aux files or serialized Lua lists). I think that's the api LaTeX3 should offer. Jan 11, 2013 at 14:25
-
1@MartinSchröder you are quite right. The high-level interface should provide persitent storage as an abtraction. What the implementation does under the hood might well be different for different engines. Jan 11, 2013 at 15:27
-
@MartinSchröder. Of course, persistent data storage is the actual purpose. But
\jobname.aux
is the method of choice, as Lua is not yet available in every TeX engine. (This is the reason why L3 explicitly avoids relying on Lua (cf. the l3fp package), I once read this somewhere).– AlexGJan 11, 2013 at 15:33
This probably doesn't conform to the guidelines, but \iow_shipout:Nn
, \iow_shipout_x:Nn
, and \iow_now:Nn
understand the usual file handler:
\documentclass{article}
\usepackage{xparse}
\ExplSyntaxOn
\makeatletter
\NewDocumentCommand{\writeaux}{ s m }
{
\IfBooleanTF{#1}
{ \iow_shipout:Nn \@auxout { #2 } }
{ \iow_shipout_x:Nn \@auxout { #2 } }
}
\makeatother
\ExplSyntaxOff
\begin{document}
a\writeaux{\noexpand\typeout{foo}}\writeaux*{\typeout{bar}}
\end{document}
For internal commands to be used in packages, one can think to
\cs_new_protected:Npn \iowaux_now:n #1 { \iow_now:Nn \@auxout { #1 } }
\cs_new_protected:Npn \iowaux_shipout:n #1 { \iow_shipout:Nn \@auxout { #1 } }
\cs_new_protected:Npn \iowaux_shipout_x:n #1 { \iow_shipout_x:Nn \@auxout { #1 } }
and similarly for the x
variant. Thus usage can become independent on the actual implementation; just modifying the four definitions will be sufficient to keep packages otherwise unchanged.
-
-
Thanks for your suggestion. I am going to formulate a similar request in layman's words and send it to LaTeX-L.– AlexGJan 11, 2013 at 14:22