Debian Codegraph @

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

raw
1 \documentclass[a4paper,11pt,article]{memoir}
2 \setlrmarginsandblock{3cm}{*}{1}
3 \setulmarginsandblock{3cm}{4cm}{*}
4 \checkandfixthelayout
5 \usepackage[latin1]{inputenc}
6 \usepackage[english]{babel}
7 \usepackage[T1]{fontenc}
8 \usepackage{fourier}
9 \usepackage{digiconfigs}
10 \usepackage{url}
11 \makeatletter
12 \newcommand*\Arg@s[1]{\textnormal{\texttt{#1}}}%
13 \newcommand*\Arg@n[1]{\textnormal{$\langle$\textit{#1}$\rangle$}}%
14 \newcommand*\Arg{\@ifstar{\Arg@s}{\Arg@n}}%
15 \newcommand*\marg@s[1]{\textnormal{\texttt{\{#1\}}}}
16 \newcommand*\marg@n[1]{%
17 \textnormal{\texttt{\{}$\langle$\textit{#1}$\rangle$\texttt{\}}}%
18 }
19 \newcommand*\marg{\@ifstar{\marg@s}{\marg@n}}
20
21 \newcommand*\oarg@s[1]{\textnormal{\texttt{[#1]}}}
22 \newcommand*\oarg@n[1]{%
23 \textnormal{\texttt{[}$\langle$\textit{#1}$\rangle$\texttt{]}}%
24 }
25 \newcommand*\oarg{\@ifstar{\oarg@s}{\oarg@n}}
26 \providecommand*\cs[1]{\textnormal{\texttt{\symbol{'134}#1}}}
27 \newenvironment{syntax}{%
28 \vskip.5\onelineskip%
29 \begin{adjustwidth}{\parindent}{0pt}
30 \parindent=0pt%
31 \obeylines%
32 \let\\=\relax%
33 }{%
34 \end{adjustwidth}%
35 \vskip.5\onelineskip%
36 }
37 \newoutputstream{SCS}
38 \newenvironment{SCSexample}{%
39 \openoutputfile{\jobname.ex}{SCS}%
40 \begingroup
41 \writeverbatim{SCS}%
42 }{%
43 \endwriteverbatim\relax%
44 \endgroup
45 \closeoutputstream{SCS}%
46 \verbatiminput{\jobname.ex}%
47 {\begin{minipage}{0.97\linewidth}
48 \input{\jobname.ex}\end{minipage}}%
49 \par\bigskip\noindent
50 }
51 \makeatother
52
53 \pagestyle{plain}
54
55
56 \begin{document}
57
58 \title{The \textsf{\jobname} package}
59 \author{Lars Madsen\thanks{Email:
60 \protect\url{[email protected]}}\thanks{Version 0.5}}
61 \maketitle
62
63 \chapter{Introduction}
64 \label{cha:introduction}
65
66 In Stochastic Geometry and Digital Image Analysis (both fields in
67 statistics) some problems can be solved in terms of so-called
68 \emph{configurations}. Which is basically a square matrix with
69 $\circ$ and $\bullet$ in them (and interpreted in a specific fashion,
70 that I do not know about).
71 \begin{quote}
72 \itshape The configurations are mainly used to estimate geometric
73 features, such as the mean normal measure, the area density, and the
74 length density, of digitized random sets in the plane. Other
75 applications include the restoration of noisy realisations of random
76 sets. \hfill --- pseudo-anonymous researcher
77 \end{quote}
78 Now, a certain type of problem might need more than 50 $5\times5$
79 matrices of $\circ$'s and $\bullet$'s, which is not very handy to
80 write in the traditional way.
81 \begin{verbatim}
82 \begin{bmatrix}
83 \circ & \bullet & \circ & \circ & \bullet \\
84 ...
85 \end{bmatrix}
86 \end{verbatim}
87
88 Of course one method of easing this (for $5\times5$ matrices) is to
89 create a macro with five arguments, which would then create the
90 matrix. (Something like \cs{macro}\marg*{o..oo}\marg*{ooo.o}%
91 \marg*{....o}\allowbreak\marg*{.....}\marg*{o.o.o}.) But that does not
92 scale very well, we need a macro that given a special string (and
93 perhaps a matrix size configuration) can simply build a
94 configuration matrix.
95
96 The \jobname-package tries to solve this problem.
97
98
99 \chapter{Usage}
100 \label{cha:usage}
101
102 Simply load the package in the traditional way:
103 \begin{verbatim}
104 \usepackage{digiconfigs}
105 \end{verbatim}
106 This will also load the \texttt{amsmath} package. Digiconfigs provides the
107 \cs{dconfig} macro, which has the following syntax:
108 \begin{syntax}
109 \cs{dconfig}\oarg{matrix-size}\marg{configuration string}
110 \end{syntax}
111 \newpage
112 \noindent Explanation:
113 \begin{description}\firmlist
114 \item[\Arg{matrix-size}] This optional argument is used to specify the
115 expected size of the matrix, the syntax to be used is of course
116 \texttt{\Arg{rows}x\Arg{cols}}, where, if
117 \texttt{\Arg{rows}=\Arg{cols}} is equivalent to simply typing
118 \texttt{\Arg{rows}}. Default is \texttt{4} (i.e. a $4\times4$
119 matrix), which is configurable.
120 \item[\Arg{configuration string}] This is suppose to be a string of
121 single characters each of which will represent an entry in the
122 matrix. The macro will react to four different characters, which by
123 default is
124 \begin{description}\tightlist
125 \item[o] represents a $\circ$,
126 \item[.] represents a $\bullet$,
127 \item[c] represents a $\cdot$ (sometimes used to indicate a blank), and
128 \item[b] which represents a \emph{blank} entry.
129 \end{description}
130 All four characters are configurable, as is the symbols used for
131 \emph{circle}, \emph{bullet}, and \emph{cdot}.
132
133 All other characters (except \texttt{\#}, \texttt{\%} and
134 \texttt{X}) will be ignored. \texttt{X} is internally added to the
135 string, and is used to detect the end of the string if it falls
136 short.
137 \end{description}
138 \cs{dconfig} will then calculate the number of entries it has to
139 look for, and simply eat up character by character (using tail
140 recursion) until it has found the number it needs. Any remaining
141 characters will be ignored. If the string it too short for the
142 expected number of entries, a warning will be issued, and the matrix
143 will simply come short at this point.
144
145 Here are a few examples
146 \begin{SCSexample}
147 \def\mystring{..o.. bb.o.. dsfsf co..}
148 \[
149 \dconfig[2]{\mystring} \dconfig[1x5]{\mystring}
150 \dconfig{\mystring} \dconfig[3x4]{\mystring}
151 \]
152 \end{SCSexample}
153 Matrix three here falls short of entries.
154
155
156
157 \chapter{Configuration}
158 \label{cha:configuration}
159
160 The package offers various configurations. All of these can be changed
161 throughout the document.
162 \begin{syntax}
163 \cs{setCircleChar}\marg{char}\hfill (\texttt{o})
164 \cs{setBulletChar}\marg{char}\hfill (\texttt{.})
165 \cs{setCdotChar}\marg{char}\hfill (\texttt{c})
166 \cs{setBlankChar}\marg{char}\hfill (\texttt{b})
167 \end{syntax}
168 Is used to alter the four main characters the macro is looking
169 for. Argument should be a single char (to keep things simple).
170
171 \begin{syntax}
172 \cs{setCircleSymbol}\marg{symbol}\hfill (\verb+\circ+)
173 \cs{setBulletSymbol}\marg{symbol}\hfill (\verb+\bullet+)
174 \cs{setCdotSymbol}\marg{symbol}\hfill (\verb+\cdot+)
175 \end{syntax}
176 Is used to alter the output symbols used in the matrix. The
177 \emph{blank} symbol cannot be changed.
178 \begin{syntax}
179 \cs{setMatrixStart}\marg{matrix start code}\hfill (\verb+\begin{bmatrix}+)
180 \cs{setMatrixEnd}\marg{matrix end code}\hfill (\verb+\end{bmatrix}+)
181 \end{syntax}
182 Fairly obvious. So if you want to save some space use\nopagebreak
183 \begin{verbatim}
184 \setMatrixStart{\left[\begin{smallmatrix}}
185 \setMatrixEnd{\end{smallmatrix}\right]}
186 \end{verbatim}
187 \begin{syntax}
188 \cs{setDefaultMatrixSize}\marg{matrix size} \hfill (\texttt{4})
189 \end{syntax}
190 Alters the expected number of entries. Use a positive integer or the
191 \texttt{\Arg{number}x\Arg{number}}-syntax.
192
193 \chapter{Example}
194 \label{cha:examples}
195
196 \begin{SCSexample}
197 \setMatrixStart{\left[\begin{smallmatrix}}
198 \setMatrixEnd{\end{smallmatrix}\right]}
199 \setCircleChar{+}
200 \setBulletChar{-}
201 \setCircleSymbol{1}
202 \setBulletSymbol{-1}
203 \[
204 \dconfig{c-+c +-+- -+-- b-+b -+--}
205 \]
206 \end{SCSexample}
207
208 \chapter{A tip}
209 \label{cha:tip}
210
211
212
213 Here is a small tip. If you find \cs{dconfig} to be a bit long, then
214 try something like
215 \begin{verbatim}
216 \newcommand\dc[2][]{\dconfig[#1]{#2}}
217 \end{verbatim}
218
219
220
221 \end{document}
222
223 %%% Local Variables:
224 %%% mode: latex
225 %%% TeX-master: t
226 %%% End: