Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

[Edit 1] originally titled "can't understand why this simple macro causes complex error"

[original post] I've written a book, and now I'm trying to produce the e-book using tex4ht. Adapting this post, I introduced the following macro:


Which should return the first argument when producing the pdf file, and the second when using mk4ht to produce the html file.

Here is my m(n)we:

\gpifpdf{this is pdf text}{this is HTML text}

mk4ht produces an html file which displays "this is HTML text." But using Latexian to generate a pdf generates the following error:

Undefined control sequence.
\clist_if_empty:NF #1->\if_meaning:w 
                                 #1\c_empty_tl \prg_return_true: \else: \prg_return_false: \fi: \c_zero {}
l.9 \begin{document}

HOWEVER, when I comment out \usepackage{fontspec}, it works perfectly, producing a pdf reading "this is pdf text," so the macro seems to work correctly in the document body. When I leave in the \usepackage{fontspec}, and comment out the line before and the 3 lines afterwards (lines 4, 6, 7, and 8) it also produces the pdf just fine.

In other words: the macro seems to function correctly, and when I do what the macro is supposed to do by hand, everything works, but when I try to get the macro to do it, it doesn't.

I just upgrade to MacTeX 2014 from 2013 (so TeXlive 2014), and the problem continues. I am using Latexian, with the XeTeX option.

share|improve this question
Aren't the braces aroun {#1} and {#2} acting as a group? You can remove them. –  Manuel Aug 30 at 12:47
You might want to change the title to a better one that explains your problem (\ifx) which could be good for future users that need to search for this. –  Manuel Aug 30 at 15:12
Thanks for your help @Manuel, changed the title as suggested, hope that is clearer. –  Nat Kuhn Aug 31 at 2:30

1 Answer 1

up vote 5 down vote accepted

The syntax is not

\ifx<firsttoken><secondtoken>{<true code>}\else{<false code>}\fi

The correct one is

\ifx<firsttoken><secondtoken><true code>\else<false code>\fi

So you can remove the braces around {#1} and {#2} (which, in the case of \usepackage{fontspec} act as a group delimiter).

share|improve this answer
Perfect! Thank you so much. –  Nat Kuhn Aug 30 at 13:16

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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