Simple LaTeX package in the vein of \ifdraft that checks for documentclass options webedition (default) or printedition.
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Taha Ahmed 31037be7d6 First working release. Works as expected in thesis. 1 year ago
.gitignore First working release. Works as expected in thesis. 1 year ago
LICENSE First working release. Works as expected in thesis. 1 year ago
README.md First working release. Works as expected in thesis. 1 year ago
ifprintedition.dtx First working release. Works as expected in thesis. 1 year ago
ifprintedition.ins First working release. Works as expected in thesis. 1 year ago
ifprintedition.pdf First working release. Works as expected in thesis. 1 year ago
ifprintedition.sty First working release. Works as expected in thesis. 1 year ago

README.md

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.

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.

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 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 (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.