![\ifPDFTeX 无法识别 pdflatex](https://linux22.com/image/384707/%5CifPDFTeX%20%E6%97%A0%E6%B3%95%E8%AF%86%E5%88%AB%20pdflatex.png)
我iftex
从 CTAN 下载并安装了它。我想我是按照文档使用它的:
\documentclass{article}
\usepackage{iftex}
\ifPDFTeX
\errmessage{Don't use pdflatex. Use plain latex and dvipdf}
\else
\errmessage{Good. You aren't using pdflatex}
\fi
\end
但是,此构造无法识别。无论我使用还是 ,pdflatex
我都会收到消息“很好。您没有使用 pdflatex” 。latex
pdflatex
$ latex iftex.tex
This is pdfeTeX, Version 3.141592-1.21a-2.2 (Web2C 7.5.4)
entering extended mode
(./iftex.tex
LaTeX2e <2003/12/01>
Babel <v3.8d> and hyphenation patterns for american, french, german, ngerman, b
ahasa, basque, bulgarian, catalan, croatian, czech, danish, dutch, esperanto, e
stonian, finnish, greek, icelandic, irish, italian, latin, magyar, norsk, polis
h, portuges, romanian, russian, serbian, slovak, slovene, spanish, swedish, tur
kish, ukrainian, nohyphenation, loaded.
(/usr/share/texmf/tex/latex/base/article.cls
Document Class: article 2004/02/16 v1.4f Standard LaTeX document class
(/usr/share/texmf/tex/latex/base/size10.clo))
(/usr/share/texmf/tex/latex/iftex/iftex.sty)
! Good. You aren't using pdflatex.
l.6 \errmessage{Good. You aren't using pdflatex}
? x
No pages of output.
Transcript written on iftex.log.
$
$ pdflatex iftex.tex
This is pdfeTeX, Version 3.141592-1.21a-2.2 (Web2C 7.5.4)
entering extended mode
(./iftex.tex
LaTeX2e <2003/12/01>
Babel <v3.8d> and hyphenation patterns for american, french, german, ngerman,
[...]
nohyphenation, loaded.
(/usr/share/texmf/tex/latex/base/article.cls
Document Class: article 2004/02/16 v1.4f Standard LaTeX document class
(/usr/share/texmf/tex/latex/base/size10.clo))
(/usr/share/texmf/tex/latex/iftex/iftex.sty)
! Good. You aren't using pdflatex.
l.6 \errmessage{Good. You aren't using pdflatex}
? x
No pages of output.
Transcript written on iftex.log.
$
难道我做错了什么?
答案1
这\ifPDFTEX
正在检查引擎正在使用(TeX90 vs pdfTeX vs XeTeX vs LuaTeX),而不是输出格式. 为此,您需要以下ifpdf
包
\documentclass{article}
\usepackage{ifpdf}
\ifpdf
\errmessage{Don't use pdflatex. Use plain latex and dvipdf}
\else
\errmessage{Good. You aren't using pdflatex}
\fi
\end
答案2
在最近的 TeX 发行版中,latex 实际上是指向 pdftex(实际上是 pdfetex)的符号链接(或在不支持符号链接的系统中等效),它以 dvi 模式运行 latex 格式。