← 返回命令列表

Linux command

troff 命令

文件

复制后可按需替换文件名、目录或参数。

常用示例

Format a document

troff -man [file.1]

Format with the ms macro package

troff -ms [file.ms]

Generate ASCII output

troff -a [file]

Print version information

troff -v

Enable all warnings

troff -w all [file]

Format with compatibility mode

troff -C [file]

说明

troff is the typesetting processor of the groff (GNU roff) text formatting system. It reads text files containing formatting commands and produces formatted output for various devices including PostScript, PDF, and terminals. troff is usually invoked through groff, which handles preprocessors (tbl, eqn, pic) and postprocessors automatically. Macro packages provide high-level formatting: man for manual pages, ms for general documents, mom for complex documents. The groff implementation extends traditional Unix troff with color support, additional escape sequences, and improved compatibility features while maintaining backward compatibility.

参数

-a
Generate ASCII approximation of typeset output.
-b
Print backtrace with each warning or error message.
-c
Disable color output.
-C
Enable compatibility mode with traditional troff.
-d _cs_
Define string c as s.
-f _fam_
Set default font family.
-F _dir_
Search directory for font files.
-i
Read standard input after processing files.
-m _name_
Include macro package (e.g., man, ms, me, mom).
-n _num_
Number first page as num.
-o _list_
Output only pages in list.
-r _cn_
Set register c to value n.
-T _name_
Prepare output for device name (default: ps).
-U
Enable unsafe mode (allows dangerous requests).
-v
Print version number.
-w _name_
Enable warning name. Use -w all for most warnings.
-W _name_
Disable warning name.

FAQ

What is the troff command used for?

troff is the typesetting processor of the groff (GNU roff) text formatting system. It reads text files containing formatting commands and produces formatted output for various devices including PostScript, PDF, and terminals. troff is usually invoked through groff, which handles preprocessors (tbl, eqn, pic) and postprocessors automatically. Macro packages provide high-level formatting: man for manual pages, ms for general documents, mom for complex documents. The groff implementation extends traditional Unix troff with color support, additional escape sequences, and improved compatibility features while maintaining backward compatibility.

How do I run a basic troff example?

Run `troff -man [file.1]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -a do in troff?

Generate ASCII approximation of typeset output.