# ifprintedition A small package that emulates the behaviour of `ifdraft` but for two other documentclass options, namely, `webedition` (the implicit default) and `printedition`. ## Package development The `.dtx` file is the source, in combination with the `.ins` file. **Step 1**: generate the `.sty` file using TeX: `tex ifprintedition.ins` ``` taha@luxor:/usr/local/texlive/texmf-local/tex/latex/ifprintedition $ tex ifprintedition.ins This is TeX, Version 3.141592653 (TeX Live 2023) (preloaded format=tex) (./ifprintedition.ins (/usr/local/texlive/2023/texmf-dist/tex/latex/base/docstrip.tex Utility: `docstrip' v2.6b <2022-09-03> English documentation <2022-09-03> ********************************************************** * This program converts documented macro-files into fast * * loadable files by stripping off (nearly) all comments! * ********************************************************** ******************************************************** * No Configuration file found, using default settings. * ******************************************************** ) Generating file(s) ifprintedition.sty Processing file ifprintedition.dtx (package) -> ifprintedition.sty File ifprintedition.dtx ended by \endinput. Lines processed: 127 Comments removed: 88 Comments passed: 0 Codelines passed: 31 ************************************************************************ * * To finish the installation you have to move the following * file into a directory searched by TeX: * * ifprintedition.sty * * To produce the documentation run the file `ifprintedition.drv' * through LaTeX. * * Happy TeXing! * ************************************************************************ ) No pages of output. Transcript written on ifprintedition.log. ``` The above command requires interactively pressing `y` to allow it to overwrite an already existing `ifprintedition.sty` file, which is very annoying. > Ok, I added `\askforoverwritefalse` to the `ins` file, this successfully overrides > the interactive confirmation step. **Step 2**: generate PDF documentation from `dtx` using LaTeX: `pdflatex ifprintedition.dtx` ``` taha@luxor:/usr/local/texlive/texmf-local/tex/latex/ifprintedition $ pdflatex ifprintedition.dtx This is pdfTeX, Version 3.141592653-2.6-1.40.25 (TeX Live 2023) (preloaded format=pdflatex) restricted \write18 enabled. entering extended mode ./ifprintedition.dtx LaTeX2e <2022-11-01> patch level 1 L3 programming layer <2023-02-22> /usr/local/texlive/2023/texmf-dist/tex/latex/base/ltxdoc.cls Document Class: ltxdoc 2022/06/22 v2.1i Standard LaTeX documentation class ************************************* * Local config file ltxdoc.cfg used ************************************* [...] *************************** * Character table correct * *************************** [1{/usr/local/texlive/2023/texmf-var/fonts/map/pdftex/updmap/pdftex.map}] No file ifprintedition.ind. ********************************** * This macro file has no checksum! * The checksum should be 23! ********************************** No file ifprintedition.gls. ``` Now is a good time to edit the `% \CheckSum{0}` line in the `dtx` file with the correct number. > Note, during development you might want to reset to `\CheckSum{0}` to > avoid compilation errors and having to reset it manually on every re-compile. And you might want to use `latexmk -pdf ...` instead of `pdflatex ...` to run the requisite number of compilations and also generate index, etc. ## In your documentclass file This package works in conjunction with the following settings in [my LuaUUThesis class](https://git.solarchemist.se/config/texmf-latex/src/branch/master/LuaUUThesis.cls) (summarised below): ``` \newif\if@webedition \newif\if@printedition % set webedition by default \@webeditiontrue \@printeditionfalse \DeclareOption{webedition}{ \PassOptionsToClass{\CurrentOption}{book} \@webeditiontrue \@printeditionfalse } \DeclareOption{printedition}{ \PassOptionsToClass{\CurrentOption}{book} \@printeditiontrue \@webeditionfalse } ``` You will need to set something similar in your own documentclass for the `\ifprintedition{}{}` commands to have any effect. ## Links + https://tex.stackexchange.com/questions/351644/use-latexmk-on-dtx-file-and-then-run-it-again-on-the-tex-files-it-creates + https://aperiodical.com/2019/03/realhats-writing-a-latex-package/ + https://tex.stackexchange.com/questions/21262/what-do-firstoftwo-and-secondoftwo-do + https://en.wikibooks.org/wiki/LaTeX/Creating_Packages + https://ftpmirror1.infania.net/mirror/CTAN/info/dtxtut/dtxtut.pdf + https://tex.stackexchange.com/questions/34175/how-do-i-create-a-latex-package + https://www.overleaf.com/learn/latex/Writing_your_own_package + https://tex.stackexchange.com/questions/21909/classes-and-packages-whats-the-difference + https://tex.stackexchange.com/questions/74941/add-option-to-class-with-command