diff options
Diffstat (limited to 'Master/texmf-dist/doc/generic/FAQ-en/html/FAQ-whatengine.html')
-rw-r--r-- | Master/texmf-dist/doc/generic/FAQ-en/html/FAQ-whatengine.html | 108 |
1 files changed, 108 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/generic/FAQ-en/html/FAQ-whatengine.html b/Master/texmf-dist/doc/generic/FAQ-en/html/FAQ-whatengine.html new file mode 100644 index 00000000000..47d47effccd --- /dev/null +++ b/Master/texmf-dist/doc/generic/FAQ-en/html/FAQ-whatengine.html @@ -0,0 +1,108 @@ +<head> +<title>UK TeX FAQ -- question label whatengine</title> +</head><body> +<h3>Am I using PDFTeX, XeTeX or LuaTeX?</h3> +<p/><p/>You often need to know what “engine” your macros are running on (the +engine is the TeX-derivative or TeX-alike processor that +typesets your document). The reason that you need to know is that the +set of functions available in each engine is different. Thus, for +TeX macros to run on any engine, they need to “know” what they +can and cannot do, which depends on the engine in use. Getting the +right answer is surprisingly tricky (see below for an elaboration of +one apparently simple test). +<p/>There is now a comprehensive set of packages that answer the question +for you. They all create a TeX conditional command: +<ul> +<li> <i>ifpdf</i> creates a command <code>\</code><code>ifpdf</code>, +<li> <i>ifxetex</i> creates a command <code>\</code><code>ifxetex</code> and +<li> <i>ifluatex</i> creates a command <code>\</code><code>ifluatex</code>. +</ul> +These TeX commands may be used within the LaTeX conditional +framework, as (for example): +<blockquote> + <code>\</code><code>ifthenelse</code><code>\char‘{</code><code>\</code><code>boolean{pdf}</code><code>\char‘}\char‘{<<i>if pdf</i>>\char‘}\char‘{<<i>not pdf</i>>\char‘}</code> +</blockquote><p> +<p/>The <i>ifxetex</i> package also provides a command +<code>\</code><code>RequireXeTeX</code> which creates an error if the code is not running +under XeTeX; while the other packages don’t provide such a command, +it’s not really difficult to write one for yourself. +<p/> + +<p/>Now for those who want to do the job for themselves: here’s a +discussion of doing the job for PDFTeX and <code>\</code><code>ifpdf</code> — the +eager programmer can regenerate <code>\</code><code>ifxetex</code> or <code>\</code><code>ifluatex</code> in the +same fashion. It’s not recommended\dots +<p/>Suppose you need to test whether your output will be PDF or +DVI. The natural thing is to check whether you have access to +some PDFTeX-only primitive; a good one to try (not least because it +was present in the very first releases of PDFTeX) is +<code>\</code><code>pdfoutput</code>. So you try +<blockquote> +<pre> +\ifx\pdfoutput\undefined + ... % not running PDFTeX +\else + ... % running PDFTeX +\fi +</pre> +</blockquote><p> +Except that neither branch of this conditional is rock-solid. The +first branch can be misleading, since the “awkward” user could have +written: +<blockquote> +<pre> +\let\pdfoutput\undefined +</pre> +</blockquote><p> +so that your test will falsely choose the first alternative. While +this is a theoretical problem, it is unlikely to be a major one. +<p/>More important is the user who loads a package that uses +LaTeX-style testing for the command name’s existence (for example, +the LaTeX <i>graphics</i> package, which is useful even to the +Plain TeX user). Such a package may have gone ahead of you, so the +test may need to be elaborated: +<blockquote> +<pre> +\ifx\pdfoutput\undefined + ... % not running PDFTeX +\else + \ifx\pdfoutput\relax + ... % not running PDFTeX + \else + ... % running PDFTeX + \fi +\fi +</pre> +</blockquote><p> +If you only want to know whether some PDFTeX extension (such as +marginal kerning) is present, you can stop at this point: you know as +much as you need. +<p/>However, if you need to know whether you’re creating PDF +output, you also need to know about the value of <code>\</code><code>pdfoutput</code>: +<blockquote> +<pre> +\ifx\pdfoutput\undefined + ... % not running PDFTeX +\else + \ifx\pdfoutput\relax + ... % not running PDFTeX + \else + % running PDFTeX, with... + \ifnum\pdfoutput>0 + ... % PDF output + \else + ... % DVI output + \fi + \fi +\fi +</pre> +</blockquote><p> +<dl> +<dt><tt><i>ifpdf.sty</i></tt><dd>Distributed as part Heiko Oberdiek’s bundle + <a href="http://mirror.ctan.org/macros/latex/contrib/oberdiek.zip">macros/latex/contrib/oberdiek</a> (or <a href="http://mirror.ctan.org/macros/latex/contrib/oberdiek/">browse the directory</a>); <a href="http://mirror.ctan.org/help/Catalogue/entries/ifpdf.html">catalogue entry</a> +<dt><tt><i>ifluatex.sty</i></tt><dd>Distributed as part of Heiko Oberdiek’s bundle + <a href="http://mirror.ctan.org/macros/latex/contrib/oberdiek.zip">macros/latex/contrib/oberdiek</a> (or <a href="http://mirror.ctan.org/macros/latex/contrib/oberdiek/">browse the directory</a>); <a href="http://mirror.ctan.org/help/Catalogue/entries/ifluatex.html">catalogue entry</a> +<dt><tt><i>ifxetex.sty</i></tt><dd><a href="http://mirror.ctan.org/macros/generic/ifxetex.zip">macros/generic/ifxetex</a> (or <a href="http://mirror.ctan.org/macros/generic/ifxetex/">browse the directory</a>); <a href="http://mirror.ctan.org/help/Catalogue/entries/ifxetex.html">catalogue entry</a> +</dl> +<p/><p>This question on the Web: <a href="http://www.tex.ac.uk/cgi-bin/texfaq2html?label=whatengine">http://www.tex.ac.uk/cgi-bin/texfaq2html?label=whatengine</a> +</body> |