Skip to content

Commit 589af92

Browse files
committed
[format.string.{std,escaped}, macros] Add missing examples
1 parent 7e2cc3b commit 589af92

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

source/macros.tex

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,8 @@
715715
%%--------------------------------------------------
716716
%% Environment for imported graphics
717717
%%--------------------------------------------------
718-
% usage: \begin{importgraphic}{CAPTION}{TAG}{FILE}
718+
% usage: \begin{importgraphic}{CAPTION}{TAG}{FILE}\end{importgraphic}
719+
% \importexample[VERTICAL OFFESET]{FILE}
719720
%
720721
% The filename is relative to the source/assets directory.
721722

@@ -730,6 +731,8 @@
730731
\caption{\cptn \quad [fig:\lbl]}\label{fig:\lbl}%
731732
\end{figure}}
732733

734+
\newcommand{\importexample}[2][-0.9pt]{\raisebox{#1}{\includegraphics{assets/#2}}}
735+
733736
%%--------------------------------------------------
734737
%% Definitions section for "Terms and definitions"
735738
%%--------------------------------------------------

source/utilities.tex

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
%!TEX root = std.tex
2+
23
\rSec0[utilities]{General utilities library}
34

45
\rSec1[utilities.general]{General}
@@ -15915,6 +15916,8 @@
1591515916
string s8 = format("{:02}", 1234); // value of \tcode{s8} is \tcode{"1234"}
1591615917
string s9 = format("{:*<}", "12"); // value of \tcode{s9} is \tcode{"12"}
1591715918
string sA = format("{:*<6}", "12345678"); // value of \tcode{sA} is \tcode{"12345678"}
15919+
string sB = format("{:@\importexample[-2pt]{example_05}\caret{}@6}", "x"); // value of \tcode{sB} is \tcode{"\importexample[-2pt]{example_05}\importexample[-2pt]{example_05}x\importexample[-2pt]{example_05}\importexample[-2pt]{example_05}\importexample[-2pt]{example_05}"}
15920+
string sC = format("{:*@\caret{}@6}", "@\importexample[-2pt]{example_05}@"); // value of \tcode{sC} is \tcode{"\importexample[-2pt]{example_05}\importexample[-2pt]{example_05}\importexample[-2pt]{example_05}"}
1591815921
\end{codeblock}
1591915922
\end{example}
1592015923
\begin{note}
@@ -15924,8 +15927,7 @@
1592415927
because padding width is \tcode{0} in that case.
1592515928
Since fill characters are assumed to have a field width of \tcode{1},
1592615929
use of a character with a different field width can produce misaligned output.
15927-
%FIXME: cannot show clown face character below.
15928-
The \unicode{1f921}{clown face} character has a field width of \tcode{2}.
15930+
The \importexample[-2pt]{example_05} (\unicode{1f921}{clown face}) character has a field width of \tcode{2}.
1592915931
The examples above that include that character
1593015932
illustrate the effect of the field width
1593115933
when that character is used as a fill character
@@ -17142,16 +17144,19 @@
1714217144
%% FIXME: their Unicode characters are not available in our font (Latin Modern).
1714317145
\begin{example}
1714417146
\begin{codeblock}
17145-
string s0 = format("[{}]", "h\tllo"); // \tcode{s0} has value: \tcode{[h\ \ \ \ llo]}
17146-
string s1 = format("[{:?}]", "h\tllo"); // \tcode{s1} has value: \tcode{["h\textbackslash tllo"]}
17147-
string s3 = format("[{:?}, {:?}]", '\'', '"'); // \tcode{s3} has value: \tcode{['\textbackslash '', '"']}
17147+
string s0 = format("[{}]", "h\tllo"); // \tcode{s0} has value: \tcode{[h\ \ \ \ llo]}
17148+
string s1 = format("[{:?}]", "h\tllo"); // \tcode{s1} has value: \tcode{["h\textbackslash tllo"]}
17149+
string s2 = format("[{:?}]", "@\importexample[-2.5pt]{example_01}@"); @\kern1.25pt@// \tcode{s2} has value: \tcode{["\importexample[-2.5pt]{example_01}"]}
17150+
string s3 = format("[{:?}, {:?}]", '\'', '"'); // \tcode{s3} has value: \tcode{['\textbackslash '', '"']}
1714817151

1714917152
// The following examples assume use of the UTF-8 encoding
1715017153
string s4 = format("[{:?}]", string("\0 \n \t \x02 \x1b", 9));
1715117154
// \tcode{s4} has value: \tcode{["\textbackslash u\{0\} \textbackslash n \textbackslash t \textbackslash u\{2\} \textbackslash u\{1b\}"]}
1715217155
string s5 = format("[{:?}]", "\xc3\x28"); // invalid UTF-8, \tcode{s5} has value: \tcode{["\textbackslash x\{c3\}("]}
17156+
string s6 = format("[{:?}]", "@\importexample{example_02}@"); @\kern0.75pt@// \tcode{s6} has value: \tcode{["\importexample{example_03}\textbackslash{u}\{200d\}\importexample{example_04}\textbackslash{u}\{fe0f\}"]}
1715317157
string s7 = format("[{:?}]", "\u0301"); // \tcode{s7} has value: \tcode{["\textbackslash u{301}"]}
1715417158
string s8 = format("[{:?}]", "\\\u0301"); // \tcode{s8} has value: \tcode{["\textbackslash \textbackslash \textbackslash u{301}"]}
17159+
string s9 = format("[{:?}]", "e\u0301\u0323"); // \tcode{s9} has value: \tcode{["\importexample[-2pt]{example_06}"]}
1715517160
\end{codeblock}
1715617161
\end{example}
1715717162

0 commit comments

Comments
 (0)