LATEX2MAN(1)

🌸 hey bestie, it's latex2man time 🌸

okay so this little legend lives in the Documentation Tools corner of your terminal, and it's literally the tool that turns your LaTeX-flavoured man pages into actual man pages. welcome to the group chat πŸ’…


✨ NAME ✨

latex2man is a tool that translates UNIX manual pages written with LaTeX into a format that the UNIX man(1) command actually understands. Alternatively, HTML, TexInfo, or LaTeX code can be produced too. You can also suppress chunks of the output using the conditional text feature β€” and for that, LaTeX generation is the one you want πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

latex2man [-ttransfile] [-cCSSfile] [-HMTL] [-h] [-V] [-Cname] [-achar]
infile outfile

πŸ’– DESCRIPTION πŸ’–

latex2man reads the file infile and writes outfile. The input has to be a LaTeX document using the latex2man LaTeX package. Then latex2man translates that document into the troff(1) format using the -man macro package. slay πŸ’…

With the -H option, HTML code gets produced instead of troff(1). And with that option you can optionally hand it a CSSfile as an argument. CSS (Cascading Style Sheets) is how you control how the resulting HTML page looks, and you'll find the names of the CSS classes that get baked into the HTML tags as attributes down below πŸ‘€

With the -T option, TexInfo code gets produced instead of troff(1).

With the -M option, troff(1) input gets produced.

With the -L option, LaTeX output gets produced instead of troff(1).


⭐ OPTIONS ⭐

  • -ttransfile β€” the translation for user defined LaTeX macros.
  • -cCSSfile β€” if you're using the -H you can also point it at a file that contains CSS style sheets. The link to that CSS file gets inserted into the generated HTML output using the CSSfile filename you specified. cute, right? πŸŽ€
  • -M β€” produce output suitable for the man(1) command. this is the default, bestie, it's the main character πŸ‘‘
  • -H β€” instead of producing output suitable for the man(1) command, HTML code gets produced (yes, despite the name of the command, we contain multitudes πŸ’€).
  • -T β€” instead of producing output suitable for the man(1) command, TexInfo code gets produced (again, despite the name of the command). The generated .texi-file may be processed with makeinfo(1) (to produce an .info-file) which in turn may be installed using install-info(1). The Info tags @dircategory and @direntry are provided. iykyk πŸ“š
  • -L β€” the LaTeX source is written to the outfile. This is useful in conjunction with the -Cname option.
  • -Cname β€” output the conditional text for name. If you want more than one name, use quotes: -C'name1 name2 ...'

The following names are defined automatically:

  • -H defines HTML
  • -T defines TEXI
  • -M defines MAN
  • -L defines LATEX
  • -achar β€” this one is used only in conjunction with -T. Here's the background lore 🧚: TexInfo ignores all blanks before the first word on a new line. In order to produce some additional space before that word (using \SP) some character has to be printed before the additional space. By default this is a . (dot). The char specifies an alternative for that first character. Giving a blank to -a suppresses the indentation of a line.
Note: only for the first \SP of a series that char is printed.
  • -h β€” show a help text.
  • -V β€” show version information.

πŸŽ€ FILES πŸŽ€

  • latex2man.tex β€” the LaTeX file containing this Man-page.
  • latex2man.inc β€” a file read with \input{..} .
  • latex2man.sty β€” the LaTeX package defining the environments and commands.
  • latex2man.cfg β€” the configuration file for the latex2man LaTeX-package.
  • latex2man.css β€” file containing example CSS definitions.
  • latex2man.trans β€” file containing example translations of user defined LaTeX macros.
  • fancyheadings.sty β€” a LaTeX package used to typeset head- and foot lines.
  • fancyhdr.sty β€” a LaTeX package used to typeset head- and foot lines.
  • rcsinfo.sty β€” a LaTeX package used to extract and use RCS version control information in LaTeX documents.
  • latex2man.pdf β€” the PDF version of this document. πŸ“„

πŸ‘€ SEE ALSO πŸ‘€

LaTeX, TexInfo, troff(1), groff(1), makeinfo(1).


πŸ’… LaTeX COMMANDS πŸ’…

The LaTeX package latex2man is what you use to write your Man-pages with LaTeX. But since we're translating into other text formats too, not all LaTeX stuff can be translated β€” fair warning, bestie 🫢

