[latexrefman] jobname

Hefferon, Jim S. jhefferon at smcvt.edu
Wed Aug 18 14:10:11 CEST 2021


Vincent,

I very much understand the pleasure in chasing down a puzzle.  But I just wanted to mention that for the reference manual, this seems to me to be just too much detail.  In some areas, perhaps such as getting mathematics to look its best and most useful, we could use more detail.  But, for me, jobname is perhaps not such an area?

Jim

...........................................................
Mathematicians usually work in comfortable offices.
  --US Bureau of Labor Statistics
  http://web.archive.org/web/20100410092206/https://www.bls.gov/oco/ocos043.htm

________________________________________
From: latexrefman <latexrefman-bounces+jhefferon=smcvt.edu at tug.org> on behalf of Vincent Belaïche <vincent.belaiche at gmail.com>
Sent: Wednesday, August 18, 2021 7:19
To: Karl Berry
Cc: latexrefman
Subject: Re: [latexrefman] jobname

⚠ External Sender ⚠


Dear Karl,

Following your instructions I did this :

pdflatex '\loggingall\documentclass{article}\input' body

where body.tex just contains this :

\begin{document}
Bonjour.
\end{document}

and I get in texput.log that the very first input is at line 626 of
the log as follows:

626: {\input}
627: (/usr/local/texlive/2020/texmf-dist/tex/latex/base/article.cls

this means that something has happened before that which freeze
\jobname to « texput », otherwise the jobname would have been «
article »
However, I realized that the texput.log file does not start from the
very beginning of what happens. The beginning of the file is as
follows (with only line numbers added) :

01: This is pdfTeX, Version 3.14159265-2.6-1.40.21 (TeX Live 2020)
(preloaded format=pdflatex 2020.4.24)  17 AUG 2021 22:24
02: entering extended mode
03:  restricted \write18 enabled.
04:  %&-line parsing enabled.
05: **\loggingall\documentclass{article}\input body
06:
07: \g_file_curr_ext_str ->
08: {changing \l__exp_internal_tl=macro:->\__kernel_file_input_push:n {}}
09: {into \l__exp_internal_tl=macro:->\seq_gput_left:Nn
\g__file_stack_seq \ETC.}
10:
11: \l__exp_internal_tl ->\seq_gput_left:Nn \g__file_stack_seq {{}{texput}{}}
12:
13: \seq_gput_left:Nn #1#2->\tl_gset:Nx #1{\exp_not:n {\s__seq
\__seq_item:n {#2}}\
14: exp_not:f {\exp_after:wN \__seq_put_left_aux:w #1}}
15: #1<-\g__file_stack_seq
16: #2<-{}{texput}{}

As you see at line 7 we have the expansion of \g_file_curr_ext_str, so
we don't see the expansion of \documentclass.
It seems that writing to the log file does not begin until the jobname
is set, so it does not begin before the first \input or the first
\jobname expansion, whichever comes first. So I changed my command
line in order to start with a \jobname expansion at the beginning, and
the new command line is as follows:

   pdflatex '\relax{\makeatletter\toks@\expandafter{\jobname}}\loggingall\documentclass{article}\input'
body

The \relax at the very beginning is there just to tell that the sequel
is code not a filename beginning with « { ».

With this, I got a log with roughly 281 additional lines prepended at
the beginning, and I understand that the processing of \documentclass
implies expanding \jobname, which confirms the assumption which I had
made and documented (in French) in the Jobname.html which I had
already sent on this thead.

In more details, in the newer log, the 9 last lines of log before the
common part with the older log are as follows :

278: \use:x #1->\cs_set_nopar:Npx \l__exp_internal_tl {#1}\l__exp_internal_tl
279: #1<-\exp_not:N \seq_gput_left:Nn \exp_not:N \g__file_stack_seq
{{\g_file_curr_d
280: ir_str }{\g_file_curr_name_str }{\g_file_curr_ext_str }}
281: {\edef}
282: {\noexpand}
283: {\noexpand}
284:
285: \g_file_curr_dir_str ->
286: {\jobname}

What I see at line 285 is that the control sequence
\g_file_curr_dir_str is expanded. But, later in the code, I have this
:
564: \cs_set_eq:NN #1->\tex_let:D #1=
565: #1<-\g_file_curr_name_str
566: {\let}
567: {globally changing \g_file_curr_name_str=\jobname}
568: {into \g_file_curr_name_str=macro:->}

which shows at line 567, that the \g_file_curr_name_str control
sequence initial value is not a macro, but is \ifx-equal to \jobname,
which means that somewhere in the LaTeX format we have something like
\expandafter\let\csname g_file_curr_name_str\encsanme\jobname.

So there is some \jobname expansion, and line 286 recalled below

286: {\jobname}

seems to be the trace of the instruction that freezes (if not yet
done) the jobname and starts logging output (if not yet started).
Which explains why this is the last line before the newer log becomes
identical to the older one taken form its start.

Now, I did one more experiment :

pdflatex '\let\tempa\jobname\edef\tempb{\tempa}\input' toto

where toto.tex is some minimal document. With this command line I get
output texput.log instead of toto.log, which confirms that expanding
some constrol sequence that is \let to \jobname is the same as
expanding \jobname, it freezes the \jobname.



Le mar. 17 août 2021 à 11:45, Vincent Belaïche
<vincent.belaiche at gmail.com> a écrit :
>
> Of course if I found how I will inform you, and if it is an easy
> answer, I would even mention it in the refman, as understanding how
> helps remember the correct usage.
>
> FYI, I raised the question on comp.text.tex, see
> https://groups.google.com/g/comp.text.tex/c/h-SKJ3gN56U
>
>   V.
>
> Le dim. 15 août 2021 à 23:21, Karl Berry <karl at freefriends.org> a écrit :
> >
> >     do you know what they did to get this behaviour.
> >
> > No, I do not know and did not care to take the time to look it up.  I
> > don't imagine it would be hard to find out. My first idea would be to
> > run a minimal document with \loggingall and look for \openin and \input.
> > Or grep the source *.dtx for such things, or job.*name, or the like.
> >
> > If you find out, let us know :).




More information about the latexrefman mailing list.