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-Hyou 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 theman(1)command. this is the default, bestie, it's the main character π-Hβ instead of producing output suitable for theman(1)command, HTML code gets produced (yes, despite the name of the command, we contain multitudes π).-Tβ instead of producing output suitable for theman(1)command, TexInfo code gets produced (again, despite the name of the command). The generated.texi-file may be processed withmakeinfo(1)(to produce an.info-file) which in turn may be installed usinginstall-info(1). The Info tags@dircategoryand@direntryare provided. iykyk π-Lβ the LaTeX source is written to the outfile. This is useful in conjunction with the-Cnameoption.-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:
-HdefinesHTML-TdefinesTEXI-MdefinesMAN-LdefinesLATEX
-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-asuppresses 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 thelatex2manLaTeX-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 packagefancyheadings.fancyhdrβ use the LaTeX packagefancyhdr.nofancyβ neither the LaTeX packagefancyheadingsnorfancyhdrare 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}β theNameenvironment takes five arguments:- the Man-page chapter,
- the name of the Man-page,
- the author,
- some short info about the tool printed in the footline of the Man-page, and
- 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}β theTableenvironment 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 withtroff(1)and tables are used, thetbl(1)preprocessor should be called, usually by giving a-tto the call oftroff(1). When viewing the generated manual page usingman(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:
descriptionenumerateitemizeverbatimcenter
They may be nested:
- Itemize and nested center:
A centered line.
Another centered line.
- Another item an nested enumerate
- a
- 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 aslatex2man.\Cmd{command}{chapter}β used to typeset references to other commands, e.g.\Cmd{latex2man}{1}will be typeset aslatex2man(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 wordVersion: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 ashttp://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 oflatex2manthis 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\SPget a leading.(dot) in the TexInfo output β peep-acharif you wanna know more π
π§ ACCEPTED MACROS FROM THE RCSINFO PACKAGE π§
\rcsInfo $Id ...$β if the LaTeX packagercsinfois in play, this command is what pulls out the date of the Man-page.\rcsInfoLongDateβ again, if the LaTeX packagercsinfois 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 asexample.\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\SPcommand 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 thercsinfoLaTeX 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 Ä 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
\foowith 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.transcontains 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 π₯
- Empty lines are typeset as paragraph separators.
- The arguments of the LaTeX commands must not be split over several lines.
- Do not nest calls to macros.
- 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. π
latex2manrequires Perl version >=5.0004_03.- 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 pageh1β classtitleheadβ the title at the top of the HTML page specified as an argument to theNameenvironmenth4β classauthorheadβ the author at the top of the HTML page specified as an argument to theNameenvironmenth4β classdateheadβ the date at the top of the HTML pageh4β classversionheadβ the man page version at the top of the HTML page specified as an argument to thesetVersionmacroh2β classsectionnameβ a section title specified as an argument to thesectionmacroh4β classsubsectionnameβ a subsection title specified as an argument to thesubsectionmacroh5β classsubsubsectionnameβ a subsubsection title specified as an argument to thesubsubsectionmacrofontβ classprognameβ a program name specified as an argument to theProgmacrofontβ classfilenameβ a file name specified as an argument to theFilemacrofontβ classcommandnameβ a command name specified as an argument to theCmdmacrofontβ classtextstyleβ all text that is not an argument to some LaTeX or latex2man macrofontβ classoptstyleβ a name of an option specified as an argument to theOpt,oOpt,OptArg,oOptArgoroOptoArgmacrosfontβ classargstyleβ a name of an argument specified as an argument to theArg,oArg,OptArg,oOptArgoroOptoArgmacrosa,fontβ classurlstyleβ a URL specified as an argument to theURLmacroa,fontβ classurlstyle.linkβ subclass ofurlstyleclassa,fontβ classurlstyle.visitedβ subclass ofurlstyleclassa,fontβ classurlstyle.hoverβ subclass ofurlstyleclassa,fontβ classemailstyleβ an email specified as an argument to theEmailmacroa,fontβ classemailstyle.linkβ subclass ofemailstyleclassa,fontβ classemailstyle.visitedβ subclass ofemailstyleclassa,fontβ classemailstyle.hoverβ subclass ofemailstyleclasstableβ classtablestyleβ a table specified as aTableenvironmenttrβ classrowstyleβ a row of a table specified as aTableenvironmenttdβ classcellstyleβ a cell of a table specified as aTableenvironment
π 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 β
latex2manrequires 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 theMakefilemanually. (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.
π LICENSE AND COPYRIGHT π
Copyright
(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 πβ¨
π¦ where this page comes from
- centos-stream 10: texlive-latex2man 13:20240311-6.el10 Β· LPPL-1.3c
- centos-stream 9: texlive-latex2man 9:20200406-26.el9 Β· LPPL
- fedora 43: texlive-latex2man 11:svn64477-93.fc43 Β· LPPL-1.3c
- fedora 43: texlive-latex2man 11:svn64477-95.fc43.1 Β· LPPL-1.3c
- fedora 44: texlive-latex2man 12:svn77377-105.fc44 Β· LPPL-1.3c
- fedora 44: texlive-latex2man 12:svn77377-111.fc44 Β· LPPL-1.3c
- opensuse-leap 16.0: texlive-latex2man-doc 2025.222.1.29svn64477-160000.3.1 Β· LPPL-1.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms