
% qwertz replacement file
% translates into groff, using ms macros
% manpages can be processed using the man macros

% Author:  Tom Gordon


% Groff dependencies are few.  To port to another roff:
% 1. Check and modify, if necessary, font changes.  (e.g. In psroff the
% same fonts have other names.)
% 2. Check the code for including Encapsulated PostScript, generated
% for eps elements.
% 3. Also make versions of general.grops and math.grops, which are sed
% scripts translating character entities into groff character references.


<qwertz>	+	".nr PS 11\n"

			".nr PI 3n\n"
			".ds CF \\\\n\%\n"
			".ds CH \\&\n"
			".ds dR $\n"   % dollar, to avoid EQN conflicts

			% Footnote style
			".nr FF 1\n"

			% James Clark's trick to prevent unintended paragraph
			% breaks

			".tr \\&\n"

			% horizontal line
			".de hl\n"
			".br\n"
			"\\l'\\\\n(.lu-\\\\n(.iu'\n"
			"..\n"

			% paragraph spacing
			".if n .nr PD 1v\n"

			% h is 1 if first paragraph after heading

			".nr h 0\n"

			% initialize heading level

			".nr il 1\n"

			% Number registers for list

			".nr bi 0\n"  % initialize begin items
			".nr ll 0\n"  % list level, stores current level
			".nr el 0\n"  % current enumeration level

			% Not all list levels are enumerations, as
			% itemizations can be embedded within enumerations
			% and vice versa

			% type of list level is in \n(t\n(ll, where
			% 0 : itemize, 1 : enumerate, 2: description

			% enumerator for an enumeration level is in
			% \n(e\n(el -- i.e. \n(e1=2 means current item of
			% enumeration level 1 is 2

			% context-sensitive paragraph macro


".de Pp\n"
".ie \\\\n(ll>0 \\{\\\n"   	 % within list?
".ie \\\\n(bi=1 \\{\\\n"   % first par element of item?
".nr bi 0\n"	 % reset bi flag
% if itemization, mark with a bullet
".if \\\\n(t\\\\n(ll=0 \\{.IP \\\\(bu\\}\n" % itemize
%  if enumeration: increment and print enumerator
% for this enumeration level
".if \\\\n(t\\\\n(ll=1 \\{.IP \\\\n+(e\\\\n(el.\\}\n"
% if first par element of descrip, do nothing
".\\}\n"
".el .sp \n"		% subsequent par element of item
".\\}\n"
".el \\{\\\n"		     	% not within list
".ie \\\\nh=1 \\{\\\n"	% first par after heading
".LP\n"
".nr h 0\n"	% reset h flag
".\\}\n"
".el .PP \n"
".\\}\n"
"..\n"



			% for each level, a number register is created
			% to store its type and current item number, where
			% -1=bullet of an itemized list.

			% Format of list level enumerators

			".ds f1 1\n"
			".ds f2 a\n"
			".ds f3 i\n"
			".ds f4 A\n"

			% Number registers for theorems
			".nr def 0\n"
			".nr prop 0\n"
			".nr lemma 0\n"
			".nr coroll 0\n"
			".nr proof 0\n"
			".nr theorem 0\n"

			% Math

			".nr eqlabel 0\n" % equation counter
			".EQ\ndelim ($$)\n.EN\n"
			".ds nequiv { \"relation\" \"\\o'/\\(=='\" }\n"
			".ds nsub { \"relation\" \"\\o'/\\(sb'\" }\n"
			".ds nsube { \"relation\" \"\\o'/\\(ib'\" }\n"
			".ds nsup { \"relation\" \"\\o'/\\(sp'\" }\n"
			".ds nsupe { \"relation\" \"\\o'/\\(ip'\" }\n"
			".ds nvDash { \"relation\" \"\\z\\(br\\o'/='\"}\n"
			".ds nvdash { \"relation\" \"\\z\\(br\\o'/\\(en'\"}\n"


			% Reference commands

% redefine superscript strings so that refer tags look like [this]

			".ds \[. \[\n"
			".ds .\] \]\n"

</qwertz>

% set initial level of headings, in register il

<article>		+	".nr il 0"		+
</article>

<report>		+ 	".nr il 1"		+
</report>	+	".bp\n"
			".rm LH\n.rm RH\n"
			".TC"			+

<book>		+	".nr il 1"		+
</book>		+	".rm LH\n.rm RH\n"
			".bp\n"
			".TC"			+

<notes>
</notes>

<manpage>	+	".nr il -1"		+
</manpage>

<titlepag>
</titlepag>

<title>		+	".TL"			+
</title>

<subtitle>	+	".br\n"
			".ft R\n"
			".SM"		+
</subtitle>	+	".LG"			+

<author>
</author>

<name>		+	".AU"			+
</name>

<and>
</and>

<thanks>			"\\**\n"
			".FS"			+
</thanks>	+	".FE"			+

<inst>		+	".AI"			+
</inst>

<newline>	+	".br"			+
</newline>

<label>
</label>

<header>
</header>

<lhead>		+	".EH '"
</lhead>		"'''"		+

<rhead>		+	".OH '''"
</rhead>		"'"			+

<comment>	+	".PP\n.ft HI"		+
</comment>	+	".ft P"			+

<abstract>	+	".AB"			+
</abstract>	+	".AE"			+

<appendix>	+ 	".af H1 A"		+
</appendix>

% limitation: no list of figures or tables.  A table of contents
% is always generated for books and reports. Thus these next three tags
% are no-ops

<toc>
</toc>

<lof>
</lof>

<lot>
</lot>

<chapt>		+	".bp\n"
			".NH \\n(il "		+
</chapt>

<sect>		+	".NH 1+\\n(il" 		+
</sect>

<sect1>		+	".NH 2+\\n(il" 	+
</sect1>

<sect2>		+	".NH 3+\\n(il"		+
</sect2>

<sect3>		+	".NH 4+\\n(il"		+
</sect3>

<sect4>		+	".NH 5+\\n(il"		+
</sect4>

<heading>		".ds h "
</heading>	+	"\\*h\n"
			".XS \\n%\n"
			"\\*(SN \\*h\n"
			".XE\n"
			".nr h 1\n"  % set heading flag to true

<p>		+	".Pp"			+
</p>

<itemize>	+	".nr ll +1\n"	   % increment list level
			".nr t\\n(ll 0\n"    % set type of level to itemize
</itemize>	+	".nr ll -1"	+  % decrement list level


<enum>		+	".nr ll +1\n"	    % increment list level
			".nr el +1\n"	    % increment enumeration level
			".nr t\\n(ll 1\n"   % set type of level to enum
			".nr e\\n(el 0 1\n" % initialize enumerator
			".af e\\n(el \\*(f\\n(el\n" % style of enumerator
			".if \\n(ll>1 .RS"  +
</enum>		+	".if \\n(ll>1 .RE\n"
			".br\n"
			".nr el -1\n"	    % decrement enumeration level
			".nr ll -1"	+   % decrement list level

<descrip>	+	".RS\n"
			".nr ll +1\n"	    % increment list level
			".nr t\\n(ll 2\n"   % set type of level to descrip
</descrip>	+	".nr ll -1\n"	    % decrement list level
			".RE"		+

% number register bi means "begin item".  Used in the .P macro to print
% bullets or numbers at beginning of first paragraph of an item.
% If bi=1 then the paragraph is the first one of the item.

<item>		+	".nr bi 1"		+
</item>

<tag>		+	".IP \"\\fB"
</tag>			"\\fP\"\n"
			".nr bi 1"			+

<cite>		+	".\[\n[ID]\n.\]"	+
</cite>

<ncite>		+	".\[\n[ID]\n.\]\n([NOTE])"
</ncite>

<footnote>		"\\**\n"
			".FS"			+
</footnote>	+	".FE"			+

<sq>			"\\*Q"
</sq>			"\\*U"

<lq>		+	".RS\n"
			".nr LL \\n(LL-\\n(PI"	+
</lq>		+	".nr LL \\n(LL+\\n(PI\n"
			".RE"			+

<em>			"\\fI"
</em>		 	"\\fP"

<bf>			"\\fB"
</bf>			"\\fR"

<it>			"\\fI"
</it>			"\\fR"

<sf>			"\\f(HR"
</sf>			"\\fR"

<sl>			"\\f(HI"
</sl>			"\\fR"

<tt>			"\\f(CR"
</tt>			"\\fR"


<ref>			"??"
</ref>

<pageref>		"??"
</pageref>

<x>
</x>

<mc>
</mc>

<biblio>	+	".\[\n"
			"$LIST$\n"
			".\]"			+
</biblio>

<code>		+	".EQ\ndelim off\n.EN\n"
			".DS L\n"
			".hl\n"
			".ft CR\n"
 			".eo"			+

</code>		+	".ec\n"
			".hl\n"
			".DE\n"
 			".EQ\ndelim ($$)\n.EN\n"
			".ft P\n"
			".LP"	+ % continue previous paragraph

<verb>		+	".EQ\ndelim off\n.EN\n"
			".DS L\n"
			".ft CR\n"
 			".eo"			+

</verb>		+	".ec\n"
			".DE\n"
 			".EQ\ndelim ($$)\n.EN\n"
			".ft P\n"
			".LP"	+  % continue previous paragraph

% theorems and such

<def>		+	".sp\n"
			".nr def \\n\[def\]+1\n"
			".B \"Definition \\n\[def\] \"" +
</def>		+	".ft P\n.sp" 		+

<prop>		+	".sp\n"
			".nr prop \\n\[prop\]+1\n"
			".B \"Proposition \\n\[prop\] \"" +
</prop>		+	".ft P\n.sp" 		+


<lemma>		+	".sp\n"
			".nr lemma \\n\[lemma\]+1\n"
			".B \"Lemma \\n\[lemma\] \""	+
</lemma>	+	".ft P\n.sp" 		+

<coroll>	+	".sp\n"
			".nr coroll \\n\[coroll\]+1\n"
			".B \"Corolloary \\n\[coroll\] \"" +
</coroll>	+	".ft P\n.sp" 		+

<proof>		+	".sp\n"
			".nr proof \\n\[proof\]+1\n"
			".B \"Proof \\n\[proof\] \""	+
</proof>	+	".ft P\n.sp" 		+

<theorem>	+	".sp\n"
			".nr theorem \\n\[theorem\]+1\n"
			".B \"Theorem \\n\[theorem\] \"" +
</theorem>	+	".ft P\n.sp" 		+

<thtag>		+ 	".B\n("
</thtag>		")\n.I"			+

% mathematics

<f>			"$"
</f>			"$"

<dm>		+	".DS L\n"
			".EQ"			+
</dm>		+	".EN\n"
			".DE"			+

<eq>		+	".DS L\n"
			".nr eqlabel \\n\[eqlabel\]+1\n"
			".EQ \\n\[eqlabel\]"		+
</eq>		+	".EN\n"
			".DE"			+

<fr>
</fr>

<nu>			"{"
</nu>			"} over "

<de>			"{"
</de>			"}"

<lim>
</lim>

<op>
</op>

<ll>			" from {"
</ll>			"}"

<ul>			" to {"
</ul>			"}"

<opd>
</opd>

<pr>			" prod "
</pr>

<in>			" int "
</in>

<sum>			" sum "
</sum>

% limitation: eqn only does square roots!

<root>			" sqrt {"
</root>			"}"

<ar>		+	".TS\n"
			"center, tab(|), delim ($$); \n"
			"[ca]."			+
</ar>		+	".TE"			+

<arr>   		"\n"
</arr>

<arc>   		"|"
</arc>


<sup>			" sup {"
</sup>			"}"

<inf>			" sub {"
</inf>			"}"


<unl>			"{"
</unl>			"} under "

<ovl>			"{"
</ovl>			"} bar "

<rf>			" bold{"
</rf>			"}"

<v>			"{"
</v>			"} vec "

% limitation: no calligraphic characters, using helvetica italics instead.  Is there a better font?

<fi>			"\\f(HI"
</fi>			"\\fP"

<phr>			" roman }"
</phr>			"}"


<tu>		+	".br"		+
</tu>

% figures

<figure>	% +	".KF"			+
</figure>	% +	".KE"			+

<eps>		+  	".if t .PSPIC [file].ps\n"
			".if n .sp 4"	  	+
</eps>

% Are TeX units properly handled by this translation of ph?

<ph>		+	".sp [VSPACE]"		+
</ph>

<caption>	+	".sp\n.ce"		+
</caption>

% tables

<table>		+	".KF\n.R"		+
</table>	+	".KE"			+

<tabular>	+	".TS\n"
			"center, tab(|), delim ($$);\n"
			"[ca]."			+
</tabular>	+	".TE"			+

<rowsep>		"\n"			+
</rowsep>

<colsep>		"|"
</colsep>

<hline>		+	"_"			+
</hline>

<slides>	+ 	".nr PS 18"		+
</slides>

<slide>
</slide>	+	".bp\n\\&"			+

% letters -- replacement for email, using mh format.

<letter>	+	".nf"	+
</letter>	+

<from>		+ 	"From: "
<to>		+	"To: "

<address>	+	".de Ad\n"
</address>	+	".."	+

<email>			" <"
</email>		">"

<subject>	+	"Subject: "

<sref>		+	"Sref: "
<rref>		+	"In-Reply-To: "

<cc>		+	"cc: "

<opening>	+	".fi\n.LP"	+

<closing>	+	".LP"		+

<encl>		+	".XP\n"
			"encl: "

<ps>		+	".LP\np.s."


% end of roff replacement file

