% -*-LaTeX-*-
% TROFFMS.STY for tr2latex - troff to latex translator
% These macros are intended to be referenced by a LaTeX
% \documentstyle[troffms,twoside]{article}
% command.  You can insert an 11pt or 12pt option if you like larger
% type--sizes set here are computed from the LaTeX point size setting.
% You need these macros since they are refered to by the translator.
% You can modify them if you want.
% I would very much want better macros for the headers and footers.
% Please pass your suggestions to me.           -Christian
% Extended by L. Jostameling

\def\ps@sepone{%
  \def\@oddhead{}
  \def\@evenhead{}
  \def\@oddfoot{\hfil\@oddcfoot\hfil}
  \def\@evenfoot{\hfil\@oddcfoot\hfil}
}
\thispagestyle{sepone}

\def\@threepart#1#2#3{\rlap{#1}\hfil #2\hfil\llap{#3}}
\def\ps@sep{%
    \def\@oddhead{\@threepart{\@oddlhead}{\@oddchead}{\@oddrhead}}%
    \def\@oddfoot{\@threepart{\@oddlfoot}{\@oddcfoot}{\@oddrfoot}}%
    \def\@evenhead{\@threepart{\@evenlhead}{\@evenchead}{\@evenrhead}}%
    \def\@evenfoot{\@threepart{\@evenlfoot}{\@evencfoot}{\@evenrfoot}}%
}
\pagestyle{sep}

\def\lefthead  #1{\def\@oddlhead{#1}\def\@evenlhead{#1}}
\def\centerhead#1{\def\@oddchead{#1}\def\@evenchead{#1}}
\def\righthead #1{\def\@oddrhead{#1}\def\@evenrhead{#1}}
\lefthead{}
\centerhead{- \thepage\ -}
\righthead{}

\def\leftfoot  #1{\def\@oddlfoot{#1}\def\@evenlfoot{#1}}
\def\centerfoot#1{\def\@oddcfoot{#1}\def\@evencfoot{#1}}
\def\rightfoot #1{\def\@oddrfoot{#1}\def\@evenrfoot{#1}}
\let\footer\centerfoot
\leftfoot{}
\centerfoot{}
\rightfoot{}

