summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/lmacs/lmacs.dtx
blob: 23c3d08adb15de02c0308ea809e9306cd5676bb9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
% \iffalse meta-comment
% http://www.texdev.net/2009/10/06/a-model-dtx-file/
% !TEX program  = pdfLaTeX
%<*internal>
\iffalse
%</internal>
%<*internal>
\fi
\def\nameofplainTeX{plain}
\ifx\fmtname\nameofplainTeX\else
  \expandafter\begingroup
\fi
%</internal>
%<*install>
\input docstrip.tex
\keepsilent
\askforoverwritefalse
\preamble
\endpreamble
\ifx\fmtname\nameofplainTeX
\generate{
  \file{\jobname.sty}{\from{\jobname.dtx}{package}}
}
\fi
%</install>
%<install>\endbatchfile
%<*internal>
\ifx\fmtname\nameofplainTeX
  \expandafter\endbatchfile\else
  \expandafter\endgroup\fi
%</internal>
%<package>\NeedsTeXFormat{LaTeX2e}
%<package>\ProvidesPackage{lmacs}
%<package> [2012/05/30 v1.1 Imports local macro files]
%<*driver>
\documentclass{ltxdoc}
%\usepackage{\jobname}
%\usepackage[numbered]{hypdoc}
%\EnableCrossrefs
%\CodelineIndex
%\RecordChanges
\begin{document}
  \DocInput{\jobname.dtx}
\end{document}
%</driver>
% \fi
%
%\GetFileInfo{\jobname.sty}
%
%\title{The  \textsf{\jobname} Package}
%\author{D. P. Story}
%\date{Released \today}
%
%\maketitle
%
%\StopEventually{^^A
%  \PrintChanges
%  \PrintIndex
%}
%
%    \begin{macrocode}
%<*package>
%    \end{macrocode}
% \paragraph*{Description.} This package is used to clean up the
% preamble of {\LaTeX} files. Some preambles have a (large) number of definitions
% in them. To clean up the preamble, move the definitions in the preamble into a separate file, and
% use this package in import them into your preamble. Normally,
% \textsf{lmacs} would have a position that follows all packages for the
% document.
%
% \textsf{lmacs} stands for \underbar{l}ocal \underbar{mac}ro\underbar{s}. Normally, the files referenced are in the same folder
% as the main source file; they should not (but can) be in the search path of {\LaTeX}.
%
% \paragraph*{Demo files:} \texttt{lmacs\_tst.tex} (a simple latex source)
% and \texttt{lmacs\_aeb.tex} (a file that uses the \textsf{web} and \textsf{exerquiz} packages).
% These are found in the \texttt{examples} folder.
%
% \paragraph*{Documentation and Code.}
% We begin by requiring \texttt{kvoptions}, this package does not test for the presence
% of a class file, so we can use it. It allows us to define key-values as options of the
% package.
%    \begin{macrocode}
\RequirePackage{kvoptions}[2009/07/21]
%    \end{macrocode}
%    \begin{macrocode}
%    \end{macrocode}
%    \begin{macro}{cfg}
%    \begin{macro}{def}
%    \begin{macro}{js}
%    With these keys, you can specify the file with the specified extension be imported.
%    For example, the following line
%\begin{verbatim}
%   \usepackage[cfg=myconf,def=mydef,js=myjs]{lmacs}
%\end{verbatim}
% will import (using \cs{InputIfFileExists}) the files \texttt{myconf.cfg},
% \texttt{mydef.def}, and \texttt{myjs.js}. Multiple specifications of the same
% extension is permitted, for example,
%\begin{verbatim}
%   \usepackage[def=mydef1,def=mydef2]{lmacs}
%\end{verbatim}
%    \begin{macrocode}
\let\LM@inputlist\@empty
%    \end{macrocode}
% \cmd{\LM@input} inputs \texttt{\#1.\#2}, while \cmd{\LM@warning} issues
% a package warning if \texttt{\#1.\#2} is not found.
%    \begin{macrocode}
\newcommand{\LM@input}[2]{\InputIfFileExists{#1.#2}{}%
    {\LM@warning{#1}{#2}}}
\newcommand{\LM@warning}[2]{\PackageWarning{lmacs}
            {The file #1.#2 cannot be found}}
%    \end{macrocode}
% \DescribeMacro{!cfg}\DescribeMacro{!def}\DescribeMacro{!js}For each of these options, we add the specified file to
% \cs{LM@inputlist}, this will be executed at the end of the package. The three options
% \texttt{!cfg}, \texttt{!def}, \texttt{!js} do nothing, making it easy to include, or
% not include a file.
%    \begin{macrocode}
\define@key{lmacs}{cfg}{\g@addto@macro\LM@inputlist{\LM@input{#1}{cfg}}}
\define@key{lmacs}{!cfg}{}
\define@key{lmacs}{def}{\g@addto@macro\LM@inputlist{\LM@input{#1}{def}}}
\define@key{lmacs}{!def}{}
\define@key{lmacs}{js}{\g@addto@macro\LM@inputlist{\LM@input{#1}{js}}}
\define@key{lmacs}{!js}{}
%    \end{macrocode}
%    \end{macro}
%    \end{macro}
%    \end{macro}
%    \begin{macrocode}
\ProcessKeyvalOptions{lmacs}
%    \end{macrocode}
%    Once the options have been process, we execute the command
%    \cs{LM@inputlist} which contains a list of the files to be input.
%    \begin{macrocode}
\LM@inputlist
%    \end{macrocode}
%    \begin{macrocode}
%</package>
%    \end{macrocode}
%\Finale