%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Project:     Documentation Tools
%% Descr:       Latex -->  MAN-page (groff -man), LaTeX package
%% Author:      Dr. Jürgen Vollmer, Juergen.Vollmer@informatik-vollmer.de
%% $Id: latex2man.sty,v 1.93 2018/11/25 13:05:37 vollmer Exp $
%% VERSION: 1.29
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%% `latex2man' package to use with LaTeX2e.
%%
%% Latex2man is a tool to translate UNIX manual pages written with LaTeX into a
%% format understood by the UNIX man(1)-command.
%% Alternatively HTML or TexInfo code can be produced too.
%% Output of parts of the text may be supressed using the conditional text
%% feature.
%%
%% There is LaTeX package (latex2man.sty) used for writing the Man-page
%% and a PERL script (latex2man) doing the actual translation.
%%
%% Copyright (C) 1998, Dr. Juergen Vollmer
%%                     Am Rennbuckel 21, D-76185 Karlsruhe, Germany
%%                     Juergen.Vollmer@informatik-vollmer.de
%% License:
%%   This program can be redistributed and/or modified under the terms
%%   of the LaTeX Project Public License Distributed from CTAN
%%   archives in directory macros/latex/base/lppl.txt; either
%%   version 1 of the License, or any later version.
%%
%% If you find this software useful, please send me a postcard.
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{latex2man}[2018/11/25 v1.29]
\usepackage{ifthen}

\newif\if@LM@UseFancy@
\newif\if@LM@UseFancyHdr@

\DeclareOption{fancy}{
  \@LM@UseFancy@true
  \@LM@UseFancyHdr@false
}
\DeclareOption{fancyhdr}{
  \@LM@UseFancyHdr@true
  \@LM@UseFancy@false
}
\DeclareOption{nofancy}{
  \@LM@UseFancy@false
  \@LM@UseFancyHdr@false
}

\input{latex2man.cfg}
\ProcessOptions
\if@LM@UseFancy@
    \RequirePackage{fancyheadings}
\fi
\if@LM@UseFancyHdr@
    \RequirePackage{fancyhdr}
\fi

\newcommand{\@LM@Arg}[1]{\textit{#1}}
\newcommand{\@LM@Opt}[1]{\textbf{#1}}

\newcommand{\Opt}[1]{\@LM@Opt{#1}}                      % Option
\newcommand{\Arg}[1]{\@LM@Arg{#1}}                      % Argument
\newcommand{\OptArg}[2]{\Opt{#1}\Arg{#2}}               % Option with Argument
\newcommand{\OptoArg}[2]{\Opt{#1}[\Arg{#2}]}            % Option with optinal
                                                        % Argument

\newcommand{\oArg}[1]{[\Arg{#1}]}                       % optional Argument
\newcommand{\oOpt}[1]{[\Opt{#1}]}                       % optional Option
\newcommand{\oOptArg}[2]{[\OptArg{#1}{#2}]}             % optional Option with Argument
\newcommand{\oOptoArg}[2]{[\OptoArg{#1}{#2}]}           % optional Option with
                                                        % optional Argument

\newcommand{\Prog}[1]{\textit{#1}}                      % Program name
\newcommand{\Cmd}[2]{\textit{#1}(#2)}                   % Command with number

\newcommand{\@LM@File}[1]{\texttt{#1}}
\newcommand{\File}[1]{\@LM@File{#1}}                    % File name

\newcommand{\Bs}{$\mathtt{\backslash}$}
\newcommand{\Bar}{$\mathtt{|}$}
\newcommand{\Tilde}{\ensuremath{\mathtt{\sim}}}
\newcommand{\Dots}{$\dots$}
\newcommand{\Circum}{\^{}}
\newcommand{\Lbr}{[}
\newcommand{\Rbr}{]}
\newcommand{\LBr}{\{}
\newcommand{\RBr}{\}}
\newcommand{\Dollar}{\$}
\newcommand{\Percent}{\%}
\newcommand{\Bullet}{$\bullet$}
\newcommand{\TEXbr}{~\\}
\newcommand{\MANbr}{}
\newcommand{\HTMLbr}{}
\newcommand{\TEXIbr}{}
\newcommand{\SP}{\hspace*{0.5em}}

\def\@LM@Date{}
\newcommand{\setDate}[1]{\def\@LM@Date{#1}}
\newcommand{\Date}{\@LM@Date}

\def\@LM@VersionWord{Version:}
\newcommand{\setVersionWord}[1]{\def\@LM@VersionWord{#1}}

\def\@LM@Version{}
\newcommand{\setVersion}[1]{\def\@LM@Version{#1}}
\newcommand{\Version}{\@LM@Version}

\newcommand{\Email}[1]{\texttt{#1}}
\newcommand{\URL}[1]{\texttt{#1}}
\newcommand{\LatexManEnd}{}

\newenvironment{Name}[5]{
% #1 Chapter
% #2 Name
% #3 Author
% #4 Tool
\if@LM@UseFancy@
\gdef\@LM@Foot{\emph{\@LM@VersionWord\ \@LM@Version, \@LM@Date}}
\rfoot[\fancyplain{#2 (#1)}{#2 (#1)}]{\fancyplain{\@LM@Foot}{\@LM@Foot}}
\lfoot[\fancyplain{\@LM@Foot}{\@LM@Foot}]{\fancyplain{#2 (#1)}{#2 (#1)}}
\fi
\if@LM@UseFancyHdr@
\gdef\@LM@Foot{\emph{\@LM@VersionWord\ \@LM@Version, \@LM@Date}}
\rfoot[\fancyplain{#2 (#1)}{#2 (#1)}]{\fancyplain{\@LM@Foot}{\@LM@Foot}}
\lfoot[\fancyplain{\@LM@Foot}{\@LM@Foot}]{\fancyplain{#2 (#1)}{#2 (#1)}}
\fi
\title{#5}
\author{#3}
\date{\@LM@Date\\{\small Version \@LM@Version}}
\maketitle
\begin{abstract}
}{
\end{abstract}
}

% first optional argument specifies width of last column
% second argrtment specifies number of columns
\newenvironment{Table}[2][]{
\def\OPTARG{#1}
\def\COLUMNS{#2}
\def\LASTCOL{}
\def\EMPTY{}
\ifx\OPTARG\EMPTY\else%
 \def\COLUMNS{%
  \ifcase#2 1\or 1\or 1\or 2\or 3\or 4\or 5\or 6\or 7\or 8\or 9\else 10\fi%
 }
 \def\LASTCOL{p{#1}}
\fi%
\par
\begin{tabular}{*\COLUMNS{l}\LASTCOL}
}{
\end{tabular}
\par
}

\newenvironment{Description}[1][]{
\begin{list}{}{
 \ifthenelse{\equal{#1}{}}{
   % optional argument not given
     \labelwidth\z@ \itemindent-\leftmargin
     \let\makelabel\descriptionlabel
     \renewcommand{\makelabel}[1]{\hspace\labelsep\normalfont\bfseries##1}
  }{
   % optional argument given
   \settowidth{\labelwidth}{\normalfont\bfseries#1}
   \setlength{\leftmargin}{\labelwidth}
   \addtolength{\leftmargin}{\labelsep}
   \renewcommand{\makelabel}[1]{\normalfont\bfseries##1\hfil}
  }}
}{
\end{list}
}

\AtBeginDocument{
\if@LM@UseFancy@
  \pagestyle{fancyplain}
\fi
\if@LM@UseFancyHdr@
  \pagestyle{fancyplain}
\fi
\setDate{\today}
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\endinput