expl3-strategy to automatically update the title of a document, depending on its contentWhen is the aux file read and written?TeX and LaTeX differently expl3-x-written (exhaustive expansion) to an auxiliary fileExpl3' tl variable storing the result of a seq_map_inline: OK in article's title but not in beamer's titleWhat is the basic mechanism for writing something to an aux file?Replace inputfileX by the content of fileX automaticallyWrite on a file and input itTexmaker bibtex works with input not with includeChapters not showing in right order in PDF [solved]How to do multiple calls to includeonly?Including only a part of a TEX fileAny way to move content definition to end of latex input file for use earlier in the file?How to add my own directory to TexWorks search listExpl3' tl variable storing the result of a seq_map_inline: OK in article's title but not in beamer's title

Why would company (decision makers) wait for someone to retire, rather than lay them off, when their role is no longer needed?

Does the wearer know what items are in which patch in the Robe of Useful items?

How does Ctrl+c and Ctrl+v work?

What metal is most suitable for a ladder submerged in an underground water tank?

Is the seat-belt sign activation when a pilot goes to the lavatory standard procedure?

Why when I add jam to my tea it stops producing thin "membrane" on top?

How to rename multiple files in a directory at the same time

What do you call the hair or body hair you trim off your body?

Why would someone open a Netflix account using my Gmail address?

Aligning group plot titles horizontally

Why did the metro bus stop at each railway crossing, despite no warning indicating a train was coming?

Are there microwaves to heat baby food at Brussels airport?

How did the horses get to space?

How could it be that 80% of townspeople were farmers during the Edo period in Japan?

UUID type for NEWID()

It is as easy as A B C, Figure out U V C from the given relationship

What dog breeds survive the apocalypse for generations?

Given 0s on Assignments with suspected and dismissed cheating?

Should I communicate in my applications that I'm unemployed out of choice rather than because nobody will have me?

Why do galaxies collide?

Why is the Advance Variation considered strong vs the Caro-Kann but not vs the Scandinavian?

History of the Frobenius Endomorphism?

tikz drawing rectangle discretized with triangle lattices and its centroids

Meaning of "legitimate" in Carl Jung's quote "Neurosis is always a substitute for legitimate suffering."



expl3-strategy to automatically update the title of a document, depending on its content


When is the aux file read and written?TeX and LaTeX differently expl3-x-written (exhaustive expansion) to an auxiliary fileExpl3' tl variable storing the result of a seq_map_inline: OK in article's title but not in beamer's titleWhat is the basic mechanism for writing something to an aux file?Replace inputfileX by the content of fileX automaticallyWrite on a file and input itTexmaker bibtex works with input not with includeChapters not showing in right order in PDF [solved]How to do multiple calls to includeonly?Including only a part of a TEX fileAny way to move content definition to end of latex input file for use earlier in the file?How to add my own directory to TexWorks search listExpl3' tl variable storing the result of a seq_map_inline: OK in article's title but not in beamer's title













3















Context



