| 1 |
\documentclass[pagesize=auto, fontsize=12pt, DIV=10]{scrartcl} |
| 2 |
|
| 3 |
\usepackage{fixltx2e} |
| 4 |
\usepackage{etex} |
| 5 |
\usepackage{xspace} |
| 6 |
\usepackage{lmodern} |
| 7 |
\usepackage[T1]{fontenc} |
| 8 |
\usepackage{textcomp} |
| 9 |
\usepackage{microtype} |
| 10 |
\usepackage{hyperref} |
| 11 |
|
| 12 |
\newcommand*{\mail}[1]{\href{mailto:#1}{\texttt{#1}}} |
| 13 |
\newcommand*{\pkg}[1]{\textsf{#1}} |
| 14 |
\newcommand*{\cs}[1]{\texttt{\textbackslash#1}} |
| 15 |
\makeatletter |
| 16 |
\newcommand*{\cmd}[1]{\cs{\expandafter\@gobble\string#1}} |
| 17 |
\makeatother |
| 18 |
\newcommand*{\opt}[1]{\texttt{#1}} |
| 19 |
|
| 20 |
\addtokomafont{title}{\rmfamily} |
| 21 |
|
| 22 |
\title{The \pkg{optional} package\thanks{This manual corresponds to \pkg{optional}~v2.2b, dated~2005/01/26.}} |
| 23 |
\author{Donald Arseneau\thanks{\mail{[email protected]}}} |
| 24 |
\date{2005/01/26} |
| 25 |
|
| 26 |
|
| 27 |
\begin{document} |
| 28 |
|
| 29 |
\maketitle |
| 30 |
|
| 31 |
\begin{abstract} |
| 32 |
\noindent |
| 33 |
Enable multiple versions of a document to be printed from one source file, |
| 34 |
especially if most of the text is shared between versions. |
| 35 |
\end{abstract} |
| 36 |
|
| 37 |
\begin{quote} |
| 38 |
\scriptsize |
| 39 |
Copyright 1993, 1999, 2001, 2005 by Donald Arseneau (\mail{[email protected]}). |
| 40 |
This software is released under the terms of the \LaTeX\ Project Public |
| 41 |
License (\url{ftp://ctan.tug.org/tex-archive/macros/latex/base/lppl.txt}). |
| 42 |
(Essentially: Free to use, copy, distribute (sell) and change, but, if |
| 43 |
changed, that fact must be made apparent to the user.) It has a |
| 44 |
status of ``maintained''. |
| 45 |
\end{quote} |
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
\section{How to use} |
| 50 |
|
| 51 |
One way to use this package is to declare (for example) |
| 52 |
% |
| 53 |
\begin{verbatim} |
| 54 |
\usepackage[opta]{optional} |
| 55 |
\end{verbatim} |
| 56 |
% |
| 57 |
at the beginning of your document, and flag optional text throughout |
| 58 |
your document like: |
| 59 |
% |
| 60 |
\begin{verbatim} |
| 61 |
\opt{opta}{Do this if option opta was declared} |
| 62 |
\opt{optb}{Do this if option optb was declared} |
| 63 |
\opt{optx,opty}{Do this if either option optx or opty} |
| 64 |
\opt{}{Never print this text!} |
| 65 |
\opt{opta}{\input{appendices}} |
| 66 |
\optv{xam}{Type: \verb|[root /]$ rm -r *|.} |
| 67 |
\end{verbatim} |
| 68 |
% |
| 69 |
Note that both the package option and the ``\cmd{\opt}'' argument can contain |
| 70 |
lists of options although, in practice, one or the other should be a |
| 71 |
single option name. Lists are allowed in both places to allow more |
| 72 |
flexibility in the style of use. (But making the definitions much more |
| 73 |
difficult, Grrr.) |
| 74 |
|
| 75 |
Just as for ``\cmd{\includeonly}'', you will have to edit the main document |
| 76 |
file to switch option codes (i.\,e.,\ change the ``\cmd{\usepackage}'' line). |
| 77 |
There are, however, several ways to use this package without altering |
| 78 |
the main document file: separate files, file-name sensing, interactive |
| 79 |
prompting, and command-line option selection. |
| 80 |
|
| 81 |
Typically, different versions of a document will require different |
| 82 |
document class and package setup, besides the different tags for |
| 83 |
\pkg{optional.sty}. In that case it is best to have a separate main file |
| 84 |
for each version of the document. Each stub file will declare the |
| 85 |
document class and load some packages (including this one) and then |
| 86 |
input the rest of the document from a file common to all versions. |
| 87 |
% |
| 88 |
\begin{verbatim} |
| 89 |
\documentclass[A0]{poster} |
| 90 |
\usepackage[poster]{optional} |
| 91 |
\input{my_paper} |
| 92 |
\end{verbatim} |
| 93 |
% |
| 94 |
If the different opt-tags match the different stub file names (file |
| 95 |
\texttt{poster.tex} will typeset the ``\opt{poster}'' version) then you can specify |
| 96 |
% |
| 97 |
\begin{verbatim} |
| 98 |
\usepackage[\jobname]{optional} |
| 99 |
\end{verbatim} |
| 100 |
% |
| 101 |
Alternatively, this ``\cmd{\jobname}'' technique can make use of symbolic links, |
| 102 |
if your computer system supports them, by having a single main input |
| 103 |
file accessed under different names (and different ``\cmd{\jobname}''s). |
| 104 |
|
| 105 |
Another scheme is to invoke \LaTeX\ with the command line such as: |
| 106 |
% |
| 107 |
\begin{verbatim} |
| 108 |
latex "\def\UseOption{opta,optb}\input{file}" |
| 109 |
\end{verbatim} |
| 110 |
% |
| 111 |
(with quoting appropriate to your operating system) then options ``\opt{opta}'' |
| 112 |
and ``\opt{optb}'' will be used in addition to any options specified with the |
| 113 |
``\cmd{\usepackage}'' command. |
| 114 |
|
| 115 |
You can prompt yourself to specify the option(s) with every run |
| 116 |
through \LaTeX: |
| 117 |
% |
| 118 |
\begin{verbatim} |
| 119 |
\usepackage{optional} |
| 120 |
\newcommand{\ExplainOptions}{man = users manual, check = checklist, |
| 121 |
ref = reference card, post = poster.} |
| 122 |
\AskOption |
| 123 |
\end{verbatim} |
| 124 |
% |
| 125 |
The definition of ``\cmd{\ExplainOptions}'' is optional; it only serves to help |
| 126 |
the person who answers the question. The ``\cmd{\AskOption}'' is also optional; |
| 127 |
it will be executed automatically whenever optional.sty sees no list of |
| 128 |
options. This method is too tedious to use much. |
| 129 |
|
| 130 |
The normal restrictions forbidding special characters in package options |
| 131 |
and reference tags apply also the the tags used by the ``\cmd{\opt}'' command. |
| 132 |
|
| 133 |
These are not `comment' macros: The optional text must be well-formed |
| 134 |
with balanced braces, even if not printed. The ``\cmd{\opt}'' command \emph{is} |
| 135 |
completely `expandable' which means it is robust and can even be used |
| 136 |
in messages (``\cmd{\typeout}''). |
| 137 |
|
| 138 |
As usual, ``\cmd{\verb}'' commands and verbatim environments cannot be used |
| 139 |
in the argument to ``\cmd{\opt}''. For this purpose there is a variant form |
| 140 |
of ``\cmd{\opt}'' called ``\cmd{\optv}'' (optional verbatim) which may have a limited |
| 141 |
class of verbatim material in the argument. It can do so by leaving |
| 142 |
the braces around the argument, which may have undesired side effects. |
| 143 |
For an ``\cmd{\optv}'' argument to be successfully ignored, the verbatim material |
| 144 |
must have balanced braces etc. |
| 145 |
|
| 146 |
The ``\cmd{\opt}'' command is only intended for small sections of text. If you |
| 147 |
need to optionally include whole sections or chapters, put that material |
| 148 |
in a separate file, and ``\cmd{\opt}''-ionally use an ``\cmd{\input}'' command: |
| 149 |
% |
| 150 |
\begin{verbatim} |
| 151 |
\opt{internal}{\input{prog_listings}} |
| 152 |
\end{verbatim} |
| 153 |
|
| 154 |
\end{document} |