forked from CTeX-org/tex-by-topic-cn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchapter06.tex
836 lines (764 loc) · 31.3 KB
/
chapter06.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
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
% -*- coding: utf-8 -*-
\documentclass{book}
\input{preamble}
\setcounter{chapter}{5}
\begin{document}
%\chapter{Horizontal and Vertical Mode}\label{hvmode}
%\label{chap:hvmode}
\chapter{Horizontal and Vertical Mode}\label{hvmode}
\label{chap:hvmode}
%At any point in its processing \TeX\ is in some \indexterm{mode}.
%There are six modes, divided in three categories:
%\begin{enumerate}
%\item horizontal mode and restricted horizontal mode,
%\item vertical mode and internal vertical mode, and
%\item math mode and display math mode.
%\end{enumerate}
%The math modes will be treated elsewhere (see page~\pageref{math:modes}).
%Here we shall look
%at the horizontal and vertical modes, the kinds of objects
%that can occur in the corresponding lists, and the
%commands that are exclusive for one mode or the other.
At any point in its processing \TeX\ is in some \indexterm{mode}.
There are six modes, divided in three categories:
\begin{enumerate}
\item horizontal mode and restricted horizontal mode,
\item vertical mode and internal vertical mode, and
\item math mode and display math mode.
\end{enumerate}
The math modes will be treated elsewhere (see page~\pageref{math:modes}).
Here we shall look
at the horizontal and vertical modes, the kinds of objects
that can occur in the corresponding lists, and the
commands that are exclusive for one mode or the other.
%\label{cschap:vadjust}\label{cschap:showlists}
%\begin{inventory}
%\item [\cs{ifhmode}]
% Test whether the current mode is (possibly restricted) horizontal mode.
\label{cschap:vadjust}\label{cschap:showlists}
\begin{inventory}
\item [\cs{ifhmode}]
Test whether the current mode is (possibly restricted) horizontal mode.
%\item [\cs{ifvmode}]
% Test whether the current mode is (possibly internal) vertical mode.
\item [\cs{ifvmode}]
Test whether the current mode is (possibly internal) vertical mode.
%\item [\cs{ifinner}]
% Test whether the current mode is an internal mode.
\item [\cs{ifinner}]
Test whether the current mode is an internal mode.
%\item [\cs{vadjust}]
% Specify vertical material for the enclosing vertical list
% while in horizontal mode.
\item [\cs{vadjust}]
Specify vertical material for the enclosing vertical list
while in horizontal mode.
%\item [\cs{showlists}]
% Write to the log file the contents of the partial lists
% currently being built in all modes.
%\end{inventory}
\item [\cs{showlists}]
Write to the log file the contents of the partial lists
currently being built in all modes.
\end{inventory}
%%\point Horizontal and vertical mode
%\section{Horizontal and vertical mode}
%\point Horizontal and vertical mode
\section{Horizontal and vertical mode}
%When not typesetting mathematics, \TeX\ is in horizontal
%or vertical mode, building horizontal or vertical lists
%respectively. Horizontal mode is typically used to
%make lines of text; vertical mode is typically used
%to stack the lines of a paragraph on top of each other.
%Note that
%these modes
%are different from the internal states of \TeX's input processor
%(see page~\pageref{input:states}).
When not typesetting mathematics, \TeX\ is in horizontal
or vertical mode, building horizontal or vertical lists
respectively. Horizontal mode is typically used to
make lines of text; vertical mode is typically used
to stack the lines of a paragraph on top of each other.
Note that
these modes
are different from the internal states of \TeX's input processor
(see page~\pageref{input:states}).
%%\spoint Horizontal mode
%\subsection{Horizontal mode}
%\spoint Horizontal mode
\subsection{Horizontal mode}
%The main activity in \indextermbus{horizontal}{mode} is building lines of text.
%Text on the page and text in a \cs{vbox} or \cs{vtop} is built in
%horizontal mode (this might be called `paragraph mode');
%if the text is in an \cs{hbox} there is only one line
%of text, and the corresponding mode is the restricted
%horizontal mode.
The main activity in \indextermbus{horizontal}{mode} is building lines of text.
Text on the page and text in a \cs{vbox} or \cs{vtop} is built in
horizontal mode (this might be called `paragraph mode');
if the text is in an \cs{hbox} there is only one line
of text, and the corresponding mode is the restricted
horizontal mode.
%In horizontal mode all material is added to a horizontal list.
%If this list is built in unrestricted horizontal mode, it
%will later be broken into lines and added to the surrounding vertical list.
In horizontal mode all material is added to a horizontal list.
If this list is built in unrestricted horizontal mode, it
will later be broken into lines and added to the surrounding vertical list.
%Each element of a \indextermbus{horizontal}{list} is one of the following:
%\begin{itemize} \item a box (a character, ligature, \cs{vrule},
%or a \gr{box}),
%\item a discretionary break,
%\item a whatsit (see Chapter~\ref{io}),
%\item vertical material enclosed in \cs{mark},
%\cs{vadjust}, or \cs{insert},
%\item
%\mdqon
%glue or leaders, a kern, a penalty, or a math-on/""off item.
%\mdqoff
%\end{itemize}
%The items in the last point are all discardable.
%\emph{Discardable items}\index{discardable items}
%are called that, because they disappear in
%a break. Breaking of horizontal
%lists is discussed in Chapter~\ref{line:break}.
Each element of a \indextermbus{horizontal}{list} is one of the following:
\begin{itemize} \item a box (a character, ligature, \cs{vrule},
or a \gr{box}),
\item a discretionary break,
\item a whatsit (see Chapter~\ref{io}),
\item vertical material enclosed in \cs{mark},
\cs{vadjust}, or \cs{insert},
\item
\mdqon
glue or leaders, a kern, a penalty, or a math-on/""off item.
\mdqoff
\end{itemize}
The items in the last point are all discardable.
\emph{Discardable items}\index{discardable items}
are called that, because they disappear in
a break. Breaking of horizontal
lists is discussed in Chapter~\ref{line:break}.
%\subsection{Vertical mode}
\subsection{Vertical mode}
%\emph{Vertical mode}\index{mode!vertical}
%can be used to stack items on top of one another.
%Most of the time, these items are boxes
%containing the lines of paragraphs.
\emph{Vertical mode}\index{mode!vertical}
can be used to stack items on top of one another.
Most of the time, these items are boxes
containing the lines of paragraphs.
%Stacking material can take place inside a
%vertical box, but the
%items that are stacked can also
%appear by themselves on the page. In the latter case
%\TeX\ is in vertical mode; in the former case, inside a
%vertical box, \TeX\ operates in internal vertical mode.
Stacking material can take place inside a
vertical box, but the
items that are stacked can also
appear by themselves on the page. In the latter case
\TeX\ is in vertical mode; in the former case, inside a
vertical box, \TeX\ operates in internal vertical mode.
%In vertical mode all material is added to a vertical list.
%If this list is built in external vertical mode, it
%will later be broken when pages are formed.
In vertical mode all material is added to a vertical list.
If this list is built in external vertical mode, it
will later be broken when pages are formed.
%Each element of a \indextermbus{vertical}{list} is one of the following:
%\begin{itemize}
%\item a box (a horizontal or vertical box or an \cs{hrule}),
%\item a whatsit,
%\item a mark,
%\item glue or leaders, a kern, or a penalty.
%\end{itemize}
%The items in the last point are all discardable.
%Breaking of vertical lists
%is discussed in Chapter~\ref{page:break}.
Each element of a \indextermbus{vertical}{list} is one of the following:
\begin{itemize}
\item a box (a horizontal or vertical box or an \cs{hrule}),
\item a whatsit,
\item a mark,
\item glue or leaders, a kern, or a penalty.
\end{itemize}
The items in the last point are all discardable.
Breaking of vertical lists
is discussed in Chapter~\ref{page:break}.
%There are a few exceptional conditions at the beginning
%of a vertical list: the value of \cs{prevdepth} is set
%to \n{-1000pt}. Furthermore, no \cs{parskip} glue is added
%at the top of an internal vertical list;
%at the top of the main vertical list (the top of the
%`current page') no glue or other discardable items
%are added, and \cs{topskip} glue is added when the
%first box is placed on this list
%(see Chapters \ref{page:shape} and~\ref{page:break}).
There are a few exceptional conditions at the beginning
of a vertical list: the value of \cs{prevdepth} is set
to \n{-1000pt}. Furthermore, no \cs{parskip} glue is added
at the top of an internal vertical list;
at the top of the main vertical list (the top of the
`current page') no glue or other discardable items
are added, and \cs{topskip} glue is added when the
first box is placed on this list
(see Chapters \ref{page:shape} and~\ref{page:break}).
%%\point Horizontal and vertical commands
%\section{Horizontal and vertical commands}
%\point Horizontal and vertical commands
\section{Horizontal and vertical commands}
%Some commands are so intrinsically horizontal or vertical
%in nature that they force \TeX\ to go into that mode, if
%possible. A~command that forces \TeX\ into horizontal mode
%is called a \gr{horizontal command}; similarly a command that
%forces \TeX\ into vertical mode is called a
%\gr{vertical command}.
Some commands are so intrinsically horizontal or vertical
in nature that they force \TeX\ to go into that mode, if
possible. A~command that forces \TeX\ into horizontal mode
is called a \gr{horizontal command}; similarly a command that
forces \TeX\ into vertical mode is called a
\gr{vertical command}.
%However, not all transitions are possible:
%\TeX\ can switch from both vertical modes to
%(unrestricted) horizontal mode and back
%through horizontal and vertical commands, but no transitions
%to or from restricted horizontal mode are possible
%(other than by enclosing horizontal boxes in vertical boxes or
%the other way around).
%A~vertical command in restricted horizontal mode thus gives
%an error; the \cs{par} command in restricted horizontal mode
%has no effect.
However, not all transitions are possible:
\TeX\ can switch from both vertical modes to
(unrestricted) horizontal mode and back
through horizontal and vertical commands, but no transitions
to or from restricted horizontal mode are possible
(other than by enclosing horizontal boxes in vertical boxes or
the other way around).
A~vertical command in restricted horizontal mode thus gives
an error; the \cs{par} command in restricted horizontal mode
has no effect.
%The \indextermbus{horizontal}{commands} are the following:
%\label{h:com:list}
%\begin{itemize}
%\item any \gr{letter}, \gr{otherchar}, \cs{char},
%a control sequence defined by \cs{chardef}, or \cs{noboundary};
%\item \cs{accent}, \cs{discretionary}, the discretionary
%hyphen~\verb|\-| and control space~\verb|\|\n{\char32};
%\item \cs{unhbox} and \cs{unhcopy};
%\item \cs{vrule} and the
%\gr{horizontal skip} commands
%\cs{hskip}, \cs{hfil}, \cs{hfill}, \cs{hss}, and \cs{hfilneg};
%\item \cs{valign};
%\item math shift (\n\$).
%\end{itemize}
The \indextermbus{horizontal}{commands} are the following:
\label{h:com:list}
\begin{itemize}
\item any \gr{letter}, \gr{otherchar}, \cs{char},
a control sequence defined by \cs{chardef}, or \cs{noboundary};
\item \cs{accent}, \cs{discretionary}, the discretionary
hyphen~\verb|\-| and control space~\verb|\|\n{\char32};
\item \cs{unhbox} and \cs{unhcopy};
\item \cs{vrule} and the
\gr{horizontal skip} commands
\cs{hskip}, \cs{hfil}, \cs{hfill}, \cs{hss}, and \cs{hfilneg};
\item \cs{valign};
\item math shift (\n\$).
\end{itemize}
%The \indextermbus{vertical}{commands} are the following:
%\label{v:com:list}
%\begin{itemize}
%\item \cs{unvbox} and \cs{unvcopy};
%\item \cs{hrule} and the \gr{vertical skip} commands
% \cs{vskip}, \cs{vfil}, \cs{vfill}, \cs{vss}, and \cs{vfilneg};
%\item \cs{halign};
%\item \cs{end} and \cs{dump}.
%\end{itemize}
%Note that the vertical commands do not include \cs{par};
%nor are \cs{indent} and \cs{noindent} horizontal commands.
The \indextermbus{vertical}{commands} are the following:
\label{v:com:list}
\begin{itemize}
\item \cs{unvbox} and \cs{unvcopy};
\item \cs{hrule} and the \gr{vertical skip} commands
\cs{vskip}, \cs{vfil}, \cs{vfill}, \cs{vss}, and \cs{vfilneg};
\item \cs{halign};
\item \cs{end} and \cs{dump}.
\end{itemize}
Note that the vertical commands do not include \cs{par};
nor are \cs{indent} and \cs{noindent} horizontal commands.
%The connection between boxes and modes is explored below;
%see Chapter~\ref{rules} for more on the connection between
%rules and modes.
The connection between boxes and modes is explored below;
see Chapter~\ref{rules} for more on the connection between
rules and modes.
%\section{The internal modes}
\section{The internal modes}
%The \indextermbus{restricted horizontal}{mode} and
%\indextermbus{internal vertical}{mode}
%are those variants of horizontal mode and vertical mode
%that hold inside an \cs{hbox} and \cs{vbox} (or \cs{vtop}
%or \cs{vcenter}) respectively.
%However, restricted horizontal mode is rather more
%restricted in nature than internal vertical mode.
%The third internal mode is non-display math mode
%(see Chapter~\ref{math}).
The \indextermbus{restricted horizontal}{mode} and
\indextermbus{internal vertical}{mode}
are those variants of horizontal mode and vertical mode
that hold inside an \cs{hbox} and \cs{vbox} (or \cs{vtop}
or \cs{vcenter}) respectively.
However, restricted horizontal mode is rather more
restricted in nature than internal vertical mode.
The third internal mode is non-display math mode
(see Chapter~\ref{math}).
%%\spoint Restricted horizontal mode
%\subsection{Restricted horizontal mode}
%\spoint Restricted horizontal mode
\subsection{Restricted horizontal mode}
%The main difference between restricted horizontal mode,
%the mode in an \cs{hbox}, and unrestricted horizontal mode,
%the mode in which paragraphs in vertical boxes
%and on the page are built,
%is that you cannot break out of restricted horizontal mode:
%\cs{par}~does nothing in this mode.
%Furthermore, a~\gram{vertical command} in restricted horizontal
%mode gives an error.
%In unrestricted horizontal mode it would cause a
%\cs{par} token to be inserted and vertical mode to be entered
%(see also Chapter~\ref{par:end}).
The main difference between restricted horizontal mode,
the mode in an \cs{hbox}, and unrestricted horizontal mode,
the mode in which paragraphs in vertical boxes
and on the page are built,
is that you cannot break out of restricted horizontal mode:
\cs{par}~does nothing in this mode.
Furthermore, a~\gram{vertical command} in restricted horizontal
mode gives an error.
In unrestricted horizontal mode it would cause a
\cs{par} token to be inserted and vertical mode to be entered
(see also Chapter~\ref{par:end}).
%%\spoint Internal vertical mode
%\subsection{Internal vertical mode}
%\spoint Internal vertical mode
\subsection{Internal vertical mode}
%Internal vertical mode, the vertical mode inside
%a~\cs{vbox}, is a lot like external vertical
%mode, the mode in which pages are built.
%A~\gram{horizontal command} in internal vertical mode,
%for instance, is perfectly valid:
%\TeX\ then starts building a paragraph in
%unrestricted horizontal mode.
Internal vertical mode, the vertical mode inside
a~\cs{vbox}, is a lot like external vertical
mode, the mode in which pages are built.
A~\gram{horizontal command} in internal vertical mode,
for instance, is perfectly valid:
\TeX\ then starts building a paragraph in
unrestricted horizontal mode.
%One difference is that the commands
%\cs{unskip} and \cs{unkern} have no effect
%in external vertical mode, and
%\cs{lastbox} is always empty in external vertical mode.
%See further pages \pageref{lastbox} and~\pageref{unskip}.
One difference is that the commands
\cs{unskip} and \cs{unkern} have no effect
in external vertical mode, and
\cs{lastbox} is always empty in external vertical mode.
See further pages \pageref{lastbox} and~\pageref{unskip}.
%The entries of alignments (see Chapter~\ref{align}) are
%processed in internal modes: restricted horizontal mode
%for the entries of an \cs{halign}, and internal vertical
%mode for the entries of a~\cs{valign}.
%The material in \cs{vadjust} and \cs{insert} items
%is also processed in internal vertical mode; furthermore,
%\TeX\ enters this mode when processing the \cs{output} token list.
The entries of alignments (see Chapter~\ref{align}) are
processed in internal modes: restricted horizontal mode
for the entries of an \cs{halign}, and internal vertical
mode for the entries of a~\cs{valign}.
The material in \cs{vadjust} and \cs{insert} items
is also processed in internal vertical mode; furthermore,
\TeX\ enters this mode when processing the \cs{output} token list.
%The commands \cs{end} and \cs{dump} (the latter exists only in \IniTeX)
%are not allowed in
%internal vertical mode; furthermore, \cs{dump} is not allowed
%inside a group (see Chapter~\ref{TeXcomm}).
The commands \cs{end} and \cs{dump} (the latter exists only in \IniTeX)
are not allowed in
internal vertical mode; furthermore, \cs{dump} is not allowed
inside a group (see Chapter~\ref{TeXcomm}).
%%\point[hvbox] Boxes and modes
%\section{Boxes and modes}
%\label{hvbox}
%\point[hvbox] Boxes and modes
\section{Boxes and modes}
\label{hvbox}
%There are horizontal and vertical boxes, and there is
%horizontal and vertical mode. Not surprisingly, there is
%a connection between the boxes and the modes.
%One can ask about this connection in two ways.
There are horizontal and vertical boxes, and there is
horizontal and vertical mode. Not surprisingly, there is
a connection between the boxes and the modes.
One can ask about this connection in two ways.
%%\spoint What box do you use in what mode?
%\subsection{What box do you use in what mode?}
%\spoint What box do you use in what mode?
\subsection{What box do you use in what mode?}
%This is the wrong question. Both horizontal and vertical boxes
%can be used in both horizontal and vertical mode.
%Their placement is determined by the prevailing mode at that moment.
This is the wrong question. Both horizontal and vertical boxes
can be used in both horizontal and vertical mode.
Their placement is determined by the prevailing mode at that moment.
%%\spoint What mode holds in what box?
%\subsection{What mode holds in what box?}
%\spoint What mode holds in what box?
\subsection{What mode holds in what box?}
%This is the right question.
%When an \cs{hbox} starts, \TeX\ is in restricted horizontal
%mode. Thus everything in a horizontal box is lined up horizontally.
This is the right question.
When an \cs{hbox} starts, \TeX\ is in restricted horizontal
mode. Thus everything in a horizontal box is lined up horizontally.
%When a \cs{vbox} is started, \TeX\ is in internal vertical mode.
%Boxes of both kinds and other items are then stacked
%on top of each other.
When a \cs{vbox} is started, \TeX\ is in internal vertical mode.
Boxes of both kinds and other items are then stacked
on top of each other.
%%\spoint Mode-dependent behaviour of boxes
%\subsection{Mode-dependent behaviour of boxes}
%\spoint Mode-dependent behaviour of boxes
\subsection{Mode-dependent behaviour of boxes}
%Any \gr{box} (see Chapter \ref{boxes} for the full definition)
%can be used in horizontal, vertical, and math mode.
%Unboxing commands, however, are specific for horizontal or vertical mode.
%Both \cs{unhbox} and \cs{unhcopy} are \gr{horizontal command}s,
%so they can make \TeX\ switch from vertical to horizontal
%mode;
%both \cs{unvbox} and \cs{unvcopy} are \gr{vertical command}s,
%so they can make \TeX\ switch from horizontal to vertical
%mode.
Any \gr{box} (see Chapter \ref{boxes} for the full definition)
can be used in horizontal, vertical, and math mode.
Unboxing commands, however, are specific for horizontal or vertical mode.
Both \cs{unhbox} and \cs{unhcopy} are \gr{horizontal command}s,
so they can make \TeX\ switch from vertical to horizontal
mode;
both \cs{unvbox} and \cs{unvcopy} are \gr{vertical command}s,
so they can make \TeX\ switch from horizontal to vertical
mode.
%In horizontal mode the \cs{spacefactor} is set to 1000
%after a box has been placed. In vertical mode the
%\cs{prevdepth} is set to the depth of the box placed.
%Neither statement holds for
%unboxing commands: after an \cs{unhbox} or \cs{unhcopy} the
%spacefactor is not altered, and after \cs{unvbox} or \cs{unvcopy}
%the \cs{prevdepth} remains unchanged.
%After all, these commands do not add a box,
%but a piece of a~(horizontal or vertical) list.
In horizontal mode the \cs{spacefactor} is set to 1000
after a box has been placed. In vertical mode the
\cs{prevdepth} is set to the depth of the box placed.
Neither statement holds for
unboxing commands: after an \cs{unhbox} or \cs{unhcopy} the
spacefactor is not altered, and after \cs{unvbox} or \cs{unvcopy}
the \cs{prevdepth} remains unchanged.
After all, these commands do not add a box,
but a piece of a~(horizontal or vertical) list.
%The operations \cs{raise} and \cs{lower} can only be
%applied to a box in horizontal mode; similarly, \cs{moveleft} and
%\cs{moveright} can only be applied in vertical mode.
The operations \cs{raise} and \cs{lower} can only be
applied to a box in horizontal mode; similarly, \cs{moveleft} and
\cs{moveright} can only be applied in vertical mode.
%%\point Modes and glue
%\section{Modes and glue}
%\point Modes and glue
\section{Modes and glue}
%Both in horizontal and vertical mode
%\TeX\ can insert glue items the size of which is
%determined by the preceding object in the list.
Both in horizontal and vertical mode
\TeX\ can insert glue items the size of which is
determined by the preceding object in the list.
%For horizontal mode the amount of glue that is inserted
%for a space token depends on the \cs{spacefactor} of
%the previous object in the list. This is treated
%in Chapter~\ref{space}.
For horizontal mode the amount of glue that is inserted
for a space token depends on the \cs{spacefactor} of
the previous object in the list. This is treated
in Chapter~\ref{space}.
%In vertical mode \TeX\ inserts glue to keep boxes at a certain
%distance from each other. This glue is influenced by the
%height of the current item and the depth of the previous one.
%The depth of items is recorded in the \cs{prevdepth} parameter
%(see Chapter~\ref{baseline}).
In vertical mode \TeX\ inserts glue to keep boxes at a certain
distance from each other. This glue is influenced by the
height of the current item and the depth of the previous one.
The depth of items is recorded in the \cs{prevdepth} parameter
(see Chapter~\ref{baseline}).
%The two quantities \cs{prevdepth}
%and \cs{spacefactor}
%use the same internal register of \TeX. Thus the \cs{prevdepth}
%can be used or asked only in vertical mode, and the \cs{spacefactor}
%only in horizontal mode.
The two quantities \cs{prevdepth}
and \cs{spacefactor}
use the same internal register of \TeX. Thus the \cs{prevdepth}
can be used or asked only in vertical mode, and the \cs{spacefactor}
only in horizontal mode.
%%\point[migrate] Migrating material
%\section{Migrating material}
%\label{migrate}
%\point[migrate] Migrating material
\section{Migrating material}
\label{migrate}
%The three control sequences \cs{insert}, \cs{mark}, and \cs{vadjust}
%can be given in a paragraph
%(the first two can also occur
%in vertical mode) to specify \indexterm{migrating material}:
%material that will wind up on the
%surrounding vertical list rather than on the current list.
%Note that this need not be
%the main vertical list: it can be a vertical box
%containing a paragraph of text. In this case a \cs{mark}
%or \cs{insert} command will not reach the page breaking algorithm.
The three control sequences \cs{insert}, \cs{mark}, and \cs{vadjust}
can be given in a paragraph
(the first two can also occur
in vertical mode) to specify \indexterm{migrating material}:
material that will wind up on the
surrounding vertical list rather than on the current list.
Note that this need not be
the main vertical list: it can be a vertical box
containing a paragraph of text. In this case a \cs{mark}
or \cs{insert} command will not reach the page breaking algorithm.
%When several migrating items are specified in a certain line
%of text, their left-to-right order is preserved when they are
%placed on the surrounding vertical list. These items are placed
%directly after the horizontal box containing the line of text
%in which they were specified: they come before any
%penalty or glue items that are automatically inserted
%(see page~\pageref{between:lines}).
When several migrating items are specified in a certain line
of text, their left-to-right order is preserved when they are
placed on the surrounding vertical list. These items are placed
directly after the horizontal box containing the line of text
in which they were specified: they come before any
penalty or glue items that are automatically inserted
(see page~\pageref{between:lines}).
%%\spoint \cs{vadjust}
%\subsection{\cs{vadjust}}
%\spoint \cs{vadjust}
\subsection{\cs{vadjust}}
%The command
%\cstoidx vadjust\par
%\begin{disp}\cs{vadjust}\gr{filler}\lb\gr{vertical mode material}\rb\end{disp}
%is only allowed in horizontal and math modes (but it is
%not a \gr{horizontal command}).
%Vertical mode material specified by \cs{vadjust} is moved from
%the horizontal list in which the command is given
%to the surrounding vertical list, directly after the box
%in which it occurred.
The command
\cstoidx vadjust\par
\begin{disp}\cs{vadjust}\gr{filler}\lb\gr{vertical mode material}\rb\end{disp}
is only allowed in horizontal and math modes (but it is
not a \gr{horizontal command}).
Vertical mode material specified by \cs{vadjust} is moved from
the horizontal list in which the command is given
to the surrounding vertical list, directly after the box
in which it occurred.
%In the current line
%\vadjust{\setbox0=\hbox{$\bullet$\hskip1em}\ht0=0pt \dp0=0pt \llap{\box0}}
%a \cs{vadjust} item was placed to put the bullet in the margin.
In the current line
\vadjust{\setbox0=\hbox{$\bullet$\hskip1em}\ht0=0pt \dp0=0pt \llap{\box0}}
a \cs{vadjust} item was placed to put the bullet in the margin.
%Any vertical material in a \cs{vadjust} item is processed
%in internal vertical mode, even though it will wind up
%on the main vertical list. For instance, the \cs{ifinner}
%test is true in a \cs{vadjust}, and at the start
%\mdqon
%of the vertical material \cs{prevdepth}$=$""\n{-1000pt}.
%\mdqoff
Any vertical material in a \cs{vadjust} item is processed
in internal vertical mode, even though it will wind up
on the main vertical list. For instance, the \cs{ifinner}
test is true in a \cs{vadjust}, and at the start
\mdqon
of the vertical material \cs{prevdepth}$=$""\n{-1000pt}.
\mdqoff
%%\point Testing modes
%\section{Testing modes}
%\point Testing modes
\section{Testing modes}
%The three conditionals \cs{ifhmode}, \cs{ifvmode}, and
%\cs{ifinner} can distinguish between the four modes of
%\TeX\ that are not math modes.
%The \cs{ifinner} test is true if \TeX\ is in
%restricted horizontal mode or internal vertical mode
%(or in non-display math mode).
%Exceptional condition: during a \cs{write} \TeX\
%is in a `no mode' state. The tests \cs{ifhmode},
%\cs{ifvmode}, and \cs{ifmmode} are then all false.
The three conditionals \cs{ifhmode}, \cs{ifvmode}, and
\cs{ifinner} can distinguish between the four modes of
\TeX\ that are not math modes.
The \cs{ifinner} test is true if \TeX\ is in
restricted horizontal mode or internal vertical mode
(or in non-display math mode).
Exceptional condition: during a \cs{write} \TeX\
is in a `no mode' state. The tests \cs{ifhmode},
\cs{ifvmode}, and \cs{ifmmode} are then all false.
%Inspection of all current lists, including the `recent
%contributions' (see Chapter~\ref{page:break}),
%is possible through the command \csidx{showlists}\label{showlists}.
%This command writes to the log file the contents of all
%lists that are being built at the moment the command is given.
Inspection of all current lists, including the `recent
contributions' (see Chapter~\ref{page:break}),
is possible through the command \csidx{showlists}\label{showlists}.
This command writes to the log file the contents of all
lists that are being built at the moment the command is given.
%Consider the example
%\begin{verbatim}
%a\hfil\break b\par
%c\hfill\break d
%\hbox{e\vbox{f\showlists
%\end{verbatim}
%Here the first paragraph has been broken into two lines, and
%these have been added to the current page. The second paragraph
%has not been concluded or broken into lines.
Consider the example
\begin{verbatim}
a\hfil\break b\par
c\hfill\break d
\hbox{e\vbox{f\showlists
\end{verbatim}
Here the first paragraph has been broken into two lines, and
these have been added to the current page. The second paragraph
has not been concluded or broken into lines.
%The log file shows the following. \TeX\ was busy
%building a paragraph (starting with an indentation box
%\n{20pt} wide):\begin{verbatim}
%### horizontal mode entered at line 3
%\hbox(0.0+0.0)x20.0
%\tenrm f
%spacefactor 1000
%\end{verbatim}
%This paragraph was inside a vertical box:\begin{verbatim}
%### internal vertical mode entered at line 3
%prevdepth ignored
%\end{verbatim}
%The vertical box was in a horizontal box,
%\begin{verbatim}
%### restricted horizontal mode entered at line 3
%\tenrm e
%spacefactor 1000
%\end{verbatim}
%which was part of
%an as-yet unfinished paragraph:\begin{verbatim}
%### horizontal mode entered at line 2
%\hbox(0.0+0.0)x20.0
%\tenrm c
%\glue 0.0 plus 1.0fill
%\penalty -10000
%\tenrm d
%etc.
%spacefactor 1000
%\end{verbatim}
%Note how the infinite glue and the \cs{break} penalty
%are still part of the horizontal list.
The log file shows the following. \TeX\ was busy
building a paragraph (starting with an indentation box
\n{20pt} wide):\begin{verbatim}
### horizontal mode entered at line 3
\hbox(0.0+0.0)x20.0
\tenrm f
spacefactor 1000
\end{verbatim}
This paragraph was inside a vertical box:\begin{verbatim}
### internal vertical mode entered at line 3
prevdepth ignored
\end{verbatim}
The vertical box was in a horizontal box,
\begin{verbatim}
### restricted horizontal mode entered at line 3
\tenrm e
spacefactor 1000
\end{verbatim}
which was part of
an as-yet unfinished paragraph:\begin{verbatim}
### horizontal mode entered at line 2
\hbox(0.0+0.0)x20.0
\tenrm c
\glue 0.0 plus 1.0fill
\penalty -10000
\tenrm d
etc.
spacefactor 1000
\end{verbatim}
Note how the infinite glue and the \cs{break} penalty
are still part of the horizontal list.
%Finally, the first paragraph has been broken into lines and
%added to the current page:\begin{verbatim}
%### vertical mode entered at line 0
%### current page:
%\glue(\topskip) 5.69446
%\hbox(4.30554+0.0)x469.75499, glue set 444.75497fil
%.\hbox(0.0+0.0)x20.0
%.\tenrm a
%.\glue 0.0 plus 1.0fil
%.\penalty -10000
%.\glue(\rightskip) 0.0
%\penalty 300
%\glue(\baselineskip) 5.05556
%\hbox(6.94444+0.0)x469.75499, glue set 464.19943fil
%.\tenrm b
%.\penalty 10000
%.\glue(\parfillskip) 0.0 plus 1.0fil
%.\glue(\rightskip) 0.0
%etc.
%total height 22.0 plus 1.0
% goal height 643.20255
%prevdepth 0.0
%\end{verbatim}
Finally, the first paragraph has been broken into lines and
added to the current page:\begin{verbatim}
### vertical mode entered at line 0
### current page:
\glue(\topskip) 5.69446
\hbox(4.30554+0.0)x469.75499, glue set 444.75497fil
.\hbox(0.0+0.0)x20.0
.\tenrm a
.\glue 0.0 plus 1.0fil
.\penalty -10000
.\glue(\rightskip) 0.0
\penalty 300
\glue(\baselineskip) 5.05556
\hbox(6.94444+0.0)x469.75499, glue set 464.19943fil
.\tenrm b
.\penalty 10000
.\glue(\parfillskip) 0.0 plus 1.0fil
.\glue(\rightskip) 0.0
etc.
total height 22.0 plus 1.0
goal height 643.20255
prevdepth 0.0
\end{verbatim}
%\endofchapter
%%%%% end of input file [modes]
\endofchapter
%%%% end of input file [modes]
\end{document}