\newcommand{\EvenHeader}[3]{
    \def\@evenlhead{#1}%
    \def\@evenchead{#2}%
    \def\@evenrhead{#3}%
}
\newcommand{\EvenFooter}[3]{
    \def\@evenlfoot{#1}%
    \def\@evencfoot{#2}%
    \def\@evenrfoot{#3}%
}
\newcommand{\OddHeader}[3]{
    \def\@oddlhead{#1}%
    \def\@oddchead{#2}%
    \def\@oddrhead{#3}%
}
\newcommand{\OddFooter}[3]{
    \def\@oddlfoot{#1}%
    \def\@oddcfoot{#2}%
    \def\@oddrfoot{#3}%
}

\def\makefootline{\baselineskip24\p@\line{\the\footline}}
\def\makeheadline{\vbox to 0pt{\vskip-22.5pt \line{vbox to 8.5pt{}\the\headline}\vss}\nointerlineskip}

\font\bigbf=cmbx10 scaled\magstep 3
\font\bigit=cmti10 scaled\magstep 2
\font\bigrm=cmr10 scaled\magstep 2

\newdimen\en \en=.5em

% Dimens for A4 paper
\topmargin=0cm
\ifcase \@ptsize
    % mods for 10 pt
    % \baselineskip = 12pt
    \textheight 53\baselineskip %= 636pt
\or % mods for 11 pt
    % \baselineskip = 13.6pt
    \textheight 46\baselineskip % = 625pt
\or % mods for 12 pt
    % \baselineskip = 15pt
    \textheight 42\baselineskip % = 630pt
\fi
\advance\textheight by \topskip

\textwidth=6.3in
\textfloatsep 30pt plus 3pt minus 6pt
\parskip=5pt
\oddsidemargin=0in
\evensidemargin=6in
\voffset=0in
\newdimen\singlespacing
\singlespacing=11pt % single line spacing
\normalbaselineskip=15pt     % 1.5 line spacing
\baselineskip=\normalbaselineskip
\parindent=5\en
\let\@listi\@listii

% change the BEFORESKIP and AFTERSKIP to make a break after tht head
\def\paragraph{\@startsection
    {paragraph}{4}{\z@}{-2ex plus -lex minus -.2ex}{1ex}{\normalsize\bf}}
% set levelnumber for subparagraph to 5 and make no indent
\def\subparagraph{\@startsection
    {subparagraph}{5}{\z@}{-2ex plus -lex minus -.2ex}{lex}{\normalsize\bf}}

\setcounter{secnumdepth}{5} % to number paragraphs and subpara iraphs A
\setcounter{tocdepth}{4}    %	let paragraphs apear in ToC

% multi-line title
\newenvironment{SEPtitle}{\begin{center}\bigbf}{\end{center}}
\def\title#1{
    \begin{SEPtitle}
    \vbox{\baselineskip=1.5\normalbaselineskip
    \vskip1in #1\vskip.3in}
    \end{SEPtitle}}
% multi-line author
\newenvironment{SEPauthor}{\begin{center}\bigit}{\end{center}}
\def\author#1{
    \begin{SEPauthor}
    \vbox{\baselineskip-1.3\normalbaselineskip
    #1 \vskip.3cm}
    \end{SEPauthor}}
\newenvironment{SEPauthoraff}{\begin{center}\bigrm}{\end{center}}
\def \authoraff#1{
    \begin{SEPauthoraff}
    \vbox{\baselineskip=1.1\normalbaselineskip
    #1 \vskip.2in}
    \end{SEPauthoraff}}
% multi-line centered section heading
\newenvironment{SEPmhead}{\begin{center}\bf}{\end{center}}
\def\mhead#1{\pagebreak[3]
    \begin{SEPmhead}\pagebreak[3]
    \vbox{\vskip.3in #1}\nopagebreak
    \end{SEPmhead}\nopagebreak}
%multi-line left-justified subheading
%\newenvironment{SEPshead}{\begin{flushleft/}\bf}{\end{flushleft}}
%\def\shead#1{\pagebreak[3]
%	\begin{SEPshead}\pagebreak[3]
%	\vbox{\vskip.2in #1}\nopagebreak
%	\end{SEPhead}\nopagebreak}
\newcommand{\shead}[1]{\subsubsection*{#1}}

% define ABSTRACT, INTRODUCTION, DISCUSSION, CONCLUSIONS, REFERENCES
% and APPENDIX as the first three letters
\def\ABS{\mhead{ABSTRACT}}
\def\INT{\mhead{INTRODUCTION}}
\def\DIS{\mhead{DISCUSSION}}
\def\CON{\mhead{CONCLUSIONS}}
\def\ACK{\mhead{ACKNOWLEDGMENT}}
\def\REF{\mhead{REFERENCES}}
\def\APP{\mhead{APPENDIX}}
\renewcommand{\abstractname}{\ABS}

% reference macro, second ... lines are indented
\newdimen\dtmp     % temporary dimension variable
\def\reference#1{\baselineskip=\singlespacing \dtmp=\hsize
                \advance\dtmp by-\parindent \parshape 2 0in \hsize \parindent
                \dtmp \noindent #1 \endgraf \baselineskip=\normalbaselineskip
                \vskip4pt
                }

\def\bs{$\backslash$}
\let\under=\underline
\let\dotdot=\ddot

\def \Dash{\leavevmode $\mathsurround=0pt\vcenter{\hrule width 0.75em}$}

\def \registered{{\ooalign{\hfil\raise.05ex\hbox{\the\scriptfont0 R}%
    \hfil\crcr\mathhexbox20D}}}

\def\fraction #1/#2{\leavevmode\kern.1em\raise.6ex\hbox{\the\scriptfont 0 #1}%
	\kern-.15em/\kern-.2em\lower.4ex\hbox{\the\scriptfont 0 #2}}

\newcommand{\themonth}{\ifcase\month\or
	January\or February\or March\or April\or May\or June\or
	July\or August\or September\or October\or November\or December\fi}

\def\nwl{\ifhmode \unskip\hfil \penalty -\@M\relax\fi}
							% similar to latex's \newline but does lot
							% complain if there is no line to break
\def\ind#1{\par\noindent\everypar{\hangindent=#1\hangafter=0}}
\def\tmpind#1{\par\hskip#1}
\newenvironment{SEPcntr}{\begin{center}}{\end{center}}
\def\cntr#1{\begin{SEPcntr}#1\end{SEPcntr}}

% displayed text* indented* justification off
\def\displaybegin{\par\begingroup\medskip\narrower\narrower\noindent
	\obeylines\obeyspaces}
\def\displayend{\endgroup\smallskip\noindent}

% fill and nofill
%\def\nofill{\par\begingroup\noindent\obeylines
%	\frenchspacing\@vobeyspaces\linepenalty10000}
\def\nofill{\par\noindent\obeylines
	\frenchspacing\@vobeyspaces\linepenalty10000}
%{\catcode`\ =\active\gdef\@vobeyspaces{\catcode`\ \active \let \@xobeysp}}
\def\@xobeysp{\leavevmode{}}
%\def\fill{\endgroup\noindent}
\def\fill{\nonfrenchspacing\allowbreak\noindent}

% define a boxing macro
\def\boxit#1{\vbox{\hrule\hbox{\vrule\kern10pt\vbox{\medskip\kern5pt#1\bigskip
	\kern5pt}\kern10pt\vrule}\hrule}}

% for the ".ad c" troff command
\def\noragged{\par\leftskip\z@ \rightskip\z@ \let\\=\@normalcr
	\parfillskip\@flushglue}
\def\adjust#1{\if#1l \raggedright
	     \else\if#1c \centering
	     \else\if#1r \raggedleft
	     \else\noragged
\fi\fi\fi}
%
\def\XParagraph{\smallbreak \noindent \hangindent=\parindent \hangafter=1}
%\newenviromnent{\XParagraph}{\list{}{\leftmargin\parindent \labelwidth\z@
%	\itemindent-\leftmargin \itemi[]}}{\endlist}

% \begin{display}[x][y] := dispaly with no keep
% \begin{display}*[x][y] := dispaly with keep
%       x=I,L,C,B; default=I; y=indent (L = Left, I = Indent, C = center, B = block)
%
\newdimen{\displaydistance}
\setlength{\displaydistance}{.5\baselineskip}
\newcommand{\@ndmacro}{\relax}
\newenvironment{display}{\parsep\displaydistance
        \@ifstar{\samepage\@display}{\@display}}%
    {\@ndmacro}%
\def\@display{\obeycr\@ifnextchar[{\@xdisplay}{\@xdisplay[I]}}%
\def\@xdisplay[#1]{\csname @#1display\endcsname}%
\def\@Idisplay{\@ifnextchar[{\@xIdisplay}{\@xIdisplay[\parindent]}}%
\def\@xIdisplay[#1]{\let\@ndmacro\endlist
    \def\@nolnerr{}%	suppress error message from \obeycr
    \list{}{\leftmargin#1\item[]}}%
\def\@Ldisplay{\@xIdisplay[0pt]}%
\def\@Cdisplay{\let\@ndmacro\endcenter
    \def\@nolnerr{}%	suppress error message from \obeycr
    \center}%
\def\@Bdisplay{\def\@ndmacro{\endtabular\endcenter}\center\tabular[t]{l}}%

% .ux ==
\newcommand{\unix}{{\sc Unix}\footnote{UNIX is a trademark of Bell Laboratories.}
\def\unix{{\sc Unix}}}

\def\setleftmargin[#1]{%
        \setlength{\leftmargin}{#1\en}%
        \setlength{\labelwidth}{\leftmargin}%
        \addtolength{\labelwidth}{-\labelsep}%
}

% definitions for the '.SM* and '.LG* macros
\newcounter{fontsize}
\setcounter{fontsize}{4}
\newcommand{\SMaller}{%
    \addtocounter{fontsize}{-1}
    \ifnum\c@fontsize < \z@ \else \SelectFont{\c@fontsize}\fi}
\newcommand{\LarGer}{%
    \addtocounter{fontsize}{1}
    \ifnum\c@fontsize > 9 \else \SelectFont{\c@fontsize}\fi}
\newcommand{\SelectFont}[1]{
    \ifcase #1
        \tiny \or
        \scriptsize \or
        \footnotesize\or
        \small \or
        \normalsize \or
        \large \or
        \Large \or
        \LARGE \or
        \huge\or
        \Huge
    \fi
}

\newcommand{\Normalfont}{%
    \setcounter{fontsize}{4}
    \SelectFont{\c@fontsize}}

% for own defined strings
\def\defTroffString#1#2{\@namedef{TroffString@#1}{#2}}
%
\newcommand{\useTroffString}[1]{\@nameuse{TroffString@#1}}
%\@ifnextchar ({\@@useTroffString}{\@useTroffString}}%
%\def\@useTroffString#1{\@nameuse{TroffString@#1}}%
%\def\@@useTroffString (#1#2{\@nameuse{TroffString@#1#2}}%

\newlength{\IPitemlength}
\newcommand{\IPitem}[1]{\item[#1]
\settowidth{\IPitemlength}{#1}
\ifdim\IPitemlength>\labelwidth \hfill \break \fi
}
% try this IPlist environment
%\newcommand{\deflabel}[1]{#1\hfill}
\newenvironment{IPlist}{\@IPlist}{\end{list}}%
\def\@IPlist{\par\vspace{-1ex}\@ifnextchar[{\@beginIPlist}{\@beginIPlist[5]}}%
\def\@beginIPlist[#1]{\begin{list}{}{%
    \setlength{\itemsep}{\parsep}%
    \setleftmargin[#1]
    \def \makelabel##1{##1\hfil}%
    }%
}%

\def\TroffString@la{$\langle$}
\def\TroffString@ra{$\rangle$}
\def\TroffString@lq{\textquotedblleft}
\def\TroffString@rq{\textquotedblright}
\def\TroffString@ae{\ae}
\def\TroffString@tx{\TeX}
\def\TroffString@lx{\LaTeX}
\def\TroffString@SN{\thesection.}

\newcommand{\defTroffNr}[2]{\expandafter
    \def\csname TroffRegister@#1\endcsname{#2}}

\newcommand\useTroffNr[1]{\@nameuse{TroffRegister@#1}}
\defTroffNr{H1}{\thesection}

\newcommand\useTroffFont[1]{\@nameuse{TroffFont@#1}}
\def\TroffFont@CW{\tt}
\def\TroffFont@CI{\it\ttfamily}
