5

For a number of days I've been confused with some problems I had when using the \pdftex_if_engine:TF switch in a LaTeX3/expl3 class of my own. I thought it would be equivalent to the \ifpdf switch, but I've found quite a different behavior from one to the other with regard to the minted package and to polar coordinates-based nodes in PSTricks. To be more precise, in the second case I had PostScript errors precluding the generation of graphics including nodes defined in terms of polar coordinates when using the LaTeX3 switch. The strangest thing to me was that changing to the LaTeX2e switch got everything right without needing to use the \ExplSyntax(Off|On) switch at all.

My reason for this post is that I thought it might be useful to have somebody explaining why this different behavior -- or pointing to relevant documentation --, and that knowing about this effect might help other package/class developers who are eager of using LaTeX3/expl3. I'm aware of Frank Mittelbach's sound advice in a comment to this linked post with regard to switching off the expl3 syntax when loading LaTeX2e packages, but in this case it was just about the engine switch.

2
  • \pdftex_if_engine:TF just checks the engine used, which is pdfTeX for both pdflatex and latex. It will evaluate false if XeLaTeX or LuaLaTeX are used. In order to check for PDF output you still need to use \ifpdf.
    – egreg
    Sep 2, 2013 at 14:12
  • @egreg: But I got my PSTricks graphics right if they did not have nodes defined in terms of polar coordinates. I guess there must be something else going on. Or, does your comment explain this "partial sensitivity"?
    – Marcos
    Sep 2, 2013 at 14:19

1 Answer 1

5

There are three engines in use: pdftex, luatex and xetex. Both pdftex and luatex can be used for getting either PDF or DVI output, by calling them pdflatex or lualatex (for PDF output) and latex or dvilualatex (for DVI output).

If the engine is pdftex, independently if the call is pdflatex or latex, \pdftex_if_engine:TF evaluates to true, as expl3 macros are “output agnostic”. Similarly, \luatex_if_engine:TF evaluates to true with either lualatex or dvilualatex.

You still need \ifpdf for a check about the output.

It's possible to define an expl3 conditional based on ifpdf:

\usepackage{ifpdf}
\prg_new_conditional:Npnn \output_if_pdf: { p, T, F, TF }
 {
  \ifpdf \prg_return_true: \else: \prg_return_false: \fi:
 }

which will make available the “predicate” form \output_if_pdf_p: and the usual boolean functions \output_if_pdf:TF, \output_if_pdf:T and \output_if_pdf:TF

4
  • Though without understanding entirely yet the behavior I observed when compiling with my expl3 class using the LaTeX3 engine switch, now I understand much better what is going on in the relationship between the different engines and the output format. Thx for enhancing your original comment in the form of an answer.
    – Marcos
    Sep 2, 2013 at 15:41
  • 2
    @Marcos perhaps one additional comment here: as egreg explained these commands test which "engine" is used and the reason for having them is that different engines provide different primitives (sometimes the same functionality is done differently, sometims a certain functionality is only available in a specific engine). So they are there to allow the kernel (or a package to built some low-level support code in a different way depending on which engine actually runs. Perhaps they should have been marked "internal" but we anticipated that some packages may be written that only work with say lua Sep 2, 2013 at 18:58
  • @egreg: Oh, and thx for the new custom conditional. I'll put it to good use ;-)
    – Marcos
    Sep 3, 2013 at 9:40
  • @Frank Mittelbach: An insightful addition in a few words. Thanks so much, again.
    – Marcos
    Sep 3, 2013 at 9:42

You must log in to answer this question.

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