Debian Codegraph @

texmf-dist/doc/latex/skeldoc/skeldoc.tex

raw
1 % Copyright (c) 2021 Magnus Lie Hetland
2 %
3 % Permission is hereby granted, free of charge, to any person obtaining a copy
4 % of this software and associated documentation files (the "Software"), to deal
5 % in the Software without restriction, including without limitation the rights
6 % to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 % copies of the Software, and to permit persons to whom the Software is
8 % furnished to do so, subject to the following conditions:
9 %
10 % The above copyright notice and this permission notice shall be included in all
11 % copies or substantial portions of the Software.
12 %
13 % THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 % IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 % FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 % AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 % LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 % OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 % SOFTWARE.
20
21 \documentclass[twocolumn, a4paper]{article}
22
23 \usepackage{lmodern}
24 \def\sfdefault{cmbr}
25 \def\ttdefault{cmtl}
26
27 \usepackage{skeldoc}
28 % \skelset{hide-notes}
29 % \skelset{hide-all}
30
31 \usepackage{cleveref}
32
33 \usepackage{amsthm}
34 \newtheorem{thm}{Theorem}
35
36 % For discussing commmands:
37
38 \makeatletter
39 \ExplSyntaxOn
40
41 % Copied from http://ctan.uib.no/macros/latex/base/doc.dtx
42 % Protect when used in moving arguments.
43 {\catcode`\|=\z@ \catcode`\\=12 |gdef|bslash{\}}
44
45 \NewDocumentCommand \cs { m } {%
46 \texttt{\bslash #1}%
47 }
48
49 \NewDocumentCommand \braces { +m } {%
50 \string{#1\string}%
51 }
52
53 \NewDocumentCommand \pkg { o m } {
54 \IfNoValueTF { #1 } {
55 \textsf { #2 }
56 } {
57 \href{ #1 }{ \textsf { #2 } }
58 }
59 }
60
61 \NewDocumentCommand \var { m } {
62 $\langle$
63 \textnormal{\textit{#1}}
64 $\rangle$
65 }
66
67 \ExplSyntaxOff
68 \makeatother
69
70 % To illustrate the \skelpseudo command:
71
72 \usepackage{pseudo}
73
74 \title{\skelline{The \pkg{skeldoc} package is intended for incremental
75 document development, with commands that insert simplified placeholder
76 elements for missing parts, similar to \emph{skeleton screens}, optionally
77 with associated notes explaining the placeholders.}}
78
79 \author{\skelline[5cm]{The \pkg{skeldoc} package is written by Magnus Lie
80 Hetland.}}
81
82 \begin{document}
83 \maketitle
84
85 \begin{abstract}
86 \skelpar[4]
87 \end{abstract}
88
89 \section{Introduction}
90
91 \skelpar[7]{All the skeleton commands are followed by an optional argument in
92 brackets, and one (also optional) in braces, like
93 \cs{skelfoo}\texttt{[\var{conf}]\braces{\var{note}}}. The first argument is
94 for limited local
95 configuration, setting keys relevant to the specific command. Each command
96 also lets you supply one such config value \emph{without} a key, leaving the
97 key implicit. For example, for \cs{skelline} (a single skeleton line), this is
98 \texttt{width} and for \cs{skelpar} (a single skeleton paragraph), it's
99 \texttt{lines}. So \cs{skelline[5cm]} is the same as
100 \cs{skelline[width\,=\,5cm]}. The \cs{skelpar} command also has the keys
101 \texttt{first-width}, \texttt{width} and \texttt{last-width}, to adjust the
102 various line widths.
103
104 The argument in braces is a \emph{note} associated with the skeleton element,
105 typeset using the \cs{skelnote} command, which places a number in the margin
106 and an note at the end of the document (or wherever the \cs{printskelnotes}
107 command is placed), with hyperlinks in both directions.
108
109 Beyond the keys available locally, there are several \emph{global} config
110 keys, which may be set using the \cs{skelset} command (which respects \TeX{}
111 groups, so such config may also be local, e.g., by wrapping the relevant part
112 of the document in braces). For example, one might use
113 \cs{skelset\braces{main-color\allowbreak\,=\,black}} to produce a look along
114 the lines of the \pkg[https://ctan.org/pkg/censor]{censor} package. Or one could
115 use \cs{skelset\braces{hide-notes}} to hide notes and note numbers (or even use
116 \texttt{hide-all} to remove \emph{all} \pkg{skeldoc} elements). Shared defaults
117 for the local keys may also be set in this way, generally using the local key
118 name with the type of element as a prefix; for example, \texttt{par-lines} is
119 used to set the default for the \texttt{lines} key of the \cs{skelpar} command.
120 There are also some other general keys, like \texttt{main-color} and
121 \texttt{full-width}. For an overview of the configuration keys, please consult
122 the source file, \texttt{skeldoc.sty}.}
123 \skelenum[3]
124 \noindent
125 \skelpar[3]
126
127 \section{\skelline}
128
129 \skelpar
130
131 \skelnote{It is possible to add notes in arbitrary parts of a document with
132 the \cs{skelnote} command. This could also be used as a simple to-do or
133 annotation mechanism. Note that \cs{skelnote} is designed so you can place it
134 before a paragraph or the like, and get the number positioned correctly. This
135 means it gobbles up any space that follows it. To avoid this, simply follow it
136 by an escaped space, for example, as in \texttt{\cs{skelnote}\braces{My
137 note}\cs{\char32}}.}
138 Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy
139 eirmod tempor invidunt ut labore et dolore magna aliquyam erat~\skelref{Here I'm
140 referring to something non-existent, with \cs{skelref}, whose implicit key is
141 \texttt{width}.}, sed diam voluptua~\cref{fig}.
142 \skelpar[2]
143 At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd
144 gubergren, no sea takimata sanctus est~\skelcite{And here is a missing
145 bibliographic reference, with \cs{skelcite}, whose implicit key is
146 \texttt{width}. You can also control the left and right braces (or whatever text
147 you wish to surround the citation with) using the \texttt{left} and
148 \texttt{right} keys.}.
149
150 \skelpar
151 \skelitems{The \cs{skelenum} and \cs{skelitems} commands produce skeleton
152 \emph{lists} (using \texttt{enumeration} and \texttt{itemize}). Their implicit
153 key is \texttt{items}, which controls the number of items, while
154 \texttt{item-lines} controls the number of lines per item.}
155 \noindent
156 \skelpar[4]
157
158 \begin{figure}
159 \skelfig[5cm]{Skeleton figures (\cs{skelfig}) have \texttt{height} as their
160 implicit key. The width may be modified using the \texttt{width} key.}
161 \skelcaption{Skeleton captions are best typeset using the special-purpose
162 \cs{skelcaption} command, rather than simply placing a \cs{skelpar} in a
163 normal \cs{caption}, at least if you intend to attach a note. This is because
164 captions are generally typeset more than once, in order to determine whether
165 to center them; \cs{skelcaption} prevents any attached note from being added
166 to the note list twice.
167
168 The implicit argument of \cs{skelcaption} is \texttt{lines}, and the other
169 keys are as for \cs{skelpar}, relying on the same defaults and global
170 configuration.}
171 \label{fig}
172 \end{figure}%
173
174 \skelpar
175 \begin{equation}
176 \skelline
177 \end{equation}
178 \skelpars[3]{Multiple skeleton paragraphs may be produced using the
179 \cs{skelpars} command, whose implicit key is \texttt{pars}, controlling
180 the number of paragraphs.}
181
182 \begin{table}
183 \skelcaption[1]{The \cs{skelcaption} command may be used for figures and
184 tables alike.}
185 \skeltabular[7]{The \cs{skeltabular} command produces a skeleton table
186 (specifically, a \texttt{tabularx}). The implicit key is \texttt{rows},
187 controlling the number of rows in the table. The \cs{tabcolsep} and
188 \cs{arraystretch} used can be set with the \texttt{colsep} and
189 \texttt{stretch} keys.}
190 \end{table}
191
192 \skelpar
193
194 \begin{thm}
195 \skelpar[3]
196 \end{thm}
197 \begin{proof}
198 \skelpar
199 \end{proof}
200
201 \skelpar
202
203 \section{\skelline}
204
205 \skelpar
206 \skelpseudo[
207 head={\pr{Lorem-Ipsum}(\id{dolor}, \id{sit}, \id{amet})},
208 ]{The \cs{skelpseudo} command only works if the
209 \pkg[https://ctan.org/pkg/pseudo]{pseudo} package has been imported. (It is
210 not imported by the \pkg{skeldoc} package.) The implicit key is
211 \texttt{lines}, the number of lines to produce (in addition to the headline,
212 if any). By default, no headline is included, but one may be set using the
213 \texttt{head} key (e.g., using the \cs{pr} command from the
214 \pkg[https://ctan.org/pkg/pseudo]{pseudo} package, rather than \cs{hd},
215 because the \texttt{head} key handles the \cs{multicolumn} stuff itself; for
216 example, use
217 \texttt{head\,=\,\braces{\cs{pr}\braces{\var{name}}(\var{args})}}). The indent
218 pattern is set using the \texttt{newlines} key, which should be a
219 comma-separated list of newline commands as used by the
220 \pkg[https://ctan.org/pkg/pseudo]{pseudo} package (such as \cs{\bslash+} or
221 \cs{\bslash--}). This list is used round-robin as the lines progress. E.g., if
222 you want pseudocode without any indentation, simply use
223 \texttt{newlines\,=\,\cs{\bslash}}.}
224 \skelpar
225
226 \section{Discussion}
227
228 \skelpars[2]
229
230 \skelbib{The \cs{skelbib} command produces a skeleton bibliography, with the
231 number of items controlled by the implicit key \texttt{items}. The number of
232 lines per item is controlled by \texttt{item-lines}.}
233
234 \printskelnotes
235
236 \end{document}