mag-0007-mkiv.tex /size: 5640 b    last modification: 2023-12-21 09:43
1% language=us
2
3% author    : Hans Hagen
4% copyright : ConTeXt Development Team
5% license   : Creative Commons Attribution ShareAlike 4.0 International
6% reference : pragma-ade.nl | contextgarden.net | texlive (related) distributions
7% origin    : the ConTeXt distribution
8%
9% comment   : Because this manual is distributed with TeX distributions it comes with a rather
10%             liberal license. We try to adapt these documents to upgrades in the (sub)systems
11%             that they describe. Using parts of the content otherwise can therefore conflict
12%             with existing functionality and we cannot be held responsible for that. Many of
13%             the manuals contain characteristic graphics and personal notes or examples that
14%             make no sense when used out-of-context.
15%
16% comment   : Some chapters might have been published in TugBoat, the NTG Maps, the ConTeXt
17%             Group journal or otherwise. Thanks to the editors for corrections. Also thanks
18%             to users for testing, feedback and corrections.
19
20\usemodule[mag-01,abr-02,visual]
21
22\startbuffer[abstract]
23    The \type {m-visual} module is used in some manuals that come with \CONTEXT\
24    to generate random text. This is sometimes less confusing that nice quotes
25    because the reader can then distinguish the explanation from the example.
26    This module is not extensive (but may grow) and is just an addition to
27    already built in visualization tools.
28\stopbuffer
29
30\startdocument
31  [title={Faking Text and More},
32   author=Hans Hagen,
33   affiliation=PRAGMA ADE,
34   date=August 2004,
35   number=7 \MKIV]
36
37\setupindenting[medium] \indenting[always] \setupwhitespace[none]
38
39\subject{Remark}
40
41When again a user asked me for the macros that I use to generate fake text, I
42took a while to document them. Most macros use the built in random number
43generator. In manuals you may want to control the randomization a bit. You can do
44that by setting the seed:
45
46\starttyping
47\setupystem[random=12345]
48\stoptyping
49
50% Some more visualization tricks are discussed in the visual debugger modules \type
51% {supp-vis.tex} and \type {core-vis.tex}. If you have special wishes, let me know.
52% If they make sense (or more important: if they can be implemented in a decent
53% way) they may be honored in the future.
54
55In \MKIV\ there is a lot of visualization available like showing all boxes, glue,
56characters etc.\ (try \type {\showmakeup}) . Many mechanism have dedicated
57trackers that visualize matters with color. Here we just mention a few
58possibilities of a module with helpers. This module is loaded with:
59
60\starttyping
61\usemodule[visual]
62\stoptyping
63
64\subject{Faking words}
65
66We don't need much words to demonstrate the macros. Here we fake a single work
67with \type {\fakeword}: \fakeword. You can fake a whole bunch with:
68
69\startbuffer
70\fakewords{100}{200} \par
71\fakewords {30} {80} \par
72\fakewords{200}{200}
73\stopbuffer
74
75\typebuffer \getbuffer
76
77In addition to \type {\fakewords} we have \type {\fakenwords}. This time we don't
78specify a range, but a number and a random seed.
79
80\startbuffer
81\fakenwords{100}{2} % words seed
82\stopbuffer
83
84\typebuffer \getbuffer
85
86Drop caps can be faked as follows:
87
88\startbuffer
89\fakedroppedcaps{3}
90\fakewords{100}{200} \par
91\fakewords{100}{200}
92\stopbuffer
93
94\typebuffer \getbuffer
95
96You can visualize the indentation by adding another faker:
97
98\startbuffer
99\fakeparindent \fakewords{100}{200}
100\stopbuffer
101
102\typebuffer \getbuffer
103
104You can suppress indentation with:
105
106\startbuffer
107\onlyfakewords{100}{200}
108\stopbuffer
109
110\typebuffer \getbuffer
111
112You can influence the color by redefining one or more of the folowing fake
113colors:
114
115\startbuffer
116\definecolor[fakerulecolor]     [black]
117\definecolor[fakebaselinecolor] [green]
118\definecolor[fakeparindentcolor][blue]
119\stopbuffer
120
121\typebuffer \getbuffer
122
123In case you wonder if fake words hyphenate, they kind of do, as is shown here:
124\bgroup \showfakewords \onlyfakewords{100}{200} \egroup
125
126\subject{Faking lines}
127
128Lines can be faked with:
129
130\startbuffer
131\fakelines{3}{5}
132\fakelines{4}{8}
133\stopbuffer
134
135\typebuffer \getbuffer
136
137This is (of course) more efficient than faking words.
138
139\subject{Faking figures}
140
141Faking figures does not make that much sense.
142
143\startbuffer
144\fakefigure
145  [left][]
146  {10em}{12em}
147  {3\lineheight}{5\lineheight}
148
149\fakewords{100}{200}
150\stopbuffer
151
152\typebuffer \getbuffer
153
154In this case the width will vary between \type {10em} and \type {12em}, while the
155height end up somewhere between 3 and~5 times the lineheight.
156
157If you want nice placeholders you can better use the \METAPOST\ \type {dum}
158library. This one hooks into the external figure placement macros and will
159produce a random graphic (with more or less random colors).
160
161\startbuffer
162\useMPlibrary[dum]
163\placefigure
164  [left][]
165  {\fakewords{3}{6}}
166  {\externalfigure[ForTheMomentFaked][width=3cm,height=2cm]}
167
168\fakewords{100}{200}
169\stopbuffer
170
171\typebuffer \getbuffer
172
173\subject{Faking formulas}
174
175Another probably seldom used placeholder is \type {\fakeformula}:
176
177\startbuffer
178\startformula \fakeformula \stopformula
179\stopbuffer
180
181\typebuffer \getbuffer
182
183An alternative, showing baselines, is:
184
185\startbuffer
186\startformula \fakespacingformula \stopformula
187\stopbuffer
188
189\typebuffer \getbuffer
190
191You can trigger drawing of baseline yourself too:
192
193\startbuffer
194\showbaselines
195\fakewords{100}{200} \par
196\fakewords {30} {80} \par
197\fakewords{200}{200}
198\stopbuffer
199
200\typebuffer \bgroup \getbuffer \egroup
201
202In this case you will notice that this document is not typeset on a grid, and
203therefore, since the blank space is set to big the baseline visualization shows
204this distance when applicable.
205
206\stopdocument
207