texinfo-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[6689] index entry formatting


From: Gavin D. Smith
Subject: [6689] index entry formatting
Date: Tue, 13 Oct 2015 11:53:36 +0000

Revision: 6689
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=6689
Author:   gavin
Date:     2015-10-13 11:53:31 +0000 (Tue, 13 Oct 2015)
Log Message:
-----------
index entry formatting

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/doc/texinfo.tex

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog     2015-10-12 21:02:23 UTC (rev 6688)
+++ trunk/ChangeLog     2015-10-13 11:53:31 UTC (rev 6689)
@@ -1,3 +1,14 @@
+2015-10-13  Gavin Smith  <address@hidden>
+
+       * doc/texinfo.tex (\entry): Get length of index entry text and 
+       length of whole entry.  If it's too long, use \parshape to split 
+       the entry across two lines.  Use \rightskip and \leftskip to 
+       align first line of entry to the left, and last line to the 
+       right.  Increase \hyphenpenalty to 10000.  Re-add a comment to 
+       explain why the entry text isn't absorbed as a macro argument.
+       (\indexdotfill): Increase stretchability of leaders to "filll" 
+       level.
+
 2015-10-12  Gavin Smith  <address@hidden>
 
        * doc/texinfo.texi (@setfilename): @setfilename not required.

Modified: trunk/doc/texinfo.tex
===================================================================
--- trunk/doc/texinfo.tex       2015-10-12 21:02:23 UTC (rev 6688)
+++ trunk/doc/texinfo.tex       2015-10-13 11:53:31 UTC (rev 6689)
@@ -3,7 +3,7 @@
 % Load plain if necessary, i.e., if running under initex.
 \expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi
 %
-\def\texinfoversion{2015-10-09.18}
+\def\texinfoversion{2015-10-13.13}
 %
 % Copyright 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995,
 % 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
@@ -1106,6 +1106,7 @@
 \newtoks\toksC
 \newtoks\toksD
 \newbox\boxA
+\newbox\boxB
 \newcount\countA
 \newif\ifpdf
 \newif\ifpdfmakepagedest
@@ -5214,30 +5215,6 @@
     %  How much \indexdotfill is stretched, or how much \parfillskip is shrunk
     %  Number of lines (\linepenalty)
     %  
-    % Do not prefer a separate line ending with a hyphen to fewer lines.
-    \finalhyphendemerits = 0
-    %
-    % Word spacing - no stretch
-    \spaceskip=\fontdimen2\font minus \fontdimen4\font
-    %
-    \linepenalty=1000  % Discourage line breaks.
-    \hyphenpenalty=5000  % Discourage hyphenation.
-    %
-    % Ragged right margin, but not for the last line with the leaders in it.
-    % When an index entry spans lines, this stretch competes with the stretch
-    % in \indexdotfill to determine how the line will be split.
-    \rightskip=\entryrightmargin
-    \advance\rightskip by 0pt plus .6\hsize
-    %
-    % \parfillskip is at the end of the line with the page number
-    \parfillskip=0pt
-    % Cancel the \rightskip stretch
-    \advance \parfillskip by 0pt plus -.6\hsize
-    % Determine how far we can stretch into the margin.
-    % This allows, e.g., "Appendix H  GNU Free Documentation License" to fit
-    % on one line.
-    \advance \parfillskip by 0pt minus .6\entryrightmargin
-    %
     % Swallow the left brace of the text (first parameter):
     \afterassignment\doentry
     \let\temp =
@@ -5245,20 +5222,26 @@
 \def\entrybreak{\unskip\space\ignorespaces}%
 \def\doentry{%
     % Save the text of the entry in a \vtop.
-    \global\setbox\entryindexbox=\vtop\bgroup
+    \global\setbox\boxA=\hbox\bgroup
     \bgroup % Instead of the swallowed brace.
       \noindent
       \aftergroup\finishentry
       % And now comes the text of the entry.
+      % Not absorbing as a macro argument reduces the chance of problems
+      % with catcodes occurring.
 }
-\def\finishentry#1{%
address@hidden
+\gdef\finishentry#1{%
+    \egroup % end box A
+    \dimen@ = \wd\boxA % Length of text of entry
+    \global\setbox\boxA=\hbox\bgroup\unhbox\boxA
     % #1 is the page number.
     %
     % The following is kludged to not output a line of dots in the index if
     % there are no page numbers.  The next person who breaks this will be
     % cursed by a Unix daemon.
