Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8d20eaa

Browse files
committed
Improve our workaround for 'TeX capacity exceeded' in building PDF files.
In commita5ec86a I wrote a quick hackthat reduced the number of TeX string pool entries created while convertingour documentation to PDF form. That held the fort for awhile, but as ofHEAD we're back up against the same limitation. It turns out that theoriginal coding of \FlowObjectSetup actually results in *three* string poolentries being generated for every "flow object" (that is, potentialcross-reference target) in the documentation, and my previous hack only gotrid of one of them. With a little more care, we can reduce the stringcount to one per flow object plus one per actually-cross-referenced flowobject (about 115000 + 5000 as of current HEAD); that should work untilthe documentation volume roughly doubles from where it is today.As a not-incidental side benefit, this change also causes pdfjadetex tostop emitting unreferenced hyperlink anchors (bookmarks) into the PDF file.It had been making one willy-nilly for every flow object; now it's just oneper actually-cross-referenced object. This results in close to a 2Xsavings in PDF file size. We will still want to run the output through"jpdftweak" to get it to be compressed; but we no longer need removal ofunreferenced bookmarks, so we might be able to find a quicker tool forthat step.Although the failure only affects HEAD and US-format output at the moment,9.5 cannot be more than a few pages short of failing likewise, so itwill inevitably fail after a few rounds of minor-version release notes.I don't have a lot of faith that we'll never hit the limit in the olderbranches; and anyway it would be nice to get rid of jpdftweak across theboard. Therefore, back-patch to all supported branches.
1 parenteb66ee6 commit8d20eaa

File tree

1 file changed

+69
-10
lines changed

1 file changed

+69
-10
lines changed

‎doc/src/sgml/jadetex.cfg

Lines changed: 69 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,89 @@
11
% doc/src/sgml/jadetex.cfg
22
%
3-
% This file redefines FlowObjectSetup to eliminate one of the two control
4-
% sequences it normally creates, thereby substantially reducing string usage
5-
% and permitting the complete Postgres documentation to be built without
6-
% overflowing a hard-to-expand TeX limit. The only known penalty is an
7-
% increased number of TeX warnings about ignoring duplicate definitions.
3+
% This file redefines \FlowObjectSetup and some related macros to greatly
4+
% reduce the number of control sequence names created, and also to avoid
5+
% creation of many useless hyperlink anchors (bookmarks) in PDF files.
86
%
9-
% Curiously, we only see the failure when building PDF output --- plain PS
10-
% output does not come anywhere close to overflowing the string table.
11-
% There may be another solution hidden in that observation.
7+
% The original coding of \FlowObjectSetup defined a control sequence x@LABEL
8+
% for pretty nearly every flow object in the file, whether that object was
9+
% cross-referenced or not. Worse yet, it created a hyperlink anchor for
10+
% every such object, which not only bloated the output PDF with useless
11+
% anchors but consumed an additional control sequence name per anchor.
12+
% This results in overrunning TeX's limited-size string pool.
13+
%
14+
% To fix, extend\PageLabel's already-existing mechanism whereby a p@LABEL
15+
% control sequence is filled in only for labels that are referenced by at
16+
% least one \Pageref call. We now also fill in p@LABEL for labels that are
17+
% referenced by a \Link. Then, we can drop x@LABEL entirely, and use p@LABEL
18+
% to control emission of both a hyperlink anchor and a page-number label.
19+
% Now, both of those things are emitted for all and only the flow objects
20+
% that have either a hyperlink reference or a page-number reference.
21+
% We consume about one control sequence name per flow object plus one per
22+
% referenced object, which is a lot better than three per flow object.
23+
%
24+
% (With a more invasive patch, we could track the need for an anchor and a
25+
% page-number label separately, but that would probably require two control
26+
% sequences for every flow object. Besides, many objects that have one kind
27+
% of reference will have the other one too; that's certainly true for objects
28+
% referenced in either the TOC or the index, for example.)
29+
%
30+
%
31+
% In addition to checking p@LABEL not x@LABEL, this version of \FlowObjectSetup
32+
% is fixed to clear \Label and \Element whether or not it emits an anchor
33+
% and page label. Failure to do that seems to explain some pre-existing bugs
34+
% in which certain SGML constructs weren't correctly cross-referenced.
1235
%
1336
\def\FlowObjectSetup#1{%
1437
\ifDoFOBSet
1538
\ifLabelElements
1639
\ifx\Label\@empty\let\Label\Element\fi
1740
\fi
1841
\ifx\Label\@empty\else
42+
\expandafter\ifx\csname p@\Label\endcsname\relax
43+
\else
1944
\bgroup
2045
\ifNestedLink
2146
\else
2247
\hyper@anchorstart{\Label}\hyper@anchorend
2348
\PageLabel{\Label}%
2449
\fi
2550
\egroup
26-
\let\Label\@empty
27-
\let\Element\@empty
51+
\fi
52+
\let\Label\@empty
53+
\let\Element\@empty
2854
\fi
2955
\fi
3056
}
57+
%
58+
% Adjust\PageLabel so that the p@NAME control sequence acquires a correct
59+
% value immediately; this seems to be needed to avoid scenarios wherein
60+
% additional TeX runs are needed to reach a stable state of the .aux file.
61+
%
62+
\def\PageLabel#1{%
63+
\@bsphack
64+
\expandafter\ifx\csname p@#1\endcsname\relax
65+
\else
66+
\protected@write\@auxout{}%
67+
{\string\pagelabel{#1}{\thepage}}%
68+
% Ensure the p@NAME control sequence acquires correct value immediately
69+
\expandafter\xdef\csname p@#1\endcsname{\thepage}%
70+
\fi
71+
\@esphack}
72+
%
73+
% In\Link, add code to emit an aux-file entry if the p@NAME sequence isn't
74+
% defined. Much as in \@Setref, this ensures we'll process the referenced
75+
% item correctly on the next TeX run.
76+
%
77+
\def\Link#1{%
78+
\begingroup
79+
\SetupICs{#1}%
80+
\ifx\Label\@empty\let\Label\Element\fi
81+
%\typeout{Made a Link at\the\inputlineno, to\Label}%
82+
\hyper@linkstart{\LinkType}{\Label}%
83+
\NestedLinktrue
84+
% If p@NAME control sequence isn't defined, emit dummy def to aux file
85+
% so it will get defined properly on next run, much as in \@Setref
86+
\expandafter\ifx\csname p@\Label\endcsname\relax
87+
\immediate\write\@mainaux{\string\pagelabel{\Label}{qqq}}%
88+
\fi
89+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp