pauld@cs.washington.edu (Paul Barton-Davis) (06/05/91)
Below are two files, unixman.sty & unixman.tex that contain various fixes added since this was first posted. I have asked Don Hosek to upload this to the archive, since the version there is broken. This new version does NOT require any further style files in order to work. Unixman.tex is a manual page that uses unixman.sty to document how to use this style. ---- 8< cut here for unixman.sty ---- %% Unix `man' macros for LaTeX %% Paul Davis <pauld@cs.washington.edu> Feb 1989, June 1991 %% v1.2 - removed references to new font switches, tidied up %% page dimensions a little. \def\@truedocstyle{Document Style `Unix Manual' V1.2 June 4th 1991} \input{article.sty} %% %% --------------- PAGE DIMENSIONS ------------------- %% \newdimen\sectionindent \newdimen\subsectionindent \newdimen\subsubsectionindent \sectionindent 0.5 true in \subsectionindent 0.25 true in \subsubsectionindent 0pt \oddsidemargin \sectionindent \evensidemargin \sectionindent \hoffset -1.35 cm %% I really don't know why it needs this ... \textwidth 6 in \textheight 21.5cm \headsep 0.5 in \topmargin -8mm \topskip 0pt \footskip 0.5 in \parindent 0pt \parskip \baselineskip %% %% ------------------- FONTS ------------------- %% %% Normal troff uses Times Roman for its output. I much prefer %% this, but many LaTeX users have no access to this. If you %% want to, you can insert a magic incantation here that will %% give you Times Roman (I use \input{times.sty}). Otherwise, %% you'll get cruddy old Computer Modern throughout. %% %% ---------------- SECTIONING COMMANDS -------------- %% \def\section{\@startsection {section}{1}{-\sectionindent} {0pt plus .5ex minus -.2ex}{-1sp}{\normalsize\bf}*} \def\subsection{\@startsection {subsection}{2}{-\subsectionindent} {0pt plus .5ex minus -.2ex}{-1sp}{\normalsize\bf}*} \def\subsubsection{\@startsection {subsubsection}{3}{\subsubsectionindent} {0pt plus .5ex minus -.2ex}{-1sp}{\normalsize\it}*} %% %% a modified version of \@xsect %% %% In this case, if AFTERSKIP is negative, we simply %% backup by \parskip immediately after the section heading. %% This has the net effect of leaving no extra vertical space %% between the heading and any following material. We also set %% \@nobreaktrue to avoid extra space when putting a \list %% immediately after such a heading. \def\@xsect#1{\@tempskipa #1\relax \ifdim \@tempskipa>\z@ \par \nobreak \vskip \@tempskipa \@afterheading \else \global\@nobreaktrue \global\@noskipsectrue \everypar{\if@noskipsec \global\@noskipsecfalse \clubpenalty\@M \hskip -\parindent \begingroup \@svsechd \endgroup \unskip \vskip -\parskip \else \clubpenalty \@clubpenalty \everypar{}\fi}% \fi \ignorespaces} %% %% --------------- MISCELLANEOUS MACROS --------------- %% \def\command#1#2{{\it #1}\/{\rm (#2)}}% \def\code#1{{\bf #1}} \def\>{$>$\ignorespaces}% \def\<{$<$\ignorespaces}% \def\tilde{\~{}}% \def\HOME{\tilde}% \def\bs{$\backslash$} \def\file#1{{\bf #1\/}} \def\prog#1{{\sf #1}} \def\pipe{{\tt |}} \def\ltrl#1{{\bf #1}} \def\arg#1{{\it #1}} \def\name#1#2{% \section{NAME} #1 -- #2} \def\synopsis{\section{SYNOPSIS}} \def\description{\section{DESCRIPTION}} \def\usage{\section{USAGE}} \def\options{\section{OPTIONS}} \def\diagnostics{\section{DIAGNOSTICS}} \def\files{\section{FILES}} \def\see{\section{SEE ALSO}} % super speedy font switching \def\I #1 {{\it #1}\ } \def\R #1 {{\rm #1}\ } \def\B #1 {{\bf #1}\ } \def\T #1 {{\tt #1}\ } \def\S #1 {{\sf #1}\ } \def\BI #1 #2 {{\bf #1}\ {\it #2}\ } \def\BR #1 #2 {{\bf #1}\ {\rm #2}\ } \def\RB #1 #2 {{\rm #1}\ {\bf #2}\ } \def\RI #1 #2 {{\rm #1}\ {\it #2}\ } \def\IB #1 #2 {{\it #1}\ {\bf #2}\ } \def\IR #1 #2 {{\it #1}\ {\rm #2}\ } %% %% ---------------- HEADERS AND FOOTERS ------------------ %% %% first we define `thing' to expand to the name of whatever this %% manpage is about. Then, we case on #2 and define the manual section %% that this fits under. It is in this section that we have some %% local specialities - sections numbered above 8 define local %% manual sections. %% Here is a map - %% 9 - Operations %% 10 - Communications %% 11 - Checklists %% 12 - Procedures %% 13 - Standards %% 14 - Devices %% %% page numbering %% %% This allows us to have selected `extra pages' in the style %% of some of the newer troff filters - Pages normally numbered %% with a pagenumber after \@xpgstart are subsequently numbered %% \@xpgstart{a,b,c ...} %% where \@xpgstart is (hopefully obviously) a number ! \newcount\@xpgstart \newcounter{@xpg} \setcounter{@xpg}{1} \newif\ifxpg \xpgfalse \def\startpage#1{\setcounter{page}{#1}} \def\extrapagesfrom#1{\@xpgstart #1 \xpgtrue} %% %% now define the header and footer %% %%%%%%%%%%%%%%%%%%%%%%% threepart.sty inlined %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% % Three part head and foot macros. 1/87 % Lance Berc % Olsen & Associates mcvax!unizh!olsen!lance@seismo.css.gov % Seefeldstrasse 233 % CH-8008 Zurich % How users can set the head and foot text. \def\lhead#1{\gdef\@lhead{#1}} \def\lfoot#1{\gdef\@lfoot{#1}} \def\chead#1{\gdef\@chead{#1}} \def\cfoot#1{\gdef\@cfoot{#1}} \def\rhead#1{\gdef\@rhead{#1}} \def\rfoot#1{\gdef\@rfoot{#1}} % Initialization of the head and foot text. % By default the page number is at the center of the foot and everything % else is empty. \def\@lhead{} \def\@lfoot{} \def\@chead{} \def\@cfoot{{\rm \thepage}} \def\@rhead{} \def\@rfoot{} % Put together a three part header or footer given the left, center and % right text. The \lap commands put the text into an hbox of zero size, % so overlapping text is not detected (it just overlaps). \def\@threepart#1#2#3{\rlap{#1} \hfil {#2} \hfil \llap{#3}} % Swap the notices on odd and even pages when twosided. \def\ps@threepartheadings { \def\@oddhead{\@threepart{\@lhead}{\@chead}{\@rhead}} \def\@oddfoot{\@threepart{\@lfoot}{\@cfoot}{\@rfoot}} \if@twoside \def\@evenhead{\@threepart{\@rhead}{\@chead}{\@lhead}} \def\@evenfoot{\@threepart{\@rfoot}{\@cfoot}{\@lfoot}} \else \def\@evenhead{\@threepart{\@lhead}{\@chead}{\@rhead}} \def\@evenfoot{\@threepart{\@lfoot}{\@cfoot}{\@rfoot}} \fi } % Default page style \ps@threepartheadings % Default footers \cfoot{\thepage} %%%%%%%%%%%%%%%%% end of threepart.sty %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \def\@foottxt{\hbox to 0pt{\hfill}} \def\@date{\hbox to 0pt{\hfill}} %%\version{VERSION-NUMBER}{DATE} \def\version#1#2{% \def\@foottxt{#1} \def\@date{#2}} %%\header{NAME}{SECTION}[HEADER][FOOTER] \newif\if@userhead \def\header#1#2{ \@userheadfalse \def\@mansecnum{#2} \@ifnextchar[% {\@bhead{#1}{#2}} {\@head{#1}{#2}}} \def\@bhead#1#2[#3]{% \def\@mansect{\uppercase{#3}}% \@ifnextchar[% {\@chead{#1}{0}} {\@head{#1}{0}}} \def\@chead#1#2[#3]{\def\@foottxt{#3} \@head{#1}{#2}} \def\@head#1#2{% \def\this{{\bf #1}} \ifcase #2 \relax \or \def\@mansect{USER COMMANDS} \or \def\@mansect{SYSTEM CALLS} \or \def\@mansect{LIBRARY FUNCTIONS} \or \def\@mansect{SPECIAL FILES} \or \def\@mansect{FILE FORMATS} \or \def\@mansect{GAMES AND DEMOS} \or \def\@mansect{TABLES} \or \def\@mansect{MAINTAINANCE COMMANDS} \or \def\@mansect{OPERATIONS} \or \def\@mansect{COMMUNCIATIONS} \or \def\@mansect{PROCEDURES} \or \def\@mansect{STANDARDS} \or \def\@mansect{DEVICES} \fi %% %% head line %% \rhead{\normalsize\uppercase{#1\/(\@mansecnum)}} \chead{\normalsize\@mansect} \lhead{\normalsize\uppercase{#1(\@mansecnum)}} %% %% footline %% \rfoot{\ifxpg% \ifnum \thepage < \@xpgstart% \normalsize\thepage \else% \normalsize\the\@xpgstart\alph{@xpg}% \addtocounter{@xpg}{1} \fi \else \normalsize\thepage \fi} \cfoot{\normalsize Last change: \@date} \lfoot{\normalsize Version: \@foottxt}} %% redefine outputpage so as to ensure that the headline and %% the footline cover the sectional headings as well. \def\@outputpage{\begingroup\catcode`\ =10 \if@specialpage \global\@specialpagefalse\@nameuse{ps@\@specialstyle}\fi \if@twoside \ifodd\count\z@ \let\@thehead\@oddhead \let\@thefoot\@oddfoot \let\@themargin\oddsidemargin \else \let\@thehead\@evenhead \let\@thefoot\@evenfoot \let\@themargin\evensidemargin \fi\fi \@tempdima \textwidth %% calculate total page width \advance\@tempdima \sectionindent \shipout \vbox{\normalsize \baselineskip\z@ \lineskip\z@ \vskip \topmargin \moveright\@themargin \vbox{\setbox\@tempboxa \vbox to\headheight{\hbox to\@tempdima{\strut\@thehead} \vfil}% \box\@tempboxa \vskip \headsep \hbox to\@tempdima{\hss\box\@outputbox} \baselineskip\footskip \hbox to\@tempdima{\@thefoot}}}% \global\@colht\textheight\endgroup \stepcounter{page}\let\firstmark\botmark} %% --------------- ENVIRONMENTS -------------------- %% a kludge to get correct spacing of a list environment %% immediately after a section name (used within given environments) \newdimen\@ughamount \@ughamount -14pt %% Don't ask ... \def\@ugh{\vskip \@ughamount} \def\@item[#1]{% \if@noparitem \@donoparitem \else \if@inlabel \indent \par \fi \ifhmode \unskip\unskip \par \fi \if@newlist \if@nobreak \@nbitem \else \addpenalty\@beginparpenalty \addvspace\@topsep \addvspace{-\parskip} \fi \else \addpenalty\@itempenalty \addvspace\itemsep \fi \global\@inlabeltrue \fi \everypar{\global\@minipagefalse\global\@newlistfalse \if@inlabel\global\@inlabelfalse \hskip -\parindent \box\@labels \penalty\z@ \fi \everypar{}}\global\@nobreakfalse \if@noitemarg \@noitemargfalse \if@nmbrlist \refstepcounter{\@listctr}\fi \fi \setbox\@tempboxa\hbox{\makelabel{#1}}% \global\setbox\@labels \hbox{\unhbox\@labels \hskip \itemindent \hskip -\labelwidth \hskip -\labelsep \ifdim \wd\@tempboxa >\labelwidth \box\@tempboxa \else \hbox to\labelwidth {\makelabel{#1}}\fi \hskip \labelsep}\ignorespaces} %% A new makelabel command that attempts to set %% the item label flushleft in a box of width \labelwdith. %% If the label is too wide, then we throw in an additional hbox %% the end, so that the item text is on a new line (kludge-y !) %% This matches the conventional method of displaying options %% in the Unix manuals. \def\flmakelabel#1{\setbox\@tempboxa\hbox{#1}% \ifdim \wd\@tempboxa > \labelwidth% \hbox to \labelwidth{% \vbox{% \hbox to 0pt{#1\hss}% \hbox to 0pt{\hfil}}% \hfil}% \else% #1\hfil\relax \fi} %% %% Options environment %% %% \opt{OPTION} option text ... %% \optarg{OPTION}{ARGUMENT} option text ... \def\opt#1{\item[{\bf #1}]} \def\optarg#1#2{% \def\arg{{\it #2}\ }% \item[{\bf #1}\ {\it #2}]} \newdimen\optionwidth \optionwidth\sectionindent \def\options{% \list{}{% \leftmargin \optionwidth \rightmargin 0pt \labelwidth \optionwidth \topsep -\parskip \partopsep -\parskip \labelsep 0pt \let\@nbitem=\@ugh \let\makelabel=\flmakelabel}} \let\endoptions=\endlist %% %% file lists %% \newdimen\filenamewidth \filenamewidth 2.0in \let\filelistfont=\bf \def\filelist{% \list{}{% \leftmargin \filenamewidth \rightmargin 0pt \labelwidth \filenamewidth \topsep -\parskip \partopsep -\parskip \itemsep 0pt \parsep 0pt \labelsep 0pt \let\@nbitem=\@ugh \let\makelabel=\flmakelabel}} \let\endfilelist=\endlist %% \fileref{FILENAME} description ... \def\fileref#1{\item[{\filelistfont #1}]\relax} %% description \newdimen\descriptionwidth \descriptionwidth 1.5 in \def\descriptionlabel#1{\flmakelabel{\bf #1}} \def\description{\list{}{% \labelwidth \descriptionwidth \leftmargin \descriptionwidth \rightmargin 0pt \topsep 0pt plus 1pt \partopsep 0pt plus 1pt \labelsep 0pt \let\makelabel=\descriptionlabel}} \let\enddescription=\endlist %% a kludge for use immediately after a section heading: \def\sdescription{\list{}{% \labelwidth \descriptionwidth \leftmargin \descriptionwidth \rightmargin 0pt \topsep 0pt plus 1pt \partopsep 0pt plus 1pt \labelsep 0pt \let\@nbitem=@ugh \let\makelabel=\descriptionlabel}} \let\endsdescription=\endlist %% examples \let\examplefont=\tt \def\example{\list{}{% \leftmargin 1cm \rightmargin 1cm \topsep 0pt \partopsep 0pt \examplefont} \item[]} \let\endexample=\endlist ---- 8< cut here for unixman.tex --- \documentstyle{unixman} \filenamewidth 3.5 in \def\met#1{{\it #1}} \def\meta#1{{$<${\it #1}$>$}} \gdef\[{\char'133} \gdef\]{\char'135} \begin{document} \version{1.1}{4th June 1991} \header{unixman}{1L}[\LaTeX\ styles] \section{NAME} unixman -- \LaTeX\ document style produce Unix-style manual pages \section{SYNOPSIS} {\tt \bs documentstyle[unixman]\\ \bs begin\{document\}\\ \bs header\{\met{name}\}\{\met{section-number}\}[\met{section-name}]\\ \bs version\{\met{version-id}\}\{\met{date}\} \bs section\{NAME\} \hbox to 2cm{\hfil \vdots \hfil} \bs end\{document\} } \section{DESCRIPTION} The \this\ document style produces documents conforming to the conventions of the Unix manual, as embodied in the \command{troff}{1} ``man'' macros. It uses the standard \LaTeX\ sectioning commands, and defines several new commands and environments to make manual page formatting easier. These include facilities for printing lists of command line flags and doing rapid font switches, which tend to be common to reference manuals. \subsection{Commands} \begin{description} \item[\bs version\{{\it version-id}\}\{{\it date}\}] define the version number and date of modification of this manual entry. \item[\bs header\{\I name \}\{\I section-number \}\[\I section-name \]] define the name of the command and the section number in which it is to appear. \I section-name is an optional argument used to override the default name for \I section-number. \item[\bs startpage\{{\it page-number}\}] start page numbering from {\it pagenumber}. \item[\bs extrapagesfrom\{{\it page-number}\}] number all pages beyond {\it pagenumber} in the style {\it pagenumber}a, {\it pagenumber}b and so on. For use when adding extra pages to an existing manual. For instance, if you use {\tt \bs extrapagesfrom\{260\}}, then instead of 260, 261, 262 you will get 260, 260a, 260b and so on. \item[\bs file\{{\it file}\}] prints the name of a file in the default font for such items\\ (e.g. {\tt \bs file\{/usr/lib\}} $\rightarrow$ \file{/usr/lib}) \item[\bs prog\{{\it program}\}] prints a program in the default font for such items\\ (e.g. {\tt \bs prog\{awk\}} $\rightarrow$ \prog{awk}). \item[\bs this] prints the name of this manual page, emboldened. \item[\bs R, \bs B, \bs T, \bs I, \bs S] print the next word in a \R roman, \B bold, \T typewriter, \I italic, and \S san-serif font respectively. The word must be delimited by white space. \item[\bs RB, \bs RI, \bs IB, \bs IR, \bs BI, \bs BR] print the next two words in alternating fonts, where the two letters specify the font according to the single word version described above. The words must be delimited by whitespace. \item[\bs tilde] prints a tilde (\tilde) \item[\bs pipe] prints a vertical bar (\pipe). \item[\bs bs] prints a backslash (\bs). Useful for manual pages about \LaTeX. \item[\bs\<\ \R \& \bs\>] print left- and right- arrow brackets (\<\ \& \>). These commands ignore following spaces completely. \item[\bs \[\ \R and \bs \]] print left and right square brackets (\[\ \& \]). Necessary in {\tt item} labels within a list environment. \end{description} \subsection{Environments} The \this\ style defines several new environments to make the formatting of manual pages easier and more consistent. \subsubsection{Options} The {\tt options} environment is intended for creating lists of command line flags. Within it there are two special commands, {\tt \bs opt} and {\tt \bs optarg}. The first is used to describe an flag that has no arguments; the second is used in the case where there are arguments. With the {\tt optarg} command, you can use the command {\tt \bs arg} to simply print the argument in the same style and without retyping it. An example -- the following \LaTeX\ specification: \begin{example} \begin{verbatim} \begin{options} \opt{-p} print top value on the stack \optarg{-s}{x} put top of stack into register named \arg \optarg{-I}{directory} add \arg to the list of directories searched. \end{options} \end{verbatim} \end{example} produces the following results \begin{example} \rm \begin{options} \opt{-p} print top value on the stack \optarg{-s}{x} put top of stack into register named \arg \optarg{-I}{directory} add \arg to the list of directories searched. \end{options} \end{example} Note how the description is positioned when the argument associated with an option flag is especially long (see PARAMETERS, below). \subsubsection{Filelist} The {\tt filelist} environment provides a simple means of formatting lists of files for the standard FILES section of a manual page, or elsewhere if desired. \begin{example} \bs begin\{filelist\}\\ \bs fileref\{\I filename\} \I description \ldots\\ \bs end\{filelist\} \end{example} {\tt \bs fileref} sets its argument in a default face. The description part is optional, and its position in the case of very long filenames follows the pattern for the `options' environment described above (see PARAMETERS, below). \subsubsection{Example} The example environment provides an indented environment with a typewriter font (Courier) as the default. If you wish to be able to use all letters and symbols easily, you should use a verbatim environment within an example. \subsection{Parameters} \begin{description} \item[\bs filenamewidth] the width of a filename in a filelist that when exceeded, causes the description (if present) to be wrapped to the next line. The default is 2.0 inches. \item[\bs optionwidth] the width of an option in an options list that when exceeded, causes the description (if present) to be wrapped to the next line. The default is 0.5 inches \item[\bs descriptionwidth] as {\tt \bs optionwidth}, but for description environments, which are otherwise like the normal LaTeX description environment. The default is 1.5 inches. \item[\bs examplefont] the font to use in the {\tt example} environment. The defaut is typewriter (Courier). \end{description} \subsection{Conventions} A typical manual page for a command or function is laid out as follows: {\tt \bs header}\{TITLE\}\{1-8\} The name of the command or function in upper-case, which serves as the title of the manual page. This is followed by the number of the section in which it appears. {\tt \bs version}\{VERSION\}\{DATE\} The version number and last modification of this manual page. {\tt \bs section}\{NAME\} {\tt name} (or comma-separated list of names) -- one-line summary The name, or list of names, by which the command is called, followed by a dash and then a one-line summary of the action performed. The summary should contain no \LaTeX\ macros since it is used to contribute to the `whatis' database. {\tt \bs section}\{SYNOPSIS\} {\bf Commands:} The syntax of the command and its arguments, as typed on the command line. When in boldface, a word must be typed exactly as printed. When in italics, a word can be replaced with an argument that you supply. References to bold or italicized items are not capitalized in other sections, even when they begin a sentence. Syntactic symbols appear in roman face: \begin{description} \item[\[\ \]] An argument, when surrounded by brackets is optional. \item[\pipe] Arguments separated by a vertical bar are exclusive. You can supply only item from such a list. \item[\ldots] Arguments followed by an elipsis can be repeated. When an elipsis follows a bracketed set, the expression within the brackets can be repeated. \end{description} {\bf Functions:} If required, the data declaration, or \#include directive, is shown first, followed by the function declaration. Otherwise, the function declaration is shown. {\tt \bs section}\{DESCRIPTION\} A narrative overview of the command or function's external behavior. This includes how it interacts with files or data, and how it handles the standard input, standard output and standard error. Internals and implementation details are normally omitted. This section attempts to provide a succinct overview in answer to the question, ``what does it do?'' Literal text from the synopsis appears in boldface, as do literal filenames and references to items that appear elsewhere in a reference manual. Arguments are italicized. If a command interprets either subcommands or an input grammar, its command interface or input grammar is normally described in a USAGE section, which follows the OPTIONS section. (The DESCRIPTION section only describes the behavior of the command itself, not that of subcommands.) {\tt \bs section}\{OPTIONS\} The list of options along with a description of how each affects the command's operation. These should be formatted within an {\tt options} environment. {\tt \bs section}\{FILES\} A list of files associated with the command or function. These should be formatted within a {\tt filelist} environment. {\tt \bs section}\{SEE ALSO\} A comma-separated list of related manual pages, followed by references to other published materials. {\tt \bs section}\{DIAGNOSTICS\} A list of diagnostic messages and an explanation of each. {\tt \bs section}\{BUGS\} A description of limitations, known defects, and possible problems associated with the command or function. \section{FILES} \begin{filelist} \fileref{/usr/local/lib/tex/macros/unixman.sty} The base style file \fileref{/usr/local/lib/tex/macros/*.sty} other style options \end{filelist} \section{SEE ALSO} \command{man}{7}, \command{troff}{1} {\it Formatting Documents, Chapter 3: the \T -man macro package} \section{BUGS} There is an \bs hoffset in the page dimensions whose function is not clear. There is a grotesque kludge used to get lists after section headings spaced from the latter as if they were pure text, consisting of {\tt\bs vskip}'ing 14pt's back up the page. This is highly non-portable and very bad style. Any better ideas~? An \T verbatim environment immediately within another environment other than \T example will not leave the normal amount of vertical space before it. In fact, it leaves less than none at all. \end{document} -- Paul Barton-Davis <pauld@cs.washington.edu> UW Computer Science Lab "People cannot cooperate towards common goals if they are forced to compete with each other in order to guarantee their own survival."