-
Notifications
You must be signed in to change notification settings - Fork 18
/
chapter16.tex
671 lines (621 loc) · 22.8 KB
/
chapter16.tex
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
% -*- coding: utf-8 -*-
\documentclass{book}
\input{preamble}
\setcounter{chapter}{15}
\begin{document}
%\chapter{Paragraph Start}\label{par:start}
%\index{paragraph!start|(}
\chapter{Paragraph Start}\label{par:start}
\index{paragraph!start|(}
%At the start of a paragraph \TeX\ inserts a vertical skip
%as a separation from the preceding paragraph, and a horizontal
%skip as an indentation for the current paragraph.
%This chapter explains the exact sequence
%of actions,
%and it discusses how \TeX's decisions can be altered.
At the start of a paragraph \TeX\ inserts a vertical skip
as a separation from the preceding paragraph, and a horizontal
skip as an indentation for the current paragraph.
This chapter explains the exact sequence
of actions,
and it discusses how \TeX's decisions can be altered.
%\label{cschap:indent}\label{cschap:noindent}\label{cschap:parskip}\label{cschap:parindent}\label{cschap:everypar}\label{cschap:leavevmode}
%\begin{inventory}
%\item [\cs{indent}]
% Switch to horizontal mode and insert a box of width \cs{parindent}.
\label{cschap:indent}\label{cschap:noindent}\label{cschap:parskip}\label{cschap:parindent}\label{cschap:everypar}\label{cschap:leavevmode}
\begin{inventory}
\item [\cs{indent}]
Switch to horizontal mode and insert a box of width \cs{parindent}.
%\item [\cs{noindent}]
% Switch to horizontal mode with an empty horizontal list.
\item [\cs{noindent}]
Switch to horizontal mode with an empty horizontal list.
%\item [\cs{parskip}]
% Amount of glue added to
% the surrounding vertical list when a paragraph starts.
% Plain \TeX\ default:~\n{0pt plus 1pt}.
\item [\cs{parskip}]
Amount of glue added to
the surrounding vertical list when a paragraph starts.
Plain \TeX\ default:~\n{0pt plus 1pt}.
%\item [\cs{parindent}]
% Size of the indentation box added in front of a paragraph.
% Plain \TeX\ default:~\n{20pt}.
\item [\cs{parindent}]
Size of the indentation box added in front of a paragraph.
Plain \TeX\ default:~\n{20pt}.
%\item [\cs{everypar}]
% Token list inserted in front of paragraph text;
\item [\cs{everypar}]
Token list inserted in front of paragraph text;
%\item [\cs{leavevmode}]
% Macro to switch to horizontal mode if necessary.
\item [\cs{leavevmode}]
Macro to switch to horizontal mode if necessary.
%\end{inventory}
\end{inventory}
%%\point When does a paragraph start
%\section{When does a paragraph start}
%\point When does a paragraph start
\section{When does a paragraph start}
%\TeX\ starts a paragraph whenever it switches from
%vertical mode to (unrestricted) horizontal mode. This switch can
%be effected by one of the commands
%\cs{indent} and
%\cs{noindent}, for example
%\begin{verbatim}
%{\bf And now~\dots}
%\vskip3pt
%\noindent It's~\dots
%\end{verbatim}
%or by any \gram{horizontal command}.
%Horizontal commands include characters, in-line formulas,
%and horizontal skips, but not boxes.
%Consider the following examples.
%\alt
%The character `I' is a horizontal command:
%\begin{verbatim}
%\vskip3pt
%It's~\dots
%\end{verbatim}
%A single \n\$ is a horizontal command:
%\begin{verbatim}
%$x$ is supposed~\dots
%\end{verbatim}
%The control sequence \cs{hskip} is a horizontal command:
%\begin{verbatim}
%\hskip .5\hsize Long indentation~\dots
%\end{verbatim}
%The full list of horizontal commands is given on
%page~\pageref{h:com:list}.
\TeX\ starts a paragraph whenever it switches from
vertical mode to (unrestricted) horizontal mode. This switch can
be effected by one of the commands
\cs{indent} and
\cs{noindent}, for example
\begin{verbatim}
{\bf And now~\dots}
\vskip3pt
\noindent It's~\dots
\end{verbatim}
or by any \gram{horizontal command}.
Horizontal commands include characters, in-line formulas,
and horizontal skips, but not boxes.
Consider the following examples.
\alt
The character `I' is a horizontal command:
\begin{verbatim}
\vskip3pt
It's~\dots
\end{verbatim}
A single \n\$ is a horizontal command:
\begin{verbatim}
$x$ is supposed~\dots
\end{verbatim}
The control sequence \cs{hskip} is a horizontal command:
\begin{verbatim}
\hskip .5\hsize Long indentation~\dots
\end{verbatim}
The full list of horizontal commands is given on
page~\pageref{h:com:list}.
%Upon recognizing a horizontal command in vertical mode,
%\TeX\ will perform an \cs{indent} command (and all the actions
%associated with it; see below),
%and after that it will reexamine the horizontal command,
%this time executing it.
Upon recognizing a horizontal command in vertical mode,
\TeX\ will perform an \cs{indent} command (and all the actions
associated with it; see below),
and after that it will reexamine the horizontal command,
this time executing it.
%%\point What happens when a paragraph starts
%\section{What happens when a paragraph starts}
%\point What happens when a paragraph starts
\section{What happens when a paragraph starts}
%The \csidx{indent} and \csidx{noindent} commands
%cause a paragraph to be started.
%An~\cs{indent} command can either be placed explicitly by
%the user or a macro, or it can be inserted by \TeX\ when
%a \gr{horizontal command} occurs in vertical mode;
%a~\cs{noindent} command can only be placed explicitly.
The \csidx{indent} and \csidx{noindent} commands
cause a paragraph to be started.
An~\cs{indent} command can either be placed explicitly by
the user or a macro, or it can be inserted by \TeX\ when
a \gr{horizontal command} occurs in vertical mode;
a~\cs{noindent} command can only be placed explicitly.
%After either command is encountered,
%\csidx{parskip} glue is appended to the surrounding vertical
%list
%unless \TeX\ is in internal vertical mode
%and that list is empty
%(for example, at the start of a \cs{vbox} or \cs{vtop}).
%\TeX\ then switches to unrestricted horizontal mode
%with an empty horizontal list.
%In the case of \cs{indent} (which may be inserted
%implicitly) an empty \cs{hbox} of width
%\cstoidx parindent\par
%\cs{parindent} is placed at the start of the horizontal list;
%after \cs{noindent} no indentation
%box is inserted.
After either command is encountered,
\csidx{parskip} glue is appended to the surrounding vertical
list
unless \TeX\ is in internal vertical mode
and that list is empty
(for example, at the start of a \cs{vbox} or \cs{vtop}).
\TeX\ then switches to unrestricted horizontal mode
with an empty horizontal list.
In the case of \cs{indent} (which may be inserted
implicitly) an empty \cs{hbox} of width
\cstoidx parindent\par
\cs{parindent} is placed at the start of the horizontal list;
after \cs{noindent} no indentation
box is inserted.
%The contents of the \csidx{everypar} \gr{token parameter}
%are then inserted into the input (see some applications below).
%After that,
%the page builder is exercised (see Chapter~\ref{page:break}).
%Note that this happens in horizontal mode: this is to
%move the \cs{parskip} glue to the current page.
The contents of the \csidx{everypar} \gr{token parameter}
are then inserted into the input (see some applications below).
After that,
the page builder is exercised (see Chapter~\ref{page:break}).
Note that this happens in horizontal mode: this is to
move the \cs{parskip} glue to the current page.
%If an \cs{indent} command is given while \TeX\ is already in
%horizontal mode, the indentation box is inserted just the same.
%This is not very useful.
If an \cs{indent} command is given while \TeX\ is already in
horizontal mode, the indentation box is inserted just the same.
This is not very useful.
%%\point Assorted remarks
%\section{Assorted remarks}
%\point Assorted remarks
\section{Assorted remarks}
%%\spoint Starting a paragraph with a box
%\subsection{Starting a paragraph with a box}
%\spoint Starting a paragraph with a box
\subsection{Starting a paragraph with a box}
%An \cs{hbox} does not imply horizontal mode, so
%an attempt to start a paragraph with a box, for instance
%\begin{verbatim}
%\hbox to 0cm{\hss$\bullet$\hskip1em}Text ....
%\end{verbatim}
%will make the text following the box
%wind up one line below the box.
%It is necessary to switch to horizontal mode
%explicitly, using for instance \cs{noindent} or
%\cs{leavevmode}.
%The latter is defined using \cs{unhbox},
%which is a horizontal command.
An \cs{hbox} does not imply horizontal mode, so
an attempt to start a paragraph with a box, for instance
\begin{verbatim}
\hbox to 0cm{\hss$\bullet$\hskip1em}Text ....
\end{verbatim}
will make the text following the box
wind up one line below the box.
It is necessary to switch to horizontal mode
explicitly, using for instance \cs{noindent} or
\cs{leavevmode}.
The latter is defined using \cs{unhbox},
which is a horizontal command.
%%\spoint Starting a paragraph with a group
%\subsection{Starting a paragraph with a group}
%\spoint Starting a paragraph with a group
\subsection{Starting a paragraph with a group}
%If the first \gram{horizontal command} of a paragraph
%is enclosed in braces, the \cs{everypar} is evaluated
%inside the group. This may give unexpected results.
%Consider this example:
%\begin{verbatim}
%\everypar={\setbox0=\vbox\bgroup\def\par{\egroup}}
%{\bf Start} a paragraph ... \par
%\end{verbatim}
%The \gr{horizontal command} starting the paragraph is the
%character~`S', so when \cs{everypar} has been inserted
%the input is essentially
%\begin{verbatim}
%{\bf \indent\setbox0=\vbox\bgroup
% \def\par{\egroup}Start} a paragraph ... \par
%\end{verbatim}
%which is equivalent to
%\begin{verbatim}
%{\bf \setbox0=\vbox{Start} a paragraph ... \par
%\end{verbatim}
%The effect of this is rather different from what was intended.
%\alt
%Also, \TeX\ will probably end the job inside a group.
If the first \gram{horizontal command} of a paragraph
is enclosed in braces, the \cs{everypar} is evaluated
inside the group. This may give unexpected results.
Consider this example:
\begin{verbatim}
\everypar={\setbox0=\vbox\bgroup\def\par{\egroup}}
{\bf Start} a paragraph ... \par
\end{verbatim}
The \gr{horizontal command} starting the paragraph is the
character~`S', so when \cs{everypar} has been inserted
the input is essentially
\begin{verbatim}
{\bf \indent\setbox0=\vbox\bgroup
\def\par{\egroup}Start} a paragraph ... \par
\end{verbatim}
which is equivalent to
\begin{verbatim}
{\bf \setbox0=\vbox{Start} a paragraph ... \par
\end{verbatim}
The effect of this is rather different from what was intended.
\alt
Also, \TeX\ will probably end the job inside a group.
%%\point Examples
%\section{Examples}
%\point Examples
\section{Examples}
%%\spoint Stretchable indentation
%\subsection{Stretchable indentation }
%\spoint Stretchable indentation
\subsection{Stretchable indentation }
%Considering that \cs{parindent} is a \gram{dimen}, not a \gram{glue},
%it is not possible to declare
%\begin{verbatim}
%\parindent=1cm plus 1fil
%\end{verbatim}
%in order to get
%a variable indentation at the start of a paragraph.
%This problem may be solved by putting
%\begin{verbatim}
%\everypar={\nobreak\hskip 1cm plus 1fil\relax}
%\end{verbatim}
%The \cs{nobreak} serves to prevent (in rare cases) a line break
%at the stretchable glue.
Considering that \cs{parindent} is a \gram{dimen}, not a \gram{glue},
it is not possible to declare
\begin{verbatim}
\parindent=1cm plus 1fil
\end{verbatim}
in order to get
a variable indentation at the start of a paragraph.
This problem may be solved by putting
\begin{verbatim}
\everypar={\nobreak\hskip 1cm plus 1fil\relax}
\end{verbatim}
The \cs{nobreak} serves to prevent (in rare cases) a line break
at the stretchable glue.
%%\spoint Suppressing indentation
%\subsection{Suppressing indentation}
%\spoint Suppressing indentation
\subsection{Suppressing indentation}
%Inserting
%\verb.{\setbox0=\lastbox}. in the horizontal list
%at the beginning of the paragraph
%removes the indentation:
%indentation consists of a box, which is available through
%\cs{lastbox}. Assigning it effectively removes it from the list.
Inserting
\verb.{\setbox0=\lastbox}. in the horizontal list
at the beginning of the paragraph
removes the indentation:
indentation consists of a box, which is available through
\cs{lastbox}. Assigning it effectively removes it from the list.
%However, this command sequence
%has to be inserted at a moment when \TeX\ has
%already switched to horizontal mode, so explicit insertion
%of these commands in front of the first \gram{horizontal
%command} of the paragraph does not work.
%The moment of insertion of the \cs{everypar} tokens
%is a better candidate: specifying
%\begin{verbatim}
%\everypar={{\setbox0=\lastbox}}
%\end{verbatim}
%leads to unindented paragraphs, even if \cs{parindent} is
%not zero.
However, this command sequence
has to be inserted at a moment when \TeX\ has
already switched to horizontal mode, so explicit insertion
of these commands in front of the first \gram{horizontal
command} of the paragraph does not work.
The moment of insertion of the \cs{everypar} tokens
is a better candidate: specifying
\begin{verbatim}
\everypar={{\setbox0=\lastbox}}
\end{verbatim}
leads to unindented paragraphs, even if \cs{parindent} is
not zero.
%%\spoint[indent:scheme] An indentation scheme
%\subsection{An indentation scheme}
%\label{indent:scheme}
%\spoint[indent:scheme] An indentation scheme
\subsection{An indentation scheme}
\label{indent:scheme}
%The above idea of letting the indentation box be removed
%\howto Control indentation systematically\par
%by \cs{everypar} can be put to use in a systematic approach
%to indentation, where two conditionals
%\begin{verbatim}
%\newif\ifNeedIndent %as a rule
%\newif\ifneedindent %special cases
%\end{verbatim}
%control whether paragraphs should indent as a rule, and
%whether in special cases indentation is needed.
%This section is taken from~\cite{E3}.
The above idea of letting the indentation box be removed
\howto Control indentation systematically\par
by \cs{everypar} can be put to use in a systematic approach
to indentation, where two conditionals
\begin{verbatim}
\newif\ifNeedIndent %as a rule
\newif\ifneedindent %special cases
\end{verbatim}
control whether paragraphs should indent as a rule, and
whether in special cases indentation is needed.
This section is taken from~\cite{E3}.
%We take a fixed \cs{everypar}:
%\begin{verbatim}
%\everypar={\ControlledIndentation}
%\end{verbatim}
%which executes in some cases the macro \cs{RemoveIndentation}
%\begin{verbatim}
%\def\RemoveIndentation{{\setbox0=\lastbox}}
%\end{verbatim}
%The implementation of \cs{ControlledIndentation} is:
%\begin{verbatim}
%\def\ControlledIndentation
% {\ifNeedIndent \ifneedindent
% \else \RemoveIndentation\needindenttrue \fi
% \else \ifneedindent \needindentfalse
% \else \RemoveIndentation
% \fi \fi}
%\end{verbatim}
%In order to regulate indentation for a whole document,
%the user now once specifies, for instance,
%\begin{verbatim}
%\NeedIndenttrue
%\end{verbatim}
%to indicate that, in principle,
%all paragraphs should indent.
%Macros such as \cs{section} can then prevent
%indentation in individual cases:
%\begin{verbatim}
%\def\section#1{ ... \needindentfalse}
%\end{verbatim}
%
We take a fixed \cs{everypar}:
\begin{verbatim}
\everypar={\ControlledIndentation}
\end{verbatim}
which executes in some cases the macro \cs{RemoveIndentation}
\begin{verbatim}
\def\RemoveIndentation{{\setbox0=\lastbox}}
\end{verbatim}
The implementation of \cs{ControlledIndentation} is:
\begin{verbatim}
\def\ControlledIndentation
{\ifNeedIndent \ifneedindent
\else \RemoveIndentation\needindenttrue \fi
\else \ifneedindent \needindentfalse
\else \RemoveIndentation
\fi \fi}
\end{verbatim}
In order to regulate indentation for a whole document,
the user now once specifies, for instance,
\begin{verbatim}
\NeedIndenttrue
\end{verbatim}
to indicate that, in principle,
all paragraphs should indent.
Macros such as \cs{section} can then prevent
indentation in individual cases:
\begin{verbatim}
\def\section#1{ ... \needindentfalse}
\end{verbatim}
%%\spoint[skip:scheme] A paragraph skip scheme
%\subsection{A paragraph skip scheme}
%\label{skip:scheme}
%\spoint[skip:scheme] A paragraph skip scheme
\subsection{A paragraph skip scheme}
\label{skip:scheme}
%The use of \cs{everypar} to control indentation,
%\howto Control vertical white space systematically\par
%as was sketched above, can be extended to the
%paragraph skip.
The use of \cs{everypar} to control indentation,
\howto Control vertical white space systematically\par
as was sketched above, can be extended to the
paragraph skip.
%A visible white space between paragraphs can be
%created by the \cs{parskip} parameter, but, once this
%parameter has been set to some value, it is difficult
%to prevent paragraph skip in certain places elegantly.
%Usually, white space above and below environments
%and section headings should be specifiable independently
%of the paragraph skip. This section sketches an
%approach where \cs{parskip} is set to zero directly
%above and below certain constructs, while the \cs{everypar}
%is used to restore former values. This section is
%taken from~\cite{E4}.
A visible white space between paragraphs can be
created by the \cs{parskip} parameter, but, once this
parameter has been set to some value, it is difficult
to prevent paragraph skip in certain places elegantly.
Usually, white space above and below environments
and section headings should be specifiable independently
of the paragraph skip. This section sketches an
approach where \cs{parskip} is set to zero directly
above and below certain constructs, while the \cs{everypar}
is used to restore former values. This section is
taken from~\cite{E4}.
%First of all, here are two tools. The control sequence
%\cs{csarg} will be used only inside other macros;
%a typical call will look like
%\begin{verbatim}
%\csarg\vskip{#1Parskip}
%\end{verbatim}
%Here is the definition:
%\begin{verbatim}
%\def\csarg#1#2{\expandafter#1\csname#2\endcsname}
%\end{verbatim}
%Next follows a generalization of \cs{vskip}: the macro
%\cs{vspace} will not place its argument if the previous glue item
%is larger; otherwise it will eliminate the preceding
%glue, and place its argument.\begin{verbatim}
%\newskip\tempskipa
%\def\vspace#1{\tempskipa=#1\relax
% \ifvmode \ifdim\tempskipa<\lastskip
% \else \vskip-\lastskip \vskip\tempskipa \fi
% \else \vskip\tempskipa \fi}
%\end{verbatim}
%
%Now assume that any construct \n{foo}
%with surrounding white space
%starts and ends with macro calls \verb>\StartEnvironment{foo}> and
%\verb>\EndEnvironment{foo}> respectively.
%Furthermore, assume that to this environment there correspond
%three glue registers:
%the \cs{fooStartskip} (glue
%above the environment), \cs{fooParskip} (the paragraph skip
%inside the environment), and the \cs{fooEndskip} (glue below
%the environment).
First of all, here are two tools. The control sequence
\cs{csarg} will be used only inside other macros;
a typical call will look like
\begin{verbatim}
\csarg\vskip{#1Parskip}
\end{verbatim}
Here is the definition:
\begin{verbatim}
\def\csarg#1#2{\expandafter#1\csname#2\endcsname}
\end{verbatim}
Next follows a generalization of \cs{vskip}: the macro
\cs{vspace} will not place its argument if the previous glue item
is larger; otherwise it will eliminate the preceding
glue, and place its argument.\begin{verbatim}
\newskip\tempskipa
\def\vspace#1{\tempskipa=#1\relax
\ifvmode \ifdim\tempskipa<\lastskip
\else \vskip-\lastskip \vskip\tempskipa \fi
\else \vskip\tempskipa \fi}
\end{verbatim}
Now assume that any construct \n{foo}
with surrounding white space
starts and ends with macro calls \verb>\StartEnvironment{foo}> and
\verb>\EndEnvironment{foo}> respectively.
Furthermore, assume that to this environment there correspond
three glue registers:
the \cs{fooStartskip} (glue
above the environment), \cs{fooParskip} (the paragraph skip
inside the environment), and the \cs{fooEndskip} (glue below
the environment).
%For restoring the value of the paragraph skip
%a conditional and a glue register are needed:
%\begin{verbatim}
%\newskip\TempParskip \newif\ifParskipNeedsRestoring
%\end{verbatim}
%The basic sequence for the
%starting and ending macros for the environments is then
%\begin{verbatim}
%\TempParskip=\parskip\parskip=0cm\relax
%\ParskipNeedsRestoringtrue
%\end{verbatim}
For restoring the value of the paragraph skip
a conditional and a glue register are needed:
\begin{verbatim}
\newskip\TempParskip \newif\ifParskipNeedsRestoring
\end{verbatim}
The basic sequence for the
starting and ending macros for the environments is then
\begin{verbatim}
\TempParskip=\parskip\parskip=0cm\relax
\ParskipNeedsRestoringtrue
\end{verbatim}
%The implementations can now be given as:
%\begin{verbatim}
%\def\StartEnvironment#1{\csarg\vspace{#1Startskip}
%
%\begingroup % make changes local
% \csarg\TempParskip{#1Parskip} \parskip=0cm\relax
% \ParskipNeedsRestoringtrue}
%\def\EndEnvironment#1{\csarg\vspace{#1Endskip}
% \endgroup % restore global values
% \ifParskipNeedsRestoring
% \else \TempParskip=\parskip \parskip=0cm\relax
% \ParskipNeedsRestoringtrue
% \fi}
%\end{verbatim}
%The \cs{EndEnvironment} macro needs a little comment:
%if an environment is used inside another one, and
%it occurs before the first paragraph in that environment,
%the value of the paragraph skip for the outer environment
%has already been saved. Therefore no further actions are
%required in that case.
The implementations can now be given as:
\begin{verbatim}
\def\StartEnvironment#1{\csarg\vspace{#1Startskip}
\begingroup % make changes local
\csarg\TempParskip{#1Parskip} \parskip=0cm\relax
\ParskipNeedsRestoringtrue}
\def\EndEnvironment#1{\csarg\vspace{#1Endskip}
\endgroup % restore global values
\ifParskipNeedsRestoring
\else \TempParskip=\parskip \parskip=0cm\relax
\ParskipNeedsRestoringtrue
\fi}
\end{verbatim}
The \cs{EndEnvironment} macro needs a little comment:
if an environment is used inside another one, and
it occurs before the first paragraph in that environment,
the value of the paragraph skip for the outer environment
has already been saved. Therefore no further actions are
required in that case.
%Note that both macros start with a vertical skip. This prevents
%the \cs{begingroup} and \cs{endgroup} statements from
%occurring in a paragraph.
Note that both macros start with a vertical skip. This prevents
the \cs{begingroup} and \cs{endgroup} statements from
occurring in a paragraph.
%We now come to the main point: if necessary, the
%\cs{everypar} will restore the value of the paragraph skip.
%\begin{verbatim}
%\everypar={\ControlledIndentation\ControlledParskip}
%\def\ControlledParskip
% {\ifParskipNeedsRestoring
% \parskip=\TempParskip \ParskipNeedsRestoringfalse
% \fi}
%\end{verbatim}
We now come to the main point: if necessary, the
\cs{everypar} will restore the value of the paragraph skip.
\begin{verbatim}
\everypar={\ControlledIndentation\ControlledParskip}
\def\ControlledParskip
{\ifParskipNeedsRestoring
\parskip=\TempParskip \ParskipNeedsRestoringfalse
\fi}
\end{verbatim}
%\index{paragraph!start|)}
%\endofchapter
\index{paragraph!start|)}
\endofchapter
\end{document}