11f2edfa |
1 | \C{input} Halibut input format |
2 | |
3 | This chapter describes the format in which you should write |
4 | documents to be processed by Halibut. |
5 | |
6 | \H{input-basics} The basics |
7 | |
8 | Halibut's input files mostly look like ordinary ASCII text files; |
9 | you can edit them with any text editor you like. |
10 | |
339cbe09 |
11 | Writing \i{paragraphs of ordinary text} is very simple: you just |
12 | write ordinary text in the ordinary way. You can wrap a paragraph |
13 | across more than one line using \i{line breaks} in the text file, |
14 | and Halibut will ignore this when it \I{wrapping paragraphs}rewraps |
15 | the paragraph for each output format. To separate paragraphs, use a |
16 | \i{blank line} (i.e. two consecutive line breaks). For example, a |
17 | fragment of Halibut input looking like this: |
11f2edfa |
18 | |
19 | \c This is a line of text. |
20 | \c This is another line of text. |
21 | \c |
22 | \c This line is separated from the previous one by a blank line. |
23 | |
24 | will produce two paragraphs looking like this: |
25 | |
26 | \quote{ |
27 | This is a line of text. |
28 | This is another line of text. |
29 | |
30 | This line is separated from the previous one by a blank line. |
31 | } |
32 | |
33 | The first two lines of the input have been merged together into a |
34 | single paragraph, and the line break in the input file was treated |
35 | identically to the spaces between the individual words. |
36 | |
339cbe09 |
37 | Halibut is designed to have very few \I{escaping, special |
38 | characters}\i{special characters}. The only printable characters in |
39 | Halibut input which will not be treated exactly literally in the |
40 | output are the \i{backslash} (\c{\\}) and the \i{braces} (\c{\{} and |
41 | \c{\}}). If you do not use these characters, \e{everything} else you |
42 | might type in normal ASCII text is perfectly safe. If you do need to |
43 | use any of those three characters in your document, you will have to |
44 | precede each one with a backslash. Hence, for example, you could |
45 | write |
11f2edfa |
46 | |
47 | \c This \\ is a backslash, and these are \{braces\}. |
48 | |
49 | and Halibut would generate the text |
50 | |
51 | \quote{ |
52 | This \\ is a backslash, and these are \{braces\}. |
53 | } |
54 | |
339cbe09 |
55 | \H{input-inline} Simple \i{inline formatting commands} |
11f2edfa |
56 | |
57 | Halibut formatting commands all begin with a backslash, followed by |
58 | a word or character identifying the command. Some of them then use |
59 | braces to surround one or more pieces of text acted on by the |
60 | command. (In fact, the \c{\\\\}, \c{\\\{} and \c{\\\}} sequences you |
61 | met in \k{input-basics} are themselves formatting commands.) |
62 | |
63 | This section describes some simple formatting commands you can use |
64 | in Halibut documents. The commands in this section are \e{inline} |
65 | commands, which means you can use them in the middle of a paragraph. |
66 | \K{input-para} describes some \e{paragraph} commands, which affect a |
67 | whole paragraph at a time. |
68 | |
c63ce2c7 |
69 | Many of these commands are followed by a pair of braces surrounding |
339cbe09 |
70 | some text. In all cases, it is perfectly safe to have a \i{line break} |
c63ce2c7 |
71 | (in the input file) within those braces; Halibut will treat that |
72 | exactly the same as a space. For example, these two paragraphs will |
73 | be treated identically: |
74 | |
75 | \c Here is some \e{emphasised |
76 | \c text}. |
77 | \c |
78 | \c Here is some \e{emphasised text}. |
79 | |
11f2edfa |
80 | \S{input-emph} \c{\\e}: Emphasising text |
81 | |
82 | Possibly the most obvious piece of formatting you might want to use |
339cbe09 |
83 | in a document is \i\e{emphasis}. To emphasise text, you use the |
84 | \i\c{\\e} command, and follow it up with the text to be emphasised |
85 | in braces. For example, the first sentence in this paragraph was |
11f2edfa |
86 | generated using the Halibut input |
87 | |
88 | \c Possibly the most obvious piece of formatting you might want to use |
89 | \c in a document is \e{emphasis}. |
90 | |
339cbe09 |
91 | \S{input-code} \c{\\c} and \c{\\cw}: Displaying \i{computer code} inline |
11f2edfa |
92 | |
93 | Halibut was primarily designed to produce software manuals. It can |
94 | be used for other types of document as well, but software manuals |
95 | are its speciality. |
96 | |
97 | In software manuals, you often want to format text in a way that |
339cbe09 |
98 | indicates that it is something you might see displayed \i{verbatim} |
99 | on a computer screen. In printed manuals, this is typically done by |
100 | setting that text in a font which is obviously \I{fixed-width |
101 | font}fixed-width. This provides a visual cue that the text being |
102 | displayed is code, and it also ensures that punctuation marks are |
103 | clearly separated and shown individually (so that a user can copy |
104 | the text accurately and conveniently). |
11f2edfa |
105 | |
106 | Halibut provides \e{two} commands for this, which are subtly |
339cbe09 |
107 | different. The names of those commands are \i\c{\\c} (\q{code}) and |
108 | \i\c{\\cw} (\q{\i{weak code}}). You use them just like \c{\\e}, by |
11f2edfa |
109 | following them with some text in braces. For example, this... |
110 | |
111 | \c This sentence contains some \c{code} and some \cw{weak code}. |
112 | |
113 | ... produces this: |
114 | |
115 | \quote{ |
116 | This sentence contains some \c{code} and some \cw{weak code}. |
117 | } |
118 | |
119 | The distinction between code and weak code is mainly important when |
120 | producing plain text output. Plain text output is typically viewed |
121 | in a fixed-width font, so there is no need (and no way) to change |
122 | font in order to make the order of punctuation marks clear. However, |
123 | marking text as code is also \e{sometimes} done to provide a visual |
124 | distinction between it and the text around it, so that the reader |
125 | knows where the literal computer text starts and stops; and in plain |
126 | text, this cannot be done by changing font, so there needs to be an |
127 | alternative way. |
128 | |
e21ccf73 |
129 | So in the plain text output format, things marked as code (\c{\\c}) |
130 | will be surrounded by quote marks, so that it's obvious where they |
131 | start and finish. Things marked as weak code (\c{\\cw}) will not |
132 | look any different from normal text. |
11f2edfa |
133 | |
134 | I recommend using weak code for any application where it is |
135 | \e{obvious} that the text is literal computer input or output. For |
136 | example, if the text is capitalised, that's usually good enough. If |
137 | I talk about the Pentium's \cw{EAX} and \cw{EDX} registers, for |
138 | example, you don't need quotes to notice that those are special; so |
139 | I would write that in Halibut as \q{\c{the Pentium's \\cw\{EAX\} and |
140 | \\cw\{EDX\} registers}}. But if I'm talking about the Unix command |
141 | \c{man}, which is an ordinary English word in its own right, a reader |
142 | might be slightly confused if it appeared in the middle of a |
143 | sentence undecorated; so I would write that as \q{\c{the Unix command |
144 | \\c\{man\}}}. |
145 | |
146 | In summary: |
147 | |
148 | \b \c{\\c} means \q{this text \e{must} be visually distinct from the |
149 | text around it}. Halibut's various output formats will do this by |
150 | changing the font if possible, or by using quotes if not. |
151 | |
152 | \b \c{\\cw} means \q{it would be nice to display this text in a |
153 | fixed-width font if possible, but it's not essential}. |
154 | |
155 | There is a separate mechanism for displaying computer code in an |
156 | entire paragraph; see \k{input-codepara} for that one. |
157 | |
339cbe09 |
158 | \S{input-quotes} \c{\\q}: \ii{Quotation marks} |
11f2edfa |
159 | |
160 | Halibut's various output formats don't all use the same conventions |
161 | for displaying text in ordinary quotation marks (\q{like these}). |
162 | Some output formats have access to proper matched quote characters, |
163 | whereas others are restricted to using plain ASCII. Therefore, it is |
164 | not ideal to use the ordinary ASCII double quote character in your |
165 | document (although you can if you like). |
166 | |
339cbe09 |
167 | Halibut provides the formatting command \i\c{\\q} to indicate quoted |
11f2edfa |
168 | text. If you write |
169 | |
170 | \c Here is some \q{text in quotes}. |
171 | |
172 | then Halibut will print |
173 | |
174 | \quote{ |
175 | Here is some \q{text in quotes}. |
176 | } |
177 | |
178 | and in every output format Halibut generates, it will choose the |
179 | best quote characters available to it in that format. |
180 | |
339cbe09 |
181 | You can still use ordinary ASCII \i{double quotes} if you prefer; or |
182 | you could even use the \c{\\u} command (see \k{input-unicode}) to |
183 | generate \i{Unicode matched quotes} (single or double) and fall back |
184 | to the normal ASCII one if they aren't available. But I recommend |
185 | using the built-in \c{\\q} command in most cases, because it's |
186 | simple and does the best it can everywhere. |
11f2edfa |
187 | |
188 | (Note that if you're using the \c{\\c} or \c{\\cw} commands to |
189 | display literal computer code, you probably \e{will} want to use |
339cbe09 |
190 | literal \i{ASCII quote characters}, because it is likely to matter |
11f2edfa |
191 | precisely which quote character you use.) |
192 | |
339cbe09 |
193 | \S{input-nonbreaking} \c{\\-} and \c{\\_}: \ii{Non-breaking hyphens} |
194 | and \I{non-breaking spaces}spaces |
11f2edfa |
195 | |
196 | If you use an ordinary hyphen in the middle of a word (such as |
197 | \q{built-in}), Halibut's output formats will feel free to break a |
339cbe09 |
198 | line after that hyphen when \i{wrapping paragraphs}. This is fine |
199 | for a word like \q{built-in}, but if you were displaying some |
200 | literal computer code such as the Emacs command |
11f2edfa |
201 | \c{M\-x\_psychoanalyze\-pinhead}, you might prefer to see the whole |
202 | hyphenated word treated as an unbreakable block. In some cases, you |
203 | might even want to prevent the \e{space} in that command from |
204 | becoming a line break. |
205 | |
339cbe09 |
206 | For these purposes, Halibut provides the commands \i\c{\\-} and |
207 | \i\c{\\_}, which generate a non-breaking hyphen and a non-breaking |
11f2edfa |
208 | space respectively. So the above Emacs command might be written as |
209 | |
210 | \c the Emacs command \c{M\-x\_psychoanalyze\-pinhead} |
211 | |
212 | Unfortunately, some of Halibut's output formats do not support |
213 | non-breaking hyphens, and others don't support \e{breaking} hyphens! |
214 | So Halibut cannot promise to honour these commands in all situations. |
215 | All it can do is make a best effort. |
216 | |
339cbe09 |
217 | \S{input-date} \c{\\date}: Automatic \i{date} generation |
11f2edfa |
218 | |
219 | Sometimes you might want your document to give an up-to-date |
220 | indication of the date on which it was run through Halibut. |
221 | |
339cbe09 |
222 | Halibut supplies the \i\c{\\date} command to do this. In its |
223 | simplest form, you simply say |
11f2edfa |
224 | |
225 | \c This document was generated on \date. |
226 | |
227 | and Halibut generates something like |
228 | |
229 | \quote{ |
230 | This document was generated on \date. |
231 | } |
232 | |
acbb8b72 |
233 | You can follow the \c{\\date} command directly with punctuation (as |
234 | in this example, where it is immediately followed by a full stop), |
235 | but if you try to follow it with an alphabetic or numeric character |
236 | (such as writing \c{\\dateZ}) then Halibut will assume you are |
237 | trying to invoke the name of a macro command you have defined |
238 | yourself, and will complain if no such command exists. To get round |
239 | this you can use the special \c{\\.} do-nothing command. See |
240 | \k{input-macro} for more about general Halibut command syntax and |
241 | \c{\\.}. |
242 | |
11f2edfa |
243 | If you would prefer the date to be generated in a specific format, |
244 | you can follow the \c{\\date} command with a format specification in |
245 | braces. The format specification will be run through the standard C |
339cbe09 |
246 | function \i\c{strftime}, so any format acceptable to that function |
247 | is acceptable here as well. I won't document the format here, |
248 | because the details vary from computer to computer (although there |
249 | is a standard core which should be supported everywhere). You should |
250 | look at your local system's manual for \c{strftime} for details. |
11f2edfa |
251 | |
252 | Here's an example which generates the date in the international |
339cbe09 |
253 | standard \i{ISO 8601} format: |
11f2edfa |
254 | |
255 | \c This document was generated on \date{%Y-%m-%d %H:%M:%S}. |
256 | |
257 | And here's some sample output from that command: |
258 | |
259 | \quote{ |
260 | This document was generated on \date{%Y-%m-%d %H:%M:%S}. |
261 | } |
262 | |
339cbe09 |
263 | \S{input-weblink} \c{\\W}: \i{WWW hyperlinks} |
11f2edfa |
264 | |
339cbe09 |
265 | Since one of Halibut's output formats is \i{HTML}, it's obviously |
266 | useful to be able to provide \I{linking to web sites}links to |
267 | arbitrary \i{web sites} in a Halibut document. |
11f2edfa |
268 | |
339cbe09 |
269 | This is done using the \i\c{\\W} command. \c{\\W} expects to be |
11f2edfa |
270 | followed by \e{two} sets of braces. In the first set of braces you |
339cbe09 |
271 | put a \i{URL}; in the second set you put the text which should be a |
272 | \i{hyperlink}. For example, you might write |
11f2edfa |
273 | |
274 | \c Try searching on \W{http://www.google.com/}{Google}. |
275 | |
276 | and Halibut would generate |
277 | |
278 | \quote{ |
279 | Try searching on \W{http://www.google.com/}{Google}. |
280 | } |
281 | |
282 | Note that hyperlinks, like the non-breaking commands discussed in |
283 | \k{input-nonbreaking}, are \e{discretionary}: if an output format |
284 | does not support them then they will just be left out completely. So |
285 | unless you're \e{only} intending to use the HTML output format, you |
286 | should avoid storing vital content in the URL part of a \c{\\W} |
287 | command. The Google example above is reasonable (because most users |
288 | are likely to be able to find Google for themselves even without a |
289 | convenient hyperlink leading straight there), but if you really need |
290 | to direct users to a specific web site, you will need to give the |
291 | URL in actual displayed text (probably displayed as code as well). |
292 | However, there's nothing to stop you making it a hyperlink \e{as |
293 | well} for the convenience of HTML readers. |
294 | |
295 | The \c{\\W} command supports a piece of extra syntax to make this |
296 | convenient for you. You can specify \c{\\c} or \c{\\cw} \e{between} |
297 | the first and second pairs of braces. For example, you might write |
298 | |
299 | \c Google is located at \W{http://www.google.com/}\cw{www.google.com}. |
300 | |
301 | and Halibut would produce |
302 | |
303 | \quote{ |
304 | Google is located at \W{http://www.google.com/}\cw{www.google.com}. |
305 | } |
306 | |
339cbe09 |
307 | \S{input-unicode} \c{\\u}: Specifying arbitrary \i{Unicode} |
308 | characters |
11f2edfa |
309 | |
310 | When Halibut is finished, it should have full Unicode support. You |
339cbe09 |
311 | should be able to specify any (reasonably well known) \i{character |
312 | set} for your input document, and Halibut should convert it all to |
11f2edfa |
313 | Unicode as it reads it in. Similarly, you should be able to specify |
314 | the character set you want for each output format and have all the |
315 | conversion done automatically. |
316 | |
317 | Currently, none of this is actually supported. Input text files are |
339cbe09 |
318 | assumed to be in \i{ISO 8859-1}, and each output format has its own |
11f2edfa |
319 | non-configurable character set (although the HTML output can use the |
320 | \c{Ӓ} mechanism to output any Unicode character it likes). |
321 | |
322 | If you need to specify a Unicode character in your input document |
323 | which is not supported by the input character set, you can use the |
339cbe09 |
324 | \i\c{\\u} command to do this. \c{\\u} expects to be followed by a |
11f2edfa |
325 | sequence of hex digits; so that \c{\\u0041}, for example, denotes |
326 | the Unicode character \cw{0x0041}, which is the capital letter A. |
327 | |
328 | If a Unicode character specified in this way is not supported in a |
329 | particular \e{output} format, you probably don't just want it to be |
330 | omitted. So you can put a pair of braces after the \c{\\u} command |
339cbe09 |
331 | containing \i{fallback text}. For example, to specify an amount of |
332 | money in euros, you might write this: |
11f2edfa |
333 | |
16ea3abe |
334 | \c This is likely to cost \u20AC{EUR\_}2500 at least. |
11f2edfa |
335 | |
336 | Halibut will render that as a Euro sign \e{if available}, and |
16ea3abe |
337 | the text \q{EUR\_} if not. In the output format you're currently |
11f2edfa |
338 | reading in, the above input generates this: |
339 | |
340 | \quote{ |
16ea3abe |
341 | This is likely to cost \u20AC{EUR\_}2500 at least. |
11f2edfa |
342 | } |
343 | |
344 | If you read it in other formats, you may see different results. |
345 | |
339cbe09 |
346 | \S{input-xref} \i\c{\\k} and \i\c{\\K}: \ii{Cross-references} to |
347 | other sections |
11f2edfa |
348 | |
339cbe09 |
349 | \K{intro-features} mentions that Halibut \I{section numbers}numbers |
350 | the sections of your document automatically, and can generate |
351 | cross-references to them on request. \c{\\k} and \c{\\K} are the |
352 | commands used to generate those cross-references. |
11f2edfa |
353 | |
354 | To use one of these commands, you simply follow it with a pair of |
355 | braces containing the keyword for the section in question. For |
356 | example, you might write something like |
357 | |
358 | \c \K{input-xref} expands on \k{intro-features}. |
359 | |
360 | and Halibut would generate something like |
361 | |
362 | \quote{ |
363 | \K{input-xref} expands on \k{intro-features}. |
364 | } |
365 | |
339cbe09 |
366 | The \i{keywords} \c{input-xref} and \c{intro-features} are |
367 | \i{section keywords} used in this manual itself. In your own |
368 | document, you would have supplied a keyword for each one of your own |
369 | sections, and you would provide your own keywords for the \c{\\k} |
370 | command to work on. |
11f2edfa |
371 | |
372 | The difference between \c{\\k} and \c{\\K} is simply that \c{\\K} |
373 | starts the cross-reference text with a capital letter; so you would |
374 | use \c{\\K} at the beginning of a sentence, and \c{\\k} everywhere |
375 | else. |
376 | |
377 | In output formats which permit it, cross-references act as |
339cbe09 |
378 | \i{hyperlinks}, so that clicking the mouse on a cross-reference |
379 | takes you straight to the referenced section. |
11f2edfa |
380 | |
381 | The \c{\\k} commands are also used for referring to entries in a |
339cbe09 |
382 | \i{bibliography} (see \k{input-biblio} for more about |
383 | bibliographies), and can also be used for referring to an element of |
384 | a \i{numbered list} by its number (see \k{input-list-number} for |
385 | more about numbered lists). |
11f2edfa |
386 | |
387 | See \k{input-sections} for more about chapters and sections. |
388 | |
339cbe09 |
389 | \S{input-inline-comment} \i\c{\\#}: Inline comments |
11f2edfa |
390 | |
339cbe09 |
391 | If you want to include \i{comments} in your Halibut input, to be seen |
11f2edfa |
392 | when reading it directly but not copied into the output text, then |
393 | you can use \c{\\#} to do this. If you follow \c{\\#} with text in |
394 | braces, that text will be ignored by Halibut. |
395 | |
396 | For example, you might write |
397 | |
398 | \c The typical behaviour of an antelope \#{do I mean gazelle?} is... |
399 | |
400 | and Halibut will simply leave out the aside about gazelles, and will |
401 | generate nothing but |
402 | |
403 | \quote{ |
404 | The typical behaviour of an antelope \#{do I mean gazelle?} is... |
405 | } |
406 | |
acbb8b72 |
407 | This command will respect nested braces, so you can use it to |
408 | comment out sections of Halibut markup: |
409 | |
410 | \c This function is \#{very, \e{very}} important. |
411 | |
412 | In this example, the comment lasts until the final closing brace (so |
413 | that the whole \q{very, \e{very}} section is commented out). |
414 | |
11f2edfa |
415 | The \c{\\#} command can also be used to produce a whole-paragraph |
416 | comment; see \k{input-commentpara} for details of that. |
417 | |
339cbe09 |
418 | \H{input-para} \ii{Paragraph-level commands} |
11f2edfa |
419 | |
420 | This section describes Halibut commands which affect an entire |
421 | paragraph, or sometimes even \e{more} than one paragraph, at a time. |
422 | |
339cbe09 |
423 | \S{input-codepara} \i\c{\\c}: Displaying whole \I{code |
424 | paragraphs}paragraphs of \i{computer code} |
11f2edfa |
425 | |
426 | \K{input-code} describes a mechanism for displaying computer code in |
427 | the middle of a paragraph, a few words at a time. |
428 | |
429 | However, this is often not enough. Often, in a computer manual, you |
339cbe09 |
430 | really want to show several lines of code in a \i{display |
431 | paragraph}. |
11f2edfa |
432 | |
433 | This is also done using the \c{\\c} command, in a slightly different |
434 | way. Instead of using it in the middle of a paragraph followed by |
435 | braces, you can use it at the start of each line of a paragraph. For |
436 | example, you could write |
437 | |
438 | \c \c #include <stdio.h> |
439 | \c \c |
440 | \c \c int main(int argc, char **argv) { |
441 | \c \c printf("hello, world\n"); |
442 | \c \c return 0; |
443 | \c \c } |
444 | |
445 | and Halibut would generate |
446 | |
447 | \quote{ |
448 | |
449 | \c #include <stdio.h> |
450 | \c |
451 | \c int main(int argc, char **argv) { |
452 | \c printf("hello, world\n"); |
453 | \c return 0; |
454 | \c } |
455 | |
456 | } |
457 | |
458 | Note that the above paragraph makes use of a backslash and a pair of |
459 | braces, and does \e{not} need to escape them in the way described in |
460 | \k{input-basics}. This is because code paragraphs formatted in this |
461 | way are a special case; the intention is that you can just copy and |
462 | paste a lump of code out of another program, put \q{\cw{\\c }} at the |
463 | start of every line, and simply \e{not have to worry} about the |
464 | details - you don't have to go through the whole block looking for |
465 | characters to escape. |
466 | |
467 | Since a backslash inside a code paragraph generates a literal |
468 | backslash, this means you cannot use any other Halibut formatting |
469 | commands inside a code paragraph. In particular, if you want to |
470 | emphasise a particular word in the paragraph, you can't do that |
471 | using \c{\\e} (\k{input-emph}) in the normal way. |
472 | |
339cbe09 |
473 | Therefore, Halibut provides an alternative means of \i{emphasis in |
474 | code paragraphs}. Each line beginning with \c{\\c} can optionally be |
11f2edfa |
475 | followed by a single line beginning with \c{\\e}, indicating the |
476 | emphasis in that line. The emphasis line contains the letters \c{b} |
477 | and \c{i} (for \q{bold} and \q{italic}, although some output formats |
339cbe09 |
478 | might render \c{i} as underlining instead of italics), positioned to |
479 | line up under the parts of the text that you want emphasised. |
11f2edfa |
480 | |
339cbe09 |
481 | For example, if you wanted to do \i{syntax highlighting} on the |
482 | above C code by highlighting the preprocessor command in italic and |
483 | the keywords in bold, you might do it like this: |
11f2edfa |
484 | |
485 | \c \c #include <stdio.h> |
486 | \c \e iiiiiiiiiiiiiiiiii |
487 | \c \c |
488 | \c \c int main(int argc, char **argv) { |
489 | \c \e bbb bbb bbbb |
490 | \c \c printf("hello, world\n"); |
491 | \c \c return 0; |
492 | \c \e bbbbbb |
493 | \c \c } |
494 | |
495 | and Halibut would generate: |
496 | |
497 | \quote{ |
498 | |
499 | \c #include <stdio.h> |
500 | \e iiiiiiiiiiiiiiiiii |
501 | \c |
502 | \c int main(int argc, char **argv) { |
503 | \e bbb bbb bbbb |
504 | \c printf("hello, world\n"); |
505 | \c return 0; |
506 | \e bbbbbb |
507 | \c } |
508 | |
509 | } |
510 | |
511 | Note that not every \c{\\c} line has to be followed by a \c{\\e} |
512 | line; they're optional. |
513 | |
514 | Also, note that highlighting within a code paragraph is |
515 | \e{discretionary}. Not all of Halibut's output formats can support |
516 | it (plain text, in particular, has no sensible way to do it). Unless |
517 | you know you are using a restricted range of output formats, you |
518 | should use highlighting in code paragraphs \e{only} as a visual aid, |
519 | and not rely on it to convey any vital semantic content. |
520 | |
339cbe09 |
521 | \S{input-lists} \c{\\b}, \c{\\n}, \c{\\dt}, \c{\\dd}, \c{\\lcont}: |
522 | \ii{Lists} |
11f2edfa |
523 | |
524 | Halibut supports bulletted lists, numbered lists and description |
525 | lists. |
526 | |
339cbe09 |
527 | \S2{input-list-bullet} \i\c{\\b}: \ii{Bulletted lists} |
11f2edfa |
528 | |
529 | To create a bulletted list, you simply prefix each paragraph |
530 | describing a bullet point with the command \c{\\b}. For example, this |
531 | Halibut input: |
532 | |
533 | \c Here's a list: |
534 | \c |
535 | \c \b One. |
536 | \c |
537 | \c \b Two. |
538 | \c |
539 | \c \b Three. |
540 | |
541 | would produce this Halibut output: |
542 | |
543 | \quote{ |
544 | Here's a list: |
545 | |
546 | \b One. |
547 | |
548 | \b Two. |
549 | |
550 | \b Three. |
551 | } |
552 | |
339cbe09 |
553 | \S2{input-list-number} \i\c{\\n}: \ii{Numbered lists} |
11f2edfa |
554 | |
555 | Numbered lists are just as simple: instead of \c{\\b}, you use |
556 | \c{\\n}, and Halibut takes care of getting the numbering right for |
557 | you. For example: |
558 | |
559 | \c Here's a list: |
560 | \c |
561 | \c \n One. |
562 | \c |
563 | \c \n Two. |
564 | \c |
565 | \c \n Three. |
566 | |
567 | This produces the Halibut output: |
568 | |
569 | \quote{ |
570 | Here's a list: |
571 | |
572 | \n One. |
573 | |
574 | \n Two. |
575 | |
576 | \n Three. |
577 | } |
578 | |
579 | The disadvantage of having Halibut sort out the list numbering for |
580 | you is that if you need to refer to a list item by its number, you |
581 | can't reliably do so. To get round this, Halibut allows an optional |
582 | keyword in braces after the \c{\\n} command. This keyword can then |
583 | be referenced using the \c{\\k} or \c{\\K} command (see |
584 | \k{input-xref}) to provide the number of the list item. For example: |
585 | |
586 | \c Here's a list: |
587 | \c |
588 | \c \n One. |
589 | \c |
590 | \c \n{this-one} Two. |
591 | \c |
592 | \c \n Three. |
593 | \c |
594 | \c \n Now go back to step \k{this-one}. |
595 | |
596 | This produces the following output: |
597 | |
598 | \quote{ |
599 | Here's a list: |
600 | |
601 | \n One. |
602 | |
603 | \n{this-one} Two. |
604 | |
605 | \n Three. |
606 | |
607 | \n Now go back to step \k{this-one}. |
608 | } |
609 | |
acbb8b72 |
610 | The keyword you supply after \c{\\n} is allowed to contain escaped |
611 | special characters (\c{\\\\}, \c{\\\{} and \c{\\\}}), but should not |
612 | contain any other Halibut markup. It is intended to be a word or two |
613 | of ordinary text. (This also applies to keywords used in other |
614 | commands, such as \c{\\B} and \c{\\C}). |
615 | |
339cbe09 |
616 | \S2{input-list-description} \i\c{\\dt} and \i\c{\\dd}: |
617 | \ii{Description lists} |
11f2edfa |
618 | |
339cbe09 |
619 | To write a description list, you prefix alternate paragraphs with |
620 | the \c{\\dt} (\q{described thing}) and \c{\\dd} (description) |
621 | commands. For example: |
11f2edfa |
622 | |
623 | \c \dt Pelican |
624 | \c |
625 | \c \dd This is a large bird with a big beak. |
626 | \c |
627 | \c \dt Panda |
628 | \c |
629 | \c \dd This isn't. |
630 | |
631 | This produces the following output: |
632 | |
633 | \quote{ |
634 | |
635 | \dt Pelican |
636 | |
637 | \dd This is a large bird with a big beak. |
638 | |
639 | \dt Panda |
640 | |
641 | \dd This isn't. |
642 | |
643 | } |
644 | |
339cbe09 |
645 | \S2{input-list-continuation} \ii{Continuing list items} into further |
11f2edfa |
646 | paragraphs |
647 | |
648 | All three of the above list types assume that each list item is a |
649 | single paragraph. For a short, snappy list in which each item is |
650 | likely to be only one or two words, this is perfectly sufficient; |
651 | but occasionally you will find you want to include several |
339cbe09 |
652 | paragraphs in a single list item, or even to \I{nested lists}nest |
653 | other types of paragraph (such as code paragraphs, or other lists) |
654 | inside a list item. |
11f2edfa |
655 | |
339cbe09 |
656 | To do this, you use the \i\c{\\lcont} command. This is a command |
657 | which can span \e{multiple} paragraphs. |
11f2edfa |
658 | |
659 | After the first paragraph of a list item, include the text |
660 | \c{\\lcont\{}. This indicates that the subsequent paragraph(s) are a |
661 | \e{continuation} of the list item that has just been seen. So you |
662 | can include further paragraphs, and eventually include a closing |
663 | brace \c{\}} to finish the list continuation. After that, you can |
664 | either continue adding other items to the original list, or stop |
665 | immediately and return to writing normal paragraphs of text. |
666 | |
667 | Here's a (long) example. |
668 | |
669 | \c Here's a list: |
670 | \c |
671 | \c \n One. This item is followed by a code paragraph: |
672 | \c |
673 | \c \lcont{ |
674 | \c |
675 | \c \c code |
676 | \c \c paragraph |
677 | \c |
678 | \c } |
679 | \c |
680 | \c \n Two. Now when I say \q{two}, I mean: |
681 | \c |
682 | \c \lcont{ |
683 | \c |
684 | \c \n Two, part one. |
685 | \c |
686 | \c \n Two, part two. |
687 | \c |
688 | \c \n Two, part three. |
689 | \c |
690 | \c } |
691 | \c |
692 | \c \n Three. |
693 | |
694 | The output produced by this fragment is: |
695 | |
696 | \quote{ |
697 | |
698 | Here's a list: |
699 | |
700 | \n One. This item is followed by a code paragraph: |
701 | |
702 | \lcont{ |
703 | |
704 | \c code |
705 | \c paragraph |
706 | |
707 | } |
708 | |
709 | \n Two. Now when I say \q{two}, I mean: |
710 | |
711 | \lcont{ |
712 | |
713 | \n Two, part one. |
714 | |
715 | \n Two, part two. |
716 | |
717 | \n Two, part three. |
718 | |
719 | } |
720 | |
721 | \n Three. |
722 | |
723 | } |
724 | |
725 | This syntax seems a little bit inconvenient, and perhaps |
726 | counter-intuitive: you might expect the enclosing braces to have to |
727 | go around the \e{whole} list item, rather than everything except the |
728 | first paragraph. |
729 | |
730 | \c{\\lcont} is a recent addition to the Halibut input language; |
731 | previously, \e{all} lists were required to use no more than one |
732 | paragraph per list item. So it's certainly true that this feature |
733 | looks like an afterthought because it \e{is} an afterthought, and |
734 | it's possible that if I'd been designing the language from scratch |
735 | with multiple-paragraph list items in mind, I would have made it |
736 | look different. |
737 | |
738 | However, the advantage of doing it this way is that no enclosing |
739 | braces are required in the \e{common} case: simple lists with only |
740 | one paragraph per item are really, really easy to write. So I'm not |
741 | too unhappy with the way it turned out; it obeys the doctrine of |
742 | making simple things simple, and difficult things possible. |
743 | |
744 | Note that \c{\\lcont} can only be used on \c{\\b}, \c{\\n} and |
745 | \c{\\dd} paragraphs; it cannot be used on \c{\\dt}. |
746 | |
339cbe09 |
747 | \S{input-rule} \i\c{\\rule}: \ii{Horizontal rules} |
11f2edfa |
748 | |
749 | The command \c{\\rule}, appearing on its own as a paragraph, will |
750 | cause a horizontal rule to be drawn, like this: |
751 | |
752 | \c Some text. |
753 | \c |
754 | \c \rule |
755 | \c |
756 | \c Some more text. |
757 | |
758 | This produces the following output: |
759 | |
760 | \quote{ |
761 | |
762 | Some text. |
763 | |
764 | \rule |
765 | |
766 | Some more text. |
767 | |
768 | } |
769 | |
339cbe09 |
770 | \S{input-quote} \i\c{\\quote}: \ii{Indenting multiple paragraphs} as a |
771 | long \i{quotation} |
11f2edfa |
772 | |
773 | Quoting verbatim text using a code paragraph (\k{input-codepara}) is |
774 | not always sufficient for your quoting needs. Sometimes you need to |
775 | quote some normally formatted text, possibly in multiple paragraphs. |
339cbe09 |
776 | This is similar to HTML's \i\cw{<BLOCKQUOTE>} command. |
11f2edfa |
777 | |
778 | To do this, you can use the \c{\\quote} command. Like \c{\\lcont}, |
779 | this is a command which expects to enclose at least one paragraph |
780 | and possibly more. Simply write \c{\\quote\{} at the beginning of |
781 | your quoted section, and \c{\}} at the end, and the paragraphs in |
782 | between will be formatted to indicate that they are a quotation. |
783 | |
784 | (This very manual, in fact, uses this feature a lot: all of the |
785 | examples of Halibut source followed by Halibut output have the |
786 | output quoted using \c{\\quote}.) |
787 | |
788 | Here's some example Halibut input: |
789 | |
790 | \c In \q{Through the Looking Glass}, Lewis Carroll wrote: |
791 | \c |
792 | \c \quote{ |
793 | \c |
794 | \c \q{The question is,} said Alice, \q{whether you \e{can} make |
795 | \c words mean so many different things.} |
796 | \c |
797 | \c \q{The question is,} said Humpty Dumpty, \q{who is to be master - |
798 | \c that's all.} |
799 | \c |
800 | \c } |
801 | \c |
802 | \c So now you know. |
803 | |
804 | The output generated by this is: |
805 | |
806 | \quote{ |
807 | |
808 | In \q{Through the Looking Glass}, Lewis Carroll wrote: |
809 | |
810 | \quote{ |
811 | |
812 | \q{The question is,} said Alice, \q{whether you \e{can} make |
813 | words mean so many different things.} |
814 | |
815 | \q{The question is,} said Humpty Dumpty, \q{who is to be master - |
816 | that's all.} |
817 | |
818 | } |
819 | |
820 | So now you know. |
821 | |
822 | } |
823 | |
339cbe09 |
824 | \S{input-sections} \i\c{\\C}, \i\c{\\H}, \i\c{\\S}, \i\c{\\A}, |
825 | \i\c{\\U}: Chapter and \i{section headings} |
11f2edfa |
826 | |
339cbe09 |
827 | \K{intro-features} mentions that Halibut \I{section |
828 | numbering}numbers the sections of your document automatically, and |
829 | can generate cross-references to them on request; \k{input-xref} |
830 | describes the \c{\\k} and \c{\\K} commands used to generate the |
831 | cross-references. This section describes the commands used to set up |
832 | the sections in the first place. |
11f2edfa |
833 | |
834 | A paragraph beginning with the \c{\\C} command defines a chapter |
835 | heading. The \c{\\C} command expects to be followed by a pair of |
836 | braces containing a keyword for the chapter; this keyword can then |
837 | be used with the \c{\\k} and \c{\\K} commands to generate |
838 | cross-references to the chapter. After the closing brace, the rest |
839 | of the paragraph is used as the displayed chapter title. So the |
840 | heading for the current chapter of this manual, for example, is |
841 | written as |
842 | |
843 | \c \C{input} Halibut input format |
844 | |
845 | and this allows me to use the command \c{\\k\{input\}} to generate a |
846 | cross-reference to that chapter somewhere else. |
847 | |
acbb8b72 |
848 | The \I{keyword syntax}keyword you supply after one of these commands |
849 | is allowed to contain escaped special characters (\c{\\\\}, \c{\\\{} |
850 | and \c{\\\}}), but should not contain any other Halibut markup. It |
851 | is intended to be a word or two of ordinary text. (This also applies |
852 | to keywords used in other commands, such as \c{\\B} and \c{\\n}). |
853 | |
11f2edfa |
854 | The next level down from \c{\\C} is \c{\\H}, for \q{heading}. This |
855 | is used in exactly the same way as \c{\\C}, but section headings |
856 | defined with \c{\\H} are considered to be part of a containing |
857 | chapter, and will be numbered with a pair of numbers. After \c{\\H} |
858 | comes \c{\\S}, and if necessary you can then move on to \c{\\S2}, |
859 | \c{\\S3} and so on. |
860 | |
861 | For example, here's a sequence of heading commands. Normally these |
862 | commands would be separated at least by blank lines (because each is |
863 | a separate paragraph), and probably also by body text; but for the |
864 | sake of brevity, both of those have been left out in this example. |
865 | |
866 | \c \C{foo} Using Foo |
867 | \c \H{foo-intro} Introduction to Foo |
868 | \c \H{foo-running} Running the Foo program |
869 | \c \S{foo-inter} Running Foo interactively |
870 | \c \S{foo-batch} Running Foo in batch mode |
871 | \c \H{foo-trouble} Troubleshooting Foo |
872 | \c \C{bar} Using Bar instead of Foo |
873 | |
874 | This would define two chapters with keywords \c{foo} and \c{bar}, |
875 | which would end up being called Chapter 1 and Chapter 2 (unless |
876 | there were other chapters before them). The sections \c{foo-intro}, |
877 | \c{foo-running} and \c{foo-trouble} would be referred to as Section |
878 | 1.1, Section 1.2 and Section 1.3 respectively; the subsections |
879 | \c{foo-inter} and \c{foo-batch} would be Section 1.2.1 and Section |
339cbe09 |
880 | 1.2.2. If there had been a \i\c{\\S2} command within one of those, |
881 | it would have been something like Section 1.2.1.1. |
11f2edfa |
882 | |
883 | If you don't like the switch from \c{\\H} to \c{\\S}, you can use |
884 | \c{\\S1} as a synonym for \c{\\S} and \c{\\S0} as a synonym for |
885 | \c{\\H}. Chapters are still designated with \c{\\C}, because they |
886 | need to be distinguished from other types of chapter such as |
887 | appendices. (Personally, I like the \c{\\C},\c{\\H},\c{\\S} notation |
888 | because it encourages me to think of my document as a hard disk :-) |
889 | |
339cbe09 |
890 | You can define an \i{appendix} by using \c{\\A} in place of \c{\\C}. |
11f2edfa |
891 | This is no different from a chapter except that it's given a letter |
892 | instead of a number, and cross-references to it will say \q{Appendix |
893 | A} instead of \q{Chapter 9}. Subsections of an appendix will be |
894 | numbered \q{A.1}, \q{A.2}, \q{A.2.1} and so on. |
895 | |
339cbe09 |
896 | \I{renaming sections}If you want a particular section to be referred |
897 | to as something other than a \q{chapter}, \q{section} or |
898 | \q{appendix}, you can include a second pair of braces after the |
899 | keyword. For example, if you're \i{writing a FAQ} chapter and you |
900 | want cross-references between questions to refer to \q{question |
901 | 1.2.3} instead of \q{section 1.2.3}, you can write each section |
902 | heading as |
11f2edfa |
903 | |
904 | \c \S{question-about-fish}{Question} What about fish? |
905 | |
906 | (The word \q{Question} should be given with an initial capital |
907 | letter. Halibut will lower-case it when you refer to it using |
908 | \c{\\k}, and will leave it alone if you use \c{\\K}.) |
909 | |
910 | This technique allows you to change the designation of |
911 | \e{particular} sections. To make an overall change in what \e{every} |
912 | section is called, see \k{input-config}. |
913 | |
339cbe09 |
914 | Finally, the \c{\\U} command defines an \I{unnumbered |
915 | chapter}\e{unnumbered} chapter. These sometimes occur in books, for |
916 | specialist purposes such as \q{Bibliography} or |
917 | \q{Acknowledgements}. \c{\\U} does not expect a keyword argument, |
918 | because there is no sensible way to generate an automatic |
919 | cross-reference to such a chapter anyway. |
11f2edfa |
920 | |
8902e0ed |
921 | \S{input-blurb} \c{\\copyright}, \c{\\title}, \c{\\versionid}: |
339cbe09 |
922 | Miscellaneous \i{blurb commands} |
11f2edfa |
923 | |
339cbe09 |
924 | These three commands define a variety of \i{special paragraph |
925 | types}. They are all used in the same way: you put the command at |
926 | the start of a paragraph, and then just follow it with normal text, |
927 | like this: |
11f2edfa |
928 | |
929 | \c \title My First Manual |
930 | |
8902e0ed |
931 | The three special paragraph types are: |
11f2edfa |
932 | |
339cbe09 |
933 | \dt \i\cw{\\title} |
11f2edfa |
934 | |
935 | \dd This defines the overall title of the entire document. This |
936 | title is treated specially in some output formats (for example, it's |
937 | used in a \cw{<title>} tag in the HTML output), so it needs a |
938 | special paragraph type to point it out. |
939 | |
339cbe09 |
940 | \dt \i\cw{\\copyright} |
11f2edfa |
941 | |
942 | \dd This command indicates that the paragraph attached to it |
339cbe09 |
943 | contains a \i{copyright statement} for the document. This text is |
9057a0a8 |
944 | displayed inline where it appears, exactly like a normal paragraph; |
945 | but in some output formats it is given additional special treatment. |
946 | For example, Windows Help files have a standard slot in which to |
947 | store a copyright notice, so that other software can display it |
948 | prominently. |
11f2edfa |
949 | |
339cbe09 |
950 | \dt \i\cw{\\versionid} |
11f2edfa |
951 | |
952 | \dd This command indicates that the paragraph contains a version |
953 | identifier, such as those produced by CVS (of the form \c{$\#{hope this |
954 | defuses CVS}Id: thingy.but,v 1.6 2004/01/01 16:47:48 simon Exp $}). |
955 | This text will be tucked away somewhere unobtrusive, so that anyone |
956 | wanting to (for example) report errors to the document's author can |
339cbe09 |
957 | pick out the \i{version IDs} and send them as part of the report, so |
11f2edfa |
958 | that the author can tell at a glance which revision of the document |
959 | is being discussed. |
960 | |
339cbe09 |
961 | \S{input-commentpara} \i\c{\\#}: Whole-paragraph \i{comments} |
11f2edfa |
962 | |
963 | \K{input-inline-comment} describes the use of the \c{\\#} command to |
964 | put a short comment in the middle of a paragraph. |
965 | |
966 | If you need to use a \e{long} comment, Halibut also allows you to |
967 | use \c{\\#} without braces, to indicate that an entire paragraph is |
968 | a comment, like this: |
969 | |
970 | \c Here's a (fairly short) paragraph which will be displayed. |
971 | \c |
972 | \c \# Here's a comment paragraph which will not be displayed, no |
973 | \c matter how long it goes on. All I needed to indicate this was the |
974 | \c single \# at the start of the paragraph; I don't need one on |
975 | \c every line or anything like that. |
976 | \c |
977 | \c Here's another displayed paragraph. |
978 | |
979 | When run through Halibut, this produces the following output: |
980 | |
981 | \quote{ |
982 | |
983 | Here's a (fairly short) paragraph which will be displayed. |
984 | |
985 | \# Here's a comment paragraph which will not be displayed, no |
986 | matter how long it goes on. All I needed to indicate this was the |
987 | single \# at the start of the paragraph; I don't need one on |
988 | every line or anything like that. |
989 | |
990 | Here's another displayed paragraph. |
991 | |
992 | } |
993 | |
339cbe09 |
994 | \H{input-biblio} Creating a \i{bibliography} |
11f2edfa |
995 | |
996 | If you need your document to refer to other documents (research |
997 | papers, books, websites, whatever), you might find a bibliography |
998 | feature useful. |
999 | |
339cbe09 |
1000 | You can define a bibliography entry using the \i\c{\\B} command. This |
11f2edfa |
1001 | looks very like the \c{\\C} command and friends: it expects a |
1002 | keyword in braces, followed by some text describing the document |
1003 | being referred to. For example: |
1004 | |
1005 | \c \B{freds-book} \q{The Taming Of The Mongoose}, by Fred Bloggs. |
1006 | \c Published by Paperjam & Notoner, 1993. |
1007 | |
1008 | If this bibliography entry appears in the finished document, it will |
1009 | look something like this: |
1010 | |
1011 | \quote{ |
1012 | |
1013 | \B{freds-book} \q{The Taming Of The Mongoose}, by Fred Bloggs. |
1014 | Published by Paperjam & Notoner, 1993. |
1015 | |
1016 | } |
1017 | |
1018 | I say \q{if} above because not all bibliography entries defined |
1019 | using the \c{\\B} command will necessarily appear in the finished |
339cbe09 |
1020 | document. They only appear if they are \I{citation}referred to by a |
1021 | \i\c{\\k} command (see \k{input-xref}). This allows you to (for |
1022 | example) maintain a single Halibut source file with a centralised |
1023 | database of \e{all} the references you have ever needed in any of |
1024 | your writings, include that file in every document you feed to |
1025 | Halibut, and have it only produce the bibliography entries you |
1026 | actually need for each particular document. (In fact, you might even |
1027 | want this centralised source file to be created automatically by, |
1028 | say, a Perl script from BibTeX input, so that you can share the same |
1029 | bibliography with users of other formatting software.) |
11f2edfa |
1030 | |
1031 | If you really want a bibliography entry to appear in the document |
1032 | even though no text explicitly refers to it, you can do that using |
339cbe09 |
1033 | the \i\c{\\nocite} command: |
11f2edfa |
1034 | |
1035 | \c \nocite{freds-book} |
1036 | |
1037 | Normally, each bibliography entry will be referred to (in citations |
1038 | and in the bibliography itself) by a simple reference number, such |
1039 | as \k{freds-book}. If you would rather use an alternative reference |
339cbe09 |
1040 | notation, such as [Fred1993], you can use the \i\c{\\BR} |
11f2edfa |
1041 | (\q{Bibliography Rewrite}) command to specify your own reference |
1042 | format for a particular book: |
1043 | |
1044 | \c \BR{freds-book} [Fred1993] |
1045 | |
acbb8b72 |
1046 | The keyword you supply after \c{\\B} is allowed to contain escaped |
1047 | special characters (\c{\\\\}, \c{\\\{} and \c{\\\}}), but should not |
1048 | contain any other Halibut markup. It is intended to be a word or two |
1049 | of ordinary text. (This also applies to keywords used in other |
1050 | commands, such as \c{\\n} and \c{\\C}). |
1051 | |
339cbe09 |
1052 | \H{input-index} Creating an \i{index} |
11f2edfa |
1053 | |
1054 | Halibut contains a comprehensive indexing mechanism, which attempts |
1055 | to be reasonably easy to use in the common case in spite of its |
1056 | power. |
1057 | |
1058 | \S{input-index-simple} Simple indexing |
1059 | |
1060 | In normal usage, you should be able to add index terms to your |
339cbe09 |
1061 | document simply by using the \i\c{\\i} command to wrap one or two |
11f2edfa |
1062 | words at a time. For example, if you write |
1063 | |
1064 | \c The \i{hippopotamus} is a particularly large animal. |
1065 | |
1066 | then the index will contain an entry under \q{hippopotamus}, |
1067 | pointing to that sentence (or as close to that sentence as the |
1068 | output format sensibly permits). |
1069 | |
1070 | You can wrap more than one word in \c{\\i} as well: |
1071 | |
1072 | \c We recommend using a \i{torque wrench} for this job. |
1073 | |
1074 | \S{input-index-special} Special cases of indexing |
1075 | |
1076 | If you need to index a computer-related term, you can use the |
339cbe09 |
1077 | special case \i\c{\\i\\c} (or \i\c{\\i\\cw} if you prefer): |
11f2edfa |
1078 | |
1079 | \c The \i\c{grep} command is what you want here. |
1080 | |
1081 | This will cause the word \q{grep} to appear in code style, as if the |
1082 | \c{\\i} were not present and the input just said \c{\\c\{grep\}}; |
1083 | the word will also appear in code style in the actual index. |
1084 | |
1085 | If you want to simultaneously index and emphasise a word, there's |
339cbe09 |
1086 | another special case \i\c{\\i\\e}: |
11f2edfa |
1087 | |
1088 | \c This is what we call a \i\e{paper jam}. |
1089 | |
1090 | This will cause the words \q{paper jam} to be emphasised in the |
1091 | document, but (unlike the behaviour of \c{\\i\\c}) they will \e{not} |
1092 | be emphasised in the index. This different behaviour is based on an |
1093 | expectation that most people indexing a word of computer code will |
1094 | still want it to look like code in the index, whereas most people |
1095 | indexing an emphasised word will \e{not} want it emphasised in the |
1096 | index. |
1097 | |
8856f150 |
1098 | (In fact, \e{no} emphasis in the text inside \c{\\i} will be |
1099 | preserved in the index. If you really want a term in the index to |
1100 | appear emphasised, you must say so explicitly using \c{\\IM}; see |
1101 | \k{input-index-rewrite}.) |
1102 | |
11f2edfa |
1103 | Sometimes you might want to index a term which is not explicitly |
1104 | mentioned, but which is highly relevant to the text and you think |
1105 | that somebody looking up that term in the index might find it useful |
339cbe09 |
1106 | to be directed here. To do this you can use the \i\c{\\I} command, |
1107 | to create an \i{\e{invisible} index tag}: |
11f2edfa |
1108 | |
1109 | \c If your printer runs out of toner, \I{replacing toner |
1110 | \c cartridge}here is what to do: |
1111 | |
1112 | This input will produce only the output \q{If your printer runs out |
1113 | of toner, here is what to do}; but an index entry will show up under |
1114 | \q{replacing toner cartridge}, so that if a user thinks the obvious |
1115 | place to start in the index is under R for \q{replacing}, they will |
1116 | find their way here with a minimum of fuss. |
1117 | |
1118 | (It's worth noting that there is no functional difference between |
1119 | \c{\\i\{foo\}} and \c{\\I\{foo\}foo}. The simple \c{\\i} case is |
1120 | only a shorthand for the latter.) |
1121 | |
1122 | Finally, if you want to index a word at the start of a sentence, you |
1123 | might very well not want it to show up with a capital letter in the |
339cbe09 |
1124 | index. For this, Halibut provides the \i\c{\\ii} command, for |
1125 | \q{index (case-)insensitively}. You use it like this: |
11f2edfa |
1126 | |
1127 | \c \ii{Lions} are at the top of the food chain in this area. |
1128 | |
1129 | This is equivalent to \c{\\I\{lions\}Lions}; in other words, the |
1130 | text will say \q{Lions}, but it will show up in the index as |
1131 | \q{lions}. The text inside \c{\\ii} is converted entirely into lower |
1132 | case before being added to the index data. |
1133 | |
339cbe09 |
1134 | \S{input-index-rewrite} \ii{Fine-tuning the index} |
11f2edfa |
1135 | |
1136 | Halibut's index mechanism as described so far still has a few |
1137 | problems left: |
1138 | |
1139 | \b In a reasonably large index, it's often difficult to predict |
339cbe09 |
1140 | \I{replicating index terms}which of several words a user will think |
1141 | of first when trying to look something up. For example, if they want |
1142 | to know how to replace a toner cartridge, they might look up |
1143 | \q{replacing} or they might look up \q{toner cartridge}. You |
1144 | probably don't really want to have to try to figure out which of |
1145 | those is more likely; instead, what you'd like is to be able to |
1146 | effortlessly index the same set of document locations under \e{both} |
1147 | terms. |
11f2edfa |
1148 | |
1149 | \b Also, you may find you've indexed the same concept under multiple |
339cbe09 |
1150 | different \I{merging index terms}index terms; for example, there |
1151 | might be several instances of \c{\\i\{frog\}} and several of |
1152 | \c{\\i\{frogs\}}, so that you'd end up with two separate index |
1153 | entries for what really ought to be the same concept. |
11f2edfa |
1154 | |
1155 | \b You might well not want the word \q{\cw{grep}} to appear in the |
1156 | index without explanation; you might prefer it to say something more |
339cbe09 |
1157 | \I{rewriting index terms}verbose such as \q{\cw{grep} command}, so |
1158 | that a user encountering it in the index has some idea of what it is |
1159 | \e{without} having to follow up the reference. However, you |
1160 | certainly don't want to have to write \c{\\I\{\\cw\{grep\} |
1161 | command\}\\c\{grep\}} every time you want to add an index term for |
1162 | this! You wanted to write \c{\\i\\c\{grep\}} as shown in the |
1163 | previous section, and tidy it all up afterwards. |
1164 | |
1165 | All of these problems can be cleaned up by the \i\c{\\IM} (for |
11f2edfa |
1166 | \q{Index Modification}) command. \c{\\IM} expects to be followed by |
1167 | one or more pairs of braces containing index terms as seen in the |
1168 | document, and then a piece of text (not in braces) describing how it |
1169 | should be shown in the index. |
1170 | |
1171 | So to rewrite the \c{grep} example above, you might do this: |
1172 | |
1173 | \c \IM{grep} \cw{grep} command |
1174 | |
1175 | This will arrange that the set of places in the document where you |
1176 | asked Halibut to index \q{\cw{grep}} will be listed under |
1177 | \q{\cw{grep} command} rather than just under \q{\cw{grep}}. |
1178 | |
1179 | You can specify more than one index term in a \c{\\IM} command; so |
1180 | to merge the index terms \q{frog} and \q{frogs} into a single term, |
1181 | you might do this: |
1182 | |
1183 | \c \IM{frog}{frogs} frog |
1184 | |
1185 | This will arrange that the single index entry \q{frog} will list |
1186 | \e{all} the places in the document where you asked Halibut to index |
1187 | either \q{frog} or \q{frogs}. |
1188 | |
1189 | You can use multiple \c{\\IM} commands to replicate the same set of |
1190 | document locations in more than one index entry. For example: |
1191 | |
1192 | \c \IM{replacing toner cartridge} replacing toner cartridge |
1193 | \c \IM{replacing toner cartridge} toner cartridge, replacing |
1194 | |
1195 | This will arrange that every place in the document where you have |
1196 | indexed \q{replacing toner cartridge} will be listed both there |
1197 | \e{and} under \q{toner cartridge, replacing}, so that no matter |
1198 | whether the user looks under R or under T they will stil find their |
1199 | way to the same parts of the document. |
1200 | |
1201 | In this example, note that although the first \c{\\IM} command |
1202 | \e{looks} as if it's a tautology, it is still necessary, because |
1203 | otherwise those document locations will \e{only} be indexed under |
1204 | \q{toner cartridge, replacing}. If you have \e{no} explicit \c{\\IM} |
1205 | commands for a particular index term, then Halibut will assume a |
1206 | default one (typically \c{\\IM\{foo\}\_foo}, although it might be |
1207 | \c{\\IM\{foo\}\_\\c\{foo\}} if you originally indexed using |
1208 | \c{\\i\\c}); but as soon as you specify an explicit \c{\\IM}, |
1209 | Halibut discards its default implicit one, and you must then specify |
1210 | that one explicitly as well if you wanted to keep it. |
1211 | |
339cbe09 |
1212 | \H{input-config} \ii{Configuring} Halibut |
11f2edfa |
1213 | |
339cbe09 |
1214 | Halibut uses the \i\c{\\cfg} command to allow you to configure various |
11f2edfa |
1215 | aspects of its functionality. |
1216 | |
1217 | The \c{\\cfg} command expects to be followed by at least one pair of |
1218 | braces, and usually more after that. The first pair of braces |
1219 | contains a keyword indicating what aspect of Halibut you want to |
1220 | configure, and the meaning of the one(s) after that depends on the |
1221 | first keyword. |
1222 | |
1223 | The current list of configuration keywords in the main Halibut code |
1224 | is quite small. Here it is in full: |
1225 | |
339cbe09 |
1226 | \dt \I\cw{\\cfg\{chapter\}}\cw{\\cfg\{chapter\}\{}\e{new chapter name}\cw{\}} |
11f2edfa |
1227 | |
1228 | \dd This tells Halibut that you don't want to call a chapter a |
339cbe09 |
1229 | \I{renaming sections}\I{configuring heading display}chapter any |
1230 | more. For example, if you give the command |
11f2edfa |
1231 | \cw{\\cfg\{chapter\}\{Book\}}, then any chapter defined with the |
1232 | \c{\\C} command will be labelled \q{Book} rather than \q{Chapter}, |
1233 | both in the section headings and in cross-references. This is |
1234 | probably most useful if your document is not written in English. |
1235 | |
339cbe09 |
1236 | \lcont{ |
1237 | |
1238 | Your replacement name should be given with a capital letter. Halibut |
1239 | will leave it alone if it appears at the start of a sentence (in a |
1240 | chapter title, or when \c{\\K} is used), and will lower-case it |
1241 | otherwise (when \c{\\k} is used). |
1242 | |
1243 | } |
1244 | |
1245 | \dt \I\cw{\\cfg\{section\}}\cw{\\cfg\{section\}\{}\e{new section name}\cw{\}} |
11f2edfa |
1246 | |
1247 | \dd Exactly like \c{chapter}, but changes the name given to |
1248 | subsections of a chapter. |
1249 | |
339cbe09 |
1250 | \dt \I\cw{\\cfg\{appendix\}}\cw{\\cfg\{appendix\}\{}\e{new appendix name}\cw{\}} |
11f2edfa |
1251 | |
339cbe09 |
1252 | \dd Exactly like \c{chapter}, but changes the name given to |
11f2edfa |
1253 | appendices. |
1254 | |
1255 | In addition to these configuration commands, there are also |
1256 | configuration commands provided by each individual output format. |
1257 | These configuration commands are discussed along with each output |
16ea3abe |
1258 | format, in \k{output}. |
11f2edfa |
1259 | |
339cbe09 |
1260 | The \i{default settings} for the above options are: |
1261 | |
1262 | \c \cfg{chapter}{Chapter} |
1263 | \c \cfg{section}{Section} |
1264 | \c \cfg{appendix}{Appendix} |
1265 | |
1266 | \H{input-macro} Defining \i{macros} |
11f2edfa |
1267 | |
1268 | If there's a complicated piece of Halibut source which you think |
1269 | you're going to use a lot, you can define your own Halibut command |
1270 | to produce that piece of source. |
1271 | |
1272 | In \k{input-unicode}, there is a sample piece of code which prints a |
1273 | Euro sign, or replaces it with \q{EUR} if the Euro sign is not |
1274 | available: |
1275 | |
16ea3abe |
1276 | \c This is likely to cost \u20AC{EUR\_}2500 at least. |
11f2edfa |
1277 | |
1278 | If your document quotes a \e{lot} of prices in Euros, you might not |
1279 | want to spend all your time typing that out. So you could define a |
339cbe09 |
1280 | macro, using the \i\c{\\define} command: |
11f2edfa |
1281 | |
16ea3abe |
1282 | \c \define{eur} \u20AC{EUR\_} |
11f2edfa |
1283 | |
acbb8b72 |
1284 | Your macro names may include Roman alphabetic characters |
1285 | (\c{a}-\c{z}, \c{A}-\c{Z}) and ordinary Arabic numerals |
1286 | (\c{0}-\c{9}), but nothing else. (This is general \I{command |
1287 | syntax}syntax for all of Halibut's commands, except for a few |
1288 | special ones such as \c{\\_} and \c{\\-} which consist of a single |
1289 | punctuation character only.) |
1290 | |
672e4626 |
1291 | Then you can just write ... |
11f2edfa |
1292 | |
1293 | \c This is likely to cost \eur 2500 at least. |
1294 | |
672e4626 |
1295 | ... except that that's not terribly good, because you end up with a |
acbb8b72 |
1296 | space between the Euro sign and the number. (If you had written |
1297 | \c{\\eur2500}, Halibut would have tried to interpret it as a macro |
1298 | command called \c{eur2500}, which you didn't define.) In this case, |
1299 | it's helpful to use the special \i\c{\\.} command, which is defined |
1300 | to \I{NOP}\I{doing nothing}do nothing at all! But it acts as a |
339cbe09 |
1301 | separator between your macro and the next character: |
672e4626 |
1302 | |
1303 | \c This is likely to cost \eur\.2500 at least. |
1304 | |
1305 | This way, you will see no space between the Euro sign and the number |
1306 | (although, of course, there will be space between \q{EUR} and the |
1307 | number if the Euro sign is not available, because the macro |
1308 | definition specifically asked for it). |