| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
% Copyright 2006, 2020 |
| 4 |
% Sergio Callegari <[email protected]> |
| 5 |
% |
| 6 |
% --------------------------------------------- |
| 7 |
% This file is part of the flippdf package, |
| 8 |
% a contribution to the LaTeX2e system. |
| 9 |
% --------------------------------------------- |
| 10 |
% |
| 11 |
% This work may be distributed and/or modified under the |
| 12 |
% conditions of the LaTeX Project Public License, version 1.3c. |
| 13 |
% This license is in |
| 14 |
% https://www.latex-project.org/lppl/lppl-1-3c/ |
| 15 |
% and is part of all distributions of LaTeX later than |
| 16 |
% 2008-05-04. |
| 17 |
% |
| 18 |
% This work has the LPPL maintenance status "maintained". |
| 19 |
% |
| 20 |
% This program consists of the files listed in the README.md file |
| 21 |
% included in the package. |
| 22 |
% |
| 23 |
%<*driver> |
| 24 |
\documentclass{ltxdoc} |
| 25 |
\usepackage{mathptmx} |
| 26 |
\usepackage[scaled=0.92]{helvet} |
| 27 |
\usepackage{hologo} |
| 28 |
\usepackage[T1]{fontenc} |
| 29 |
\usepackage{hypdoc} |
| 30 |
\EnableCrossrefs |
| 31 |
\CodelineIndex |
| 32 |
\RecordChanges |
| 33 |
\begin{document} |
| 34 |
\DocInput{flippdf.dtx} |
| 35 |
\end{document} |
| 36 |
%</driver> |
| 37 |
% |
| 38 |
% \fi |
| 39 |
% |
| 40 |
% \DoNotIndex{\NeedsTeXFormat, \documentclass} |
| 41 |
% \DoNotIndex{\begin, \end} |
| 42 |
% \DoNotIndex{\def, \gdef, \let, \newcommand} |
| 43 |
% \DoNotIndex{\ProvidesPackage, \RequirePackage, \usepackage, \PackageError} |
| 44 |
% \DoNotIndex{\DeclareOption, \ProcessOptions} |
| 45 |
% \DoNotIndex{\ifx, \fi, \newif, \else} |
| 46 |
% \DoNotIndex{\paperwidth, \space, \strip@pt} |
| 47 |
% \DoNotIndex{\maketitle, \title, \lipsum} |
| 48 |
% \DoNotIndex{\thispagestyle, \relax, \setcounter, \Large, \clearpage, \bigskip} |
| 49 |
% \DoNotIndex{\@ifundefined, \AtBeginDocument, \endinput, \MessageBreak} |
| 50 |
% \DoNotIndex{\PackageWarningNoLine} |
| 51 |
|
| 52 |
% \CheckSum{86} |
| 53 |
% |
| 54 |
% \def\filename{flippdf.dtx} |
| 55 |
% \def\fileversion{2.0b} |
| 56 |
% \def\filedate{2020/10/27} |
| 57 |
% \def\docdate{2020/10/27} |
| 58 |
% |
| 59 |
% \newcommand*{\Lpack}[1]{\textsf {#1}} ^^A typeset a package |
| 60 |
% \newcommand*{\Lopt}[1]{\textsf {#1}} ^^A typeset an option |
| 61 |
% \newcommand*{\file}[1]{\texttt {#1}} ^^A typeset a file |
| 62 |
% \newcommand*{\Lcount}[1]{\textsl {\small#1}} ^^A typeset a counter |
| 63 |
% \newcommand*{\pstyle}[1]{\textsl {#1}} ^^A typeset a pagestyle |
| 64 |
% \newcommand*{\Lenv}[1]{\texttt {#1}} ^^A typeset an environment |
| 65 |
% |
| 66 |
% \title{The \Lpack{flippdf} package\thanks{This file |
| 67 |
% (\texttt{\filename}) has version number \fileversion, last |
| 68 |
% revised \filedate.}} |
| 69 |
% |
| 70 |
% \author{% |
| 71 |
% Sergio Callegari\thanks{Sergio Callegari can be reached at |
| 72 |
% \texttt{sergio.callegar at gmail dot com}}} |
| 73 |
% |
| 74 |
% \date{\docdate} |
| 75 |
% |
| 76 |
% \maketitle |
| 77 |
% |
| 78 |
% \begin{abstract} |
| 79 |
% The \Lpack{pdfflip} package extends \hologo{pdfLaTeX} and |
| 80 |
% \hologo{LuaLaTeX} making it possible to typeset a ``mirrored'' version |
| 81 |
% of the document. This is sometimes required by publishers who use |
| 82 |
% photographic printing processes that need ``camera-ready'' documents |
| 83 |
% to be printable on transparent films, so that one reads the pages |
| 84 |
% correctly by looking \emph{through} the film with the \emph{unprinted} |
| 85 |
% side of the film towards his eyes. This package requires |
| 86 |
% \Lpack{everypage} by the same author and works exclusively with |
| 87 |
% \hologo{pdfLaTeX} and \hologo{LuaLaTeX} in PDF output mode. |
| 88 |
% \end{abstract} |
| 89 |
% |
| 90 |
% \section{Introduction} |
| 91 |
% |
| 92 |
% This \LaTeX\ package makes it possible to typeset a document flipping |
| 93 |
% its pages horizontally. This is sometimes required by publishers who use |
| 94 |
% photographic printing process that need ``camera-ready'' documents to be |
| 95 |
% printable on transparent films, so that one reads the pages correctly by |
| 96 |
% looking \emph{through} the film (i.e., with the \emph{unprinted} side of |
| 97 |
% the film towards his eyes). |
| 98 |
% |
| 99 |
% It is also possible to activate the mirroring capability on a page |
| 100 |
% by page basis. |
| 101 |
% |
| 102 |
% This package requires \Lpack{everypage} by the same author and works |
| 103 |
% exclusively with \hologo{pdfLaTeX} and \hologo{LuaLaTeX} in PDF output |
| 104 |
% mode. |
| 105 |
% |
| 106 |
% \section{User interface} |
| 107 |
% By default, once loaded as: |
| 108 |
% \begin{quote} |
| 109 |
% |\usepackage{pdfflip}| |
| 110 |
% \end{quote} |
| 111 |
% the \Lpack{pdfflip} becomes immediately \emph{active} (i.e., starts |
| 112 |
% flipping horizontally every page). Conversely, by selecting the |
| 113 |
% \Lopt{off} option as in |
| 114 |
% \begin{quote} |
| 115 |
% |\usepackage[off]{pdfflip}| |
| 116 |
% \end{quote} |
| 117 |
% The package is loaded but remains inactive. |
| 118 |
% |
| 119 |
% \DescribeMacro{\FlipPDF} The |\FlipPDF| command lets one switch on page |
| 120 |
% flipping. Conversely, \DescribeMacro{\UnFlipPDF}|\UnFlipPDF| switches |
| 121 |
% off page flipping. |
| 122 |
% |
| 123 |
% |
| 124 |
% \section{Examples} |
| 125 |
% \subsection{Plain case} |
| 126 |
% In this example, every page of the document is flipped, relying on the |
| 127 |
% automatic operation mode of the package. |
| 128 |
% \iffalse |
| 129 |
%<*test-1> |
| 130 |
% \fi |
| 131 |
% \begin{macrocode} |
| 132 |
\documentclass[a4paper]{article} |
| 133 |
\usepackage{flippdf} |
| 134 |
\usepackage{lipsum} |
| 135 |
|
| 136 |
\title{Test document for the flippdf package} |
| 137 |
|
| 138 |
\begin{document} |
| 139 |
\maketitle |
| 140 |
\lipsum[1-5] |
| 141 |
\end{document} |
| 142 |
% \end{macrocode} |
| 143 |
% \iffalse |
| 144 |
%</test-1> |
| 145 |
% \fi |
| 146 |
% |
| 147 |
% \subsection{Case with activation and deactivation} |
| 148 |
% In this example, the page flipping is manually activated and deactivated. |
| 149 |
% \iffalse |
| 150 |
%<*test-2> |
| 151 |
% \fi |
| 152 |
% \begin{macrocode} |
| 153 |
\documentclass[a4paper]{article} |
| 154 |
\usepackage[off]{flippdf} |
| 155 |
\usepackage{lipsum} |
| 156 |
|
| 157 |
\title{Test document for the flippdf package} |
| 158 |
|
| 159 |
\begin{document} |
| 160 |
|
| 161 |
\thispagestyle{empty} |
| 162 |
{\Large Some non-mirrored initial info} |
| 163 |
|
| 164 |
\bigskip |
| 165 |
|
| 166 |
\lipsum[1] |
| 167 |
|
| 168 |
\maketitle |
| 169 |
\setcounter{page}{1} |
| 170 |
\FlipPDF |
| 171 |
\lipsum[2-6] |
| 172 |
|
| 173 |
\clearpage |
| 174 |
\UnFlipPDF |
| 175 |
\thispagestyle{empty} |
| 176 |
{\Large Some non-mirrored final info} |
| 177 |
|
| 178 |
\bigskip |
| 179 |
|
| 180 |
\lipsum[7] |
| 181 |
\end{document} |
| 182 |
% \end{macrocode} |
| 183 |
% \iffalse |
| 184 |
%</test-2> |
| 185 |
% \fi |
| 186 |
% |
| 187 |
% \section{Package redesign} |
| 188 |
% |
| 189 |
% Until Fall 2020, \Lpack{flippdf} relied on package \Lpack{everypage} for |
| 190 |
% its operation. Recently, functionalities similar to those offered by |
| 191 |
% \Lpack{everypage} have been incorporated into \hologo{LaTeX} and |
| 192 |
% \Lpack{everypage} has been deprecated, maintaining support for it just |
| 193 |
% in view of compatibility for legacy packages still relying on it. As a |
| 194 |
% consequence, \Lpack{flippdf} has been redesigned to take advantage of the |
| 195 |
% new \hologo{LaTeX} features and to drop the dependence on |
| 196 |
% \Lpack{everypage}. |
| 197 |
% |
| 198 |
% Version 2.0 of \Lpack{flippdf} is the result of the redesign. Version |
| 199 |
% 1.x remains availabe las \Lpack{flippdf-1x} and modern \Lpack{flippdf} |
| 200 |
% knows how to fallback on it when used on a \hologo{LaTeX} format missing |
| 201 |
% the new features. |
| 202 |
% |
| 203 |
% \StopEventually {} |
| 204 |
% |
| 205 |
% \section{Implementation} |
| 206 |
% |
| 207 |
% \subsection{Implementation of \Lpack{flippdf}} |
| 208 |
% |
| 209 |
% \iffalse |
| 210 |
%<*flippdf> |
| 211 |
% \fi |
| 212 |
% \changes{R2.0}{2020/10/18}{Use modern \hologo{LaTeX} features.}% |
| 213 |
% Announce the name and version of the package, that requires |
| 214 |
% \hologo{LaTeX2e} (actually \hologo{pdfLaTeX} or \hologo{LuaLaTeX}). |
| 215 |
% \begin{macrocode} |
| 216 |
\NeedsTeXFormat{LaTeX2e} |
| 217 |
\ProvidesPackage{flippdf}% |
| 218 |
[2020/10/27 R2.0b Horizontal flipping of pages with pdfLaTeX] |
| 219 |
% \end{macrocode} |
| 220 |
% \changes{R2.0b}{2020/10/27}{Assure that options are passed to |
| 221 |
% \Lpack{flippdf-1x} when the old code is used.} |
| 222 |
% Depending on the actual functionalities provided by \hologo{LaTeX} |
| 223 |
% consider loading \Lpack{flippdf-1x}. If so doing, warn about this, |
| 224 |
% and hand over the operation to that package. |
| 225 |
% \begin{macrocode} |
| 226 |
\@ifundefined{AddToHook}{% |
| 227 |
\PackageWarningNoLine{flippdf}{% |
| 228 |
You appear to be running a version of LaTeX\MessageBreak |
| 229 |
unsupported by current flippdf.\MessageBreak |
| 230 |
Forcing fallback to `flippdf-1x` that\MessageBreak |
| 231 |
uses an older code base}% |
| 232 |
\RequirePackageWithOptions{flippdf-1x}% |
| 233 |
\endinput}{} |
| 234 |
% \end{macrocode} |
| 235 |
% State package requirements, including \Lpack{iftex} |
| 236 |
% \begin{macrocode} |
| 237 |
\RequirePackage{iftex} |
| 238 |
% \end{macrocode} |
| 239 |
% Error out if not working in PDF mode |
| 240 |
% \begin{macrocode} |
| 241 |
\AtBeginDocument{% |
| 242 |
\ifpdf |
| 243 |
\relax |
| 244 |
\else |
| 245 |
\PackageError{flippdf}{% |
| 246 |
package only works in pdf output mode.}% |
| 247 |
\fi} |
| 248 |
% \end{macrocode} |
| 249 |
% |
| 250 |
% \begin{macro}{\if@sc@flippdf} |
| 251 |
% Define a boolean variable to remember if pages are to be flipped or |
| 252 |
% not. |
| 253 |
% \begin{macrocode} |
| 254 |
\newif\if@sc@flippdf |
| 255 |
% \end{macrocode} |
| 256 |
% \end{macro} |
| 257 |
% |
| 258 |
% \begin{macro}{\FlipPDF}\begin{macro}{\UnFlipPDF} |
| 259 |
% Define the commands used to switch on and off the horizontal |
| 260 |
% flipping of the document pages. |
| 261 |
% \begin{macrocode} |
| 262 |
\newcommand\FlipPDF{\@sc@flippdftrue} |
| 263 |
\newcommand\UnFlipPDF{\@sc@flippdffalse} |
| 264 |
% \end{macrocode} |
| 265 |
% \end{macro}\end{macro} |
| 266 |
% |
| 267 |
% By default activate the flipping: |
| 268 |
% \begin{macrocode} |
| 269 |
\FlipPDF |
| 270 |
% \end{macrocode} |
| 271 |
% |
| 272 |
% Set up the processing of options: |
| 273 |
% \begin{macrocode} |
| 274 |
\DeclareOption{off}{\UnFlipPDF} |
| 275 |
\ProcessOptions |
| 276 |
% \end{macrocode} |
| 277 |
% |
| 278 |
% And eventually, tell \hologo{LaTeX} to flip every page, by using the |
| 279 |
% \Lpack{everypage} hook. First consider the case when running in |
| 280 |
% \hologo{pdfLaTeX} |
| 281 |
% \begin{macrocode} |
| 282 |
\ifpdftex |
| 283 |
\AddToHook{shipout/background}{% |
| 284 |
\if@sc@flippdf |
| 285 |
\pdfliteral direct {-1 0 0 1 \strip@pt\paperwidth\space 0 cm}% |
| 286 |
\fi}% |
| 287 |
\fi |
| 288 |
% \end{macrocode} |
| 289 |
% Then consider the case when running in \hologo{LuaLaTeX} |
| 290 |
% \changes{R1.1}{2020/10/17}{Extend package to work also with |
| 291 |
% \hologo{LuaLaTeX}.} |
| 292 |
% \begin{macrocode} |
| 293 |
\ifluatex |
| 294 |
\AddToHook{shipout/background}{% |
| 295 |
\if@sc@flippdf |
| 296 |
\pdfextension literal direct {% |
| 297 |
-1 0 0 1 \strip@pt\paperwidth\space 0 cm}% |
| 298 |
\fi}% |
| 299 |
\fi |
| 300 |
% \end{macrocode} |
| 301 |
% \iffalse |
| 302 |
%</flippdf> |
| 303 |
% \fi |
| 304 |
|
| 305 |
|
| 306 |
% \subsection{Implementation of \Lpack{flippdf-1x}} |
| 307 |
% \iffalse |
| 308 |
%<*flippdf-1x> |
| 309 |
% \fi |
| 310 |
% Announce the name and version of the package, that requires |
| 311 |
% \hologo{LaTeX2e} (actually \hologo{pdfLaTeX} or \hologo{LuaLaTeX}). |
| 312 |
% \changes{R1.0b}{2020/10/11}{% |
| 313 |
% Require \Lpack{everypage} package to be at least at its 2007/06/20 (R1.1) |
| 314 |
% release.} |
| 315 |
% \begin{macrocode} |
| 316 |
\NeedsTeXFormat{LaTeX2e} |
| 317 |
\ProvidesPackage{flippdf-1x}% |
| 318 |
[2020/10/17 1.1 Horizontal flipping of pages with pdfLaTeX] |
| 319 |
% \end{macrocode} |
| 320 |
% |
| 321 |
% Assure that the dependence on \Lpack{everypage} is satisfied. |
| 322 |
% \begin{macrocode} |
| 323 |
\RequirePackage{everypage}[2007/06/20] |
| 324 |
% \end{macrocode} |
| 325 |
% |
| 326 |
% Depend on \Lpack{iftex} and error out if not working in PDF mode |
| 327 |
% \changes{R1.1}{2020/10/17}{Error out if output mode is not PDF.}% |
| 328 |
% \begin{macrocode} |
| 329 |
\RequirePackage{iftex} |
| 330 |
\AtBeginDocument{% |
| 331 |
\ifpdf |
| 332 |
\relax |
| 333 |
\else |
| 334 |
\PackageError{flippdf}{% |
| 335 |
package only works in pdf output mode}% |
| 336 |
\fi} |
| 337 |
% \end{macrocode} |
| 338 |
% |
| 339 |
% \begin{macro}{\if@sc@flippdf} |
| 340 |
% Define a boolean variable to remember if pages are to be flipped or |
| 341 |
% not. |
| 342 |
% \begin{macrocode} |
| 343 |
\newif\if@sc@flippdf |
| 344 |
% \end{macrocode} |
| 345 |
% \end{macro} |
| 346 |
% |
| 347 |
% \begin{macro}{\FlipPDF}\begin{macro}{\UnFlipPDF} |
| 348 |
% Define the commands used to switch on and off the horizontal |
| 349 |
% flipping of the document pages. |
| 350 |
% \begin{macrocode} |
| 351 |
\newcommand\FlipPDF{\@sc@flippdftrue} |
| 352 |
\newcommand\UnFlipPDF{\@sc@flippdffalse} |
| 353 |
% \end{macrocode} |
| 354 |
% \end{macro}\end{macro} |
| 355 |
% |
| 356 |
% By default activate the flipping: |
| 357 |
% \begin{macrocode} |
| 358 |
\FlipPDF |
| 359 |
% \end{macrocode} |
| 360 |
% |
| 361 |
% Set up the processing of options: |
| 362 |
% \begin{macrocode} |
| 363 |
\DeclareOption{off}{\UnFlipPDF} |
| 364 |
\ProcessOptions |
| 365 |
% \end{macrocode} |
| 366 |
% |
| 367 |
% And eventually, tell \LaTeX\ to flip every page, by using the |
| 368 |
% \Lpack{everypage} hook. First consider the case when running in |
| 369 |
% \hologo{pdfLaTeX} |
| 370 |
% \begin{macrocode} |
| 371 |
\ifpdftex |
| 372 |
\AddEverypageHook{% |
| 373 |
\if@sc@flippdf |
| 374 |
\pdfliteral direct {-1 0 0 1 \strip@pt\paperwidth\space 0 cm}% |
| 375 |
\fi}% |
| 376 |
\fi |
| 377 |
% \end{macrocode} |
| 378 |
% Then consider the case when running in \hologo{LuaLaTeX} |
| 379 |
% \changes{R1.1}{2020/10/17}{Extend package to work also with |
| 380 |
% \hologo{LuaLaTeX}.} |
| 381 |
% \begin{macrocode} |
| 382 |
\ifluatex |
| 383 |
\AddEverypageHook{% |
| 384 |
\if@sc@flippdf |
| 385 |
\pdfextension literal direct {% |
| 386 |
-1 0 0 1 \strip@pt\paperwidth\space 0 cm}% |
| 387 |
\fi}% |
| 388 |
\fi |
| 389 |
% \end{macrocode} |
| 390 |
% \iffalse |
| 391 |
%</flippdf-1x> |
| 392 |
% \fi |
| 393 |
% |
| 394 |
% \Finale |
| 395 |
% \PrintChanges |
| 396 |
% \PrintIndex |
| 397 |
% |
| 398 |
% \CharacterTable |
| 399 |
% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z |
| 400 |
% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z |
| 401 |
% Digits \0\1\2\3\4\5\6\7\8\9 |
| 402 |
% Exclamation \! Double quote \" Hash (number) \# |
| 403 |
% Dollar \$ Percent \% Ampersand \& |
| 404 |
% Acute accent \' Left paren \( Right paren \) |
| 405 |
% Asterisk \* Plus \+ Comma \, |
| 406 |
% Minus \- Point \. Solidus \/ |
| 407 |
% Colon \: Semicolon \; Less than \< |
| 408 |
% Equals \= Greater than \> Question mark \? |
| 409 |
% Commercial at \@ Left bracket \[ Backslash \\ |
| 410 |
% Right bracket \] Circumflex \^ Underscore \_ |
| 411 |
% Grave accent \` Left brace \{ Vertical bar \| |
| 412 |
% Right brace \} Tilde \~} |
| 413 |
\endinput |
| 414 |
|
| 415 |
% %% Local Variables: |
| 416 |
% %% mode: doctex |
| 417 |
% %% TeX-master: t |
| 418 |
% %% End: |