0

I'm using LaTeX to generate a 100 pages document. Every page is basically a different randomly generated identity. At the end of every page, I use the \write command to write some datas that I generated in an external document.

When the compiler executes the command \immediate\write\Query{\Name}%, though, I receive the error ! Incomplete \iffalse; all text was ignored after line 3002. Error which I don't receive if I just write \Name in the document.

I need to understand why this happens, and the issue here is that the \Name command that I used there is actually a quite complex and big command, that includes other commands I made, a lot of \ifthenelse commands, \ifcase ones, \csname and so on...

So, it's hard for me to understand exactly which part of this is giving such error.

Before I can build an MWE, so, it would be useful for me to know exactly what is the meaning of the aforementioned error. What does it mean that there is an incomplete \iffalse, and what usually generates such an event in a \write command?

1
  • It means that there was an \iffalse and no matching \fi but usually the error is not that relevant it is just that Tex has gone wrong earlier and so is executing unintended code until it finally hits some more or less arbitrary error condition and stops. May 24 '17 at 18:13
0

This is the source of the "fragile command in a moving argument" errors and the \protect command in LaTeX.

If you want to write \Name to the file then it is simple:

\immediate\write\Query{\string\Name}%

If you want to write some version of the expansion of \Name then it's trickier, \ifthenelse for example does not work by expansion so will not expand to its true or false branch while expanding in a \write.

You may be able to use

  \protected@write

instead of \write depending on whether all the commands in the definition of \Name are robust.

1
  • Indeed, working around the \ifthenelse commands did the job. Thank you ;) May 25 '17 at 15:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.