The current question arises:



  • as an attempt to improve the aim explained in a question of mine
    (Expl3' tl variable storing the result of a seq_map_inline: OK in article's title but not in beamer's title),

  • in order to explain why using exp_not:N instead of exp_not:V, as
    suggested by egreg in his answer of another question of mine
    (TeX and LaTeX differently expl3-x-written (exhaustive expansion) to an auxiliary file), is useless in my use case.

Aim (sum up)



I have a main (beamer) document, say main.tex, the content of which varying,
depending on the targeted audience. For this, main.tex inputs one or more of,
say, 5 slave files: topic1.tex, topic2.tex, topic3.tex, topic4.tex,
topic5.tex.



Each topic (file) has a topic title and I want the title of the main document to
automatically be the list of the titles of the topics that are input (and only
the ones that are input).



For this, I used the following strategy:



  • At the beginning of each topic file, the topic title is specified, thanks to
    a topictitle macro.

  • Each time it is used, this macro appends the corresponding topic title to the
    right of a g_topics_seq sequence.

  • At the end of the (main) document:

    • the content of g_topics_seq sequence is placed in
      a g_presentation_title_tl token list,

    • the (not expanded: exp_not:V) content of g_presentation_title_tl is
      x-written to an auxiliary .sbj file.


  • At the end of the preamble of the (main) document (hence at the next
    compilation):

    • a scratch token list is x-set to contain the content of the auxiliary
      file,

    • the content of this scratch token list is passed to title.


The following MCE is the implementation of this strategy but I wonder if expl3
could provide a better one.



documentclassbeamer
usepackage[T1]fontenc
usepackage[utf8]inputenc
usepackagefilecontents
usepackage[check-declarations]expl3
usepackagexparse

beginfilecontents*topic1
topictitle% TeX,
LaTeX and café%

beginframe
TeX, LaTeX and café are nice!
endframe
endfilecontents*

beginfilecontents*topic2
topictitleTopic 2
beginframe
Topic 2 is nice!
endframe
endfilecontents*

beginfilecontents*topic3
topictitleTopic 3
beginframe
Topic 3 is nice!
endframe
endfilecontents*

beginfilecontents*topic4
topictitleTopic 4
beginframe
Topic 4 is nice!
endframe
endfilecontents*

beginfilecontents*topic5
topictitleTopic 5
beginframe
Topic 5 is nice!
endframe
endfilecontents*

ExplSyntaxOn

seq_new:N g_topics_seq
tl_new:N g_presentation_title_tl
iow_new:N g_output_stream

NewDocumentCommandtopictitlem

__topic_title:n #1


cs_new_protected:Npn __topic_title:n #1

seq_gput_right:Nn g_topics_seq #1


AtEndDocument

tl_gset:Nx g_presentation_title_tl

seq_use:Nng_topics_seq ,~

iow_open:Nn g_output_stream c_sys_jobname_str.sbj
iow_now:Nx g_output_stream exp_not:Vg_presentation_title_tl
iow_close:N g_output_stream


AtEndPreamble%
file_if_exist:nTF c_sys_jobname_str.sbj
tl_set:Nx l_tmpa_tl file_input:n c_sys_jobname_str.sbj
exp_args:NV title l_tmpa_tl

titleNo topic!


ExplSyntaxOff

begindocument
maketitle
%
inputtopic1
% inputtopic2
inputtopic3
% inputtopic4
inputtopic5
enddocument









share|improve this question



















  • 1





    it sounds a bit overdoing to use an extra file for this. Why don't you write to the aux-file?

    – Ulrike Fischer
    May 10 at 14:57











  • @UlrikeFischer I agree. That is what I tried first but, when I wanted to read the content of the .aux file, it was empty (I probably didn't read it at the right moment). IIRC, I also had some difficulties to write both a verbatim text (e.g.title and ) and, inside, the (not expanded: exp_not:V) content of g_presentation_title_tl.

    – Denis Bitouzé
    May 10 at 15:05






  • 1





    You don't have to manually read the .aux file: it is automatically input as part of the work done by begindocument, before the AtBeginDocument hooks are run.

    – frougon
    May 10 at 15:17











  • @frougon Yes, I know that but when I tried to exploit what was in it, it simply didn't exist according to LaTeX's message.

    – Denis Bitouzé
    May 10 at 15:38











  • Proof needed. :-)

    – frougon
    May 10 at 15:40















3















Context



The current question arises:



  • as an attempt to improve the aim explained in a question of mine
    (Expl3' tl variable storing the result of a seq_map_inline: OK in article's title but not in beamer's title),

  • in order to explain why using exp_not:N instead of exp_not:V, as
    suggested by egreg in his answer of another question of mine
    (TeX and LaTeX differently expl3-x-written (exhaustive expansion) to an auxiliary file), is useless in my use case.

Aim (sum up)



I have a main (beamer) document, say main.tex, the content of which varying,
depending on the targeted audience. For this, main.tex inputs one or more of,
say, 5 slave files: topic1.tex, topic2.tex, topic3.tex, topic4.tex,
topic5.tex.



Each topic (file) has a topic title and I want the title of the main document to
automatically be the list of the titles of the topics that are input (and only
the ones that are input).



For this, I used the following strategy:



  • At the beginning of each topic file, the topic title is specified, thanks to
    a topictitle macro.

  • Each time it is used, this macro appends the corresponding topic title to the
    right of a g_topics_seq sequence.

  • At the end of the (main) document:

    • the content of g_topics_seq sequence is placed in
      a g_presentation_title_tl token list,

    • the (not expanded: exp_not:V) content of g_presentation_title_tl is
      x-written to an auxiliary .sbj file.


  • At the end of the preamble of the (main) document (hence at the next
    compilation):

    • a scratch token list is x-set to contain the content of the auxiliary
      file,

    • the content of this scratch token list is passed to title.


The following MCE is the implementation of this strategy but I wonder if expl3
could provide a better one.



documentclassbeamer
usepackage[T1]fontenc
usepackage[utf8]inputenc
usepackagefilecontents
usepackage[check-declarations]expl3
usepackagexparse

beginfilecontents*topic1
topictitle% TeX,
LaTeX and café%

beginframe
TeX, LaTeX and café are nice!
endframe
endfilecontents*

beginfilecontents*topic2
topictitleTopic 2
beginframe
Topic 2 is nice!
endframe
endfilecontents*

beginfilecontents*topic3
topictitleTopic 3
beginframe
Topic 3 is nice!
endframe
endfilecontents*

beginfilecontents*topic4
topictitleTopic 4
beginframe
Topic 4 is nice!
endframe
endfilecontents*

beginfilecontents*topic5
topictitleTopic 5
beginframe
Topic 5 is nice!
endframe
endfilecontents*

ExplSyntaxOn

seq_new:N g_topics_seq
tl_new:N g_presentation_title_tl
iow_new:N g_output_stream

NewDocumentCommandtopictitlem

__topic_title:n #1


cs_new_protected:Npn __topic_title:n #1

seq_gput_right:Nn g_topics_seq #1


AtEndDocument

tl_gset:Nx g_presentation_title_tl

seq_use:Nng_topics_seq ,~

iow_open:Nn g_output_stream c_sys_jobname_str.sbj
iow_now:Nx g_output_stream exp_not:Vg_presentation_title_tl
iow_close:N g_output_stream


AtEndPreamble%
file_if_exist:nTF c_sys_jobname_str.sbj
tl_set:Nx l_tmpa_tl file_input:n c_sys_jobname_str.sbj
exp_args:NV title l_tmpa_tl

titleNo topic!


ExplSyntaxOff

begindocument
maketitle
%
inputtopic1
% inputtopic2
inputtopic3
% inputtopic4
inputtopic5
enddocument









share|improve this question



















  • 1





    it sounds a bit overdoing to use an extra file for this. Why don't you write to the aux-file?

    – Ulrike Fischer
    May 10 at 14:57











  • @UlrikeFischer I agree. That is what I tried first but, when I wanted to read the content of the .aux file, it was empty (I probably didn't read it at the right moment). IIRC, I also had some difficulties to write both a verbatim text (e.g.title and ) and, inside, the (not expanded: exp_not:V) content of g_presentation_title_tl.

    – Denis Bitouzé
    May 10 at 15:05






  • 1





    You don't have to manually read the .aux file: it is automatically input as part of the work done by begindocument, before the AtBeginDocument hooks are run.

    – frougon
    May 10 at 15:17











  • @frougon Yes, I know that but when I tried to exploit what was in it, it simply didn't exist according to LaTeX's message.

    – Denis Bitouzé
    May 10 at 15:38











  • Proof needed. :-)

    – frougon
    May 10 at 15:40













3












3








3








Context



The current question arises:



  • as an attempt to improve the aim explained in a question of mine
    (Expl3' tl variable storing the result of a seq_map_inline: OK in article's title but not in beamer's title),

  • in order to explain why using exp_not:N instead of exp_not:V, as
    suggested by egreg in his answer of another question of mine
    (TeX and LaTeX differently expl3-x-written (exhaustive expansion) to an auxiliary file), is useless in my use case.

Aim (sum up)



I have a main (beamer) document, say main.tex, the content of which varying,
depending on the targeted audience. For this, main.tex inputs one or more of,
say, 5 slave files: topic1.tex, topic2.tex, topic3.tex, topic4.tex,
topic5.tex.



Each topic (file) has a topic title and I want the title of the main document to
automatically be the list of the titles of the topics that are input (and only
the ones that are input).



For this, I used the following strategy:



  • At the beginning of each topic file, the topic title is specified, thanks to
    a topictitle macro.

  • Each time it is used, this macro appends the corresponding topic title to the
    right of a g_topics_seq sequence.

  • At the end of the (main) document:

    • the content of g_topics_seq sequence is placed in
      a g_presentation_title_tl token list,

    • the (not expanded: exp_not:V) content of g_presentation_title_tl is
      x-written to an auxiliary .sbj file.


  • At the end of the preamble of the (main) document (hence at the next
    compilation):

    • a scratch token list is x-set to contain the content of the auxiliary
      file,

    • the content of this scratch token list is passed to title.


The following MCE is the implementation of this strategy but I wonder if expl3
could provide a better one.



documentclassbeamer
usepackage[T1]fontenc
usepackage[utf8]inputenc
usepackagefilecontents
usepackage[check-declarations]expl3
usepackagexparse

beginfilecontents*topic1
topictitle% TeX,
LaTeX and café%

beginframe
TeX, LaTeX and café are nice!
endframe
endfilecontents*

beginfilecontents*topic2
topictitleTopic 2
beginframe
Topic 2 is nice!
endframe
endfilecontents*

beginfilecontents*topic3
topictitleTopic 3
beginframe
Topic 3 is nice!
endframe
endfilecontents*

beginfilecontents*topic4
topictitleTopic 4
beginframe
Topic 4 is nice!
endframe
endfilecontents*

beginfilecontents*topic5
topictitleTopic 5
beginframe
Topic 5 is nice!
endframe
endfilecontents*

ExplSyntaxOn

seq_new:N g_topics_seq
tl_new:N g_presentation_title_tl
iow_new:N g_output_stream

NewDocumentCommandtopictitlem

__topic_title:n #1


cs_new_protected:Npn __topic_title:n #1

seq_gput_right:Nn g_topics_seq #1


AtEndDocument

tl_gset:Nx g_presentation_title_tl

seq_use:Nng_topics_seq ,~

iow_open:Nn g_output_stream c_sys_jobname_str.sbj
iow_now:Nx g_output_stream exp_not:Vg_presentation_title_tl
iow_close:N g_output_stream


AtEndPreamble%
file_if_exist:nTF c_sys_jobname_str.sbj
tl_set:Nx l_tmpa_tl file_input:n c_sys_jobname_str.sbj
exp_args:NV title l_tmpa_tl

titleNo topic!


ExplSyntaxOff

begindocument
maketitle
%
inputtopic1
% inputtopic2
inputtopic3
% inputtopic4
inputtopic5
enddocument









share|improve this question
















Context



The current question arises:



  • as an attempt to improve the aim explained in a question of mine
    (Expl3' tl variable storing the result of a seq_map_inline: OK in article's title but not in beamer's title),

  • in order to explain why using exp_not:N instead of exp_not:V, as
    suggested by egreg in his answer of another question of mine
    (TeX and LaTeX differently expl3-x-written (exhaustive expansion) to an auxiliary file), is useless in my use case.

Aim (sum up)



I have a main (beamer) document, say main.tex, the content of which varying,
depending on the targeted audience. For this, main.tex inputs one or more of,
say, 5 slave files: topic1.tex, topic2.tex, topic3.tex, topic4.tex,
topic5.tex.



Each topic (file) has a topic title and I want the title of the main document to
automatically be the list of the titles of the topics that are input (and only
the ones that are input).



For this, I used the following strategy:



  • At the beginning of each topic file, the topic title is specified, thanks to
    a topictitle macro.

  • Each time it is used, this macro appends the corresponding topic title to the
    right of a g_topics_seq sequence.

  • At the end of the (main) document:

    • the content of g_topics_seq sequence is placed in
      a g_presentation_title_tl token list,

    • the (not expanded: exp_not:V) content of g_presentation_title_tl is
      x-written to an auxiliary .sbj file.


  • At the end of the preamble of the (main) document (hence at the next
    compilation):

    • a scratch token list is x-set to contain the content of the auxiliary
      file,

    • the content of this scratch token list is passed to title.


The following MCE is the implementation of this strategy but I wonder if expl3
could provide a better one.



documentclassbeamer
usepackage[T1]fontenc
usepackage[utf8]inputenc
usepackagefilecontents
usepackage[check-declarations]expl3
usepackagexparse

beginfilecontents*topic1
topictitle% TeX,
LaTeX and café%

beginframe
TeX, LaTeX and café are nice!
endframe
endfilecontents*

beginfilecontents*topic2
topictitleTopic 2
beginframe
Topic 2 is nice!
endframe
endfilecontents*

beginfilecontents*topic3
topictitleTopic 3
beginframe
Topic 3 is nice!
endframe
endfilecontents*

beginfilecontents*topic4
topictitleTopic 4
beginframe
Topic 4 is nice!
endframe
endfilecontents*

beginfilecontents*topic5
topictitleTopic 5
beginframe
Topic 5 is nice!
endframe
endfilecontents*

ExplSyntaxOn

seq_new:N g_topics_seq
tl_new:N g_presentation_title_tl
iow_new:N g_output_stream

NewDocumentCommandtopictitlem

__topic_title:n #1


cs_new_protected:Npn __topic_title:n #1

seq_gput_right:Nn g_topics_seq #1


AtEndDocument

tl_gset:Nx g_presentation_title_tl

seq_use:Nng_topics_seq ,~

iow_open:Nn g_output_stream c_sys_jobname_str.sbj
iow_now:Nx g_output_stream exp_not:Vg_presentation_title_tl
iow_close:N g_output_stream


AtEndPreamble%
file_if_exist:nTF c_sys_jobname_str.sbj
tl_set:Nx l_tmpa_tl file_input:n c_sys_jobname_str.sbj
exp_args:NV title l_tmpa_tl

titleNo topic!


ExplSyntaxOff

begindocument
maketitle
%
inputtopic1
% inputtopic2
inputtopic3
% inputtopic4
inputtopic5
enddocument






expl3 input automation auxiliary-files






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited May 10 at 15:12







Denis Bitouzé

















asked May 10 at 14:47









Denis BitouzéDenis Bitouzé

3,70211351




3,70211351







  • 1





    it sounds a bit overdoing to use an extra file for this. Why don't you write to the aux-file?

    – Ulrike Fischer
    May 10 at 14:57











  • @UlrikeFischer I agree. That is what I tried first but, when I wanted to read the content of the .aux file, it was empty (I probably didn't read it at the right moment). IIRC, I also had some difficulties to write both a verbatim text (e.g.title and ) and, inside, the (not expanded: exp_not:V) content of g_presentation_title_tl.

    – Denis Bitouzé
    May 10 at 15:05






  • 1





    You don't have to manually read the .aux file: it is automatically input as part of the work done by begindocument, before the AtBeginDocument hooks are run.

    – frougon
    May 10 at 15:17











  • @frougon Yes, I know that but when I tried to exploit what was in it, it simply didn't exist according to LaTeX's message.

    – Denis Bitouzé
    May 10 at 15:38











  • Proof needed. :-)

    – frougon
    May 10 at 15:40












  • 1





    it sounds a bit overdoing to use an extra file for this. Why don't you write to the aux-file?

    – Ulrike Fischer
    May 10 at 14:57











  • @UlrikeFischer I agree. That is what I tried first but, when I wanted to read the content of the .aux file, it was empty (I probably didn't read it at the right moment). IIRC, I also had some difficulties to write both a verbatim text (e.g.title and ) and, inside, the (not expanded: exp_not:V) content of g_presentation_title_tl.

    – Denis Bitouzé
    May 10 at 15:05






  • 1





    You don't have to manually read the .aux file: it is automatically input as part of the work done by begindocument, before the AtBeginDocument hooks are run.

    – frougon
    May 10 at 15:17











  • @frougon Yes, I know that but when I tried to exploit what was in it, it simply didn't exist according to LaTeX's message.

    – Denis Bitouzé
    May 10 at 15:38











  • Proof needed. :-)

    – frougon
    May 10 at 15:40







1




1





it sounds a bit overdoing to use an extra file for this. Why don't you write to the aux-file?

– Ulrike Fischer
May 10 at 14:57





it sounds a bit overdoing to use an extra file for this. Why don't you write to the aux-file?

– Ulrike Fischer
May 10 at 14:57













@UlrikeFischer I agree. That is what I tried first but, when I wanted to read the content of the .aux file, it was empty (I probably didn't read it at the right moment). IIRC, I also had some difficulties to write both a verbatim text (e.g.title and ) and, inside, the (not expanded: exp_not:V) content of g_presentation_title_tl.

– Denis Bitouzé
May 10 at 15:05





@UlrikeFischer I agree. That is what I tried first but, when I wanted to read the content of the .aux file, it was empty (I probably didn't read it at the right moment). IIRC, I also had some difficulties to write both a verbatim text (e.g.title and ) and, inside, the (not expanded: exp_not:V) content of g_presentation_title_tl.

– Denis Bitouzé
May 10 at 15:05




1




1





You don't have to manually read the .aux file: it is automatically input as part of the work done by begindocument, before the AtBeginDocument hooks are run.

– frougon
May 10 at 15:17





You don't have to manually read the .aux file: it is automatically input as part of the work done by begindocument, before the AtBeginDocument hooks are run.

– frougon
May 10 at 15:17













@frougon Yes, I know that but when I tried to exploit what was in it, it simply didn't exist according to LaTeX's message.

– Denis Bitouzé
May 10 at 15:38





@frougon Yes, I know that but when I tried to exploit what was in it, it simply didn't exist according to LaTeX's message.

– Denis Bitouzé
May 10 at 15:38













Proof needed. :-)

– frougon
May 10 at 15:40





Proof needed. :-)

– frougon
May 10 at 15:40










2 Answers
2






active

oldest

votes


















4














I would simply write to the aux-file:



documentclassbeamer
usepackage[T1]fontenc
usepackage[utf8]inputenc
usepackagefilecontents
usepackage[check-declarations]expl3
usepackagexparse

beginfilecontents*topic1
topictitle% TeX,
LaTeX and café%

beginframe
TeX, LaTeX and café are nice!
endframe
endfilecontents*

beginfilecontents*topic2
topictitleTopic 2
beginframe
Topic 2 is nice!
endframe
endfilecontents*

beginfilecontents*topic3
topictitleTopic 3
beginframe
Topic 3 is nice!
endframe
endfilecontents*

beginfilecontents*topic4
topictitleTopic 4
beginframe
Topic 4 is nice!
endframe
endfilecontents*

beginfilecontents*topic5
topictitleTopic 5
beginframe
Topic 5 is nice!
endframe
endfilecontents*

ExplSyntaxOn

seq_new:N g_topics_seq


NewDocumentCommandaddtopictitlem

seq_gput_right:Nng_topics_seq #1


makeatletter
NewDocumentCommandtopictitlem

iow_now:Nx @mainaux

exp_not:n addtopictitle#1



titleseq_use:Nng_topics_seq ,~

ExplSyntaxOff

begindocument
maketitle
%
inputtopic1
% inputtopic2
inputtopic3
inputtopic4
inputtopic5
enddocument


enter image description here






share|improve this answer






























    5














    I'd do as Ulrike suggests, writing to the @mainaux to avoid polluting the file streams. I'd also avoid expansion (mainly x-type) of the text, as this is likely to cause you trouble.



    Note also that in your code the tl_set:Nx l_tmpa_tl file_input:n c_sys_jobname_str.sbj didn't do anything because input is not expandable, so you ended up with titleinputjobname.sbj.



    The approach I propose is to, at the end of the document, write a gdef@input@topics<stuff> to the @mainaux, which will be read in the next run. After the file is read then the @input@topics is already known and can be simply used in the title. The written definition has to be global because the contents of the .aux file are read inside a group.



    At the writing step I used e-type expansion in seq_use:Nn because x-type expansion is too much, and because f-type would try to expand the first tokens of the title, which would expand TeX unless there was a space before it. Everything is put in exp_not:e to avoid the x expansion of write. An extra exp_not:N is needed before @input@topics for later runs, where it is already defined.



    Here's the code:



    documentclassbeamer
    usepackage[T1]fontenc
    usepackage[utf8]inputenc
    usepackagefilecontents
    usepackage[check-declarations]expl3
    usepackagexparse

    beginfilecontents*topic1
    topictitleTeX,
    LaTeX and café%

    beginframe
    TeX, LaTeX and café are nice!
    endframe
    endfilecontents*

    beginfilecontents*topic2
    topictitleTopic 2
    beginframe
    Topic 2 is nice!
    endframe
    endfilecontents*

    beginfilecontents*topic3
    topictitleTopic 3
    beginframe
    Topic 3 is nice!
    endframe
    endfilecontents*

    beginfilecontents*topic4
    topictitleTopic 4
    beginframe
    Topic 4 is nice!
    endframe
    endfilecontents*

    beginfilecontents*topic5
    topictitleTopic 5
    beginframe
    Topic 5 is nice!
    endframe
    endfilecontents*

    ExplSyntaxOn

    seq_new:N g_topics_seq

    NewDocumentCommandtopictitlem
    __topic_title:n #1
    cs_new_protected:Npn __topic_title:n #1
    seq_gput_right:Nn g_topics_seq #1

    makeatletter
    AtEndDocument

    iow_now:Nx @auxout

    gdef exp_not:N @input@topics
    exp_not:e seq_use:Nn g_topics_seq ,~



    AtBeginDocument

    cs_if_exist:NTF @input@topics
    exp_args:NV title @input@topics
    title No~topic!

    makeatother

    ExplSyntaxOff

    begindocument
    maketitle
    %
    inputtopic1
    % inputtopic2
    inputtopic3
    % inputtopic4
    inputtopic5
    enddocument





    share|improve this answer

























    • Very nice explanations about expansions, that I still find hard to understand correctly.

      – Denis Bitouzé
      May 10 at 15:35











    • @DenisBitouzé Sorry if I couldn't explain it right. You mean the types of expansion (e, f, x)? If so you can take a look at interface3.pdf (texdoc interface3), section 3 Introducing the variants.

      – Phelype Oleinik
      May 10 at 15:40












    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "85"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f490177%2fexpl3-strategy-to-automatically-update-the-title-of-a-document-depending-on-its%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    4














    I would simply write to the aux-file:



    documentclassbeamer
    usepackage[T1]fontenc
    usepackage[utf8]inputenc
    usepackagefilecontents
    usepackage[check-declarations]expl3
    usepackagexparse

    beginfilecontents*topic1
    topictitle% TeX,
    LaTeX and café%

    beginframe
    TeX, LaTeX and café are nice!
    endframe
    endfilecontents*

    beginfilecontents*topic2
    topictitleTopic 2
    beginframe
    Topic 2 is nice!
    endframe
    endfilecontents*

    beginfilecontents*topic3
    topictitleTopic 3
    beginframe
    Topic 3 is nice!
    endframe
    endfilecontents*

    beginfilecontents*topic4
    topictitleTopic 4
    beginframe
    Topic 4 is nice!
    endframe
    endfilecontents*

    beginfilecontents*topic5
    topictitleTopic 5
    beginframe
    Topic 5 is nice!
    endframe
    endfilecontents*

    ExplSyntaxOn

    seq_new:N g_topics_seq


    NewDocumentCommandaddtopictitlem

    seq_gput_right:Nng_topics_seq #1


    makeatletter
    NewDocumentCommandtopictitlem

    iow_now:Nx @mainaux

    exp_not:n addtopictitle#1



    titleseq_use:Nng_topics_seq ,~

    ExplSyntaxOff

    begindocument
    maketitle
    %
    inputtopic1
    % inputtopic2
    inputtopic3
    inputtopic4
    inputtopic5
    enddocument


    enter image description here






    share|improve this answer



























      4














      I would simply write to the aux-file:



      documentclassbeamer
      usepackage[T1]fontenc
      usepackage[utf8]inputenc
      usepackagefilecontents
      usepackage[check-declarations]expl3
      usepackagexparse

      beginfilecontents*topic1
      topictitle% TeX,
      LaTeX and café%

      beginframe
      TeX, LaTeX and café are nice!
      endframe
      endfilecontents*

      beginfilecontents*topic2
      topictitleTopic 2
      beginframe
      Topic 2 is nice!
      endframe
      endfilecontents*

      beginfilecontents*topic3
      topictitleTopic 3
      beginframe
      Topic 3 is nice!
      endframe
      endfilecontents*

      beginfilecontents*topic4
      topictitleTopic 4
      beginframe
      Topic 4 is nice!
      endframe
      endfilecontents*

      beginfilecontents*topic5
      topictitleTopic 5
      beginframe
      Topic 5 is nice!
      endframe
      endfilecontents*

      ExplSyntaxOn

      seq_new:N g_topics_seq


      NewDocumentCommandaddtopictitlem

      seq_gput_right:Nng_topics_seq #1


      makeatletter
      NewDocumentCommandtopictitlem

      iow_now:Nx @mainaux

      exp_not:n addtopictitle#1



      titleseq_use:Nng_topics_seq ,~

      ExplSyntaxOff

      begindocument
      maketitle
      %
      inputtopic1
      % inputtopic2
      inputtopic3
      inputtopic4
      inputtopic5
      enddocument


      enter image description here






      share|improve this answer

























        4












        4








        4







        I would simply write to the aux-file:



        documentclassbeamer
        usepackage[T1]fontenc
        usepackage[utf8]inputenc
        usepackagefilecontents
        usepackage[check-declarations]expl3
        usepackagexparse

        beginfilecontents*topic1
        topictitle% TeX,
        LaTeX and café%

        beginframe
        TeX, LaTeX and café are nice!
        endframe
        endfilecontents*

        beginfilecontents*topic2
        topictitleTopic 2
        beginframe
        Topic 2 is nice!
        endframe
        endfilecontents*

        beginfilecontents*topic3
        topictitleTopic 3
        beginframe
        Topic 3 is nice!
        endframe
        endfilecontents*

        beginfilecontents*topic4
        topictitleTopic 4
        beginframe
        Topic 4 is nice!
        endframe
        endfilecontents*

        beginfilecontents*topic5
        topictitleTopic 5
        beginframe
        Topic 5 is nice!
        endframe
        endfilecontents*

        ExplSyntaxOn

        seq_new:N g_topics_seq


        NewDocumentCommandaddtopictitlem

        seq_gput_right:Nng_topics_seq #1


        makeatletter
        NewDocumentCommandtopictitlem

        iow_now:Nx @mainaux

        exp_not:n addtopictitle#1



        titleseq_use:Nng_topics_seq ,~

        ExplSyntaxOff

        begindocument
        maketitle
        %
        inputtopic1
        % inputtopic2
        inputtopic3
        inputtopic4
        inputtopic5
        enddocument


        enter image description here






        share|improve this answer













        I would simply write to the aux-file:



        documentclassbeamer
        usepackage[T1]fontenc
        usepackage[utf8]inputenc
        usepackagefilecontents
        usepackage[check-declarations]expl3
        usepackagexparse

        beginfilecontents*topic1
        topictitle% TeX,
        LaTeX and café%

        beginframe
        TeX, LaTeX and café are nice!
        endframe
        endfilecontents*

        beginfilecontents*topic2
        topictitleTopic 2
        beginframe
        Topic 2 is nice!
        endframe
        endfilecontents*

        beginfilecontents*topic3
        topictitleTopic 3
        beginframe
        Topic 3 is nice!
        endframe
        endfilecontents*

        beginfilecontents*topic4
        topictitleTopic 4
        beginframe
        Topic 4 is nice!
        endframe
        endfilecontents*

        beginfilecontents*topic5
        topictitleTopic 5
        beginframe
        Topic 5 is nice!
        endframe
        endfilecontents*

        ExplSyntaxOn

        seq_new:N g_topics_seq


        NewDocumentCommandaddtopictitlem

        seq_gput_right:Nng_topics_seq #1


        makeatletter
        NewDocumentCommandtopictitlem

        iow_now:Nx @mainaux

        exp_not:n addtopictitle#1



        titleseq_use:Nng_topics_seq ,~

        ExplSyntaxOff

        begindocument
        maketitle
        %
        inputtopic1
        % inputtopic2
        inputtopic3
        inputtopic4
        inputtopic5
        enddocument


        enter image description here







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered May 10 at 15:26









        Ulrike FischerUlrike Fischer

        203k9312701




        203k9312701





















            5














            I'd do as Ulrike suggests, writing to the @mainaux to avoid polluting the file streams. I'd also avoid expansion (mainly x-type) of the text, as this is likely to cause you trouble.



            Note also that in your code the tl_set:Nx l_tmpa_tl file_input:n c_sys_jobname_str.sbj didn't do anything because input is not expandable, so you ended up with titleinputjobname.sbj.



            The approach I propose is to, at the end of the document, write a gdef@input@topics<stuff> to the @mainaux, which will be read in the next run. After the file is read then the @input@topics is already known and can be simply used in the title. The written definition has to be global because the contents of the .aux file are read inside a group.



            At the writing step I used e-type expansion in seq_use:Nn because x-type expansion is too much, and because f-type would try to expand the first tokens of the title, which would expand TeX unless there was a space before it. Everything is put in exp_not:e to avoid the x expansion of write. An extra exp_not:N is needed before @input@topics for later runs, where it is already defined.



            Here's the code:



            documentclassbeamer
            usepackage[T1]fontenc
            usepackage[utf8]inputenc
            usepackagefilecontents
            usepackage[check-declarations]expl3
            usepackagexparse

            beginfilecontents*topic1
            topictitleTeX,
            LaTeX and café%

            beginframe
            TeX, LaTeX and café are nice!
            endframe
            endfilecontents*

            beginfilecontents*topic2
            topictitleTopic 2
            beginframe
            Topic 2 is nice!
            endframe
            endfilecontents*

            beginfilecontents*topic3
            topictitleTopic 3
            beginframe
            Topic 3 is nice!
            endframe
            endfilecontents*

            beginfilecontents*topic4
            topictitleTopic 4
            beginframe
            Topic 4 is nice!
            endframe
            endfilecontents*

            beginfilecontents*topic5
            topictitleTopic 5
            beginframe
            Topic 5 is nice!
            endframe
            endfilecontents*

            ExplSyntaxOn

            seq_new:N g_topics_seq

            NewDocumentCommandtopictitlem
            __topic_title:n #1
            cs_new_protected:Npn __topic_title:n #1
            seq_gput_right:Nn g_topics_seq #1

            makeatletter
            AtEndDocument

            iow_now:Nx @auxout

            gdef exp_not:N @input@topics
            exp_not:e seq_use:Nn g_topics_seq ,~



            AtBeginDocument

            cs_if_exist:NTF @input@topics
            exp_args:NV title @input@topics
            title No~topic!

            makeatother

            ExplSyntaxOff

            begindocument
            maketitle
            %
            inputtopic1
            % inputtopic2
            inputtopic3
            % inputtopic4
            inputtopic5
            enddocument





            share|improve this answer

























            • Very nice explanations about expansions, that I still find hard to understand correctly.

              – Denis Bitouzé
              May 10 at 15:35











            • @DenisBitouzé Sorry if I couldn't explain it right. You mean the types of expansion (e, f, x)? If so you can take a look at interface3.pdf (texdoc interface3), section 3 Introducing the variants.

              – Phelype Oleinik
              May 10 at 15:40
















            5














            I'd do as Ulrike suggests, writing to the @mainaux to avoid polluting the file streams. I'd also avoid expansion (mainly x-type) of the text, as this is likely to cause you trouble.



            Note also that in your code the tl_set:Nx l_tmpa_tl file_input:n c_sys_jobname_str.sbj didn't do anything because input is not expandable, so you ended up with titleinputjobname.sbj.



            The approach I propose is to, at the end of the document, write a gdef@input@topics<stuff> to the @mainaux, which will be read in the next run. After the file is read then the @input@topics is already known and can be simply used in the title. The written definition has to be global because the contents of the .aux file are read inside a group.



            At the writing step I used e-type expansion in seq_use:Nn because x-type expansion is too much, and because f-type would try to expand the first tokens of the title, which would expand TeX unless there was a space before it. Everything is put in exp_not:e to avoid the x expansion of write. An extra exp_not:N is needed before @input@topics for later runs, where it is already defined.



            Here's the code:



            documentclassbeamer
            usepackage[T1]fontenc
            usepackage[utf8]inputenc
            usepackagefilecontents
            usepackage[check-declarations]expl3
            usepackagexparse

            beginfilecontents*topic1
            topictitleTeX,
            LaTeX and café%

            beginframe
            TeX, LaTeX and café are nice!
            endframe
            endfilecontents*

            beginfilecontents*topic2
            topictitleTopic 2
            beginframe
            Topic 2 is nice!
            endframe
            endfilecontents*

            beginfilecontents*topic3
            topictitleTopic 3
            beginframe
            Topic 3 is nice!
            endframe
            endfilecontents*

            beginfilecontents*topic4
            topictitleTopic 4
            beginframe
            Topic 4 is nice!
            endframe
            endfilecontents*

            beginfilecontents*topic5
            topictitleTopic 5
            beginframe
            Topic 5 is nice!
            endframe
            endfilecontents*

            ExplSyntaxOn

            seq_new:N g_topics_seq

            NewDocumentCommandtopictitlem
            __topic_title:n #1
            cs_new_protected:Npn __topic_title:n #1
            seq_gput_right:Nn g_topics_seq #1

            makeatletter
            AtEndDocument

            iow_now:Nx @auxout

            gdef exp_not:N @input@topics
            exp_not:e seq_use:Nn g_topics_seq ,~



            AtBeginDocument

            cs_if_exist:NTF @input@topics
            exp_args:NV title @input@topics
            title No~topic!

            makeatother

            ExplSyntaxOff

            begindocument
            maketitle
            %
            inputtopic1
            % inputtopic2
            inputtopic3
            % inputtopic4
            inputtopic5
            enddocument





            share|improve this answer

























            • Very nice explanations about expansions, that I still find hard to understand correctly.

              – Denis Bitouzé
              May 10 at 15:35











            • @DenisBitouzé Sorry if I couldn't explain it right. You mean the types of expansion (e, f, x)? If so you can take a look at interface3.pdf (texdoc interface3), section 3 Introducing the variants.

              – Phelype Oleinik
              May 10 at 15:40














            5












            5








            5







            I'd do as Ulrike suggests, writing to the @mainaux to avoid polluting the file streams. I'd also avoid expansion (mainly x-type) of the text, as this is likely to cause you trouble.



            Note also that in your code the tl_set:Nx l_tmpa_tl file_input:n c_sys_jobname_str.sbj didn't do anything because input is not expandable, so you ended up with titleinputjobname.sbj.



            The approach I propose is to, at the end of the document, write a gdef@input@topics<stuff> to the @mainaux, which will be read in the next run. After the file is read then the @input@topics is already known and can be simply used in the title. The written definition has to be global because the contents of the .aux file are read inside a group.



            At the writing step I used e-type expansion in seq_use:Nn because x-type expansion is too much, and because f-type would try to expand the first tokens of the title, which would expand TeX unless there was a space before it. Everything is put in exp_not:e to avoid the x expansion of write. An extra exp_not:N is needed before @input@topics for later runs, where it is already defined.



            Here's the code:



            documentclassbeamer
            usepackage[T1]fontenc
            usepackage[utf8]inputenc
            usepackagefilecontents
            usepackage[check-declarations]expl3
            usepackagexparse

            beginfilecontents*topic1
            topictitleTeX,
            LaTeX and café%

            beginframe
            TeX, LaTeX and café are nice!
            endframe
            endfilecontents*

            beginfilecontents*topic2
            topictitleTopic 2
            beginframe
            Topic 2 is nice!
            endframe
            endfilecontents*

            beginfilecontents*topic3
            topictitleTopic 3
            beginframe
            Topic 3 is nice!
            endframe
            endfilecontents*

            beginfilecontents*topic4
            topictitleTopic 4
            beginframe
            Topic 4 is nice!
            endframe
            endfilecontents*

            beginfilecontents*topic5
            topictitleTopic 5
            beginframe
            Topic 5 is nice!
            endframe
            endfilecontents*

            ExplSyntaxOn

            seq_new:N g_topics_seq

            NewDocumentCommandtopictitlem
            __topic_title:n #1
            cs_new_protected:Npn __topic_title:n #1
            seq_gput_right:Nn g_topics_seq #1

            makeatletter
            AtEndDocument

            iow_now:Nx @auxout

            gdef exp_not:N @input@topics
            exp_not:e seq_use:Nn g_topics_seq ,~



            AtBeginDocument

            cs_if_exist:NTF @input@topics
            exp_args:NV title @input@topics
            title No~topic!

            makeatother

            ExplSyntaxOff

            begindocument
            maketitle
            %
            inputtopic1
            % inputtopic2
            inputtopic3
            % inputtopic4
            inputtopic5
            enddocument





            share|improve this answer















            I'd do as Ulrike suggests, writing to the @mainaux to avoid polluting the file streams. I'd also avoid expansion (mainly x-type) of the text, as this is likely to cause you trouble.



            Note also that in your code the tl_set:Nx l_tmpa_tl file_input:n c_sys_jobname_str.sbj didn't do anything because input is not expandable, so you ended up with titleinputjobname.sbj.



            The approach I propose is to, at the end of the document, write a gdef@input@topics<stuff> to the @mainaux, which will be read in the next run. After the file is read then the @input@topics is already known and can be simply used in the title. The written definition has to be global because the contents of the .aux file are read inside a group.



            At the writing step I used e-type expansion in seq_use:Nn because x-type expansion is too much, and because f-type would try to expand the first tokens of the title, which would expand TeX unless there was a space before it. Everything is put in exp_not:e to avoid the x expansion of write. An extra exp_not:N is needed before @input@topics for later runs, where it is already defined.



            Here's the code:



            documentclassbeamer
            usepackage[T1]fontenc
            usepackage[utf8]inputenc
            usepackagefilecontents
            usepackage[check-declarations]expl3
            usepackagexparse

            beginfilecontents*topic1
            topictitleTeX,
            LaTeX and café%

            beginframe
            TeX, LaTeX and café are nice!
            endframe
            endfilecontents*

            beginfilecontents*topic2
            topictitleTopic 2
            beginframe
            Topic 2 is nice!
            endframe
            endfilecontents*

            beginfilecontents*topic3
            topictitleTopic 3
            beginframe
            Topic 3 is nice!
            endframe
            endfilecontents*

            beginfilecontents*topic4
            topictitleTopic 4
            beginframe
            Topic 4 is nice!
            endframe
            endfilecontents*

            beginfilecontents*topic5
            topictitleTopic 5
            beginframe
            Topic 5 is nice!
            endframe
            endfilecontents*

            ExplSyntaxOn

            seq_new:N g_topics_seq

            NewDocumentCommandtopictitlem
            __topic_title:n #1
            cs_new_protected:Npn __topic_title:n #1
            seq_gput_right:Nn g_topics_seq #1

            makeatletter
            AtEndDocument

            iow_now:Nx @auxout

            gdef exp_not:N @input@topics
            exp_not:e seq_use:Nn g_topics_seq ,~



            AtBeginDocument

            cs_if_exist:NTF @input@topics
            exp_args:NV title @input@topics
            title No~topic!

            makeatother

            ExplSyntaxOff

            begindocument
            maketitle
            %
            inputtopic1
            % inputtopic2
            inputtopic3
            % inputtopic4
            inputtopic5
            enddocument






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited May 10 at 15:26

























            answered May 10 at 15:16









            Phelype OleinikPhelype Oleinik

            27.4k54793




            27.4k54793












            • Very nice explanations about expansions, that I still find hard to understand correctly.

              – Denis Bitouzé
              May 10 at 15:35











            • @DenisBitouzé Sorry if I couldn't explain it right. You mean the types of expansion (e, f, x)? If so you can take a look at interface3.pdf (texdoc interface3), section 3 Introducing the variants.

              – Phelype Oleinik
              May 10 at 15:40


















            • Very nice explanations about expansions, that I still find hard to understand correctly.

              – Denis Bitouzé
              May 10 at 15:35











            • @DenisBitouzé Sorry if I couldn't explain it right. You mean the types of expansion (e, f, x)? If so you can take a look at interface3.pdf (texdoc interface3), section 3 Introducing the variants.

              – Phelype Oleinik
              May 10 at 15:40

















            Very nice explanations about expansions, that I still find hard to understand correctly.

            – Denis Bitouzé
            May 10 at 15:35





            Very nice explanations about expansions, that I still find hard to understand correctly.

            – Denis Bitouzé
            May 10 at 15:35













            @DenisBitouzé Sorry if I couldn't explain it right. You mean the types of expansion (e, f, x)? If so you can take a look at interface3.pdf (texdoc interface3), section 3 Introducing the variants.

            – Phelype Oleinik
            May 10 at 15:40






            @DenisBitouzé Sorry if I couldn't explain it right. You mean the types of expansion (e, f, x)? If so you can take a look at interface3.pdf (texdoc interface3), section 3 Introducing the variants.

            – Phelype Oleinik
            May 10 at 15:40


















            draft saved

            draft discarded
















































            Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f490177%2fexpl3-strategy-to-automatically-update-the-title-of-a-document-depending-on-its%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

            Circuit construction for execution of conditional statements using least significant bitHow are two different registers being used as “control”?How exactly is the stated composite state of the two registers being produced using the $R_zz$ controlled rotations?Efficiently performing controlled rotations in HHLWould this quantum algorithm implementation work?How to prepare a superposed states of odd integers from $1$ to $sqrtN$?Why is this implementation of the order finding algorithm not working?Circuit construction for Hamiltonian simulationHow can I invert the least significant bit of a certain term of a superposed state?Implementing an oracleImplementing a controlled sum operation

            Magento 2 “No Payment Methods” in Admin New OrderHow to integrate Paypal Express Checkout with the Magento APIMagento 1.5 - Sales > Order > edit order and shipping methods disappearAuto Invoice Check/Money Order Payment methodAdd more simple payment methods?Shipping methods not showingWhat should I do to change payment methods if changing the configuration has no effects?1.9 - No Payment Methods showing upMy Payment Methods not Showing for downloadable/virtual product when checkout?Magento2 API to access internal payment methodHow to call an existing payment methods in the registration form?