-    \setbox\boxA = \hbox{#1}%
-    \ifdim\wd\boxA = 0pt
+    \setbox\boxB = \hbox{#1}%
+    \ifdim\wd\boxB = 0pt
       \null\nobreak\hfill\ %
     \else
       %
@@ -5271,23 +5254,62 @@
         \hskip\skip\thinshrinkable #1%
       \fi
     \fi
-    % Parameters for formatting this paragraph, reset for each paragraph.
+    \egroup % end \boxA
+    \global\setbox\entryindexbox=\vtop\bgroup\noindent
+    % We want the text of the entries to be aligned to the left, and the
+    % page numbers to be aligned to the right.
     %
-    % \hangindent is only relevant when the entry text and page number
-    % don't both fit on one line.  In that case, bob suggests starting the
-    % dots pretty far over on the line.  Unfortunately, a large
-    % indentation looks wrong when the entry text itself is broken across
-    % lines.  So we use a small indentation and put up with long leaders.
+    \advance\leftskip by 0pt plus 1fil
+    \advance\leftskip by 0pt plus -1fill
+    \rightskip = 0pt plus -1fil
+    \advance\rightskip by 0pt plus 1fill
+    % Cause last line, which could consist of page numbers on their own if the 
+    % list of page numbers is long, to be aligned to the right.
+    \parfillskip=0pt plus -1fill
     %
-    \hangafter = 1
-    \hangindent = 1em
-    \par
+    \hangindent=1em
+    %
+    \advance\rightskip by \entryrightmargin
+    % Determine how far we can stretch into the margin.
+    % This allows, e.g., "Appendix H  GNU Free Documentation License" to fit
+    % on one line.
+    \advance \parfillskip by 0pt minus .6\entryrightmargin
+    %
+    \ifdim\wd\boxA > \hsize % If the entry doesn't fit in one line
+    \ifdim\dimen@ > 0.9\hsize   % due to long index text
+      \dimen@ = 0.6\dimen@ % Try to split the text roughly evenly
+      address@hidden = \hsize
+      \advance address@hidden by -1em
+      \ifnum\dimen@>address@hidden
+        % If the entry is too long, use the whole line
+        \dimen@ = address@hidden
+      \else
+    % Cause stretch of 1fill at the end of the first line, to avoid
+    % extra spacing in a short first line.
+    \hskip 0pt plus 1fill
+      \fi
+      \parshape = 2 0pt \dimen@ 1em address@hidden
+      % Ideally we'd add a finite glue at the end of the first line only, but
+      % TeX doesn't seem to provide a way to do such a thing.
+    \fi\fi
+    \unhbox\boxA
+    %
+    % Do not prefer a separate line ending with a hyphen to fewer lines.
+    \finalhyphendemerits = 0
+    %
+    % Word spacing - no stretch
+    \spaceskip=\fontdimen2\font minus \fontdimen4\font
+    %
+    \linepenalty=1000  % Discourage line breaks.
+    \hyphenpenalty=10000  % Discourage hyphenation.
+    %
+    \par % format the paragraph
     \egroup % The \vtop
   \endgroup
   % delay text of entry until after penalty
   \bgroup\aftergroup\insertindexentrybox
   \entryorphanpenalty
-}
+}}
 
 \newskip\thinshrinkable
 \skip\thinshrinkable=.15em minus .15em
@@ -5322,11 +5344,12 @@
 }
 
 % Like plain.tex's \dotfill, except uses up at least 1 em.
-% Using a finite stretch encourages several words to appear on a second line
-% if the entry is broken.
+% The filll stretch here overpowers both the fil and fill stretch to push
+% the page number to the right.
 \def\indexdotfill{\cleaders
-  \hbox{$\mathsurround=0pt \mkern1.5mu.\mkern1.5mu$}\hskip 1em plus .4\hsize}
+  \hbox{$\mathsurround=0pt \mkern1.5mu.\mkern1.5mu$}\hskip 1em plus 1filll}
 
+
 \def\primary #1{\line{#1\hfil}}
 
 \newskip\secondaryindent \secondaryindent=0.5cm




reply via email to

[Prev in Thread] Current Thread [Next in Thread]