summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/optional
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/latex/contrib/optional
Initial commit
Diffstat (limited to 'macros/latex/contrib/optional')
-rw-r--r--macros/latex/contrib/optional/optional.pdfbin0 -> 303670 bytes
-rw-r--r--macros/latex/contrib/optional/optional.sty158
-rw-r--r--macros/latex/contrib/optional/optional.tex154
3 files changed, 312 insertions, 0 deletions
diff --git a/macros/latex/contrib/optional/optional.pdf b/macros/latex/contrib/optional/optional.pdf
new file mode 100644
index 0000000000..102c135aa3
--- /dev/null
+++ b/macros/latex/contrib/optional/optional.pdf
Binary files differ
diff --git a/macros/latex/contrib/optional/optional.sty b/macros/latex/contrib/optional/optional.sty
new file mode 100644
index 0000000000..847589cb61
--- /dev/null
+++ b/macros/latex/contrib/optional/optional.sty
@@ -0,0 +1,158 @@
+%
+% O P T I O N A L . S T Y
+% ~~~~~~~~~~~~~~~~~~~~~~~
+% ver 2.2b Jan 2005
+%
+% Enable multiple versions of a document to be printed from one source file,
+% especially if most of the text is shared between versions.
+%
+% Copyright 1993,1999,2001,2005 by Donald Arseneau (asnd@triumf.ca).
+% This software is released under the terms of the LaTeX Project Public
+% License (ftp://ctan.tug.org/tex-archive/macros/latex/base/lppl.txt).
+% (Essentially: Free to use, copy, distribute (sell) and change, but, if
+% changed, that fact must be made apparent to the user.) It has a
+% status of "maintained".
+%
+%
+% HOW TO USE
+% ~~~~~~~~~~
+% One way to use this package is to declare (for example)
+%
+% \usepackage[opta]{optional}
+%
+% at the beginning of your document, and flag optional text throughout
+% your document like:
+%
+% \opt{opta}{Do this if option opta was declared}
+% \opt{optb}{Do this if option optb was declared}
+% \opt{optx,opty}{Do this if either option optx or opty}
+% \opt{}{Never print this text!}
+% \opt{opta}{\input{appendices}}
+% \optv{xam}{Type: \verb|[root /]$ rm -r *|.}
+%
+% Note that both the package option and the "\opt" argument can contain
+% lists of options although, in practice, one or the other should be a
+% single option name. Lists are allowed in both places to allow more
+% flexibility in the style of use. (But making the definitions much more
+% difficult, Grrr.)
+%
+% Just as for "\includeonly", you will have to edit the main document
+% file to switch option codes (i.e., change the "\usepackage" line).
+% There are, however, several ways to use this package without altering
+% the main document file: separate files, file-name sensing, interactive
+% prompting, and command-line option selection.
+%
+% Typically, different versions of a document will require different
+% document class and package setup, besides the different tags for
+% optional.sty. In that case it is best to have a separate main file
+% for each version of the document. Each stub file will declare the
+% document class and load some packages (including this one) and then
+% input the rest of the document from a file common to all versions.
+%
+% \documentclass[A0]{poster}
+% \usepackage[poster]{optional}
+% \input{my_paper}
+%
+% If the different opt-tags match the different stub file names (file
+% poster.tex will typeset the "poster" version) then you can specify
+%
+% \usepackage[\jobname]{optional}
+%
+% Alternatively, this "\jobname" technique can make use of symbolic links,
+% if your computer system supports them, by having a single main input
+% file accessed under different names (and different "\jobname"s).
+%
+% Another scheme is to invoke LaTeX with the command line such as:
+%
+% latex "\def\UseOption{opta,optb}\input{file}"
+%
+% (with quoting appropriate to your operating system) then options "opta"
+% and "optb" will be used in addition to any options specified with the
+% "\usepackage" command.
+%
+% You can prompt yourself to specify the option(s) with every run
+% through LaTeX:
+%
+% \usepackage{optional}
+% \newcommand{\ExplainOptions}{man = users manual, check = checklist,
+% ref = reference card, post = poster.}
+% \AskOption
+%
+% The definition of "\ExplainOptions" is optional; it only serves to help
+% the person who answers the question. The "\AskOption" is also optional;
+% it will be executed automatically whenever optional.sty sees no list of
+% options. This method is too tedious to use much.
+%
+% The normal restrictions forbidding special characters in package options
+% and reference tags apply also the the tags used by the "\opt" command.
+%
+% These are not `comment' macros: The optional text must be well-formed
+% with balanced braces, even if not printed. The "\opt" command *IS*
+% completely `expandable' which means it is robust and can even be used
+% in messages ("\typeout").
+%
+% As usual, "\verb" commands and verbatim environments cannot be used
+% in the argument to "\opt". For this purpose there is a variant form
+% of "\opt" called "\optv" (optional verbatim) which may have a limited
+% class of verbatim material in the argument. It can do so by leaving
+% the braces around the argument, which may have undesired side effects.
+% For an "\optv" argument to be successfully ignored, the verbatim material
+% must have balanced braces etc.
+%
+% The "\opt" command is only intended for small sections of text. If you
+% need to optionally include whole sections or chapters, put that material
+% in a separate file, and "\opt"-ionally use an "\input" command:
+%
+% \opt{internal}{\input{prog_listings}}
+%
+%====================== END INSTRUCTIONS ========================
+
+\ProvidesPackage{optional}[2005/01/26 ver 2.2b; \space
+ Optional inclusion/omission]
+% Initialize used-option-list to \@gobble to eat the comma when the first
+% entry is `appended'.
+\@ifundefined{UseOption}{\let\UseOption\@gobble}{}
+\DeclareOption*{\edef\UseOption{\UseOption,\CurrentOption}}
+\ProcessOptions
+\AtBeginDocument{\Opl@Setup}
+
+\newcommand*\opt[1]{\if\Opl@notlisted{#1}\expandafter\@gobble
+ \else \expandafter\@firstofone \fi}
+
+\newcommand*\optv[1]{\if\Opl@notlisted{#1}\expandafter\@gobble\fi}
+
+% This initial definition forces immediate setup if \opt used in the preamble
+\def\Opl@notlisted{\fi \Opl@Setup \if\Opl@notlisted}
+
+\newcommand\AskOption{%
+ \@ifundefined{ExplainOptions}{}{\typeout{\ExplainOptions}}%
+ \typein[\UseOption]{Specify which optional text to process:}%
+ }
+
+\def\Opl@Setup{%
+ \ifx\UseOption\@gobble\AskOption\fi
+ \let\Opl@notlisted\@empty % initialize list of checks
+ \@for\@tempa:=\UseOption\do{%
+ \ifx\@tempa\@empty\else\expandafter\Opl@oneop\expandafter{\@tempa}\fi}%
+ \ifx\Opl@notlisted\@empty \PackageWarning{optional}%
+ {No options were selected, so all optional text will be printed}%
+ \let\opt\@secondoftwo
+ \else
+ \typeout{Using optional text marked with \UseOption. }%
+ \toks@\expandafter{\Opl@notlisted}%
+ \edef\@tempa{\def\noexpand\Opl@notlisted####1{,\the\toks@,}}\@tempa
+ \fi
+ \let\Opl@Setup\@empty \let\Opl@oneop\undefined
+ \let\AskOption\undefined \let\ExplainOptions\undefined
+}
+\begingroup
+\catcode`\Z= 3 % special delimiter
+\gdef\Opl@oneop#1{%
+ \@ifundefined{Opl@Match@#1}{%
+ \toks@\expandafter{\Opl@notlisted}%
+ \edef\Opl@notlisted{\the\toks@ \csname Opl@Match@#1\endcsname ,####1,#1,Z}%
+ \@namedef{Opl@Match@#1}##1,#1,##2Z{##2}%
+ }\relax
+}
+\endgroup
+\endinput
diff --git a/macros/latex/contrib/optional/optional.tex b/macros/latex/contrib/optional/optional.tex
new file mode 100644
index 0000000000..1e3cabba56
--- /dev/null
+++ b/macros/latex/contrib/optional/optional.tex
@@ -0,0 +1,154 @@
+\documentclass[pagesize=auto, fontsize=12pt, DIV=10]{scrartcl}
+
+\usepackage{fixltx2e}
+\usepackage{etex}
+\usepackage{xspace}
+\usepackage{lmodern}
+\usepackage[T1]{fontenc}
+\usepackage{textcomp}
+\usepackage{microtype}
+\usepackage{hyperref}
+
+\newcommand*{\mail}[1]{\href{mailto:#1}{\texttt{#1}}}
+\newcommand*{\pkg}[1]{\textsf{#1}}
+\newcommand*{\cs}[1]{\texttt{\textbackslash#1}}
+\makeatletter
+\newcommand*{\cmd}[1]{\cs{\expandafter\@gobble\string#1}}
+\makeatother
+\newcommand*{\opt}[1]{\texttt{#1}}
+
+\addtokomafont{title}{\rmfamily}
+
+\title{The \pkg{optional} package\thanks{This manual corresponds to \pkg{optional}~v2.2b, dated~2005/01/26.}}
+\author{Donald Arseneau\thanks{\mail{asnd@triumf.ca}}}
+\date{2005/01/26}
+
+
+\begin{document}
+
+\maketitle
+
+\begin{abstract}
+ \noindent
+ Enable multiple versions of a document to be printed from one source file,
+ especially if most of the text is shared between versions.
+\end{abstract}
+
+\begin{quote}
+ \scriptsize
+ Copyright 1993, 1999, 2001, 2005 by Donald Arseneau (\mail{asnd@triumf.ca}).
+ This software is released under the terms of the \LaTeX\ Project Public
+ License (\url{ftp://ctan.tug.org/tex-archive/macros/latex/base/lppl.txt}).
+ (Essentially: Free to use, copy, distribute (sell) and change, but, if
+ changed, that fact must be made apparent to the user.) It has a
+ status of ``maintained''.
+\end{quote}
+
+
+
+\section{How to use}
+
+One way to use this package is to declare (for example)
+%
+\begin{verbatim}
+\usepackage[opta]{optional}
+\end{verbatim}
+%
+at the beginning of your document, and flag optional text throughout
+your document like:
+%
+\begin{verbatim}
+\opt{opta}{Do this if option opta was declared}
+\opt{optb}{Do this if option optb was declared}
+\opt{optx,opty}{Do this if either option optx or opty}
+\opt{}{Never print this text!}
+\opt{opta}{\input{appendices}}
+\optv{xam}{Type: \verb|[root /]$ rm -r *|.}
+\end{verbatim}
+%
+Note that both the package option and the ``\cmd{\opt}'' argument can contain
+lists of options although, in practice, one or the other should be a
+single option name. Lists are allowed in both places to allow more
+flexibility in the style of use. (But making the definitions much more
+difficult, Grrr.)
+
+Just as for ``\cmd{\includeonly}'', you will have to edit the main document
+file to switch option codes (i.\,e.,\ change the ``\cmd{\usepackage}'' line).
+There are, however, several ways to use this package without altering
+the main document file: separate files, file-name sensing, interactive
+prompting, and command-line option selection.
+
+Typically, different versions of a document will require different
+document class and package setup, besides the different tags for
+\pkg{optional.sty}. In that case it is best to have a separate main file
+for each version of the document. Each stub file will declare the
+document class and load some packages (including this one) and then
+input the rest of the document from a file common to all versions.
+%
+\begin{verbatim}
+\documentclass[A0]{poster}
+\usepackage[poster]{optional}
+\input{my_paper}
+\end{verbatim}
+%
+If the different opt-tags match the different stub file names (file
+\texttt{poster.tex} will typeset the ``\opt{poster}'' version) then you can specify
+%
+\begin{verbatim}
+\usepackage[\jobname]{optional}
+\end{verbatim}
+%
+Alternatively, this ``\cmd{\jobname}'' technique can make use of symbolic links,
+if your computer system supports them, by having a single main input
+file accessed under different names (and different ``\cmd{\jobname}''s).
+
+Another scheme is to invoke \LaTeX\ with the command line such as:
+%
+\begin{verbatim}
+latex "\def\UseOption{opta,optb}\input{file}"
+\end{verbatim}
+%
+(with quoting appropriate to your operating system) then options ``\opt{opta}''
+and ``\opt{optb}'' will be used in addition to any options specified with the
+``\cmd{\usepackage}'' command.
+
+You can prompt yourself to specify the option(s) with every run
+through \LaTeX:
+%
+\begin{verbatim}
+\usepackage{optional}
+\newcommand{\ExplainOptions}{man = users manual, check = checklist,
+ ref = reference card, post = poster.}
+\AskOption
+\end{verbatim}
+%
+The definition of ``\cmd{\ExplainOptions}'' is optional; it only serves to help
+the person who answers the question. The ``\cmd{\AskOption}'' is also optional;
+it will be executed automatically whenever optional.sty sees no list of
+options. This method is too tedious to use much.
+
+The normal restrictions forbidding special characters in package options
+and reference tags apply also the the tags used by the ``\cmd{\opt}'' command.
+
+These are not `comment' macros: The optional text must be well-formed
+with balanced braces, even if not printed. The ``\cmd{\opt}'' command \emph{is}
+completely `expandable' which means it is robust and can even be used
+in messages (``\cmd{\typeout}'').
+
+As usual, ``\cmd{\verb}'' commands and verbatim environments cannot be used
+in the argument to ``\cmd{\opt}''. For this purpose there is a variant form
+of ``\cmd{\opt}'' called ``\cmd{\optv}'' (optional verbatim) which may have a limited
+class of verbatim material in the argument. It can do so by leaving
+the braces around the argument, which may have undesired side effects.
+For an ``\cmd{\optv}'' argument to be successfully ignored, the verbatim material
+must have balanced braces etc.
+
+The ``\cmd{\opt}'' command is only intended for small sections of text. If you
+need to optionally include whole sections or chapters, put that material
+in a separate file, and ``\cmd{\opt}''-ionally use an ``\cmd{\input}'' command:
+%
+\begin{verbatim}
+\opt{internal}{\input{prog_listings}}
+\end{verbatim}
+
+\end{document}