-
Notifications
You must be signed in to change notification settings - Fork 8
/
tips.tex
1686 lines (1514 loc) · 71 KB
/
tips.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
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
% -*- coding: utf-8 -*-
% This is part of the book TeX for the Impatient.
% Copyright (C) 2003, 2014 Paul W. Abrahams, Kathryn A. Hargreaves, Karl Berry.
% See file fdl.tex for copying conditions.
% 中文翻译 by Zhaopeng Xing ([email protected])
\input macros
%\chapter{Tips and techniques}
\chapter{建议和技巧}
\chapterdef{tips}
% \TeX\ is a complex program that occasionally works its will in
% mysterious ways. In this section we offer some tips on solving
% problems that you might encounter and explain some handy techniques.
\TeX{} 是一个复杂的程序,偶尔地会以你看不懂的方式变得不听话。这一章,
我们提供一些解决问题的小贴士并阐释一些有用的技巧。
%\section Correcting bad page breaks
\section 纠正不良分页
% \bix^^{page breaks//bad}
% Sometimes \TeX\ breaks a page right in the middle of material that you
% want to keep together---for example,
% a section heading and the text that follows it,
% or a short list of related items. There are two ways to correct the
% situation:
% \ulist\compact
% \li You can force the material to be kept together.
% \li You can force a page break at a different place.
% \endulist
\bix^^{分页//不良分页}
有时,\TeX{} 在你想要放在一起的素材中间分页——例如,章节标题和随后的文
本,或者一个互有联系的项目列表。有两种校正方法:
\ulist\compact
\li 强制素材被放在一起。
\li 在别的地方要求分页。
\endulist
% The simplest way to force \TeX\ to keep material together on a page is
% to enclose the material in a vbox using the |\vbox| command \ctsref{\vbox}.
% ^^|\vbox//fixing page breaks with|
% A vbox is ordinarily better than an hbox for this purpose because most
% often the material to be kept together,
% e.g., a sequence of paragraphs, will be vertical mode material.
% You should
% precede and follow the vbox by an implicit or explicit paragraph command
% (either a blank line or |\par|); otherwise
% \TeX\ may try to make the vbox part of an an adjacent paragraph.
% The vbox method has an important limitation:
% you can't apply it to portions of text smaller than a paragraph.
要强制 \TeX{} 把素材放在同一页上,最简单的办法是
使用 |\vbox| 命令\ctsref{\vbox}来使素材被封装在一个竖直盒子里。
^^|\vbox//用它修正分页|
这里使用竖直盒子比水平盒子要好,因为大多数情况下,
需要放在一起的是竖直模式素材,比如连续的段落。
竖直盒子的前后,你都要放一个隐含或明显的分段命令(或者空行,或者 |\par|);
否则的话,\TeX{} 会试图使竖直盒子成为相邻段落的一部分。
竖直盒子的方法有一个重要的局限:不能用于不足一个段落的小部分文本。
% You can sometimes keep the lines of a single paragraph together by enclosing
% the paragraph in a group and assigning |\interlinepenalty|
% \ctsref{\interlinepenalty}
% a value of $10000$ at the start of the group (or elsewhere before the
% end of the paragraph).
% This method causes \TeX\ to consider page breaks within that paragraph to be
% infinitely undesirable.
% However, if all the page breaks that \TeX\ can find are infinitely undesirable,
% it may break the page within the paragraph anyway.
有时候,要把一个自然段的各行放置在一起,你可以把它封装在一个编组中,并
在编组开始的地方(或者段落结束前的其它位置)令 |\interlinepenalty|%
\ctsref{\interlinepenalty}的值为 $10000$。这样就告诉了 \TeX{},“绝对不
能”在段内分页。但是,如果 \TeX{} 发现所有要分页的地方都是“绝对不能”的,
它可能不管三七二十一,就在自然段里分页。
% A ^|\nobreak| command (\xref{vnobreak})
% after the end of a paragraph prevents \TeX\
% from breaking the page at the following item
% (unless that item happens to be a penalty of less than $10000$).
% This is also the best way to prevent a page break after a heading,
% since a heading usually behaves like a paragraph.
% The |\nobreak| must follow the blank line or |\par| that ends
% the paragraph so that \TeX\ won't treat the |\nobreak| as part of the
% paragraph.
% For the |\nobreak| to be effective, it must also come before
% any legal breakpoint at the end of the paragraph.
% The glue that \TeX\ inserts
% before the next paragraph is such a breakpoint,
% and so is any vertical glue that you insert explicitly after a paragraph.
% Thus the |\nobreak| should usually be
% the very first thing after the end of the paragraph or heading.
在段落之后使用 ^|\nobreak| 命令 (\xref{vnobreak}) 会阻止 \TeX{} 在下一
项内容之前分页(除非下一项恰好是一个小于 $10000$ 的 惩罚项)。这也是防
止在章节标题之后分页的最佳方案,因为章节标题通常类似于一个自然段落。
|\nobreak| 需要放在段落结束的空行或者 |\par| 之后,从而避免 \TeX{} 将
|\nobreak| 作为段落的一部分处理。 |\nobreak| 还需要出现在段落末尾所有
适合分页的断点之前才有效。\TeX{} 插入在下一个段落之前的粘连就是这样的
一个断点,其他的还有你明确插入在段落后面的任何竖直粘连。 因
此,|\nobreak| 通常出现在段落或者标题结束之后的第一个位置。
% You can use the ^|\eject| command \ctsref{\eject}
% to force \TeX\ to break a page at a
% particular place. Within a paragraph, you can use the combination
% `|\vadjust{\vfill\eject}|'
% \ctsref{\vadjust}
% ^^|\vadjust|
% to force a break after the next complete output line.
% The reason for preceding |\eject| by ^|\vfill|
% \ctsref{\vfill} is to
% get \TeX\ to fill out the page with blank space.
% However, using |\eject| to fix page break problems
% has a major disadvantage:
% if the page boundaries in your document change,
% the page breaks that you've inserted may no longer be where you want them.
你可以使用 ^|\eject| 命令\ctsref{\eject},强制 \TeX{} 在特定的地方分
页。在段落内部,你可以使用一个组合:`|\vadjust{\vfill\eject}|'
\ctsref{\vadjust}
^^|\vadjust|
在下一行之后强制断开。|\eject| 之前 ^|\vfill|
\ctsref{\vfill} 的作用是让 \TeX{} 使用空白来填充页面。但是,使用
|\eject| 来纠正分页问题的主要缺点在于:如果文档的页边距改变,分页的地
方可能未必就如你所愿那样。
% If you don't provide \TeX\ with a |\vfill| command to fill out the page
% before an |\eject|,
% \TeX\ redistributes the extra blank space as best it can and then usually
% complains that ``an
% underfull |\vbox| (badness $10000$) has occurred while |\output| is active.''
% You may encounter a similar problem with
% any of the methods mentioned above for enclosing
% material that you want to keep together.
如果你没有在 |\eject| 之前使用 |\vfill| 命令,
\TeX{} 将尽其所能地重新分配额外的空白间距,然后
发牢骚:“an underfull |\vbox| (badness $10000$) has occurred while |\output| is
active.”上面讲的封装素材在一起的任一方法中,类似的问题也会出现。
% The ^|\filbreak| command \ctsref\filbreak{}
% \xrdef{filbreak}
% provides a way of keeping the lines of one or more paragraphs
% (or other vertical mode material) together on
% a page. If you enclose a paragraph in |\filbreak|s, \TeX\ will effectively
% ignore the |\filbreak|s if the paragraph fits on the current page and
% break the page before the first |\filbreak| if the paragraph doesn't fit.
% If you put |\filbreak|s around each paragraph in a sequence of paragraphs,
% like this:
% {\obeylines\display{
% {\tt \\filbreak}
% \<paragraph>
% {\tt \\filbreak}
% \<paragraph>
% {\tt \\filbreak}
% \leavevmode\indent\vdots
% \<paragraph>
% {\tt \\filbreak}
% }}
% \vfil\eject
% \noindent
% \TeX\ will keep the lines of each paragraph together on a page.
% If \TeX{} breaks a page at a |\filbreak|, it will fill the bottom of the
% page with blank space.
^|\filbreak| 命令 \ctsref\filbreak{}
\xrdef{filbreak}
提供了一种方式来把一个自然段或几个段落(或者其他竖直模式素材)放在同一
页面上。当你用 |\filbreak| 来封闭一个自然段的时候,如果段落内容可以放
置在一页, \TeX{} 会有效地忽略那些 |\filbreak|;如果不是,\TeX{} 将在
第一个 |\filbreak| 之前分页。如果在连续段落中,每个自然段前后都有
|\filbreak|,比如这样:
{\obeylines\display{
{\tt \\filbreak}
\<paragraph>
{\tt \\filbreak}
\<paragraph>
{\tt \\filbreak}
\leavevmode\indent\vdots
\<paragraph>
{\tt \\filbreak}
}}
\vfil\eject
\noindent
\TeX{} 将使每一段都是同页。如果在 |\filbreak| 处分页, \TeX{} 将用空白
填充页面底部。
% Sometimes you can get \TeX\ to modify the length of a page by changing
% the ^|\looseness| parameter \ctsref\looseness{} for one or more paragraphs.
% Setting |\looseness| negative within a paragraph causes \TeX\ to try to squeeze
% the paragraph into fewer lines; setting it positive causes \TeX\ to try to
% expand the paragraph into more lines. The disadvantage of changing |\looseness|
% is that the interword spacing in the affected region won't be optimal.
% You can get further information about \TeX's attempted line breaks by
% setting |\tracingpages| (\xref\tracingpages) to $1$.
有时,你可以改变一个或几个段落的 ^|\looseness| 参数\ctsref{\looseness}%
以修改页面的长度。设置 |\looseness| 为负会让 \TeX{} 试图缩减段落的行数;
为正则增加其行数。改变 |\looseness| 的缺点在于:受影响区域的单词间距不是最佳的。
要了解更多的断行信息,可以设置 |\tracingpages|(\xref\tracingpages )为 $1$。
% \section Preserving the end of a page
\section 保留页尾
% Sometimes you need to modify something on a single page and you want to avoid
% reprinting the entire document. If your modification doesn't
% change the page length too much, there's hope. You need to fix the end
% of the page so that it falls in the same place;
% the methods are similar to the ones for fixing a bad page break.
有时你需要在单个页面上修改某些地方但是又不想重排全部文档。如果页面长度
没有因为修改而改变很多,那就可以实现。你要做的是固定页面的尾部不
变,所需的办法跟纠正不良分页那里一样。
% If the original end of page came between paragraphs, you can
% force a page break at the same place
% using any of the methods we've described above. Otherwise,
% you must force \emph{both} a line break and a page break at a particular
% place. If the new page is shorter than the old one, the sequence:
% \csdisplay
% \vadjust{\vfill\eject}\break
% |
% ^^|\vadjust|
% should do the trick.
% But if the new page is longer,
% the problem is far more difficult because \TeX\ has probably already
% squeezed the page as tightly as it can. Your only hopes in this case are
% to set ^|\looseness| \ctsref\looseness{} to a negative value,
% to shorten some of the vertical skips on the page, to add some shrink to
% ^|\parskip| (\xref\parskip) if it was nonzero, or, as a last resort,
% to decrease |\baselineskip| \ctsref{\baselineskip} ever so slightly.
% ^^|\baselineskip//and preserving end of page|
如果原来的页尾就是正好是两个段落中间,你可以用前面描述的方法在同样位置
强制分页。其他情况下,你必须要在指定位置\emph{同时}强制断行和分页。如
果新页面比旧页面要短,命令序列:
\csdisplay
\vadjust{\vfill\eject}\break
|
^^|\vadjust|
是一个捷径。但是,如果新的页面要长一些的话,问题就非常难办,因为
\TeX{} 可能已经尽量使页面非常紧凑了。这时唯一的办法就是设定
^|\looseness|\ctsref\looseness{}为负值,来缩短页面上的一些竖直间距,
如果 ^|\parskip| (\xref\parskip) 非零,压缩一下, 或者祭出压箱底的绝
招:略微减小 |\baselineskip| \ctsref{\baselineskip}。
^^|\baselineskip//用于保留页尾|
% \section Leaving space at the top of a page
\section 保留页首空白
% \null
% ^^{vertical space//reserving at top of page}
% You can usually use the |\vskip| command \ctsref\vskip{}
% to leave vertical space on a page.
% That doesn't work at the top of a page, however, since
% \TeX\ discards glue, kerns, and penalties that occur just after a page break.
% ^^{page breaks//glue at}
% Use the ^|\topglue| command \ctsref\topglue\ instead; it produces glue that
% never disappears.
% \eix^^{page breaks//bad}
\null
^^{竖直间隔//保留页首空白}
通常你可以使用 |\vskip| 命令\ctsref\vskip{} 在页面上添加空白竖直间距,
但这一招对页首无效,因为在紧接着分页后的所有粘连,紧排和惩罚,
都会被 \TeX{} 会丢弃。
^^{分页//分页处的粘连}
一个替代:^|\topglue| 命令 \ctsref\topglue\ ,能产生永不消失的粘连。
\eix^^{分页//不良分页}
% \section Correcting bad line breaks
\section 纠正不良断行
% \null
% \bix^^{line breaks//bad}
% If \TeX\ breaks a line in the middle of material that you wanted to keep
% on a single line, there are several ways to correct the situation:
% \ulist\compact
% \li You can force a break in a nearby place with the
% |\break| command (\xref{hbreak}).
% ^^|\break//correcting line breaks with|
% \li You can insert a tie (|~|) between two words
% (see \xref{@not}) to prevent a break between them.\ttidxref{~}
% \li You can tell \TeX\ about hyphenations that it wouldn't
% otherwise consider by
% inserting one or more discretionary hyphens in various words
% (see |\-|, \xref{\@minus}).
% \ctsidxref{-//in line breaking}
% ^^{discretionary hyphens//bad line breaks, correcting with}
% \li You can enclose several words in an hbox using the ^|\hbox|
% command \ctsref{\hbox}.
% \endulist
\null
\bix^^{断行//不良断行}
如果 \TeX{} 在需要放在一行的内容中间断行了,有好几种方法能纠正这种情况:
\ulist\compact
\li 你可以使用 |\break| 命令(\xref{hbreak}),在旁边强制断行。
^^|\break//纠正断行|
\li 你可以在两个单词之间插入一个带子(|~|)(见\xref{@not}),来防止在它们之间断开。\ccidxref{\~}
\li 你可以在一些单词里插入一个或者多个自定连字符,来告诉 \TeX{} 新的断词规则(参考 |\-|,\xref{\@minus})。
\syidxref{\-//在断行中}
^^{自定连字符//纠正不良断行}
\li 你可以使用 ^|\hbox| 命令\ctsref{\hbox},把几个单词封装在一个水平盒子里。
\endulist
% The disadvantage of all of these methods, except for inserting discretionary
% hyphens, is that they may make it impossible for \TeX\ to find a
% satisfactory set of line breaks. Should that happen, \TeX\ will
% set one or more underfull or overfull boxes and complain about it.
% ^^{underfull boxes} ^^{overfull boxes}
% The hbox method has a further disadvantage: because \TeX\ sets an hbox
% as a single unit without considering its context, the interword space
% within the hbox may not be consistent with the interword space in the rest of
% the line.
% \eix^^{line breaks//bad}
除了插入临时连字符以外, 其他几种方法都有这样的缺点:\TeX{} 不能产生最佳的断行设置。
一旦如此,\TeX{} 将产生一个或多个未满或溢出盒子,并且对此抱怨。
^^{未满盒子} ^^{过满盒子}
水平盒子的方法还有另外一个缺点:
因为 \TeX{} 处理一个水平盒子的方式是不考虑其中的内容而置其为一个基本单位,
结果盒子内部的单词间距可能会与一行内其它地方不一致。
\eix^^{断行//不良断行}
% \section Correcting overfull or underfull boxes
\section 纠正溢出或未满盒子
% \null
% \bix^^{overfull boxes}
% \bix^^{underfull boxes}
% \bix^^{boxes//overfull}
% \bix^^{boxes//underfull}
% If \TeX\ complains about an overfull box, it means you've put
% more material into a box than that box has room for.
% Similarly, if \TeX\ complains about an underfull box, it means you
% haven't put enough material into the box. You can encounter
% these complaints under many different circumstances, so let's look at the more
% common ones:
\null
\bix^^{过满盒子}
\bix^^{未满盒子}
\bix^^{盒子//过满盒子}
\bix^^{盒子//未满盒子}
如果 \TeX{} 抱怨一个溢出盒子,那表示你在一个盒子里放置了超出盒子空间的内容。类似的,如果 \TeX{} 抱怨的是一个未满盒子,那是说你没有往盒子里加入足够多的内容。这些抱怨可以在许多情形下发生,所以,让我们先看看一般的情况:
% \ulist
% \li An overfull hbox that's a line of a paragraph indicates that the line was
% too long and that
% \TeX\ couldn't rearrange the paragraph
% to make the line shorter. If you set ^|\emergencystretch|
% \ctsref{\emergencystretch} to some nonzero
% value, that may cure the problem by allowing \TeX\ to put more space between
% words. Another solution is to set |\tolerance| \ctsref{\tolerance}
% to $10000$, but that's likely
% to yield lines with far too much space in them. Yet another solution is to
% insert a discretionary hyphen
% ^^{discretionary hyphens//overfull boxes, correcting with}
% in a critical word that \TeX\ didn't know how to hyphenate.
% If all else fails, you might try rewording the paragraph.
% A solution that is rarely satisfactory is increasing ^|\hfuzz| \ctsref\hfuzz,
% allowing \TeX\ to construct lines that project beyond the right margin.
\ulist
\li 一个水平溢出盒子,如果是段落中的一行,表示那一行太长而且 \TeX{} 不能重新安排段落来缩短它。
如果你设置 ^|\emergencystretch|\ctsref{\emergencystretch} 的值非零,
\TeX{} 将在单词间插入更多的空白,可能会有助于解决这个问题。
另一个办法是设置 |\tolerance| \ctsref{\tolerance} $10000$,但它往往会导致行内太多的空白。
还有一个办法是对在 \TeX\ 里未定义断词规则的关键单词插入自定连字符。
^^{自定连字符//纠正过满盒子}
如果这些都不管用,那你可能只好去重写那个段落了。
一个不是很好的方法是增加 ^|\hfuzz|\ctsref\hfuzz ,来允许 \TeX{} 排版超出右边界的行。
% \li An underfull hbox that's a line of a paragraph indicates that the line was
% too short and that \TeX\ couldn't rearrange the paragraph to
% make the line longer.
% \TeX\ will set such a line by stretching its interword spaces
% beyond their normal
% limits. Two of the cures for overfull lines mentioned above
% also apply to underfull lines:
% inserting discretionary hyphens and rewording the paragraph.
% Underfull lines
% won't trouble you if you're using ragged right formatting, which you can get
% with the ^|\raggedright| command \ctsref\raggedright.
\li 一个水平未满盒子,如果是段落里的一行,表示那一行太短了,\TeX{} 不能重新安排段落来使之变长。\TeX{} 将加大单词间的空白,甚至超过正常限度。上面提到的对付溢出行的两种纠正办法:插入临时的连字符和重写段落,都可以用于未满的行。对于使用 ^|\raggedright| 命令 \ctsref\raggedright 得到的左对齐格式,就没有未满行的问题。
% \li The complaint:
% \csdisplay
% Underfull \vbox (badness 10000) has occurred
% while \output is active
% |
% indicates that \TeX\ didn't have enough material to fill up a page. The
% likely cause is that you've been using vboxes to keep material together
% and \TeX\ has encountered a vbox near the bottom of a page that wouldn't fit on
% that page.
% It has put the vbox on the next page, but in doing so has left too much
% empty space in the current page.
% In this case you'll either have to insert some more space
% elsewhere on the current page or break up the vbox into smaller parts.
\li 抱怨信息:
\csdisplay
Underfull \vbox (badness 10000) has occurred
while \output is active
|
表明 \TeX{} 因为没有足够的素材而没有填满一页。可能的原因是:
你使用了竖直盒子来把素材放在一起,但是在接近页面的底部时,
\TeX{} 遇到了一个不适合放在那里的竖直盒子。
结果那个盒子被移至下一页,而在当前页上留下了太多空白。
在这种情况下,或者你要在别的地方插入更多的空白,
或者将那个竖直盒子打破,变得小一点。
% Another possible cause of this complaint is having a long paragraph
% that occupies an entire page without a break.
% Since \TeX\ won't ordinarily vary the spacing between lines,
% it may be unable to fill a gap at the bottom of the page
% amounting to a fraction of the line spacing.
% This can happen if |\vsize| \ctsref{\vsize}, the page length,
% is not an even multiple of |\baselineskip| \ctsref{\baselineskip},
% the space between consecutive
% baselines.
出现这一抱怨信息的另一个可能原因是:一个长段落覆盖了整页而没有分段。
通常 \TeX\ 不会自动调整基行距离,因此,在一页的末尾,就没法填满不足一个行间距的空白。
如果页面长度 |\vsize|\ctsref{\vsize}恰好不是基线距离
|\baselineskip|\ctsref{\baselineskip}的整数倍,这种情况就会出现。
% Yet another cause of this complaint,
% similar to the previous one, is setting ^|\parskip| \ctsref{\parskip},
% the interparagraph glue, to a value that doesn't have any
% stretch or shrink. You can fix these last two problems by increasing ^|\vfuzz|
% \ctsref\vfuzz.
关于这一抱怨信息还有一个原因:与上面相仿,
段落间的粘连 ^|\parskip|\ctsref{\parskip},被固定为不能拉伸或挤压的值。
后面的这两种情况,你可以增加 ^|\vfuzz|\ctsref\vfuzz 予以解决。
% \li The complaint
% \csdisplay
% Overfull \vbox (296.30745pt too high) has occurred
% while \output is active
% |
% indicates that you constructed a vbox that was longer than the page. You'll
% just have to make it shorter.
\li 抱怨信息:
\csdisplay
Overfull \vbox (296.30745pt too high) has occurred
while \output is active
|
说的是你构造了一个长于一页的竖直盒子。弄短一点吧。
% \li
% \bix^^|\hbox//overfull box from|
% \bix^^|\vbox//overfull box from|
% The only cures for an overfull hbox or vbox that you've constructed
% with the |\hbox| or |\vbox| commands
% (\pp\xrefn\hbox, \xrefn\vbox)
% are to take something out of the box, to insert some negative glue
% with ^|\hss| or ^|\vss| (\xref\hss), or to increase the size
% of the box.
\li
\bix^^|\hbox//它导致的过满盒子|
\bix^^|\vbox//它导致的过满盒子|
对于 |\hbox| 或 |\vbox| 命令(第\xrefn\hbox ,\xrefn\vbox 页)所产生的
溢出盒子问题,矫正的诀窍是:从盒子里拿一些东西出去;用 ^|\hss| 或 ^|\vss|(\xref\hss )
插入负值的粘连;或者增加盒子的尺寸。
% \li If you encounter an underfull hbox or vbox that you've constructed
% with |\hbox| or |\vbox|,
% you're usually best off to fill out the box with ^|\hfil|
% or ^|\vfil| (\xref\hfil).
% \eix^^|\hbox//overfull box from|
% \eix^^|\vbox//overfull box from|
\li 对于 |\hbox| 或 |\vbox| 命令(第\xrefn\hbox ,\xrefn\vbox 页)所产生的
未满盒子问题,只需用 ^|\hfil| 或 ^|\vfil|(\xref\hfil )来填满即可。
\eix^^|\hbox//它导致的过满盒子|
\eix^^|\vbox//它导致的过满盒子|
% \endulist
% \eix^^{boxes//overfull}
% \eix^^{boxes//underfull}
% \eix^^{overfull boxes}
% \eix^^{underfull boxes}
\endulist
\eix^^{盒子//过满盒子}
\eix^^{盒子//未满盒子}
\eix^^{过满盒子}
\eix^^{未满盒子}
% \section Recovering lost interword spaces
\section 恢复丢失的单词间距
% \null
% ^^{space//lost}
% ^^{words run together}
% If you find that \TeX\ has run two words together, the likely cause is a
% control sequence that's absorbed the spaces after it.
% Put a ^{control space} (|\!visiblespace|) after the control
% sequence.
\null
^^{间隔//丢失的间隔}
^^{单词连在一起}
如果你发现 \TeX{} 把两个单词连在一起,可能的原因是有一个控制序列吃掉
了其后所有的空格。在那个控制序列后面放一个^{控制空格}
(|\!visiblespace|) 即可。
% \section Avoiding unwanted interword spaces
\section 避免多余的单词间空白
% \null
% \bix^^{space//unwanted}\xrdef{unwantedspace}
% If you get a space in your document where you don't want and don't
% expect one, the most likely cause, in our experience,
% is an end of line or a space following a brace.
% ^^{braces//space after}
% (If you're doing fancy things with category codes,
% ^^{category codes//cause of unwanted spaces}
% you've introduced lots of other likely causes.)
% \TeX\ ordinarily translates an end-of-line into a space,
% and it considers a space after a right or left brace to be significant.
\null
\bix^^{间隔//不想要的间隔}\xrdef{unwantedspace}
如果在文档中有不想要或者未预料到的空白,以我们的经验,最可能的原因是一
行的结尾或大括号后的空格。%
^^{花括号//花括号后的空格}%
(当你用类别码来做华丽的效果时,
^^{类别码//导致不想要的间隔}
还会有其他许多类似的原因。)
\TeX{} 通常将行尾处理为空格,并且会排出左右大括号后面的空格。
% If the unwanted space is caused by a space after a brace within
% an input line, then remove that space.
% If the unwanted space is caused by a brace at the end of an input line,
% put a `|%|' immediately after the brace.
% {\recat!ttidxref[%//to eliminate unwanted spaces]]
% The `|%|' starts a comment, but this comment needn't
% have any text.
如果多余的空白是在一行内,由大括号后的空格引起的,那就移除它。如果多余的空
白是在行尾,由大括号后的空格引起的,那就紧接着在大括号后放一个`|%|'。
\chidxref{\%//去掉不想要的空格}
`|%|' 用于注释开始,但不一定真的要有注释内容。
% A macro definition can also
% introduce unwanted spaces if you haven't written it
% carefully. If you're getting unwanted spaces when you call a macro, check
% its definition to be sure that you don't have an unintended space after a
% brace and that you haven't ended a line of the definition immediately
% after a brace.
% People often end lines of macro definitions after braces in order to make
% the definitions more readable.
% To be safe, put a `|%|' after any brace that ends a line of a macro
% definition.
% It may not be needed, but it won't do any harm.\footnote{
% Admittedly there are rare cases where you really do want an end of line
% after a brace.}
宏定义如果写的不仔细,也可能导致多余的空白。当你应用一个宏,但是有多余
的空白,那就要检查其定义,确保大括号后没有额外的空格以及紧接着括号之后,
宏定义没有换行。人们经常在大括号后对宏定义换行,从而容易阅读。安全起见,
应该在所有大括号之后要换行的地方放一个`|%|'。可能有些地方不需要,但是这
么做起码没有坏处。\footnote{当然,极为偶然的情况下,你可能真的需要在大括
号后直接换行。}
% When you're having trouble locating the source of an unwanted space,
% try setting |\tracingcommands| \ctsref{\tracingcommands} to $2$.
% You'll get a |{blank space}| command in the log file for each space
% that \TeX\ sees.
当你不能准确在源文档中定位多余的空白的时候,可以尝试设置
|\tracingcommands|\ctsref{\tracingcommands}为 $2$。在日志文件里,每
一处空格都会输出一个 |{blank space}| 命令。
% It helps to know \TeX's rules for spaces:
知道 \TeX{} 关于空格的规则会有帮助。
% \olist
% \li Spaces are ignored at the beginnings of input lines.
% \li Spaces at the ends of input lines are ignored under \emph{all}
% circumstances, although the end of line itself is treated like a space.
% (A completely blank line, however, generates a |\par| token.)
% \li Multiple spaces are treated like a single space, but
% only if they appear together in your input.
% Thus a space following the arguments of a macro call is not combined
% with a final space produced by the macro call. Instead, you get two spaces.
% \li Spaces are ignored after control words.
% \li Spaces are in effect ignored after numbers, dimensions,
% and the `|plus|' and `|minus|' in glue specifications.%
% \footnote{Actually, \TeX\ ignores only a
% single space in these places.
% Since multiple spaces ordinarily reduce to a single space, however, the
% effect is that of ignoring any number of spaces.}
% \endolist
% \noindent If you've changed the category code of the space or the end-of-line
% character, all bets are off.
% \eix^^{space//unwanted}
\olist
\li 输入行开始之前的空格将被忽略。
\li 输入行结束之后的空格在任何情况下都被忽略。虽然行尾本身就被当作空格。%
(一个空白行产生的是 |\par| 标记。)
\li 多于一个的空格,如果在一起,将被处理为一个空格。因此,宏调用的参量之
后的空格将不会和宏定义末尾的空格合并。你得到的是两个空格。
\li 控制字符之后的空格将被忽略。
\li 数字,尺寸以及粘连设定中的 `|plus|' 和 `|minus|' 之后的空格在执行
中也被忽略。%
\footnote{实际上,\TeX{} 在这些地方只会忽略单个的空格。因为多个空格会
被处理为一个空格,所以结果就是忽略所有空格。}%
\endolist
如果你改变了空格符或行尾符的类别码,这些规则就不算数了。
\eix^^{间隔//不想要的间隔}
%\section Avoiding excess space around a display
\section 避免陈列公式周围的额外空白
% \null
% ^^{math display}
% If you're getting too much space above a math display, it may be because
% you've left a blank line in your input above the display.
% The blank line starts a new paragraph and puts \TeX\ into
% vertical mode. When
% \TeX\ sees a '|$|' in vertical mode, it switches back to horizontal mode
% and inserts the interparagraph glue (|\parskip|) followed by
% the interline glue (|\baselineskip|).
% Then, when it starts the display itself,
% it inserts \emph{more} glue (either ^|\abovedisplayskip|
% or ^|\abovedisplayshortskip|, depending on the length of the preceding
% line).
% This last glue is the only glue that you want.
% To avoid getting the interparagraph glue as well, don't leave a blank line above a
% math display or otherwise
% end a paragraph (with |\par|, say) just before a math display.
\null
^^{陈列公式}
如果在陈列公式之前有太多空白,有可能是因为你输入的时候在陈列公式之前留
了一个空行。这个空行将开始一个新的段落,并且把 \TeX\ 转入竖直模式。当
\TeX\ 在竖直模式里遇到一个 '|$|', 就会切换到水平模式并插入段间粘连
(|\parskip|),接下来又插入一个行间粘连(|\baselineskip|)。然后当显
示开始的时候,它插入\emph{更多}粘连(或者是 ^|\abovedisplayskip| 或者
是 ^|\abovedisplayshortskip|,取决于前一行的长度)。只有最后一个粘连是你想
要的。为了避免也得到段间粘连,在陈列公式之前不要留空行或者结束段落
(比如用 |\par|)。
% Similarly,
% if you're getting too much space below a math display, it may be because
% you've left a blank line in your input below the display.
% Just remove it.
类似的,如果在陈列公式之后有太多的空白,可能是因为在输入时留了一个空行。
去掉它即可。
%\section Avoiding excess space after a paragraph
\section 避免段后的额外空白
% If you get too much vertical space after a paragraph that was produced by a
% macro, you may be getting the interparagraph glue produced by the macro,
% an empty paragraph, and then more interparagraph glue.
% You can get rid of the second paragraph skip by inserting:
% \csdisplay
% \vskip -\parskip
% \vskip -\baselineskip
% |
% just after the macro call.
% If you always get this problem with a certain macro, you can put these
% lines at the end of the macro definition instead.
% You may also be able to cure the problem by never leaving a blank line
% after the macro call---if you want a blank line just to make your input
% more readable, start it with a `|%|'.
如果使用宏得到的段落之后有太多竖直空白,可能里头包含了宏产生的段间粘
连,一个空段,以及另外一个段间粘连。你可以通过在那个宏之后插入
\csdisplay
\vskip -\parskip
\vskip -\baselineskip
|
来消除第二个段落间距。
%\section Changing the paragraph shape
\section 改变段落形状
% \null
% \bix^^{paragraphs//shaping}
% Several \TeX\ parameters---^|\hangindent|, ^|\leftskip|, etc.---%
% affect the way that \TeX\ shapes paragraphs and breaks them into lines.
% ^^{line breaking}
% These parameters are used indirectly in \plainTeX{} commands such as
% ^|\narrower| and ^|\hang|; you can also assign to them directly.
% If you've used one of these commands (or changed one of these parameters),
% but the command or parameter change
% does not seem to be having any effect on a paragraph,
% the problem may be that you've ended a group before you've ended the
% paragraph. For example:
% \csdisplay
% {\narrower She very soon came to an open field, with
% a wood on the other side of it: it looked much darker
% than the last wood, and Alice felt a little timid
% about going into it.}
% |
% This paragraph won't be set narrower because the right brace at the end
% terminates the |\narrower| group before \TeX\ has had a chance to
% break the paragraph into lines. Instead, put a |\par| before the
% right brace; then you'll get the effect you want.
% ^^|\par//when changing paragraph shape|
% \eix^^{paragraphs//shaping}
\null
\bix^^{段落//形成段落}
有几个 \TeX\ 的参数——^|\hangindent|, ^|\leftskip|, 等等——%
影响 \TeX\ 塑段和折行的方式。
^^{断行}
\PlainTeX{} 的命令,如 ^|\narrower| 和 ^|\hang|, 会间接的用到这些参
数;你也可以直接对它们赋值。 如果你已经使用了这些命令中的一个(或者改
变了这些参数中的一个),但是看上去对段落没有任何效果,问题可能在于,段
落结束之前你先结束了一个组。例如:
\csdisplay
{\narrower She very soon came to an open field, with
a wood on the other side of it: it looked much darker
than the last wood, and Alice felt a little timid
about going into it.}
|
这个段落不会变窄,因为最后那个右边大括号在 \TeX\ 拆段组行之前就结束了
|\narrower| 的组。作为补救,放一个 |\par| 在右边大括号之前;这样你才能
看到想要的效果。
^^|\par//在修改段落形状时|
\eix^^{段落//形成段落}
%\section Putting paragraphs into a box
\section 把段落放入盒子
% Suppose you have a few paragraphs of text that you want to put in a
% particular place on the page. The obvious way to do it is to enclose
% the paragraphs in an hbox of an appropriate size, and then place the hbox
% where you want it to be. Alas, the obvious way doesn't work because
% \TeX\ won't do line breaking in restricted horizontal mode.
% ^^{restricted mode//horizontal}
% If you try it,
% you'll get a misleading error message that suggests you're
% missing the end of a group.
% The way around this restriction is to write:
% \csdisplay
% \vbox{\hsize = !<dimen> !dots !<paragraphs> !dots}
% |
% where \<dimen> is the line length that you want for the paragraphs.
% This is what you need to do, in particular, when you want to enclose some
% paragraphs in a box (a box enclosed in ruled lines, not a \TeX\ box).
假设你有一些文字段落想放到页面的一个特定位置。显而易见的方式是用一个合
适尺寸的水平盒子来封装段落,然后放到想要的位置。哎呀,这个办法不管用,
因为 \TeX\ 不能在受限水平模式下断行。
^^{受限模式//水平受限模式}
这么做,你将得到一个有些误导的错误消息,声称 you're
missing the end of a group。摆脱这个限制的方法是使用:
\csdisplay
\vbox{\hsize = !<dimen> !dots !<paragraphs> !dots}
|
其中,\<dimen> 是你希望的一行的长度。这么做就可以了,特别是当你想用盒
子(带线框的盒子,不是 \TeX 盒子)封装一些段落的时候。
%\section Drawing lines
\section 画线
% \null
% \bix^^{rules}
% You can use the ^|\hrule| and ^|\vrule| commands (\xref\hrule)
% to draw lines, i.e., rules. You'll need to
% know (a)~where you can use each command and
% (b)~how \TeX\ determines the lengths of rules when
% you haven't given the lengths explicitly.
\null
\bix^^{标线}
你可以使用 ^|\hrule| 和 ^|\vrule| 命令(\xref\hrule )来画线。
所需知道的是 (a)~在什么地方可以用哪个命令,
以及 (b)~\TeX\ 如何在你未明确指出的情况下决定线的长度。
% \ulist
% \li You can only use |\hrule| when \TeX\ is in a vertical mode and |\vrule|
% when \TeX\ is in a horizontal mode.
% This requirement means that
% you can't put a horizontal rule into an hbox or a vertical rule
% into a vbox.
% You can, however, construct a horizontal rule that looks vertical by
% specifying all three dimensions and making it tall and skinny.
% Similarly, you can construct a vertical rule that looks horizontal
% by making it short and fat.
\ulist
\li \TeX\ 处于竖直模式时,只能用 |\hrule|;\TeX\ 处于水平模式时,只能
用 |\vrule|。所以你不能在水平盒子里使用横线或者在竖直盒子里使用竖线。
然而,通过设定所有三个尺寸(dimension),你可以把横线画的又高又细,使
它看起来像竖线。类似的,你也可以把竖线画的又矮又宽,使它看起来像横线。
% \li A horizontal rule inside a vbox
% has the same width as does the vbox if you haven't
% given the width of the rule explicitly.
% Vertical rules
% inside hboxes behave analogously.
% If your rules are coming out too long or too short,
% check the dimensions of the enclosing box.
% \endulist
\li 如果你没有明确设定宽度,竖直盒子里的横线就会和盒子一样宽。水平盒子
里的竖线也类似。如果你得到的线太长或太短,请检查外面盒子的尺寸。
\endulist
% As an example, suppose we want to produce:
% \display{%
% \hbox{\vrule
% \vbox{\hrule\vskip 3pt
% \hbox{\hskip 3pt
% \vbox{\hsize .7in\raggedright
% \noindent Help! Let me out of here!}%
% \hskip 3pt}
% \vskip 3pt\hrule}%
% \vrule}}
% The following input will do it:
% \csdisplay
% \hbox{\vrule
% \vbox{\hrule \vskip 3pt
% \hbox{\hskip 3pt
% \vbox{\hsize = .7in \raggedright
% \noindent Help!! Let me out of here!!}%
% \hskip 3pt}%
% \vskip 3pt \hrule}%
% \vrule}
% |
% We need to put the text into a vbox in order to get \TeX\ to process it
% as a paragraph.
% The four levels of boxing are really
% necessary---if you doubt it, try to run this example with fewer levels.
% \eix^^{rules}
一个例子,假设你想要
\display{%
\hbox{\vrule
\vbox{\hrule\vskip 3pt
\hbox{\hskip 3pt
\vbox{\hsize .7in\raggedright
\noindent Help! Let me out of here!}%
\hskip 3pt}
\vskip 3pt\hrule}%
\vrule}}
The following input will do it:
\csdisplay
\hbox{\vrule
\vbox{\hrule \vskip 3pt
\hbox{\hskip 3pt
\vbox{\hsize = .7in \raggedright
\noindent Help!! Let me out of here!!}%
\hskip 3pt}%
\vskip 3pt \hrule}%
\vrule}
|
我们需要把文本放到竖直盒子里来让 \TeX\ 把它当作段落处理。四层盒子是必
要的---如果你有所怀疑,可以尝试在更少的盒子情况下运行这个例子。
\eix^^{标线}
%\section Creating multiline headers or footers
\section 创建多行的页眉页脚
% \null
% \xrdef{bighead}
% \bix^^{headers//multiple-line}
% \bix^^{footers//multiple-line}
% You can use
% the ^|\headline| and ^|\footline| commands
% (\xref\footline) to produce headers and footers, but they don't work properly
% for headers and footers having more than one line. However, you can get
% multiline headers and footers by redefining some of the subsidiary
% macros in \TeX's output routine.
\null
\xrdef{bighead}
\bix^^{页眉//多行页眉}
\bix^^{页脚//多行页脚}
你可以使用 ^|\headline| 和 ^|\footline| 命令(\xref\footline)来创建页
眉和页脚,但是处理多于一行的页眉和页脚,就不大灵光。然而,通过重新定义
\TeX\ 的输出例行程序的一些宏,就可以实现。
% For a multiline header, you need to do three things:
% \olist\compact
% \li Redefine the ^|\makeheadline| macro that's called from \TeX's
% output routine.
% \li Increase ^|\voffset| by the amount of vertical space consumed by the
% extra lines.
% \li Decrease ^|\vsize| by the same amount.
% \endolist
% \noindent The following example shows how you might do this:
% \csdisplay
% \advance\voffset by 2\baselineskip
% \advance\vsize by -2\baselineskip
% \def\makeheadline{\vbox to 0pt{\vss\noindent
% Header line 1\hfil Page \folio\break
% Header line 2\hfil\break
% Header line 3\hfil}%
% \vskip\baselineskip}
% |
% You can usually follow the pattern of this definition quite closely, just
% substituting your own header lines and choosing an appropriate multiple
% of |\baselineskip| (one less than the number of lines in the
% header).
为了得到多行页眉,你需要做三件事:
\olist\compact
\li 重新定义 ^|\makeheadline| 宏,\TeX\ 的输出例行程序将会用到它。
\li 把额外的行所需的竖直距离加给 ^|\voffset|。
\li 对 ^|\vsize| 减少同样的大小。
\endolist
\noindent 下面的例子演示了你可以怎样做:
\csdisplay
\advance\voffset by 2\baselineskip
\advance\vsize by -2\baselineskip
\def\makeheadline{\vbox to 0pt{\vss\noindent
Header line 1\hfil Page \folio\break
Header line 2\hfil\break
Header line 3\hfil}%
\vskip\baselineskip}
|
一般你照着这个定义的样子做就可以了,只需要替换你自己的页眉内容并选一个
合适的倍数给 |\baselineskip| (页眉行数减一)。
% For a multiline footer, the method is similar:
% \olist
% \li Redefine the ^|\makefootline| macro that's called from \TeX's
% output routine.
% \li Decrease ^|\vsize| by the amount of vertical space consumed by the
% extra lines.
% \endolist
% \noindent The following example shows how you might do this:
% \csdisplay
% \advance\vsize by -2\baselineskip
% \def\makefootline{%
% \lineskip = 24pt
% \vbox{\raggedright\noindent
% Footer line 1\hfil\break
% Footer line 2\hfil\break
% Footer line 3\hfil}}
% |
% Again, you can usually follow the pattern of this definition quite closely.
% The value of |\lineskip| determines the amount of space between the
% baseline of the last line
% of the main text on the page and the baseline of the first line of the footer.
% \eix^^{headers//multiple-line}
% \eix^^{footers//multiple-line}
对多行页脚的处理也类似:
\olist
\li 重新定义 ^|\makefootline| 宏,\TeX\ 的输出例行程序将会用到它。
\li 把额外的行所需的竖直距离加给 ^|\voffset|。
\li 从 ^|\vsize| 减去额外的行所需的竖直距离。
\endolist
\noindent 下面的例子演示了你可以怎样做:
\csdisplay
\advance\vsize by -2\baselineskip
\def\makefootline{%
\lineskip = 24pt
\vbox{\raggedright\noindent
Footer line 1\hfil\break
Footer line 2\hfil\break
Footer line 3\hfil}}
|
同样,一般你照着这个定义的样子做就可以了。|\lineskip| 的值决定了页面上正文最
后一行与页脚第一行的基行距离。
\eix^^{页眉//多行页眉}
\eix^^{页脚//多行页脚}
%\section Finding mismatched braces
\section 找出匹配错误的花括号
% \bix^^{braces//mismatched}
% \xrdef{mismatched}
% Most times when your \TeX\ input suffers from mismatched braces, you'll
% get a diagnostic from \TeX\ fairly near the place where you actually
% made the mistake.
% But one of the most frustrating errors you can get from a \TeX\ run,
% just before \TeX\ quits, is
% the following:
% \csdisplay
% (\end occurred inside a group at level 1)
% |
% This indicates that there is an extra left brace
% or a missing right brace somewhere