4

In a previous question, I learned that \ExplSyntaxOn and \ExplSyntaxOff should be put around a command because of the order in which expansion works in TeX.

Suppose now that I want to put things at the begining where I want to use expl3 and to input a huge text as in :

\ExplSyntaxOn

\AtBeginDocument
 {
  \bool_if:nT{\g_florian_whatever_bool} %\g_florian_whatever_bool being set with a key
  {
    blahblah %blahblah being a huge token list with many spaces
  }
 }
\ExplSyntaxOff

How can I still use normal spaces ' ' while writing blahblah ? I want to ensure legibility and ~ is not the best way.

5
  • Could you give more detailed example of the situation? It's not clear why would you need to input that many text on an internal function rather than on a \NewDocumentCommand, and also not clear why is “readability” that important. Usually you can write a text and then substitute in your editor the spaces for ~, in case the input is a problem for you.
    – Manuel
    Jul 10, 2016 at 12:47
  • For example, I would like to use expl3 syntax inside a \AtBeginDocument (which leads to the same type of problems) to input text if a boolean key is set as true (I do not like \fi).
    – fyusuf-a
    Jul 10, 2016 at 12:54
  • \NewDocumentCommand \fooinc { m } { #1 \ing_gincr:N \g_florian_whatever_int } and then after exiting expl3-mode \AtBeginDocument{\fooinc{the text that you want to add}}?
    – Manuel
    Jul 10, 2016 at 12:55
  • I'll edit my question more because it is not yet explicit enough.
    – fyusuf-a
    Jul 10, 2016 at 12:57
  • 1
    Why do you need spaces for testing a boolean? You should need spaces only for typesetting, i.e., stuff used after begin document.
    – cgnieder
    Jul 10, 2016 at 12:57

1 Answer 1

6

Two examples that you could use

\ExplSyntaxOn

\tl_new:N \g_florian_whatever_tl
\NewDocumentCommand \setbegdoctext { m }
  { \tl_gset:Nn \g_florian_whatever_tl { #1 } }
\NewDocumentCommand \printifwhatever { }
  { \bool_if:NT \g_florian_whatever_bool { \tl_use:N \g_florian_whatever_tl } }

\ExplSyntaxOff

\AtBeginDocument{\printifwhatever}
\setbegdoctext{the text you want to print at the beginning of the document}

or

\ExplSyntaxOn

\NewDocumentCommand \printifwhatever { m } { \bool_if:NT \g_florian_whatever_bool { #1 } }

\ExplSyntaxOff

\AtBeginDocument{\printifwhatever{the text you want to print at the beginning of the document}}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .