summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/generic/FAQ-en/faq-mac-prog.tex
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/doc/generic/FAQ-en/faq-mac-prog.tex')
-rw-r--r--Master/texmf-dist/doc/generic/FAQ-en/faq-mac-prog.tex51
1 files changed, 37 insertions, 14 deletions
diff --git a/Master/texmf-dist/doc/generic/FAQ-en/faq-mac-prog.tex b/Master/texmf-dist/doc/generic/FAQ-en/faq-mac-prog.tex
index 1d6cb2c2aeb..d2e379eed88 100644
--- a/Master/texmf-dist/doc/generic/FAQ-en/faq-mac-prog.tex
+++ b/Master/texmf-dist/doc/generic/FAQ-en/faq-mac-prog.tex
@@ -1,4 +1,4 @@
-% $Id: faq-mac-prog.tex,v 1.12 2010/04/12 22:33:01 rf10 Exp rf10 $
+% $Id: faq-mac-prog.tex,v 1.13 2011/02/13 23:08:45 rf10 Exp $
\section{Macro programming}
@@ -1375,11 +1375,43 @@ lamented Mike Downes.
\item[memoir.cls]\CTANref{memoir}
\end{ctanrefs}
-\Question[Q-ifpdf]{Am I using \PDFTeX{}?}
+\Question[Q-whatengine]{Am I using \pdftex{}, \xetex{} or \luatex{}?}
+\AliasQuestion{Q-ifpdf}
-It's often useful to know whether your macros are operating within
-\PDFTeX{} or within (``normal'') \TeX{}; getting the right answer is
-surprisingly tricky.
+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).
+
+There is now a comprehensive set of packages that answer the question
+for you. They all create a \tex{} conditional command:
+\begin{itemize}
+\item \Package{ifpdf} creates a command \csx{ifpdf},
+\item \Package{ifxetex} creates a command \csx{ifxetex} and
+\item \Package{ifluatex} creates a command \csx{ifluatex}.
+\end{itemize}
+These \tex{} commands may be used within the \latex{} conditional
+framework, as (for example):
+\begin{quote}
+ \csx{ifthenelse}\texttt{\char`\{}\cmdinvoke{boolean}{pdf}\texttt{\char`\}\char`\{\meta{if pdf}\char`\}\char`\{\meta{not pdf}\char`\}}
+\end{quote}
+
+The \Package{ifxetex} package also provides a command
+\csx{RequireXeTeX} 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.
+
+% khalighi's iftex package, too -- \require's for all engines, but i'm
+% not entirely sure of the conditionals, so "for later" if at all
+
+Now for those who want to do the job for themselves: here's a
+discussion of doing the job for \pdftex{} and \csx{ifpdf}~--- the
+eager programmer can regenerate \csx{ifxetex} or \csx{ifluatex} in the
+same fashion. It's not recommended\dots
Suppose you need to test whether your output will be \acro{PDF} or
\acro{DVI}. The natural thing is to check whether you have access to
@@ -1448,15 +1480,6 @@ output, you also need to know about the value of \csx{pdfoutput}:
\fi
\end{verbatim}
\end{quote}
-The above is, in essence, what Heiko Oberdiek's \Package{ifpdf}
-package does; the reasoning is the \acro{FAQ}'s interpretation of
-Heiko's explanation.
-
-As an aside: there are now analogous packages \Package{ifxetex} and
-\Package{ifluatex}, for the two up-and-coming \TeX{}-like engines (see
-the ``\TeX{} project'' answers covering % ! line break
-\Qref[\xetex{}~--- question]{\xetex{}}{Q-xetex}, and
-\Qref[\LuaTeX{}~--- question]{\LuaTeX{}}{Q-luatex}).
\begin{ctanrefs}
\item[ifpdf.sty]Distributed as part Heiko Oberdiek's bundle
\CTANref{oberdiek}[ifpdf]