<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">\NeedsTeXFormat{LaTeX2e}[1994/12/01]
\ProvidesPackage{monofill}[2012/10/29 v0.2 monospace alignment (UL)]

%% Copyright (C) 2012 Uwe Lueck,
%% http://www.contact-ednotes.sty.de.vu
%% -- author-maintained in the sense of LPPL below --
%%
%% This file can be redistributed and/or modified under
%% the terms of the LaTeX Project Public License; either
%% version 1.3c of the License, or any later version.
%% The latest version of this license is in
%%     http://www.latex-project.org/lppl.txt
%% We did our best to help you, but there is NO WARRANTY.
%%
%% Please report bugs, problems, and suggestions via
%%
%%   http://www.contact-ednotes.sty.de.vu
%%
%% == User Commands      ==
%% \label{sec:user}
%% %% \[...\] rather than \\[...] 2012/10/29:
%% \[|\MFfieldtemplate[&lt;fill-element&gt;]{&lt;field&gt;}{&lt;template&gt;}|\]
%% determines the width of fields with id &lt;field&gt; to be the same 
%% as of &lt;template&gt;:
\newcommand*{\MFfieldtemplate}[3][\MFfillelement]{%
%% % `\space' is the default &lt;fill-element&gt;, stored as first argument
%% % of `\MF@make@bg'. 
%% `\@bg' delimits the ``background" or 
%% ``filler list". The field id is stored at the end ahead.
    \MF@make@bg#1#3\MF@store@field@bg\@bg{#2}}
%% `\MF@make@bg' is defined in Sec.~\ref{sec:field}.
%% \medbreak\noindent                               %% \medbreak 2012/03/29
%% %% &lt;- TODO as in morgan.sty "vert. cmd. box"
%% \[|\MFfillelement|\]                             %% \[...\] 2012/10/29
%% is the default for &lt;fill-element&gt;, 
%% defined to be (like) `\space' here:
\newcommand*{\MFfillelement}{}  \let\MFfillelement\space
%% &lt;fill-element&gt; \emph{must} be a \emph{``single item"}
%% (that \TeX\ converts into a single token, due to our 
%%  comparison mechanism), so for using somewhat more complex &lt;complex&gt; than `\space',
%% \[|\renewcommand*{\MFfillelement}{&lt;complex&gt;}|\]  %% |...| 2012/10/29
%% must be used instead of the optional argument.---It was very hard 
%% for me with \emph{typesetting}, what finally worked were
%% |\MFspace| and
%% |\MFenspace| as alternative optional arguments. 
%% It is fine for half-quad spaces such as characters with `\tt' 
%% figures with more Computer Modern fonts:
\newcommand*{\MFspace}{\mbox{ }}
% \newcommand*{\MFenspace}{\leavevmode\enspace}
\newcommand*{\MFenspace}{\mbox{\enspace}}
%% For using the \ctanpkgref{nicefilelist} and \ctanpkgref{hardwrap} 
%% packges together, I needed the following |\MFotherspace| as 
%% `\MFfillelement'---expanding to a character token that is a 
%% blank space according to its character code, but belongs to the 
%% ``other" category:
\newcommand*{\MFotherspace}{} {\@makeother\ \gdef\MFotherspace{ }}
%% More generally, I guess that this is the perfect ``filling
%% element" in text to be wrapped by 'hardwrap'.
%% \medbreak\noindent                               %% \medbreak 2012/10/29
%% \[|\MFleftinfield{&lt;text&gt;}{&lt;field&gt;}|\] 
%% returns &lt;text&gt;, 
%% followed by &lt;fill-elements&gt; to get as many elements 
%% (characters) as the &lt;template&gt; associated with &lt;field&gt;:
\newcommand*{\MFleftinfield}{\MF@check@field l}
%% % \smallskip\noindent
%% \[|\MFrightinfield{&lt;text&gt;}{&lt;field&gt;}|\] %% \[...\] 2012/10/29
%% returns the &lt;fill-elements&gt; before giving &lt;text&gt;:
\newcommand*{\MFrightinfield}{\MF@check@field r}
%% `\MF@check@field' is defined in Sec.~\ref{sec:text}.
%%
%% \pagebreak                               %% 2012/10/29
%% == Internal Commands  ==
%% === Tools             ===
%% We test arguments &lt;arg&gt; on emptiness by 
%% |\MF@if@empty{&lt;arg&gt;}{&lt;yes&gt;}{&lt;no&gt;}|:
\newcommand*{\MF@if@empty}[1]{%
    \ifx\MF@store@field@bg#1\MF@store@field@bg
        \expandafter\@firstoftwo
    \else
        \expandafter\@secondoftwo
    \fi}
%% |\MF@field| stores the name space for filling jobs:
\newcommand*{\MF@field}{MF@field:}
%%
%% === Field Declaration ===
%% \label{sec:field}
%% |\MF@make@bg| essentially builds a list of as many filler elements 
%% as the template has characters, using a loop macro `\MF@make@bg'. 
%% The current list of filler elements is delimited by `\@bg'.
\def\MF@make@bg#1#2#3\MF@store@field@bg{%
    \MF@if@empty{#3}%
%% First case: `#2' is the last template element. 
%% We run `\MF@store@field@bg' with an additional filler 
%% element:\footnote{Another run of `&amp;\MF@make@bg fails' ...}
                {\MF@store@field@bg#1}%
%% Second case: the filler list gets an additional element, 
%% and the loop repeats:
                {\MF@make@bg#1#3\MF@store@field@bg#1}%
}
%% |\MF@store@field@bg&lt;background&gt;\@bg{&lt;field&gt;}|
%% essentially stores the filler list (``&lt;background&gt;"), 
%% or more precisely ...
\def\MF@store@field@bg#1\@bg#2{%
%% Here is the \strong{only assignment} when the macros run: %% \strong 2012/03/29
%% a command \[`\MF@field:&lt;field&gt;{&lt;text&gt;}'\] 
%% is defined.\footnote{This is the common, confusing way 
%%                      to describe such situations. 
%%                      Actually, the definition assigns a 
%%                      macro meaning to a ``named token" 
%%                      whose name is ```MF@field:&lt;field&gt;'". 
%%                      \emph{Typing} `&amp;\MF@field:&lt;field&gt;' won't work.}
    \@namedef{\MF@field#2}##1{%
        \MF@reduce@bg##1\rest@t#1\rest@f{##1}{#2}}}
%%
%% === Checking Field   ===
%% \label{sec:text}
%% |\MF@check@field{&lt;align&gt;}{&lt;text&gt;}{&lt;field&gt;}|
%% runs |\MF@field:&lt;field&gt;{&lt;text&gt;}| from above, 
%% provided the latter has been defined (by `\MFfieldtemplate').
%% The &lt;align&gt; command is appended.
\newcommand*{\MF@check@field}[3]{%
    \@ifundefined{\MF@field#3}%
%                  {\PackageError{field "#3" not defined}%
%                                {use \string\MFfieldtemplate}}%
%% With v0.1, I thought about errors and warnings properly only 
%% more below ...
                 {\MF@field@undeclared{#2}{#3}}%
                 {\csname\MF@field#3\endcsname{#2}#1}}
%% |\MF@field@undeclared{&lt;text&gt;}{&lt;field&gt;}| just outputs &lt;text&gt;. 
\newcommand*{\MF@field@undeclared}[2]{#1}
%% A proper message is problematic in \strong{pure expansion}
%% as on screen or in \file{.log} files. 
%% Package option |fake-undefined| (Sec.~\ref{sec:opt}) 
%% offers another ``cheap" solution.
%% (TODO)
%% 
%% === Trying Alignment ===
%% |\MF@reduce@bg&lt;r-text&gt;\rest@t&lt;r-fill&gt;\rest@f{&lt;text&gt;}{&lt;field&gt;}&lt;align&gt;| 
%% \\[\smallskipamount]
%% is invoked by that `\MF@field:&lt;field&gt;' that 
%% `\MF@store@field@bg' defines as above.
%% It takes away one element both from the (remaining) &lt;text&gt; 
%% (delimited by `\rest@t') and the filler list (delimited by `\rest@f'). 
%% The full &lt;text&gt; has been stored ahead.
\def\MF@reduce@bg#1#2\rest@t#3#4\rest@f{%
    \MF@if@empty{#2}%
        {\MF@if@empty{#4}%
%% When we have removed the last elements of both lists at the same time, 
%% we just return &lt;text&gt;:
                     \@firstofthree
%% When we have removed the last element of &lt;text&gt;, and there still is
%% a filler element, we perform the alignment:
                     {\MF@fine@align{#4}}}%
        {\MF@if@empty{#4}%
%% When we have removed the last filler element, and a &lt;text&gt; element 
%% is still present, we return &lt;text&gt;, maybe together with a warning:
                     \MF@bad@align
%% When neither #1 nor #3 have been the last elements in their lists, 
%% we run `\MF@reduce@bg' on the remaining lists:
                     {\MF@reduce@bg#2\rest@t#4\rest@f}}}
%% |\@firstofthree{&lt;use&gt;}{&lt;skip&gt;}{&lt;skip&gt;}| may be known or not ...
\long\def\@firstofthree#1#2#3{#1}
%% |\MF@fine@align{&lt;filler&gt;}{&lt;text&gt;}{&lt;field&gt;}&lt;align&gt;| ...
\newcommand*{\MF@fine@align}[4]{\if r#4#1#2\else#2#1\fi}
%% |\MF@bad@align{&lt;text&gt;}{&lt;field&gt;}{&lt;align&gt;}|\\[\smallskipamount]
%% % gobbles &lt;align&gt;,
%% % throws a message about &lt;text&gt; and &lt;field&gt;, and outputs &lt;text&gt;.
%% % If this happens at \strong{pure expansion} such as writing 
%% % to \emph{screen} or a \emph{plain text file}, something really 
%% % awful may happen ... (we may adjust `\MF@bad@align' better 
%% % for this case, another time ... TODO)
%% at present is similar to `\@firstofthree'. 
%% In a future package version, we may add some warning or so 
%% for cases where it is useful---while it is not useful to write 
%% \emph{code} for warnings to screen and \file{.log} 
%% (the originally intended use of the package).
%% We offer a ``cheap" possibility of throwing some error by 
%% package option |fake-undefined|---see Sec.~\ref{sec:opt}
\newcommand*{\MF@bad@align}[3]{#1}
%% Actually, in v0.1 |\MF@check@field| appends the &lt;field&gt; 
%% argument hoping it could be used in a warning.
%% 
%% == Package Option     ==
%% \label{sec:opt}
%% With applications like `\listfiles', it may be useful to get an 
%% ``undefined" error where the name of the undefined command 
%% is a kind of ``secret message" ...
\DeclareOption{fake-undefined}{%
%% #1 is &lt;text&gt; and will be output, #2 is &lt;field&gt;, cf.~above.
    \def\MF@field@undeclared#1#2{#1\monofillFieldUndeclared}
    \def\MF@bad@align#1#2#3{#1\monofillFieldTooSmall}}
\ProcessOptions
%% == \cs{endinput} and Version HISTORY == 
\endinput
%%
%% VERSION HISTORY

v0.1   2012/03/18   started
       2012/03/19   completed 
v0.1a  2012/03/29   doc.: \medbreak (fix); \strong
v0.2   2012/10/29   \MFotherspace; doc. slightly reformatted
</pre></body></html>