🌈 PACKAGE OPTIONS 🌈

The latex2man package accepts the following options:

  • fancy β€” use the LaTeX package fancyheadings.
  • fancyhdr β€” use the LaTeX package fancyhdr.
  • nofancy β€” neither the LaTeX package fancyheadings nor fancyhdr are used.

The default option may be specified in the file latex2man.cfg.

πŸ¦‹ PACKAGE SPECIFIC ENVIRONMENTS πŸ¦‹

The following environments are provided by the package:

  • \begin{Name}{chapter}{name}{author}{info}{title} β€” the Name environment takes five arguments:
    1. the Man-page chapter,
    2. the name of the Man-page,
    3. the author,
    4. some short info about the tool printed in the footline of the Man-page, and
    5. a title text which is used as title, for HTML and LaTeX (it's ignored for output of the Man-page or TeXinfo).

The Name environment must be the first environment in the document. Processing starts with this environment. Any text before this is ignored (exception: the setVersion and setDate commands).

Note: all arguments of \begin{Name} must be written on one line.
  • \begin{Table}[width]{columns} β€” the Table environment takes two arguments: the first optional one specifies a width of the last column, the second one gives the number of columns. For example:
\begin{Table}[2cm]{3}
Here & am & I \\\hline
A 1 & A 2 & A 3 1 2 3 4 5 A 3 1 2 3 4 5 \\
B 1 & B 2 & B 3 \\
\end{Table}

will be typeset as:

Here   am    I
──────────────────────
A 1    A 2   A 3 1 2
              3 4 5 A
              3 1 2 3
              4 5
B 1    B 2   B 3

If no optional width argument is given, all entries are typeset left justified. The width is a length measured absolutely in cm. Processing with LaTeX a p{width} column is typeset as last column. The translation to troff(1) commands results in a lw(width) column specification. Translating to HTML and TexInfo ignores the width parameter.

\hline may be used.

If the Man-page is formatted with troff(1) and tables are used, the tbl(1) preprocessor should be called, usually by giving a -t to the call of troff(1). When viewing the generated manual page using man(1), tbl(1) is called automatically.
  • \begin{Description} β€” is the same as \begin{description}
  • \begin{Description}[label] β€” is similar to \begin{description}, but the item labels have at minimum the size of the (optional) word label. The difference is visible only in the DVI and PDF-output, not in the troff, TexInfo or HTML output.
a      |a \begin{description}

ab     |ab

abc    |abc

a      |a \begin{Description}

ab     |ab

abc    |abc

a      |a \begin{Description}[aa]

ab     |ab

abc    |abc

πŸ’– ACCEPTED LaTeX ENVIRONMENTS πŸ’–

The following environments are accepted:

  • description
  • enumerate
  • itemize
  • verbatim
  • center

They may be nested:

  • Itemize and nested center:
                              A centered line.
                           Another centered line.
  • Another item an nested enumerate
    1. a
    2. b

⭐ PACKAGE SPECIFIC MACROS ⭐

The following commands are provided:

  • \Opt{option} β€” Option: \Opt{-o} will be typeset as -o.
  • \Arg{argument} β€” Argument: \Arg{filename} will be typeset as filename.
  • \OptArg{option}{argument} β€” Option with Argument: \OptArg{-o}{filename} will be typeset as -ofilename.
  • \OptoArg{option}{argument} β€” Option with optional Argument: \OptoArg{-o}{filename} will be typeset as -o[filename].
  • \oOpt{option} β€” Optional option, e.g. \oOpt{-o} will be typeset as [-o].
  • \oArg{argument} β€” Optional argument, e.g. \oArg{filename} will be typeset as [filename].
  • \oOptArg{option}{argument} β€” Optional option with argument, e.g. \oOptArg{-o}{filename} will be typeset as [-ofilename].
  • \oOptoArg{option}{argument} β€” Optional option with optional argument, e.g. \oOptoArg{-o}{filename} will be typeset as [-o[filename]].
  • \File{filename} β€” used to typeset filenames, e.g. \File{filename} will be typeset as filename.
  • \Prog{prog} β€” used to typeset program names, e.g. \Prog{latex2man} will be typeset as latex2man.
  • \Cmd{command}{chapter} β€” used to typeset references to other commands, e.g. \Cmd{latex2man}{1} will be typeset as latex2man(1).
  • \Bar β€” is typeset as |.
  • \Bs β€” (BackSlash) is typeset as \.
  • \Tilde β€” is typeset as a ~.
  • \Dots β€” is typeset as ....
  • \Bullet β€” is typeset as *.
  • \setVersion{..} β€” set .. as version information.
  • \setVersionWord{..} β€” set .. for the word Version: in the footline. The default is \setVersionWord{Version:}.
  • \Version β€” returns the version information.
  • \setDate{..} β€” sets .. as date information.
  • \Date β€” returns the date information.
  • \Email{..} β€” use to mark an Email address: \Email{Juergen.Vollmer@informatik-vollmer.de} is typeset as: Juergen.Vollmer@informatik-vollmer.de.
  • \URL{..} β€” use to mark an URL: \URL{http://www.foo.de/\Tilde vollmer} is typeset as http://www.foo.de/~vollmer.
  • \LatexManEnd β€” the input file is read and processed until reading end-of-file or \LatexManEnd (at the beginning of a line). LaTeX ignores this command.
  • \Lbr, \Rbr β€” is typeset as [ and ] (these variants are needed only sometimes like in \item[FooBar\LBr xx \Lbr]. Usually [ ] will work.)
  • \LBr, \RBr β€” is typeset as { and } (these variants are needed when using { or } as arguments to macros).
  • \Circum β€” is typeset as ^.
  • \Percent β€” is typeset as %.
  • \TEXbr β€” If processed with LaTeX causes a linebreak (i.e. is equivalent to \\). In the output of latex2man this macro is ignored.
  • \TEXIbr β€” If TexInfo output is generated, causes a linebreak (i.e. is equivalent to \\), otherwise ignored.
  • \MANbr β€” If Man-Page output is generated, causes a linebreak (i.e. is equivalent to \\), otherwise ignored.
  • \HTMLbr β€” if you're generating HTML output, this drops a linebreak (aka it's literally the same as \\) β€” but if you're not doing HTML, it just ✨ does nothing ✨ and gets ignored.
  • \medskip β€” gives you one empty line, that's it, that's the whole vibe.
  • \SP β€” adds some extra space, and it also works at the beginning of lines (which is lowkey the whole point). If the code on the second line looks like this:
\SP abc \SP\SP xx\\

then you get:

abc    xx
 abc   xx
  abc  xx
heads up bestie: because of some "problems" with TexInfo, lines that start with \SP get a leading . (dot) in the TexInfo output β€” peep -achar if you wanna know more πŸ‘€

🧚 ACCEPTED MACROS FROM THE RCSINFO PACKAGE 🧚

  • \rcsInfo $Id ...$ β€” if the LaTeX package rcsinfo is in play, this command is what pulls out the date of the Man-page.
  • \rcsInfoLongDate β€” again, if the LaTeX package rcsinfo is used, this one typesets the date that's coded inside the $Id ..$ string.

πŸ‘‘ ACCEPTED LaTeX MACROS πŸ‘‘

okay so these are the standard LaTeX commands that get accepted, no cap:

  • \section{..} β€” takes exactly one argument: the name of the Man-page section. Every Man-page is made up of several sections. Usually you've got these sections in a Man-page: Name (which gets special handling as an environment, c.f. above), Synopsis, Description, Options, Files, See Also, Diagnostics, Return Values, Bugs, Author, version, etc.
Synopsis has to be the first section after the Name environment. periodt.
Note: do not use LaTeX-macros in section names, fr fr.
  • \subsection{..} β€” works just as well as
  • \subsubsection{..} β€” those ones. πŸ’…
  • \emph{..} β€” \emph{example} gets typeset as example.
  • \textbf{..} β€” \textbf{example} gets typeset as example.
  • \texttt{..} β€” \texttt{example} gets typeset as example.
  • \underline{..} β€” \underline{example} gets typeset as an example of underline.
  • \date{..} β€” uses .. as the date.
  • \verb+..+ β€” but only + is allowed as the delimiter, no other options bestie.
  • $<$ β€” gets typeset as <.
  • $>$ β€” gets typeset as >.
  • $<=$ β€” gets typeset as <=.
  • $>=$ β€” gets typeset as >=.
  • $=$ β€” gets typeset as =.
  • $<>$ β€” gets typeset as <>.
  • $\ge$ β€” gets typeset as $>=$.
  • $\le$ β€” gets typeset as $<=$.
  • $\leftarrow$ β€” gets typeset as $<--$.
  • $\Leftarrow$ β€” gets typeset as $<==$.
  • $\rightarrow$ β€” gets typeset as $-->$.
  • $\Rightarrow$ β€” gets typeset as $==>$.
  • \{ β€” gets typeset as {.
  • \} β€” gets typeset as }.
  • \$ β€” gets typeset as $.
  • \$ β€” gets typeset as $, and this version should be used inside macro arguments.
  • \_ β€” gets typeset as _.
  • \& β€” gets typeset as &.
  • \# β€” gets typeset as #.
  • \% β€” gets typeset as %.
  • \, β€” gets typeset as a smaller blank - - (it's between the two -).
  • \- β€” used to mark hyphenation inside a word.
  • \\ β€” gets typeset as a linebreak, or it marks the end of a column in the Table environment.
  • \ (a \ followed by a blank) β€” gets typeset as a blank, BUT it can't be used at the beginning of a line to make indentation (go see the \SP command instead).
  • ~ β€” gets typeset as a blank.
  • \copyright β€” gets typeset as (C).
  • \noindent
  • \hline β€” used inside a Table environment.
  • \item β€” used inside an itemize, enumerate, or description environment.
  • \today β€” 25 November 2018 (also check out the rcsinfo LaTeX package).
  • \ss,\"a, ... β€” so \ss = ß, \"a = Γ€, \"o = ΓΆ, \"u = ΓΌ, \"A = Γ„, \"O = Γ–, \"U = Ü. You're allowed to surround these macros in { and } in literally all places, even inside other macros, like:
\textbf{\"a\"o\"u\"A\"O\"U\ss}
\textbf{\"a}{\"o}{\"u}{\"A}{\"O}{\"U}{\ss}}
\textbf{Γ€ΓΆΓΌΓ„Γ–ΓœΓŸ}
Γ€ΓΆΓΌΓ„Γ–ΓœΓŸ Γ€ΓΆΓΌΓ„Γ–ΓœΓŸ Γ€ΓΆΓΌΓ„Γ–ΓœΓŸ

If those letters show up in their LATIN-1 8-bit coding, they get translated into the equivalent letter of whatever output format you want. Like for example À becomes &Auml; in HTML and @"A in texinfo. slay ✨

  • \input{..} β€” read and process the given filename.
Please note bestie: the name of the LaTeX-macros and its arguments have to be contained in one line. Don't be splitting them up πŸ™ˆ

🌈 CONDITIONAL TEXT 🌈

latex2man preprocesses the LaTeX input so you can use text conditionally β€” it's giving choose-your-own-adventure. A special sort of LaTeX comment is used for this.

  • %@% IF condition %@%
  • %@% ELSE %@%
  • %@% END-IF %@%

A line has to contain only such a comment and nothing else. condition is a boolean expression containing "names" and operators. The names you gave with the -Cname option have the value "true", while every other name occuring in the expression is assumed to be "false". If evaluating the boolean expression comes out as "true", the text in the "then"-part is used and the text in the optional "else"-part gets skipped (and vice versa, obviously πŸ’…). The IF/ELSE/END-IF can be nested. As boolean operators, these are allowed:

( and ) for grouping are allowed.

For example:

%@% IF abc %@%
abc set
%@%  IF xyz %@%
xyz set
%@%  ELSE %@%
xyz NOT set
%@%  END-IF %@%
%@% ELSE %@%
abc NOT set
%@%  IF xyz || !XYZ %@%
xyz OR !XYZ set
%@%  ELSE %@%
xyz OR !XYZ NOT set
%@%  END-IF %@%
%@% END-IF %@%

Run this manual page through latex2man with e.g. -C'abc XYZ' and take a lil look at the generated output. (If you simply run the LaTeX-document through LaTeX, all lines are shown in the .dvi file).

abc NOT set
xyz OR !XYZ set

To check the conditional text feature, when latex2man is called with

  • -CHTML β€” the lines 1a, 2b, 3b, and 4b;
  • -CTEXI β€” the lines 1b, 2a, 3b, and 4b;
  • -CMAN β€” the lines 1b, 2b, 3a, and 4b;
  • -CLATEX β€” the lines 1b, 2b, 3b, and 4a;
  • calling LaTeX without preprocessing β€” all lines

should be shown:

  • 1b. The HTML conditional was not set.
  • 2b. The TEXI conditional was not set.
  • 3a. This text occurs only when viewing the MAN output
  • 4b. The LATEX conditional was not set.

πŸŽ€ TRANSLATION OF USER DEFINED MACROS πŸŽ€

The user macro translation file (the one given by the [-ttransfile]) contains Perl commands that specify the translation of LaTeX macros defined by the user. These macros may have none, one or two arguments. The following code is expected:

  • Comments start with a # up to the end of the line.
  • For a macro \foo with no arguments, the following code must be specified:

Translation to Man-Pages

$manMacro{'foo'} = '...';

Translation to HTML

$htmlMacro{'foo'} = '...';

Translation to TexInfo

$texiMacro{'foo'} = '...';

where ... is the translation.

  • For a macro \foo{..} with one argument, the following code must be specified:

Translation to Man-Pages

$manMacro1a{'foo'} = '...';
$manMacro1b{'foo'} = '...';

Translation to HTML

$htmlMacro1a{'foo'} = '...';
$htmlMacro1b{'foo'} = '...';

Translation to TexInfo

$texiMacro1a{'foo'} = '...';
$texiMacro1b{'foo'} = '...';

where ... is the translation. The 1a code is used before the argument, while 1b is typeset after the argument is set.

  • For a macro \foo{..}{..} with two arguments, the following code must be specified:

Translation to Man-Pages

$manMacro2a{'foo'} = '...';
$manMacro2b{'foo'} = '...';
$manMacro2c{'foo'} = '...';

Translation to HTML

$htmlMacro2a{'foo'} = '...';
$htmlMacro2b{'foo'} = '...';
$htmlMacro2c{'foo'} = '...';

Translation to TexInfo

$texiMacro2a{'foo'} = '...';
$texiMacro2b{'foo'} = '...';
$texiMacro2c{'foo'} = '...';

where ... is the translation. The 2a code is used before the first argument, 2b between the two arguments and 2c is typeset after the second argument is set.

  • The file latex2man.trans contains some example code.

πŸ¦‹ VERBATIM ENVIRONMENT πŸ¦‹

This
    {is}
        \texttt{a}
                  $test$
                         _of_
verbatim
<this is no HTML tag> and no @* TexInfo command

πŸ’œ SUBSECTION WORKS πŸ’œ

This is a \subsection.


🌸 Subsubsection works 🌸

This is a \subsubsection.


⭐ Subsubsection still works ⭐

This is another \subsubsection.


πŸ”₯ GENERAL REMARKS πŸ”₯

  1. Empty lines are typeset as paragraph separators.
  2. The arguments of the LaTeX commands must not be split over several lines.
  3. Do not nest calls to macros.
  4. Except the mentioned environment and macros, the usage of other LaTeX environments or macros are not translated. Their usage will cause garbage in the output. πŸ’€
  5. latex2man requires Perl version >= 5.0004_03.
  6. If you want to install the system with the distributed Makefile, you need GNU-make. If you don't have it, you should execute the steps shown in the Makefile manually.

πŸŽ€ CSS CLASSNAMES πŸŽ€

Okay so here's the tea, bestie: when latex2man makes HTML, it sprinkles CSS class names onto the tags as attributes. That means you can go absolutely feral in your CSS file and style every single one of these classes however your little heart desires. πŸ’… Here's the full roster:

  • body (no class name, it's just the body tag) β€” the body of the HTML page
  • h1 β†’ class titlehead β€” the title at the top of the HTML page specified as an argument to the Name environment
  • h4 β†’ class authorhead β€” the author at the top of the HTML page specified as an argument to the Name environment
  • h4 β†’ class datehead β€” the date at the top of the HTML page
  • h4 β†’ class versionhead β€” the man page version at the top of the HTML page specified as an argument to the setVersion macro
  • h2 β†’ class sectionname β€” a section title specified as an argument to the section macro
  • h4 β†’ class subsectionname β€” a subsection title specified as an argument to the subsection macro
  • h5 β†’ class subsubsectionname β€” a subsubsection title specified as an argument to the subsubsection macro
  • font β†’ class progname β€” a program name specified as an argument to the Prog macro
  • font β†’ class filename β€” a file name specified as an argument to the File macro
  • font β†’ class commandname β€” a command name specified as an argument to the Cmd macro
  • font β†’ class textstyle β€” all text that is not an argument to some LaTeX or latex2man macro
  • font β†’ class optstyle β€” a name of an option specified as an argument to the Opt, oOpt, OptArg, oOptArg or oOptoArg macros
  • font β†’ class argstyle β€” a name of an argument specified as an argument to the Arg, oArg, OptArg, oOptArg or oOptoArg macros
  • a, font β†’ class urlstyle β€” a URL specified as an argument to the URL macro
  • a, font β†’ class urlstyle.link β€” subclass of urlstyle class
  • a, font β†’ class urlstyle.visited β€” subclass of urlstyle class
  • a, font β†’ class urlstyle.hover β€” subclass of urlstyle class
  • a, font β†’ class emailstyle β€” an email specified as an argument to the Email macro
  • a, font β†’ class emailstyle.link β€” subclass of emailstyle class
  • a, font β†’ class emailstyle.visited β€” subclass of emailstyle class
  • a, font β†’ class emailstyle.hover β€” subclass of emailstyle class
  • table β†’ class tablestyle β€” a table specified as a Table environment
  • tr β†’ class rowstyle β€” a row of a table specified as a Table environment
  • td β†’ class cellstyle β€” a cell of a table specified as a Table environment

πŸ› SOME BUG FIX TESTS πŸ›

Not me showing you the receipts, but the receipts are giving. πŸ’€

Leading . and '

So like, leading . and ' in generation troff output should work propperly now, since a \& is added. Therfore the \Dot macro has been deleted. (Yes the typos are canon, bestie, we don't fix those.)

Big thanks to Frank.Schilder@Mathematik.Tu-Ilmenau.De for this one. 🫢

Testcases, as-is:

Testcase 1:

'\n'   ...

Testcase 2:
.foobar Testcase 3:
...

abc ...  abc . efg ' 123

% in verbatim

A % in a \verb and verbatim-environment was not emitted correctly. Thank you to Aleksey Nogin nogin@cs.caltech.edu for the bug report and the bug fix β€” king behaviour, honestly. πŸ‘‘

% abc

   % abc %

but ignore comments following this:


πŸ’– REQUIREMENTS πŸ’–

  • Perl β€” latex2man requires Perl version >= 5.0004_03.
  • Make β€” if you want to install the system with the distributed Makefile, you need GNU-make. If you don't have it, you should execute the steps shown in the Makefile manually. (Lowkey annoying but we cope. 😭)
  • LaTeX β€” LaTeX2e is required.

πŸ“ CHANGES πŸ“

Please check the file latex2man-CHANGES for the list of changes and acknowledgment to people contributing bugfixes or enhancements. Give the contributors their flowers, they earned them. 🌸


✨ VERSION ✨

Version: 1.29 of 2018/11/25.


(C)1998, Dr. JΓΌrgen Vollmer, Am Rennbuckel 21, D-76185 Karlsruhe, Germany, Juergen.Vollmer@informatik-vollmer.de

The most recent version of Latex2man may be found on my homepage http://www.informatik-vollmer.de/software/latex2man.html.

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.

Misc

If you find this software useful, please send me a postcard from the place where you are living. 🏻 (No, seriously β€” actual postcard. Iconic request, honestly.)


πŸ¦‹ AUTHOR πŸ¦‹

Dr. JΓΌrgen Vollmer Am Rennbuckel 21 D-76185 Karlsruhe Email: Juergen.Vollmer@informatik-vollmer.de WWW: http://www.informatik-vollmer.de.


and that's a wrap bestie!! 🌈 the whole thing came from the Documentation Tools corner of the world, dated 2018/11/25, and it's the LATEX2MAN(1) page β€” go forth and write your man pages in LaTeX like the main character you are πŸ’œβœ¨