summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/digiconfigs
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/digiconfigs
Initial commit
Diffstat (limited to 'macros/latex/contrib/digiconfigs')
-rw-r--r--macros/latex/contrib/digiconfigs/README25
-rw-r--r--macros/latex/contrib/digiconfigs/digiconfigs.pdfbin0 -> 125771 bytes
-rw-r--r--macros/latex/contrib/digiconfigs/digiconfigs.sty159
-rw-r--r--macros/latex/contrib/digiconfigs/digiconfigs.tex226
4 files changed, 410 insertions, 0 deletions
diff --git a/macros/latex/contrib/digiconfigs/README b/macros/latex/contrib/digiconfigs/README
new file mode 100644
index 0000000000..d679863c57
--- /dev/null
+++ b/macros/latex/contrib/digiconfigs/README
@@ -0,0 +1,25 @@
+% (C) Lars Madsen, daleif@imf.au.dk, 2006/06/22
+% This material is subject to the LaTeX Project Public License.
+% See http://www.ctan.org/tex-archive/help/Catalogue/licenses.lppl.html
+% for the details of that license.
+
+
+The 'digiconfigs' package provide a simple wayt ot create so-called
+configurations, which is matrices of \circ's and \bullet's used in
+Stochastic Geometry and Digital Image Analysis.
+
+So instead of writing
+
+\begin{bmatrix}
+ \circ & \bullet & \circ \\
+ \circ & \bullet & \circ \\
+ \bullet & \bullet & \circ
+\end{bmatrix}
+
+one simply writes
+
+\dconfig[3]{c.c c.c ..c}
+
+See the manual for more information.
+
+/daleif
diff --git a/macros/latex/contrib/digiconfigs/digiconfigs.pdf b/macros/latex/contrib/digiconfigs/digiconfigs.pdf
new file mode 100644
index 0000000000..d7852c8577
--- /dev/null
+++ b/macros/latex/contrib/digiconfigs/digiconfigs.pdf
Binary files differ
diff --git a/macros/latex/contrib/digiconfigs/digiconfigs.sty b/macros/latex/contrib/digiconfigs/digiconfigs.sty
new file mode 100644
index 0000000000..cd014e5036
--- /dev/null
+++ b/macros/latex/contrib/digiconfigs/digiconfigs.sty
@@ -0,0 +1,159 @@
+%%
+%% This package be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3
+%% of this license or (at your option) any later version.
+%% The latest version of this license is in
+%% http://www.latex-project.org/lppl.txt
+%% and version 1.3 or later is part of all distributions of LaTeX
+%% version 2003/12/01 or later.
+%%
+%% This work has the LPPL maintenance status "maintained".
+%%
+%% The Current Maintainer of this work is Lars Madsen (daleif@imf.au.dk).
+%%
+
+% HISTORY
+% 20060620 (daleif) package released
+% 20060620 (daleif) a few \expandafter's could be saved, thanks MH for
+% that comment
+% 20060620 (daleif) removed dependency of calc package
+
+\ProvidesPackage{digiconfigs}[2006/06/20 v0.5 by Lars 'daleif' Madsen]
+\RequirePackage{amsmath}
+
+\def\SCS@circ{o}
+\def\SCS@bullet{.}
+\def\SCS@blank{b}
+\def\SCS@cdot{c}
+\def\SCS@stop{X}
+\newcommand\setCircleChar[1]{\def\SCS@circ{#1}}
+\newcommand\setBulletChar[1]{\def\SCS@bullet{#1}}
+\newcommand\setBlankChar[1]{\def\SCS@blank{#1}}
+\newcommand\setCdotChar[1]{\def\SCS@cdot{#1}}
+
+
+\def\SCS@circ@symbol{\circ}
+\def\SCS@bullet@symbol{\bullet}
+\def\SCS@cdot@symbol{\cdot}
+\newcommand\setCircleSymbol[1]{\def\SCS@circ@symbol{#1}}
+\newcommand\setBulletSymbol[1]{\def\SCS@bullet@symbol{#1}}
+\newcommand\setCdotSymbol[1]{\def\SCS@cdot@symbol{#1}}
+
+
+%\def\SCS@matrix@env{bmatrix}
+%\newcommand\setMatrixEnv[1]{\def\SCS@matrix@env{#1}}
+
+\def\SCS@matrix@start{\begin{pmatrix}}
+\def\SCS@matrix@end{\end{pmatrix}}
+\newcommand\setMatrixStart[1]{\def\SCS@matrix@start{#1}}
+\newcommand\setMatrixEnd[1]{\def\SCS@matrix@end{#1}}
+
+
+
+\newif\ifSCS@notdone
+\newtoks\SCS@input
+\newtoks\SCS@output
+\newcounter{SCS@numtokens}
+\newcounter{SCS@cols}
+\newcounter{SCS@rows}
+
+\def\SCS@token@Pop#1(into:)#2{%
+ \edef\act{\noexpand\SCS@token@SplitOff\the#1%
+ (head:)\noexpand#2(tail:)\noexpand#1}%
+ \act}
+\def\SCS@token@SplitOff#1#2(head:)#3(tail:)#4{\def#3{#1}#4={#2}}
+
+\def\SCS@xsplit#1x#2\delim{\def\SCS@maxrows{#1}\def\SCS@maxcols{#2}}
+\def\SCS@parseX#1x#2\END{
+ \ifx\\#2\\% => ingen x
+ \def\SCS@maxrows{#1}\def\SCS@maxcols{#1}
+ \else
+ \def\SCS@maxrows{#1} \SCS@parseXc #2 \fi}
+\def\SCS@parseXc#1x{\def\SCS@maxcols{#1}}
+\def\SCS@ParseArg#1{\SCS@parseX #1x\END}
+
+
+\newcommand\SCS@config[1]{% #1 er en tokenlist
+ \ifnum\value{SCS@numtokens}<\SCS@maxtokens%
+ \SCS@token@Pop#1(into:)\first% tag første token af, husk at ' ' ignoreres
+ \ifx\first\SCS@circ%
+ % hvis \first = \Mo (o) tilføjes \circ
+ \stepcounter{SCS@numtokens}%
+ \stepcounter{SCS@cols}%
+ \expandafter\addto@hook\expandafter\SCS@output\expandafter{\SCS@circ@symbol}%
+ \else%
+ \ifx\first\SCS@bullet%
+ % hvis \first = \Mb (.) tilføjes \bullet
+ \stepcounter{SCS@numtokens}%
+ \stepcounter{SCS@cols}%
+ \expandafter\addto@hook\expandafter\SCS@output\expandafter{\SCS@bullet@symbol}%
+ \else%
+ \ifx\first\SCS@cdot%
+ \stepcounter{SCS@numtokens}%
+ \stepcounter{SCS@cols}%
+ \expandafter\addto@hook\expandafter\SCS@output\expandafter{\SCS@cdot@symbol}%
+ \else%
+ \ifx\first\SCS@blank%
+ % hvis \first = \Mbl (b for blank) skal der ikke indsættes
+ % noget kun evt &-tegn
+ \stepcounter{SCS@numtokens}%
+ \stepcounter{SCS@cols}%
+ \relax%
+ \else %
+ % resten ignoreres
+ \SCS@notdonefalse%
+ \fi%
+ \fi%
+ \fi%
+ \fi%
+ \ifSCS@notdone%
+ \ifnum\value{SCS@cols}<\SCS@maxcols%
+ % tilføj en & mellem punkterne i en række
+ \addto@hook\SCS@output{&}%
+ \else%
+ % cols=\maxcols => ny linie
+ \setcounter{SCS@cols}{0}%
+ \ifnum\value{SCS@rows}<\SCS@maxrows%
+ \addto@hook\SCS@output{\\}%
+ \fi%
+ \stepcounter{SCS@rows}%
+ \fi%
+ \fi%
+ \SCS@notdonetrue%
+ \ifx\first\SCS@stop%
+ \PackageWarning{stereoconfigs}{%
+ String too short, expected \SCS@maxtokens\space
+ chars but only found \theSCS@numtokens^^J
+ }{}%
+ \relax%
+ \else%
+ \SCS@config{#1}%
+ \fi%
+ \fi%
+}
+
+\def\SCS@default@size{4}
+\newcommand\setDefaultMatrixSize[1]{\def\SCS@default@size{4}}
+
+\newcommand\dconfig[2][\SCS@default@size]{%
+ \begingroup%
+ \SCS@ParseArg{#1}%
+% \setcounter{SCS@rows}{\SCS@maxrows * \SCS@maxcols}%
+ \setcounter{SCS@rows}{\SCS@maxrows}
+ \multiply \c@SCS@rows by \SCS@maxcols
+ \edef\SCS@maxtokens{\theSCS@rows}%
+ \setcounter{SCS@cols}{0}%
+ \setcounter{SCS@rows}{0}%
+ \setcounter{SCS@numtokens}{0}%
+ \SCS@notdonetrue%
+ \SCS@input\expandafter{#2X}%
+ \SCS@config\SCS@input%
+ \SCS@matrix@start%
+ \the\SCS@output%
+ \SCS@matrix@end%
+ \endgroup%
+}
+
+
+
+
diff --git a/macros/latex/contrib/digiconfigs/digiconfigs.tex b/macros/latex/contrib/digiconfigs/digiconfigs.tex
new file mode 100644
index 0000000000..274d5f3673
--- /dev/null
+++ b/macros/latex/contrib/digiconfigs/digiconfigs.tex
@@ -0,0 +1,226 @@
+\documentclass[a4paper,11pt,article]{memoir}
+\setlrmarginsandblock{3cm}{*}{1}
+\setulmarginsandblock{3cm}{4cm}{*}
+\checkandfixthelayout
+\usepackage[latin1]{inputenc}
+\usepackage[english]{babel}
+\usepackage[T1]{fontenc}
+\usepackage{fourier}
+\usepackage{digiconfigs}
+\usepackage{url}
+\makeatletter
+\newcommand*\Arg@s[1]{\textnormal{\texttt{#1}}}%
+\newcommand*\Arg@n[1]{\textnormal{$\langle$\textit{#1}$\rangle$}}%
+\newcommand*\Arg{\@ifstar{\Arg@s}{\Arg@n}}%
+\newcommand*\marg@s[1]{\textnormal{\texttt{\{#1\}}}}
+\newcommand*\marg@n[1]{%
+ \textnormal{\texttt{\{}$\langle$\textit{#1}$\rangle$\texttt{\}}}%
+}
+\newcommand*\marg{\@ifstar{\marg@s}{\marg@n}}
+
+\newcommand*\oarg@s[1]{\textnormal{\texttt{[#1]}}}
+\newcommand*\oarg@n[1]{%
+ \textnormal{\texttt{[}$\langle$\textit{#1}$\rangle$\texttt{]}}%
+}
+\newcommand*\oarg{\@ifstar{\oarg@s}{\oarg@n}}
+\providecommand*\cs[1]{\textnormal{\texttt{\symbol{'134}#1}}}
+\newenvironment{syntax}{%
+ \vskip.5\onelineskip%
+ \begin{adjustwidth}{\parindent}{0pt}
+ \parindent=0pt%
+ \obeylines%
+ \let\\=\relax%
+ }{%
+ \end{adjustwidth}%
+ \vskip.5\onelineskip%
+}
+\newoutputstream{SCS}
+\newenvironment{SCSexample}{%
+ \openoutputfile{\jobname.ex}{SCS}%
+ \begingroup
+ \writeverbatim{SCS}%
+}{%
+ \endwriteverbatim\relax%
+ \endgroup
+ \closeoutputstream{SCS}%
+ \verbatiminput{\jobname.ex}%
+ {\begin{minipage}{0.97\linewidth}
+ \input{\jobname.ex}\end{minipage}}%
+ \par\bigskip\noindent
+}
+\makeatother
+
+\pagestyle{plain}
+
+
+\begin{document}
+
+\title{The \textsf{\jobname} package}
+\author{Lars Madsen\thanks{Email:
+ \protect\url{daleif@imf.au.dk}}\thanks{Version 0.5}}
+\maketitle
+
+\chapter{Introduction}
+\label{cha:introduction}
+
+In Stochastic Geometry and Digital Image Analysis (both fields in
+statistics) some problems can be solved in terms of so-called
+\emph{configurations}. Which is basically a square matrix with
+$\circ$ and $\bullet$ in them (and interpreted in a specific fashion,
+that I do not know about).
+\begin{quote}
+ \itshape The configurations are mainly used to estimate geometric
+ features, such as the mean normal measure, the area density, and the
+ length density, of digitized random sets in the plane. Other
+ applications include the restoration of noisy realisations of random
+ sets. \hfill --- pseudo-anonymous researcher
+\end{quote}
+Now, a certain type of problem might need more than 50 $5\times5$
+matrices of $\circ$'s and $\bullet$'s, which is not very handy to
+write in the traditional way.
+\begin{verbatim}
+\begin{bmatrix}
+\circ & \bullet & \circ & \circ & \bullet \\
+...
+\end{bmatrix}
+\end{verbatim}
+
+Of course one method of easing this (for $5\times5$ matrices) is to
+create a macro with five arguments, which would then create the
+matrix. (Something like \cs{macro}\marg*{o..oo}\marg*{ooo.o}%
+\marg*{....o}\allowbreak\marg*{.....}\marg*{o.o.o}.) But that does not
+scale very well, we need a macro that given a special string (and
+perhaps a matrix size configuration) can simply build a
+configuration matrix.
+
+The \jobname-package tries to solve this problem.
+
+
+\chapter{Usage}
+\label{cha:usage}
+
+Simply load the package in the traditional way:
+\begin{verbatim}
+\usepackage{digiconfigs}
+\end{verbatim}
+This will also load the \texttt{amsmath} package. Digiconfigs provides the
+\cs{dconfig} macro, which has the following syntax:
+\begin{syntax}
+ \cs{dconfig}\oarg{matrix-size}\marg{configuration string}
+\end{syntax}
+\newpage
+\noindent Explanation:
+\begin{description}\firmlist
+\item[\Arg{matrix-size}] This optional argument is used to specify the
+ expected size of the matrix, the syntax to be used is of course
+ \texttt{\Arg{rows}x\Arg{cols}}, where, if
+ \texttt{\Arg{rows}=\Arg{cols}} is equivalent to simply typing
+ \texttt{\Arg{rows}}. Default is \texttt{4} (i.e. a $4\times4$
+ matrix), which is configurable.
+\item[\Arg{configuration string}] This is suppose to be a string of
+ single characters each of which will represent an entry in the
+ matrix. The macro will react to four different characters, which by
+ default is
+ \begin{description}\tightlist
+ \item[o] represents a $\circ$,
+ \item[.] represents a $\bullet$,
+ \item[c] represents a $\cdot$ (sometimes used to indicate a blank), and
+ \item[b] which represents a \emph{blank} entry.
+ \end{description}
+ All four characters are configurable, as is the symbols used for
+ \emph{circle}, \emph{bullet}, and \emph{cdot}.
+
+ All other characters (except \texttt{\#}, \texttt{\%} and
+ \texttt{X}) will be ignored. \texttt{X} is internally added to the
+ string, and is used to detect the end of the string if it falls
+ short.
+\end{description}
+\cs{dconfig} will then calculate the number of entries it has to
+look for, and simply eat up character by character (using tail
+recursion) until it has found the number it needs. Any remaining
+characters will be ignored. If the string it too short for the
+expected number of entries, a warning will be issued, and the matrix
+will simply come short at this point.
+
+Here are a few examples
+\begin{SCSexample}
+ \def\mystring{..o.. bb.o.. dsfsf co..}
+ \[
+ \dconfig[2]{\mystring} \dconfig[1x5]{\mystring}
+ \dconfig{\mystring} \dconfig[3x4]{\mystring}
+ \]
+\end{SCSexample}
+Matrix three here falls short of entries.
+
+
+
+\chapter{Configuration}
+\label{cha:configuration}
+
+The package offers various configurations. All of these can be changed
+throughout the document.
+\begin{syntax}
+\cs{setCircleChar}\marg{char}\hfill (\texttt{o})
+\cs{setBulletChar}\marg{char}\hfill (\texttt{.})
+\cs{setCdotChar}\marg{char}\hfill (\texttt{c})
+\cs{setBlankChar}\marg{char}\hfill (\texttt{b})
+\end{syntax}
+Is used to alter the four main characters the macro is looking
+for. Argument should be a single char (to keep things simple).
+
+\begin{syntax}
+\cs{setCircleSymbol}\marg{symbol}\hfill (\verb+\circ+)
+\cs{setBulletSymbol}\marg{symbol}\hfill (\verb+\bullet+)
+\cs{setCdotSymbol}\marg{symbol}\hfill (\verb+\cdot+)
+\end{syntax}
+Is used to alter the output symbols used in the matrix. The
+\emph{blank} symbol cannot be changed.
+\begin{syntax}
+\cs{setMatrixStart}\marg{matrix start code}\hfill (\verb+\begin{bmatrix}+)
+\cs{setMatrixEnd}\marg{matrix end code}\hfill (\verb+\end{bmatrix}+)
+\end{syntax}
+Fairly obvious. So if you want to save some space use\nopagebreak
+\begin{verbatim}
+ \setMatrixStart{\left[\begin{smallmatrix}}
+ \setMatrixEnd{\end{smallmatrix}\right]}
+\end{verbatim}
+\begin{syntax}
+\cs{setDefaultMatrixSize}\marg{matrix size} \hfill (\texttt{4})
+\end{syntax}
+Alters the expected number of entries. Use a positive integer or the
+\texttt{\Arg{number}x\Arg{number}}-syntax.
+
+\chapter{Example}
+\label{cha:examples}
+
+\begin{SCSexample}
+\setMatrixStart{\left[\begin{smallmatrix}}
+\setMatrixEnd{\end{smallmatrix}\right]}
+\setCircleChar{+}
+\setBulletChar{-}
+\setCircleSymbol{1}
+\setBulletSymbol{-1}
+\[
+\dconfig{c-+c +-+- -+-- b-+b -+--}
+\]
+\end{SCSexample}
+
+\chapter{A tip}
+\label{cha:tip}
+
+
+
+Here is a small tip. If you find \cs{dconfig} to be a bit long, then
+try something like
+\begin{verbatim}
+\newcommand\dc[2][]{\dconfig[#1]{#2}}
+\end{verbatim}
+
+
+
+\end{document}
+
+%%% Local Variables:
+%%% mode: latex
+%%% TeX-master: t
+%%% End: