TROFF Macros


Summary

I may do my own macro processor since I don't like the man2html output. These are my notes on the macros I need to support.


Detail

Macro lines normally start with a period. If they start with a single backquote, there should be no spacing before/after the command.

Macro Notes
.AB Abort: dump to stdout and stop
.AM Append macro
.AR Argument (i)
.B Bold (b)
.BI Alternating bold then italic
.BP Break page
.BR Alternating bold then roman
Actually: line break
.CE Center
.CF Copy file
.DA Divert append: like .DI but appends
.DD Define date
.DE Define macro
.DI Divert text to macro
.DS Define string
.DT Default tabstops
Actually Document Title
1: doc title
2: section name
3: volume
.EE Example End
.EL Else (second part of .IE)
.EX Example
.FAM Font family
.FL Flush output
.FP Font position (for downloaded fonts)
.FT Font
.FTR Font translate
.HCODE Hyphenation code
.HLA Hyphenation language
.HLM Hyphenated line max
.HP Hanging paragraph
.HPF Hyphenation pattern file
.HW Hyphenation word
.HY Enable hyphenation
.HYM Hyphenation margin
.HYS Hyphenation space
.I Italic
.IB Alternating italic then bold
.IE If/else conditional (first part)
.IF If conditional
.IN Indent
.IP Indented paragraph
.IR Alternating italic then roman
.LENGTH
.LL Line length
.LP Paragraph
.LS Line spacing
.MSO Macro source
.NA No adjust
.NE ??? next entry ??? vertical space?
.NF No-fill: line breaks in source are preserved
.NH No hyphenation
.NM Line numbers
Actually: name
.NN No line numbers
.NR Number register
.NX Next record
.OP Option (surround with []), also macro-expand params
.OS Operating System
.P Paragraph (p)
.PD Paragraph distance
.PL Page length
.PM Print macro: dumps symbol table
.PN Page number
.PNR Print number register: dumps defined registers
.PO Page offset
.PP Paragraph (p)
.PTR Print trap: dumps defined traps
.R Roman
.RB Alternating roman then bold
.RD Read into stdin
.RE Relative index end (/blockquote)
.RI Alternating roman then italic
.RS Relative indent start (blockquote)
.SB Small bold
.SH Section header (h2)
.SHC Soft hyphen character
.SM Small text
.SO Source: reads from external file
.SP Space (blank lines)
.SS Sub-subhead (h3)
.SUBSTRING
.SY System command
.TE Table end (/table)
.TH Table header (h1 and title)
.TI Temporary indent
.TL Title line
.TM dump output to stdout for debugging
.TP Tagged paragraph
.TRF Text read file
.TS Table start (table)
.VB Verbatim begin
.VE Verbatim end
.WH When (calls macro at page position)
.WHILE While flow control
.XR Cross-reference
\*(lq
Symbol Notes
\*R Registered mark
\*S type size (ignored)
\*(lq Left quotation mark
\*(rq Right quotation mark
\*(Tm Trademark symbol
\& zero-width space

Resources

  • Parsed vs not-parsed: http://www.stat.ucla.edu/cgi-bin/man-cgi?mdoc+7
  • http://unixhelp.ed.ac.uk/CGI/man-cgi
  • http://unixhelp.ed.ac.uk/CGI/man-cgi?man+7
  • http://techpubs.sgi.com/library/tpl/cgi-bin/getdoc.cgi?coll=0650&db=man&fname=/usr/share/catman/p_man/cat5/man.z
  • Especially the escape sequences: http://www.sunsite.ualberta.ca/Documentation/Gnu/groff-1.16/html_chapter/groff_6.html#SEC57
  • Tables: http://www.snake.net/software/troffcvt/tbl.html
  • http://www.uwm.edu/cgi-bin/IMT/wwwman?topic=man(5)&msection=
  • http://minix1.woodhull.com/manpages/man1/nroff.1.html
  • http://www.docs.hp.com/en/B9106-90012/man.5.html