_                    _
  ___ | |__   __ _ _______ | |_
 / _ \| '_ \ / _` |_  / _ \| __|
| (_) | | | | (_| |/ / (_) | |_
 \___/|_| |_|\__,_/___\___/ \__|

roffcheatsheet

Document about roff macros that are currently supported by mandoc and compatible with both mdoc/man output with examples.

ig : ignore input.
break : break loop.
br : break line.
fi : switch to fill mode.
nf : switch to no-fill mode.
while : while loop.
als : alias request, string, macro, diversion : .als <newname> <oldname>
am : append to a macro definition : .am <macroname>
as : append to string : .as <stringname>
de : define a macro : .de macroname {..}
ds : define string : .ds <stringname> <text>
el : else : .el <body>
ft : font selection : .ft [B|BI|CB|CI|CR|CW|I|P|R]
ie : if/else : .ie <condition>
if : conditional statement : .if <condition>
nr : define numeric register : .nr <register_name> <INTEGER>
rm : remove request, macro, string : .rm <request>
rr : remove a register : .rr <register>
po : horizontal page offset : .po +/-offset
rj : justify the next N lines to the right : .rj N
so : source file : .so <filename>
sp : break output line and emit vertical space : .sp [height]
ta : tab stop, use without arguments to remove it : .ta [width]
ti : indent the next output line by width : .ti <+/-width>
tr : translate glyph : .tr <input> <output>r

(back to top)

.ds string text
.string

text

This is the \*[string] , shows text.
This is the text , shows text.

.as string newtext
.string

textnewtext

.als newstring string
.newstring

textnewtext

.de m
.Em macrodef
..
.m

macrodef

.de m
.Em macrodef \\$1
..
.m test
macrodef test

.am m
.Em macroappend
..

macrodef

.ft BI
.text in bold italic
.ft P

text in bold italic

.nr r 1

.rr r

.if ( \nr == 1 ) \{\
.Em is 1
.\}
..

.ie ( \nr == 1 ) \{\
.Em nr is 1
.\}
.el .Em nr is 0

nr is 1 nr is 0

.ig
text
..

.rm string

(back to top)

- Translate to Spanish.
- Add missing examples.
- Review and update.
- Define whether this doc needs to be split into roff and roff_examples.
- Review nr to create a macro for Bl -column simulating Bl -enum.
- Review als.
- Review on OpenBSD 7.9.

(back to top)

documentation, openbsd, mdoc, mandoc
OpenBSD manpages: roff(7)
links
- The GNU troff Manual (roff reference, not necessarily compatible with mdoc)

(back to top)

2026-04-11 : added string interpolation and gnu roff reference.
2025-10-03 : Created.

(back to top)

ohazot | about | ohazot.com <admin@ohazot.com>

This document applies to: OpenBSD 7.7| 2026-05-30