Entity, divider, arrow, pipe and box labels –any text displayed in the chart–
can contain formatting escapes. Each formatting escape begins with the
backslash ‘\
’ character. You can also use the backslash to place special
characters into the label. Below is the list of escape sequences available.
\n
Inserts a line break.
\-
Switches to small font.
\+
Switches to normal (large) font.
\^
Switches to superscript.
\_
Switches to subscript.
\b
Toggles bold font.
\B
Sets font to bold.
\i
Toggles italics font.
\I
Sets font to italics.
\u
Toggles font underline.
\U
Sets font to underlined.
\f(font face name
)
Changes the font face. Available font face names depend on the operating system
you use. On Windows, you can use all the fonts available, but only OpenType and
TrueType fonts provide correct alignment. On Linux you can use whatever font
backend your cairo library was compiled for. This typically includes FreeType.
If you specify no font, just f()
, the font used at the beginning of
the label is restored.
\0..\9
Inserts the specified number of pixels as line spacing below the current line.
\c(color definition
)
Changes the color of the text. Color names or direct rgb definitions can
both be used, as described in Specifying Colors. No quotation is needed.
You can also omit the color and just use \c()
, which resets the color
back to the one at the beginning of the label.
\s(style name
)
Applies the specified style to the text[32]. Naturally only the text.*
attributes of the style are applied. You can omit the style name and specify
only \s()
, which resets the entire text format to the one at the
beginning of the label[33].
See Styles for more information on styles.
\mu(num
)
, \md(num
)
, \ml(num
)
, \mr(num
)
, \mi(num
)
Change the margin of the text or the inter-line spacing. The second character
stands for up, down, left, right and internal, respectively. ‘num
’ can be any
nonnegative integer and is interpreded in pixels.
Intra-line spacing comes in addition to the line-specific
spacing inserted by \0..\9
. Defaults are zero.
You can also omit the number, which restores that particular value to the one
in effect at the beginning of the label.
Note that Msc-generator always adds enough left and right margins to arrow labels
to avoid overlapping the label with the arrowhead. Thus if you specify less
margin, it may not show as you expect.
\mn(num
)
, \ms(num
)
Changes the size of the normal or small font. This applies only to the label,
where used, not globally for the entire chart. Defaults are \mn(16)\ms(10)
.
You can also omit the number, which restores that particular value to the one
at the beginning of the label.
\pl \pc \pr
Changes the identation to left, centered or right. Applying at the beginning of a line (t.i., before any literal character) will apply new identation to that line and all following lines within the label. Applying after the beginning of a line will only impact subsequent lines.
\{ \[ \" \; \# \} \]
These produce a literal ‘{
’, ‘[
’, ‘"
’, ‘;
’, ‘#
’,
‘}
’ or ‘]
’, respectively, since these are characters with special
meaning and would, otherwise signal the end of a label. The last two can
actually be used without the backslash, but result in a warning.
\|
This escape is a non-formatting escape that generates no output. It can be used
at the beginning of a label to delimit those formatting escapes that are included
in the default formatting restored by the ‘\s()
’ escape and used to format
the label number, from those which are just to be applied at the beginning of the
label.
\N
This escape marks the position of the label number within the label. If omitted
the number is prepended to the beginning of the label (after the initial formatting
escapes). If no number is specified for the label, this escape has no effect.
You can specify ‘\N
’ multiple times, with each occurrence being replaced by
the number. Note that if you omit ‘\N
’, the number inserted at the beginning of
the label is augmented by the value of the numbering.pre
and
numbering.post
options, whereas with the ‘\N
’ option, those are
not used.
\r(refname
)
This escape inserts the number of the referenced element. Use the refname
attribute to name elements. Similar to the ‘\N
’ escape, the value of the
numbering.pre
and numbering.post
options are ignored.
When no name is given (that is ‘\r()
’) the escape is equivalent to ‘\N
’.
\L(link target
)
, \L()
This escape shall be used in pairs to assign a hyperlink to the text in between the two.
The target of the link shall be specified in the first escape, whereas the second shall
be empty. For example: a->b: A \L(http://abc.com)link\L() to abc.com.;
The link target cannot contain closing parenthesis. If it contains opening square brackets
([
), opening curly braces ({
), semicolons or hash marks, which normally
terminates colon labels, use quotation marks around the label, such as
a->b: "A \L(http://abc.com/#x)link\L() to abc.com/\#x.;
Note that tag labels of boxes can also contain links.
Font size commands (including superscript or subscript) last until the
next font size formatting command. For example in order to specify a subscript
index, use label="A\_i\+ value"
.
Any unrecognized escape characters in a label are removed with a warning.
Unrecognized escapes and plain text in text.format
attributes is
ignored with a warning.
Note that the text.*
chart options can be used to set the default
text formatting.
Before Msc-generator 3.6 the user was required to manually specify line breaks in labels.
Using the text.wrap
attribute you can instruct Msc-generator to break lines
automatically depending on how much horizontal space is available. For labels with this
attribute set the line breaks of the source file inside the label are ignored.
However, the line breaks inserted into the label via the \n
escape sequence
are still honoured. You can set the text.wrap
attribute of labels globally
via the text.wrap
chart option, but you can also override this setting
individually for each label.
You cannot set this attribute for entities. Their label is always typeset with
text.wrap=no
exactly as you specify in the source file.
Note that this feature is most useful if you do not use automatic horizontal
scaling hscale=auto
, since in that case the distance between entities is determined
from the size of the labels - and with text.wrap=yes
there is no inherent size
for most labels. For notes, which float and whose width is not detemined by the spacing of
entities, a new width
attribute is inserted, which can specify the width of the note
making word wrapping meaningful.
You have effective 3 easy way to typeset long labels.
Word wrapping: Use text.wrap=yes
(and perhaps a fixed hscale
),
in this case the long labels wrap into multiple lines.
Automatic scaling: Use hscale=auto
and no word wrapping, in this case
entities are spaced apart, so that there is enough space for all labels.
None: No word wrappig or automatic scaling (default): long labels expand beyond their available space, which may be sometimes ugly.
You can some combinations, as well.
Even with hscale=auto
you can make some long labels word wrap by
applying text.wrap=yes
only to the specific arrow, box, divider or comment.
Specifying a long label with word wrapping will not cause entities to be spaced apart
to make room for it, but instead the label is typeset into the space available
(determined by other labels). Adding horizontal spacing with the hspace
command
can be applied to manually push entities somewhat apart (but perhaps not to the full
length of the long label, which will be wrapped into the space available).
Even with a fixed hscale
You can push entities further by using the
hspace
command and thereby make enough room for a long label. You can create
exactly as much as needed by using the label text as the argument for hspace
,
see below
![]() |
![]() |
[32] Note that the \s
formatting escape was used to switch to small font in 1.x versions of
Msc-generator (since 2.0 \-
is used for that). In order to work with
old format charts, if the style name is not recognized, Msc-generator will give
a warning but fall back to using small font.
[33] Any formatting escapes strictly at the beginning
of a label (up to the first non-formatting escape or literal character) are
included in the text format, so if you start a label with ‘\b
’ then
‘\s()
’ will restore a bold font. To prevent this use the ‘\|
’ escape
to create an invisible non-formatting character.