-
Notifications
You must be signed in to change notification settings - Fork 0
/
ifpdf.dtx
143 lines (140 loc) · 3.64 KB
/
ifpdf.dtx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
% \iffalse
%% Source File: ifpdf.dtx
%% Copyright 2016-2018 Heiko Oberdiek and LaTeX3 project
%%
%% This file may be distributed under the terms of the LPPL.
%% https://www.latex-project.org/lppl/
%
%<*ignore>
\ifx\ProvidesFile\undefined\let\install y\fi
\ifx\install y\else
\long\def\tmp#1\endbatchfile{}
\expandafter\tmp
\fi
%</ignore>
%<*install>
\input docstrip
\keepsilent
\preamble
\endpreamble
\askforoverwritefalse
\generate{
%<*ignore>
\file{ifpdf.ins}{\from{ifpdf.dtx}{install}}
%</ignore>
\file{ifpdf.sty}{\from{ifpdf.dtx}{package}}
}
\endbatchfile
%</install>
%<*dtx>
\ProvidesFile{ifpdf.dtx}
%</dtx>
%<*!install>
%<package>\ifnum1=0\ifx\ProvidesPackage\undefined1\else\ifx\ProvidesPackage\relax1\fi\fi
%<package>\def\next#1#2[#3]{\wlog{#2 #3}\expandafter\gdef
%<package>\csname ver\string @ifpdf.sty\endcsname{#3}}
%<package>\expandafter\next\fi
%<package>\ProvidesPackage{ifpdf}%
%<driver> \ProvidesFile{ifpdf.drv}
% \fi
% \ProvidesFile{ifpdf.dtx}
[2018/09/07 v3.3 Provides the ifpdf switch]
% \iffalse
%</!install>
%
%<*driver>
\documentclass{ltxdoc}
\usepackage{hyperref}
\begin{document}
\tableofcontents
\DocInput{ifpdf.dtx}
\end{document}
%</driver>
% \fi
%
% \GetFileInfo{ifpdf.dtx}
%
% \title{The \textsf{ifpdf} Package\thanks{This file
% has version number \fileversion, last
% revised \filedate.
% Please report any issues at \url{https://github.com/ho-tex/oberdiek/issues}}}
% \author{LaTeX3 project}
% \date{\filedate}
% \maketitle
%
% \section{Introduction}
%
% A re-implementation of Heiko Oberdiek's \textsf{ifpdf} package
% with simplified structure and updated to work with current Lua\TeX.
%
% The package defines a new boolean, \verb|\ifpdf| which is true
% for pdf\TeX\ and Lua\TeX\ in PDF mode, and false otherwise.
%
% \section{Implementation}
%
% \begin{macrocode}
%<*package>
% \end{macrocode}
%
% If \verb|\ifpdf| is not defined define it, taking care that it is
% outer in plain \TeX.
% \begin{macrocode}
\expandafter\ifx\csname ifpdf\endcsname\relax
\csname newif\expandafter\endcsname\csname ifpdf\endcsname
\else
% \end{macrocode}
% If \verb|\ifpdf| is already defined but \verb|\pdftrue| is not defined
% give up.
% \begin{macrocode}
\ifx\pdftrue\undefined
\ifx\PackageError\undefined
\begingroup\def\PackageError#1#2#3{\endgroup\errmessage{#2}}
\fi
\PackageError{ifpdf}{incompatible ifpdf definition}{}
\expandafter\expandafter\expandafter
\fi
\fi
% \end{macrocode}
% Otherwise set the boolean to false unless pdfoutput (outputmode) is greater than zero.
% For Lua\TeX, do the test in Lua as the tex primitivies may not be enabled, and
% the primitive name may be \verb|\pdfoutput| or \verb|\outputmode| depending
% on the Lua\TeX\ version number.
% \begin{macrocode}
\let\ifpdf\iffalse
% \end{macrocode}
%
% \begin{macrocode}
\ifx\directlua\undefined
% \end{macrocode}
% Not Lua\TeX.
% \begin{macrocode}
\begingroup\expandafter\expandafter\expandafter\endgroup
\expandafter\ifx\csname pdfoutput\endcsname\relax
\else
\ifnum\pdfoutput>0 %
\pdftrue
\fi
\fi
\else
% \end{macrocode}
% Lua\TeX.
% \begin{macrocode}
\directlua{%
if (tex.outputmode or tex.pdfoutput or 0) > 0 then
tex.print('\string\\pdftrue')
end
}
\fi
% \end{macrocode}
%
% \begin{macrocode}
%</package>
% \end{macrocode}
%
% \endinput
% 2016/04/04 v3.0 rewrite to be self standing and work with new luatex/
% 2016/05/14 v3.1 define [email protected] in plain tex.
% 2017/03/15 v3.2 define ver\[email protected] in amstex tex.
% https://github.com/ho-tex/oberdiek/issues/23
% 2018/09/07 v3.3 guard against \ProvidesPackage being \relax
% https://github.com/ho-tex/oberdiek/issues/38