summaryrefslogtreecommitdiff
path: root/info/drawing-with-metapost/src/split-labels.mp
blob: ca298e5e99b2117d0c7ed8cf8ec8be7ff8be4f5a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
\documentclass[border=0mm]{standalone}
\usepackage{luamplib}
\def\s#1{\let\\\cr\vbox{\halign{\hfil\strut ##\hfil\cr#1\crcr}}}
\begin{document}
\mplibtextextlabel{enable}
\begin{mplibcode}
input colorbrewer-rgb
beginfig(1);
z0 = origin; z1 = 100 down; z2 = 144 down;
picture L[];
L0 = thelabel(btex \vbox{\hsize 2in\parindent 0pt\raggedright
    An extended caption or label that will be set as a
    small paragraph with automatic hyphenation and
    line-wrapping.
} etex, z0);
L1 = thelabel(btex \s{Single line} etex, z1);
L2 = thelabel(btex \s{Longer text split\\onto a new line} etex, z2);
forsuffixes $=0,1,2: 
    draw L$; draw bbox L$ withcolor Blues 8 2;
    draw fullcircle scaled 2 shifted z$ withcolor Reds 8 7; 
endfor
endfig;
\end{mplibcode}
\end{document}