groff-commit
[Top][All Lists]
Advanced

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

[groff] 01/01: Version 2.2 release.


From: Peter Schaffter
Subject: [groff] 01/01: Version 2.2 release.
Date: Sun, 26 Feb 2017 22:18:37 -0500 (EST)

PTPi pushed a commit to branch master
in repository groff.

commit 3a4907891fe75d93857166344d525e7f1c9c791e
Author: Peter Schaffter <address@hidden>
Date:   Sun Feb 26 22:17:52 2017 -0500

    Version 2.2 release.
---
 contrib/mom/om.tmac-u | 2297 ++++++++++++++++++++++++++++++++-----------------
 1 file changed, 1488 insertions(+), 809 deletions(-)

diff --git a/contrib/mom/om.tmac-u b/contrib/mom/om.tmac-u
index b1f4e8f..d26433d 100644
--- a/contrib/mom/om.tmac-u
+++ b/contrib/mom/om.tmac-u
@@ -2,7 +2,7 @@
 .ig
 Mom -- a typesetting/document-processing macro set for groff.
 
-Copyright (C) 2002-2016  Free Software Foundation, Inc.
+Copyright (C) 2002-2017  Free Software Foundation, Inc.
  Written by Peter Schaffter <address@hidden>
  PDF integration contributed by Deri James <address@hidden>
 
@@ -21,9 +21,9 @@ for more details.
 You should have received a copy of the GNU General Public License
 along with this program. If not, see <http://www.gnu.org/licenses/>.
 
-Version 2.1-b_1
----------------
-Antoine de St-Exup�ry asserted that elegance in engineering is
+Version 2.2
+-----------
+Antoine de St-Exupéry asserted that elegance in engineering is
 achieved not when there is nothing left to add, but when there is
 nothing left to take away.
 
@@ -440,26 +440,26 @@ end
 \#   breaks to a new page.
 \#
 .MAC NEWPAGE END
-.    nr #NEWPAGE 1
-.    ie \\n[#NO_BREAK] \{\
-'       br
-.       rr #NO_BREAK
-.    \}
-.    el .br
+.    if !\\n[defer] .nr #NEWPAGE 1
 .    nr @TOP 1
-.    ie \\n[#B_MARGIN_SET]=1 \{\
-.       ie !\\n[#DOCS]=1 .DO_B_MARGIN
-.       el \{\
-.          if \\n[#COLUMNS]=1 .nr #COL_NUM \\n[#NUM_COLS]
-.          ie !\\n[#FN_DEPTH] \{\
-.             ch FN_OVERFLOW_TRAP
-.             FOOTER
-.             wh -\\n[#FN_OVERFLOW_TRAP_POS]u FN_OVERFLOW_TRAP
-.          \}
-.          el .FOOTER
+.    ie !\\n[#DOCS]=1 \
+.       if \\n[#B_MARGIN_SET]=1 .DO_B_MARGIN
+.    el \{\
+.       if \\n[#COLUMNS]=1 .nr #COL_NUM \\n[#NUM_COLS]
+.       if !\\n[#FN_DEPTH] \{\
+.          ch FN_OVERFLOW_TRAP
+.          nr #RESET_FN_OVERFLOW_TRAP 1
 .       \}
 .    \}
-.    el 'bp
+.    if dPDF.EXPORT \
+.       if \\n[#FLEX_ACTIVE] \
+.          if !\\n[#NO_FLEX] \
+.             tm .ds pre-newpage-\\n% address@hidden
+.    bp
+.    if \\n[#RESET_FN_OVERFLOW_TRAP] \{\
+.       wh -\\n[#FN_OVERFLOW_TRAP_POS]u FN_OVERFLOW_TRAP
+.       rr #RESET_FN_OVERFLOW_TRAP_POS
+.   \}
 .END
 \#
 \# =====================================================================
@@ -1042,7 +1042,6 @@ end
 \#   Requires a unit of measure.
 \#
 .MAC ALD END
-.    br
 .    if '\\$0'ALD' \{\
 .       nr #ALD (u;\\$1)
 .       sp \\n[#ALD]u
@@ -1737,11 +1736,11 @@ end
 \#
 .MAC TN END
 .    nr #TN 1
-.    TRAP OFF
+.    vpt 0
 .    sp -1v
 .    nr #NEXT_TAB \\n[#CURRENT_TAB]+1
 .    TAB\\n[#NEXT_TAB]
-.    TRAP
+.    vpt
 .END
 \#
 \# An inline escape to accomplish the same thing.  Preferable, since
@@ -1892,16 +1891,16 @@ end
 .ds TITLE_TYPE_2  AUTHOR
 .ds TITLE_TYPE_3  CHAPTER
 .ds TITLE_TYPE_4  CHAPTER_TITLE
-.ds TITLE_TYPE_12 COPYRIGHT
 .ds TITLE_TYPE_5  COVERTITLE
-.ds TITLE_TYPE_14 COVER_TITLE
 .ds TITLE_TYPE_6  DOCTITLE
 .ds TITLE_TYPE_7  DOCTYPE
 .ds TITLE_TYPE_8  DOC_COVERTITLE
-.ds TITLE_TYPE_13 DOC_COVER_TITLE
-.ds TITLE_TYPE_11 MISC
 .ds TITLE_TYPE_9  SUBTITLE
 .ds TITLE_TYPE_10 TITLE
+.ds TITLE_TYPE_11 MISC
+.ds TITLE_TYPE_12 COPYRIGHT
+.ds TITLE_TYPE_13 DOC_COVER_TITLE
+.ds TITLE_TYPE_14 COVER_TITLE
 \#
 \# UNDERLINE
 \# ---------
@@ -2054,7 +2053,6 @@ end
 .    \}
 .    nr #TEXT_WIDTH \w'\\$1'
 .    ie \\n[.u]=1 \{\
-.       nop \~
 \Z'\\$1'\
 \Z'\D't \\n[#UNDERSCORE_WEIGHT]''\
 \v'\\*[$UNDERSCORE_GAP]+\\n[#UNDERSCORE_WEIGHT_ADJ]u'\
@@ -2064,7 +2062,6 @@ end
 .       nop
 .    \}
 .    el \{\
-.       nop \ \"
 \Z'\\$1'\
 \Z'\D't \\n[#UNDERSCORE_WEIGHT]''\
 \v'\\*[$UNDERSCORE_GAP]+\\n[#UNDERSCORE_WEIGHT_ADJ]u'\
@@ -2621,9 +2618,13 @@ end
 .    nr #DC_LINES +1
 .    if \\n[#DC_LINES]v>\\n[.t] \{\
 .       nr pgnum \\n%+\\n[#PAGE_NUM_ADJ] 1
-.       tm1 "[mom]: Dropcap at line \\n[.c] does not fit on page \\n[pgnum].
-.       tm1 "       Shifting paragraph to page \\n+[pgnum].
-.       bp
+.       if \\n[#COLUMNS]=1 .ds col-num ", column \\n[#COL_NUM]
+.       tm1 \
+"[mom]: Dropcap at line \\n[.c] does not fit on page \\n[pgnum]\\*[col-num].
+.       tm1 \
+"       Shifting paragraph to next page or column.
+.       ie \\n[#COLUMNS] .COL_NEXT
+.       el .NEWPAGE
 .    \}
 .    ie \\n[#DC_COLOR]=1 \{\
 .       ie !'\\$3'' \{\
@@ -2898,9 +2899,8 @@ end
 .    ds $RL_WEIGHT \\$1
 .    ds $RL_INDENT \\$2
 .    ds $RL_DEPTH  \\$3
-.    ie !'\\$4'' \{\
+.    ie !'\\$4'' \
 .       ds $RL_COLOR  \\$4
-.    \}
 .    el .ds $RL_COLOR \\*[default]
 .    nr #SAVED_WEIGHT     \\n[#RULE_WEIGHT]
 .    nr #SAVED_WEIGHT_ADJ \\n[#RULE_WEIGHT_ADJ]
@@ -2936,7 +2936,7 @@ end
 \# BOXES - DBX
 \# -----------
 \# *Arguments:
-\#   <rule weight | SOLID> <indent> <length> <depth> [ <color> ]
+\#   <rule weight> | SOLID> <indent> <length> <depth> [ <color> ]
 \# *Function:
 \#   Draws described box.
 \# *Notes:
@@ -3029,7 +3029,7 @@ end
 \# ELLIPSES - DCL
 \# --------------
 \# *Arguments:
-\#   <rule weight | SOLID> <indent> <width> <depth> [ <color> ]
+\#   <rule weight> | SOLID> <indent> <width> <depth> [ <color> ]
 \# *Function:
 \#   Draws described ellipses.
 \# *Notes:
@@ -3541,6 +3541,7 @@ end
 .    rr #INDENT_LEFT_ACTIVE
 .    rr #INDENT_RIGHT_ACTIVE
 .    rr #INDENT_BOTH_ACTIVE
+.    rr #INDENT_ACTIVE
 .    if \\n[#INDENT_STYLE_RIGHT] \{\
 .       ie \\n[#TAB_ACTIVE] .TAB\\n[#CURRENT_TAB]
 .       el \{\
@@ -3604,7 +3605,6 @@ end
 .       rr #INDENT_STYLE_RIGHT
 .       rr #INDENT_STYLE_BOTH
 .    \}
-.    rr #INDENT_ACTIVE
 .END
 \#
 \# =====================================================================
@@ -3900,7 +3900,8 @@ end
 \# *Arguments:
 \#   <none> | <anything>
 \# *Function:
-\#   Converts text to smallcaps, or, if OFF, reverts to normal caps/lc.
+\#   Converts text to smallcaps, or, if <anything>, reverts to normal
+\#   caps/lc.
 \# *Notes:
 \#   SMALLCAPS has no inline escape eqiv. to \*[UC].
 \#
@@ -3913,7 +3914,7 @@ end
 .       nr #SMALLCAPS_ON 1
 .       nr #LOOP 0 1
 .       while \\n+[#LOOP]<=58 \{\
-.       char \\*[$c\\n[#LOOP]] \
+.          char \\*[$c\\n[#LOOP]] \
 \Z'\s[\\n[sc*size]u+\\n[sc*extend-factor]u]\H'-\\n[sc*extend-factor]u'\
 \\*[$C\\n[#LOOP]]'\
 \h'\\n[sc*wt-adj-factor]u'\\*[$C\\n[#LOOP]]\s[0]
@@ -4220,15 +4221,16 @@ y\R'#DESCENDER \\n[.cdp]'
 .       nr #LOOP 9       \" loop count
 .       while \\n+[#HD_LEVEL]<=\\n[#LOOP] \{\
 .           HEADING_STYLE \\n[#HD_LEVEL] \
-            FONT   B \
+            FONT  B  \
             SIZE  +0 \
-            QUAD   L \
-            COLOR  black
+            QUAD  L  \
+            NEEDS 1v \
+            COLOR black
 .\"  Set up default style for nine levels of TOC headings
 .           TOC_ENTRY_STYLE \\n[#HD_LEVEL] \
-            FONT   R \
+            FONT  R  \
             SIZE  +0 \
-            COLOR  black
+            COLOR black
 .       \}
 .\" Set up decreasing sizes for headings levels 1 - 3, starting at +3
 .       nr #HD_LEVEL 0 1 \" loop step
@@ -5124,9 +5126,8 @@ y\R'#DESCENDER \\n[.cdp]'
 .       if '\\$1'R' .QUAD-ERROR \\$0
 .       if '\\$1'C' .QUAD-ERROR \\$0
 .    \}
-.    if '\\$0'DOC_QUAD' \{\
+.    if '\\$0'DOC_QUAD' \
 .       if !\\n[#DOCS] .DOC_MACRO_ERROR \\$0
-.    \}
 .    ds PARAM       QUAD
 .    ds ELEMENT     \\$0
 .    if '\\$0'COPYRIGHT_QUAD' \
@@ -5152,6 +5153,7 @@ y\R'#DESCENDER \\n[.cdp]'
 .END
 \#
 .MAC ASSIGN_ELEMENT END
+.    rm $\\*[ELEMENT] \" Clear this first
 .\" HDRFTR_<POSITION>_<PARAMETER> need special handling.
 .    ds hdrftr \\*[FROM_ALIAS]
 .    substring hdrftr 0 5
@@ -5494,22 +5496,23 @@ SMALLCAPS takes precedence.
 .ds STYLE_TYPE_22 FOOTER_CENTER
 .ds STYLE_TYPE_23 FOOTER_CENTRE
 .ds STYLE_TYPE_24 FOOTER_RIGHT
-.ds STYLE_TYPE_25 HEADER_LEFT
-.ds STYLE_TYPE_26 HEADER_CENTER
-.ds STYLE_TYPE_27 HEADER_CENTRE
-.ds STYLE_TYPE_28 HEADER_RIGHT
-.ds STYLE_TYPE_29 LEAD
-.ds STYLE_TYPE_30 LINENUMBER
-.ds STYLE_TYPE_31 MISC
-.ds STYLE_TYPE_32 QUOTE
-.ds STYLE_TYPE_33 PAGENUMBER
-.ds STYLE_TYPE_34 SUBTITLE
-.ds STYLE_TYPE_35 TITLE
-.ds STYLE_TYPE_36 TOC_HEADER
+.ds STYLE_TYPE_25 FOOTNOTE
+.ds STYLE_TYPE_26 HEADER_LEFT
+.ds STYLE_TYPE_27 HEADER_CENTER
+.ds STYLE_TYPE_28 HEADER_CENTRE
+.ds STYLE_TYPE_29 HEADER_RIGHT
+.ds STYLE_TYPE_30 LEAD
+.ds STYLE_TYPE_31 LINENUMBER
+.ds STYLE_TYPE_32 MISC
+.ds STYLE_TYPE_33 QUOTE
+.ds STYLE_TYPE_34 PAGENUMBER
+.ds STYLE_TYPE_35 SUBTITLE
+.ds STYLE_TYPE_36 TITLE
+.ds STYLE_TYPE_37 TOC_HEADER
 .
 .
 .nr #LOOP 0 1
-.while \n+[#LOOP]<=36 \{\
+.while \n+[#LOOP]<=37 \{\
 . ALIAS \*[STYLE_TYPE_\n[#LOOP]]_STYLE           _STYLE
 . ALIAS COVER_\*[STYLE_TYPE_\n[#LOOP]]_STYLE     _STYLE
 . ALIAS DOC_COVER_\*[STYLE_TYPE_\n[#LOOP]]_STYLE _STYLE
@@ -5638,11 +5641,14 @@ SMALLCAPS takes precedence.
 .          el .if !r #T_MARGIN .T_MARGIN 6P
 .       \}
 .    \}
-.    if !r #T_MARGIN          .T_MARGIN \\n[#HEADER_MARGIN]+\\n[#HEADER_GAP]
-.    if !r #DOCHEADER_ADVANCE .nr #DOCHEADER_ADVANCE \\n[#T_MARGIN]
-.    if !r #FOOTER_MARGIN     .FOOTER_MARGIN 3P
-.    if !r #FOOTER_GAP        .FOOTER_GAP 3P
-.    if !r #B_MARGIN          .B_MARGIN \\n[#FOOTER_MARGIN]u+\\n[#FOOTER_GAP]u
+.    if !r #T_MARGIN \
+.       T_MARGIN \\n[#HEADER_MARGIN]+\\n[#HEADER_GAP]
+.    if !r #DOCHEADER_ADVANCE \
+.       nr #DOCHEADER_ADVANCE \\n[#T_MARGIN]
+.    if !r #FOOTER_MARGIN .FOOTER_MARGIN 3P
+.    if !r #FOOTER_GAP    .FOOTER_GAP 3P
+.    if !r #B_MARGIN \
+.       B_MARGIN \\n[#FOOTER_MARGIN]u+\\n[#FOOTER_GAP]u
 .    if !r #HEADER_RULE_GAP .HEADER_RULE_GAP 4p
 .    if !r #FOOTER_RULE_GAP .FOOTER_RULE_GAP 4p
 .    if !r #HDRFTR_RULE     .HDRFTR_RULE
@@ -5662,17 +5668,18 @@ SMALLCAPS takes precedence.
 .    if \\n[#ENDNOTES]     .nr #DOC_PT_SIZE \\n[#EN_PS]
 .    if \\n[#BIBLIOGRAPHY] .nr #DOC_PT_SIZE \\n[#BIB_PS]
 .\"
-.    nr #DOC_LEAD     \\n[.v]
-.    nr address@hidden     \\n[#DOC_LEAD]
+.    nr #DOC_LEAD \\n[.v]
+.    nr address@hidden \\n[#DOC_LEAD]
 .    if \\n[#AUTO_LEAD] .nr #DOC_AUTOLEAD \\n[#AUTOLEAD_VALUE]
 .\" #SAVED_DOC_LEAD is set in COLLATE
 .    if \\n[#SAVED_DOC_LEAD] \{\
 .       if \
-(\\n[#TOC]=0):\
-(\\n[#LIST_OF_FIGURES]=0):\
-(\\n[#LIST_OF_TABLES]=0):\
+(\\n[#TOC]=0)&\
+(\\n[#LIST_OF_FIGURES]=0)&\
+(\\n[#LIST_OF_TABLES]=0)&\
 (\\n[#LIST_OF_EQUATIONS]=0) \
-.          if !\\n[#DOC_LEAD]=\\n[#SAVED_DOC_LEAD] .nr #RERUN_TRAPS 1
+.          ie !\\n[#DOC_LEAD]=\\n[#SAVED_DOC_LEAD] .nr #RERUN_TRAPS 1
+.          el .nr #SKIP_TRAPS 1
 .    \}
 .    ie \\n[#ADJ_DOC_LEAD]=1 .
 .    el \
@@ -5692,7 +5699,10 @@ SMALLCAPS takes precedence.
 .    nr #FN_COUNT_FOR_COLS 0 1
 .    nr #DONE_ONCE         0 1
 .\" Enable shimming if user hasn't turned it off
-.    if \\n[#NO_SHIM]=2    .rr #NO_SHIM
+.   if \\n[#NO_SHIM]=2 \{\
+.      rr #NO_SHIM
+.      nr #NO_FLEX 1
+.   \}
 .\" General style defaults for both PRINTSTYLEs
 .    nr #PP_STYLE 1
 .    PARA_INDENT \\n[#PP_INDENT]u
@@ -5749,19 +5759,19 @@ SMALLCAPS takes precedence.
 .          el .ENDNOTE_NUMBERS_ALIGN RIGHT 4
 .       \}
 .    \}
-.    if !r #EN_LN_GAP         .ENDNOTE_LINENUMBER_GAP 1m
-.    if !r #EN_ALLOWS_HEADERS .ENDNOTES_ALLOWS_HEADERS
-.    if !d $BIB_PN_STYLE      .BIBLIOGRAPHY_PAGENUM_STYLE digit
-.    if !d $BIB_FAM           .BIBLIOGRAPHY_FAMILY \\*[$DOC_FAM]
-.    if !d $BIB_FT            .BIBLIOGRAPHY_FONT R
-.    if !d $BIB_QUAD          .BIBLIOGRAPHY_QUAD \\*[$DOC_QUAD]
-.    if !d $BIB_STRING        .BIBLIOGRAPHY_STRING "Bibliography"
-.    if !d $BIB_STRING_FAM    .BIBLIOGRAPHY_STRING_FAMILY \\*[$BIB_FAM]
-.    if !d $BIB_STRING_QUAD   .BIBLIOGRAPHY_STRING_QUAD CENTER
-.    if !d $TOC_HEADER_STRING .TOC_HEADER_STRING "Contents"
-.    if !d $TOC_HEADER_QUAD   .TOC_HEADER_QUAD LEFT
-.    if !d $TOC_PN_STYLE      .TOC_PAGENUM_STYLE roman
-.    if !r #TOC_PN_PADDING    .TOC_PADDING 3
+.    if !r #EN_LN_GAP            .ENDNOTE_LINENUMBER_GAP 1m
+.    if !r #EN_ALLOWS_HEADERS    .ENDNOTES_ALLOWS_HEADERS
+.    if !d $BIB_PN_STYLE         .BIBLIOGRAPHY_PAGENUM_STYLE digit
+.    if !d $BIB_FAM              .BIBLIOGRAPHY_FAMILY \\*[$DOC_FAM]
+.    if !d $BIB_FT               .BIBLIOGRAPHY_FONT R
+.    if !d $BIB_QUAD             .BIBLIOGRAPHY_QUAD \\*[$DOC_QUAD]
+.    if !d $BIB_STRING           .BIBLIOGRAPHY_STRING "Bibliography"
+.    if !d $BIB_STRING_FAM       .BIBLIOGRAPHY_STRING_FAMILY \\*[$BIB_FAM]
+.    if !d $BIB_STRING_QUAD      .BIBLIOGRAPHY_STRING_QUAD CENTER
+.    if !d $TOC_HEADER_STRING    .TOC_HEADER_STRING "Contents"
+.    if !d $TOC_HEADER_QUAD      .TOC_HEADER_QUAD LEFT
+.    if !d $TOC_PN_STYLE         .TOC_PAGENUM_STYLE roman
+.    if !r #TOC_PN_PADDING       .TOC_PADDING 3
 .\" Line numbering
 .    if !r #LN_GUTTER      .nr #LN_GUTTER 2
 .    if !r #Q_LN_GUTTER    .nr #Q_LN_GUTTER 2
@@ -5853,8 +5863,8 @@ SMALLCAPS takes precedence.
 .       if !r #FN_RULE_LENGTH .FOOTNOTE_RULE_LENGTH 2i
 .\" +Endnotes
 .       if !r #EN_PP_INDENT .ENDNOTE_PARA_INDENT \\n[#PP_INDENT]
-.       if !r #EN_STRING_UNDERLINE .nr #EN_STRING_UNDERLINE 2
 .       if !r #EN_STRING_CAPS .ENDNOTES_HEADER_CAPS
+.       if !r #EN_STRING_UNDERLINE .nr #EN_STRING_UNDERLINE 2
 .\" +Footnotes
 .       if !r #FN_RULE_ADJ .FOOTNOTE_RULE_ADJ 6p
 .\" +Slant stuff
@@ -6230,61 +6240,55 @@ SMALLCAPS takes precedence.
 .       nr #AUTO_LEAD 1
 .       nr #AUTOLEAD_VALUE  \\n[#SAVED_AUTOLEAD_VALUE]
 .    \}
-.    ie !\\n[#COLLATE] \{\
-.\" DOC_LEAD adjusted (or not) here
-.       TRAPS
-.       if \\n[#REMOVE_ADJ] .DOC_LEAD \\n[#DOC_LEAD]u-\\n[#DOC_LEAD_ADJ]u
-.       if (\\n[#FOOTER_MARGIN]+\\n[.v]>=\\n[#B_MARGIN]) \{\
-.          tm1 "[mom]: Your chosen bottom margin for running text is too close 
to the footer margin.
-.          tm1 "       No footers or bottom-of-page page numbers will be 
printed.
-.          tm1 "       Please reset B_MARGIN or FOOTER_MARGIN to allow enough 
space.
-.          tm1 "       If no footers or bottom-of-page page numbers are 
required,
-.          tm1 "       invoke .FOOTER_MARGIN 0 before .START
-.          nr #SKIP_FOOTER 1
-.       \}
+.    if !\\n[#SKIP_TRAPS] .TRAPS
+.    rr #SKIP_TRAPS
+.    if \\n[#REMOVE_ADJ] .DOC_LEAD \\n[#DOC_LEAD]u-\\n[#DOC_LEAD_ADJ]u
+.    if (\\n[#FOOTER_MARGIN]+\\n[.v]>=\\n[#B_MARGIN]) \{\
+.       tm1 "[mom]: Your chosen bottom margin for running text is too close to 
the footer margin.
+.       tm1 "       No footers or bottom-of-page page numbers will be printed.
+.       tm1 "       Please reset B_MARGIN or FOOTER_MARGIN to allow enough 
space.
+.       tm1 "       If no footers or bottom-of-page page numbers are required,
+.       tm1 "       invoke .FOOTER_MARGIN 0 before .START
+.       nr #SKIP_FOOTER 1
+.    \}
 .\" Endnote, bibliography and toc leading
-.       nr #OK_PROCESS_LEAD 1
-.       nr #RESTORE_DOC_LEAD \\n[.v]
-.       nr #RESTORE_B_MARGIN \\n[#B_MARGIN]
-.       if \\n[#PRINT_STYLE]=1 \{\
-.          ie \\n[#SINGLE_SPACE] \{\
-.             ENDNOTE_LEAD      12 ADJUST
-.             BIBLIOGRAPHY_LEAD 12 ADJUST
-.          \}
-.          el \{\
-.             ie \\n[#EN_SINGLESPACE] .ENDNOTE_LEAD 12 ADJUST
-.             el .ENDNOTE_LEAD 24 ADJUST
-.             ie \\n[#BIB_SINGLESPACE] .BIBLIOGRAPHY_LEAD 12 ADJUST
-.             el .BIBLIOGRAPHY_LEAD 24 ADJUST
-.          \}
+.    nr #OK_PROCESS_LEAD 1
+.    nr #RESTORE_DOC_LEAD \\n[.v]
+.    nr #RESTORE_B_MARGIN \\n[#B_MARGIN]
+.    if \\n[#PRINT_STYLE]=1 \{\
+.       ie \\n[#SINGLE_SPACE] \{\
+.          ENDNOTE_LEAD      12 ADJUST
+.          BIBLIOGRAPHY_LEAD 12 ADJUST
 .       \}
-.       if \\n[#PRINT_STYLE]=2 \{\
-.          ie !d $EN_LEAD  .ENDNOTE_LEAD \\n[#UNADJUSTED_DOC_LEAD]u ADJUST
-.          el .ENDNOTE_LEAD \\*[$EN_LEAD] \\*[$ADJUST_EN_LEAD]
-.          ie !d $BIB_LEAD .BIBLIOGRAPHY_LEAD \\n[#UNADJUSTED_DOC_LEAD]u ADJUST
-.          el .BIBLIOGRAPHY_LEAD \\*[$BIB_LEAD] \\*[$ADJUST_BIB_LEAD]
-.          ie !d $TOC_LEAD .TOC_LEAD \\n[#UNADJUSTED_DOC_LEAD]u 
\\*[$ADJUST_TOC_LEAD]
-.          el .TOC_LEAD \\*[$TOC_LEAD] \\*[$ADJUST_TOC_LEAD]
-.       \}
-.       ie !d $BIB_SPACE .BIBLIOGRAPHY_SPACING 0
 .       el \{\
-.          if \\n[#DEFER_BIB_SPACING]=1 \{\
-.             BIBLIOGRAPHY_SPACING \\*[$BIB_SPACE]
-.             rr #DEFER_BIB_SPACING
-.          \}
+.          ie \\n[#EN_SINGLESPACE] .ENDNOTE_LEAD 12 ADJUST
+.          el .ENDNOTE_LEAD 24 ADJUST
+.          ie \\n[#BIB_SINGLESPACE] .BIBLIOGRAPHY_LEAD 12 ADJUST
+.          el .BIBLIOGRAPHY_LEAD 24 ADJUST
 .       \}
-.       nr #DOC_LEAD \\n[#RESTORE_DOC_LEAD]u
-.       nr #B_MARGIN \\n[#RESTORE_B_MARGIN]
-.       vs \\n[#DOC_LEAD]u
 .    \}
+.    if \\n[#PRINT_STYLE]=2 \{\
+.       ie !d $EN_LEAD  .ENDNOTE_LEAD \\n[#UNADJUSTED_DOC_LEAD]u ADJUST
+.       el .ENDNOTE_LEAD \\*[$EN_LEAD] \\*[$ADJUST_EN_LEAD]
+.       ie !d $BIB_LEAD .BIBLIOGRAPHY_LEAD \\n[#UNADJUSTED_DOC_LEAD]u ADJUST
+.       el .BIBLIOGRAPHY_LEAD \\*[$BIB_LEAD] \\*[$ADJUST_BIB_LEAD]
+.       ie !d $TOC_LEAD .TOC_LEAD \\n[#UNADJUSTED_DOC_LEAD]u 
\\*[$ADJUST_TOC_LEAD]
+.       el .TOC_LEAD \\*[$TOC_LEAD] \\*[$ADJUST_TOC_LEAD]
+.    \}
+.    ie !d $BIB_SPACE .BIBLIOGRAPHY_SPACING 0
 .    el \{\
-.       if \\n[#COLLATE] \{\
-.          if !\\n[#PRINT_STYLE]=1 \{\
-.             if \\n[#RERUN_TRAPS] \{\
-.                TRAPS
-.                rr #RERUN_TRAPS
-.             \}
-.          \}
+.       if \\n[#DEFER_BIB_SPACING]=1 \{\
+.          BIBLIOGRAPHY_SPACING \\*[$BIB_SPACE]
+.          rr #DEFER_BIB_SPACING
+.       \}
+.    \}
+.    nr #DOC_LEAD \\n[#RESTORE_DOC_LEAD]u
+.    nr #B_MARGIN \\n[#RESTORE_B_MARGIN]
+.    vs \\n[#DOC_LEAD]u
+.    if !\\n[#PRINT_STYLE]=1 \{\
+.       if \\n[#RERUN_TRAPS] \{\
+.          TRAPS
+.          rr #RERUN_TRAPS
 .       \}
 .    \}
 .\" Set default heading and toc-entry family if not done already
@@ -6431,6 +6435,31 @@ SMALLCAPS takes precedence.
 .    SMALLCAPS off
 .    CAPS off
 .END
+.
+.ALIAS DO_TITLE    DO_TITLE_OR_AUTHOR
+.ALIAS DO_SUBTITLE DO_TITLE_OR_AUTHOR
+.ALIAS DO_AUTHORS  DO_TITLE_OR_AUTHOR
+\#
+.MAC DO_CHAPTER END
+.    fam \\*[$\\*[DOC_]COVER_CHAPTER_FAM]
+.    ft     \\*[$\\*[DOC_]COVER_CHAPTER_FT]
+.    ps \\n[#DOC_PT_SIZE]u\\*[$\\*[DOC_]COVER_CHAPTER_SIZE_CHANGE]
+.    if \\n[#\\*[DOC_]COVER_CHAPTER_COLOR]=1 \
+.       gcolor \\*[$\\*[DOC_]COVER_CHAPTER_COLOR]
+.    if \\n[#\\*[DOC_]COVER_CHAPTER_CAPS]=1 .CAPS
+.    if \\n[#\\*[DOC_]COVER_CHAPTER_SMALLCAPS]=1 .SMALLCAPS
+.    ie \\n[#\\*[DOC_]COVER_CHAPTER_UNDERLINE] \{\
+.       ds $TITLE_TYPE \\*[$COVER_TYPE]CHAPTER
+.       ie \\n[#\\*[DOC_]COVER_CHAPTER_UNDERLINE]=2 \
+.          UNDERSCORE2 \\*[$\\*[DOC_]COVER_CHAPTER_UNDERLINE_GAP] \
+\\*[$\\*[DOC_]COVER_CHAPTER_RULE_GAP] "\\*[$CHAPTER_STRING] \\*[$CHAPTER]"
+.       el .UNDERSCORE "\\*[$CHAPTER_STRING] \\*[$CHAPTER]"
+.    \}
+.    el .PRINT "\\*[$CHAPTER_STRING] \\*[$CHAPTER]"
+.    gcolor
+.    SMALLCAPS off
+.    CAPS off
+.END
 \#
 \# Spacing adjustments for (doc)cover and docheader elements
 \#
@@ -6554,18 +6583,17 @@ SMALLCAPS takes precedence.
 .       if \\n[#PRINT_STYLE]=2 \
 .          if \\n[#DOCHEADER_COLOR]=1 \
 .             gcolor \\*[$DOCHEADER_COLOR]
-.       ie !'\\*[$CHAPTER_TITLE_1]'' \{\
+.       if !'\\*[$CHAPTER_TITLE_1]'' \{\
 .          ds $PRFX CHAPTER_
 .          nr #DOCHEADER 1
 .          DO_TITLE
 .          rr #DOCHEADER
 .          rm $PRFX
 .       \}
-.       el .DO_TITLE
 .    \}
 .\" Chapter string, possibly with a chapter title
 .    el \{\
-.       if \\n[#PRINT_STYLE]=2 \
+.       if \\n[#PRINT_STYLE]=2 \{\
 .          if \\n[#DOCHEADER_COLOR]=1 \
 .             gcolor \\*[$DOCHEADER_COLOR]
 .          if \\n[#CHAPTER_COLOR]=1 \
@@ -6916,20 +6944,20 @@ $\\*[DOC_]COVERTITLE_\\n+[#\\*[DOC_]COVERTITLE_NUM] 
\\$\\n[#\\*[DOC_]COVERTITLE_
 .ALIAS DOC_COVER_IMAGE COVER_IMAGE
 \#
 .MAC DO_COVER_IMAGE END
-. ll \\n[#PAGE_WIDTH]u
-. po 0
-. vs 0
-. sp |0i
-. if \\n[\\*[DOC_]COVER_IMG_Y]   .sp \\n[\\*[DOC_]COVER_IMG_Y]u
-. if \\n[\\*[DOC_]COVER_IMG_X]   .in \\n[\\*[DOC_]COVER_IMG_X]u
-. if \\n[\\*[DOC_]COVER_IMG_IND] .in \\n[\\*[DOC_]COVER_IMG_IND]u
-. if \\n[.u]=1 .nf
-. nop \X'pdf: pdfpic \\*[\\*[DOC_]COVER_IMG_FILE] -L \
+.    ll \\n[#PAGE_WIDTH]u
+.    po 0
+.    vs 0
+.    sp |0i
+.    if \\n[\\*[DOC_]COVER_IMG_Y]   .sp \\n[\\*[DOC_]COVER_IMG_Y]u
+.    if \\n[\\*[DOC_]COVER_IMG_X]   .in \\n[\\*[DOC_]COVER_IMG_X]u
+.    if \\n[\\*[DOC_]COVER_IMG_IND] .in \\n[\\*[DOC_]COVER_IMG_IND]u
+.    if \\n[.u]=1 .nf
+.    nop \X'pdf: pdfpic \\*[\\*[DOC_]COVER_IMG_FILE] -L \
 \\n[\\*[DOC_]COVER_IMG_W]z \\n[\\*[DOC_]COVER_IMG_H]z'
-. in
-. vs
-. po
-. ll
+.    in
+.    vs
+.    po
+.    ll
 .END
 .
 .ALIAS DO_DOC_COVER_IMAGE DO_COVER_IMAGE
@@ -7526,9 +7554,8 @@ $\\*[DOC_]COVERTITLE_\\n+[#\\*[DOC_]COVERTITLE_NUM] 
\\$\\n[#\\*[DOC_]COVERTITLE_
 \#
 .MAC START END
 .    nr #DOCS 1
-.    if \\n[TOC.RELOCATE]==2 \{\
+.    if \\n[TOC.RELOCATE]==2 \
 .       if !\\n[TOC_BH] .TOC_BEFORE_HERE
-.    \}
 .    if !n .nop \X'ps: exec 0 setlinejoin'\X'ps: exec 0 setlinecap'
 .    if !\\n[#PRINT_STYLE] \{\
 .       PRINTSTYLE TYPEWRITE
@@ -7569,12 +7596,10 @@ $\\*[DOC_]COVERTITLE_\\n+[#\\*[DOC_]COVERTITLE_NUM] 
\\$\\n[#\\*[DOC_]COVERTITLE_
 .    nr @L_MARGIN \\n[#DOC_L_MARGIN]
 .    nr @R_MARGIN \\n[#DOC_R_MARGIN]
 .\" Covers and doc covers
-.    if \\n[#DOC_COVERS]=1 \{\
+.    if \\n[#DOC_COVERS]=1 \
 .       if \\n[#DOC_COVER]=1 .DO_DOC_COVER
-.    \}
-.    if \\n[#COVERS]=1 \{\
+.    if \\n[#COVERS]=1 \
 .       if \\n[#COVER]=1 .DO_COVER
-.    \}
 .    nr PDFHREF.VIEW.LEADING \\n[PDFHREF.VIEW.LEADING.T]
 .    if !\\n[#TOC] .RV_HARD_SET_MARGINS
 .    if \\n[#COLUMNS] .COLUMNS \\n[#NUM_COLS] \\n[#GUTTER]u
@@ -7670,7 +7695,8 @@ $\\*[DOC_]COVERTITLE_\\n+[#\\*[DOC_]COVERTITLE_NUM] 
\\$\\n[#\\*[DOC_]COVERTITLE_
 .       ie r#ADVANCE_FROM_TOP \{\
 .          br
 .          sp |\\n[#ADVANCE_FROM_TOP]u-1v
-.          if \\n[#ADJ_DOC_LEAD]=1 .SHIM
+.          if \\n[#ADJ_DOC_LEAD]=1 \
+.             if !\\n[#DOCHEADER_NO_SHIM] .SHIM_1
 .       \}
 .       el \{\
 .          br
@@ -7779,7 +7805,8 @@ $\\*[DOC_]COVERTITLE_\\n+[#\\*[DOC_]COVERTITLE_NUM] 
\\$\\n[#\\*[DOC_]COVERTITLE_
 .       if \\n[#SINGLE_SPACE]=1 .sp
 .    if \\n[#ADJ_DOC_LEAD]=1 \
 .       if \\n[#ADVANCE_FROM_TOP]=0 \
-.          if \\n[#DOC_HEADER]=1 .SHIM
+.          if \\n[#DOC_HEADER]=1 \
+.             if !\\n[#DOCHEADER_NO_SHIM] .SHIM_1
 .    mk dc
 .    FAMILY \\*[$DOC_FAM]
 .    QUAD \\*[$DOC_QUAD]
@@ -7797,6 +7824,23 @@ $\\*[DOC_]COVERTITLE_\\n+[#\\*[DOC_]COVERTITLE_NUM] 
\\$\\n[#\\*[DOC_]COVERTITLE_
 .    \}
 .    nr PDFHREF.VIEW.LEADING \\n[PDFHREF.VIEW.LEADING.H]
 .    vpt
+.    if !r flex .nr flex 1
+.    nr flex-spaces 0
+.\" If one-page, don't flex.
+.    if !dPDF.EXPORT \{\
+.       if \\n[#FLEX_ACTIVE] \{\
+.          if !\\n[#NO_FLEX] \{\
+.             if d address@hidden \
+.                nr #NO_FLEX 1
+.             if d address@hidden \
+.                nr #NO_FLEX 1
+.             if d address@hidden \
+.                nr #NO_FLEX 1
+.             if '\\*[last-page]'address@hidden' \
+.                nr #NO_FLEX 1
+.          \}
+.       \}
+.    \}
 .END
 \#
 .MAC RR_ADVANCE_FROM_TOP END
@@ -7813,6 +7857,7 @@ $\\*[DOC_]COVERTITLE_\\n+[#\\*[DOC_]COVERTITLE_NUM] 
\\$\\n[#\\*[DOC_]COVERTITLE_
 .    rr #NEXT_AUTHOR
 .    rr #NEXT_MISC
 .    wh \\n[nl]u+1u RR_ADVANCE_FROM_TOP
+.    rr #DOCHEADER_NO_SHIM
 .END
 \#
 \# ====================================================================
@@ -7822,7 +7867,7 @@ $\\*[DOC_]COVERTITLE_\\n+[#\\*[DOC_]COVERTITLE_NUM] 
\\$\\n[#\\*[DOC_]COVERTITLE_
 \# DOCUMENT HEADER
 \# ---------------
 \# *Argument:
-\#   <none> | <anything> [distance to advance from top of page]
+\#   <none> | <anything> [distance to advance from top of page] [NO_SHIM]
 \# *Function:
 \#   Turns printing of document header on or off.  If a second
 \#   numeric argument with units of measure is given, advances that
@@ -7834,10 +7879,15 @@ $\\*[DOC_]COVERTITLE_\\n+[#\\*[DOC_]COVERTITLE_NUM] 
\\$\\n[#\\*[DOC_]COVERTITLE_
 \#   (with a unit of measure).
 \#
 .MAC DOCHEADER END
-.    ie '\\$1'' .nr #DOC_HEADER 1
-.    el \{\
-.       if !'\\$2'' .nr #ADVANCE_FROM_TOP (\\$2)
+.    if \\n[#NUM_ARGS]=0 .nr #DOC_HEADER 1
+.    if \\n[#NUM_ARGS]=1 \{\
+.       ie '\\$1'NO_SHIM' .nr #DOCHEADER_NO_SHIM 1
+.       el .nr #DOC_HEADER 0
+.    \}
+.    if \\n[#NUM_ARGS]>1 \{\
 .       nr #DOC_HEADER 0
+.       if \B'\\$2' .nr #ADVANCE_FROM_TOP \\$2
+.       if '\\$3'NO_SHIM' .nr #DOCHEADER_NO_SHIM 1
 .    \}
 .END
 \#
@@ -7988,10 +8038,10 @@ $\\*[DOC_]COVERTITLE_\\n+[#\\*[DOC_]COVERTITLE_NUM] 
\\$\\n[#\\*[DOC_]COVERTITLE_
 .    nr #RESET_TRAPS 1
 .    if !\\n[#ADJ_DOC_LEAD] .nr #REMOVE_ADJ 1
 .    if !'\\$0'DOC_LEAD' \{\
-.       if '\\$0'EN_LEAD' .nr #DOC_LEAD \\n[#EN_LEAD]
+.       if '\\$0'EN_LEAD'  .nr #DOC_LEAD \\n[#EN_LEAD]
 .       if '\\$0'BIB_LEAD' .nr #DOC_LEAD \\n[#BIB_LEAD]
 .       if '\\$0'TOC_LEAD' .nr #DOC_LEAD \\n[#TOC_LEAD]
-.       if '\\$2'ADJUST' .TRAPS
+.       if '\\$2'ADJUST'   .TRAPS
 .       rr #RESET_TRAPS
 .    \}
 .END
@@ -8039,28 +8089,146 @@ $\\*[DOC_]COVERTITLE_\\n+[#\\*[DOC_]COVERTITLE_NUM] 
\\$\\n[#\\*[DOC_]COVERTITLE_
 \# And a macro to disable SHIM
 \#
 .MAC NO_SHIM END
-.    ie '\\$1'' .nr #NO_SHIM 1
-.    el .rr #NO_SHIM
+.    ie '\\$1'' \{\
+.       nr #NO_SHIM 1
+.       nr #FLEX_ACTIVE 1
+.    \}
+.    el \{\
+.       rr #NO_SHIM
+.       rr #SHIM
+.       rr #FLEX_ACTIVE 1
+.   \}
 .END
 \#
 .nr #NO_SHIM 2 \" Restored to 1 in DEFAULTS.
 \#
 .MAC SHIM END
-.    ie \\n[#NO_SHIM] .return
-.    el \{\
-.       nr #VALID_BASELINE \\n[#T_MARGIN]-\\n[#DOC_LEAD] \\n[#DOC_LEAD]
-.       if !r#CURRENT_V_POS .nr #CURRENT_V_POS \\n[.d]
-.       ie \\n[#ADVANCE_FROM_TOP] \{\
-.          ie \\n[#CURRENT_V_POS]<(\\n[#T_MARGIN]-1v) \{\
-.             while \\n-[#VALID_BASELINE]>\\n[#CURRENT_V_POS] .
-.             nr #VALID_BASELINE +\\n[#DOC_LEAD]
-.             nr #SHIM \\n[#VALID_BASELINE]-\\n[#CURRENT_V_POS]
-.          \}
-.          el .PROCESS_SHIM
+.    if \\n[#NO_SHIM] \
+.       if !'\\$0'SHIM_1' .return
+.    if !\\n[#NO_FLEX] \{\
+.       if !'\\$0'SHIM_1' \{\
+.          tm1 "[mom]: 
+SHIM, line \\n[.c], is incompatible with flex-spacing, which is enabled.
+.          tm1 "       
+Flex-spacing must be disabled with NO_FLEX before using SHIM.
+.          ab [mom]: Aborting '\\n[.F]', line \\n[.c].
+.       \}
+.    \}
+.    nr #VALID_BASELINE \\n[#T_MARGIN]-\\n[#DOC_LEAD] \\n[#DOC_LEAD]
+.    if !r#CURRENT_V_POS .nr #CURRENT_V_POS \\n[.d]
+.    ie \\n[#ADVANCE_FROM_TOP] \{\
+.       ie \\n[#CURRENT_V_POS]<(\\n[#T_MARGIN]-1v) \{\
+.          while \\n-[#VALID_BASELINE]>\\n[#CURRENT_V_POS] .
+.          nr #VALID_BASELINE +\\n[#DOC_LEAD]
+.          nr #SHIM \\n[#VALID_BASELINE]-\\n[#CURRENT_V_POS]
 .       \}
 .       el .PROCESS_SHIM
-.       if !\\n[#CALCULATE_ONLY] 'sp \\n[#SHIM]u
-.       rr #CURRENT_V_POS
+.    \}
+.    el .PROCESS_SHIM
+.    if !\\n[#CALCULATE_ONLY] 'sp \\n[#SHIM]u
+.    rr #CURRENT_V_POS
+.END
+\#
+.ALIAS SHIM_1 SHIM
+\#
+\# ====================================================================
+\#
+\# +++FLEX SPACING+++
+\#
+\# INSERT FLEX SPACE
+\# -----------------
+\# *Arguments:
+\#   FORCE
+\# *Function:
+\#   Inserts flexible whitespace ("flex-space").
+\# *Notes:
+\#   FORCE restores flex-spacing if an .ns is preventing it.
+\#   Useful in conjunction with deferred floated material that
+\#   plants an .ns after outputting the last deferred float.
+\#
+.MAC FLEX END
+.    if !\\n[#NO_SHIM] \{\
+.       if \\n[#NO_FLEX] \{\
+.          tm1 "[mom]: \
+FLEX, line \\n[.c], is incompatible with shimming, which is presently enabled.
+.          tm1 "       \
+Shimming must be disabled with NO_SHIM before using FLEX.
+.          ab   [mom]: Aborting '\\n[.F]', line \\n[.c].
+.       \}
+.    \}
+.    if '\\$1'FORCE' \{\
+.       nr flex:force 1
+.       return
+.    \}
+.    if !\\n[#NO_FLEX] \{\
+.       if !\\n[.ns] \{\
+.          if !\\n[.t]<=\\n[.v] \{\
+.             nr flex-spaces +1
+.             if dflex-space:address@hidden \{\
+.                sp \\*[flex-space:address@hidden
+.             \}
+.          \}
+.       \}
+.    \}
+.END
+\#
+.MAC NO_FLEX END
+.    rr flexed
+.    ie '\\$1'' \{\
+.       nr #NO_FLEX 1
+.       if \\n[#FLEX_ACTIVE] .rr #FLEX_ACTIVE
+.    \}
+.    el .rr #NO_FLEX
+.END
+\#
+\# CALCULATE FLEX SPACES
+\# ---------------------
+\# *Function:
+\#   Derives flex-space size by dividing the space remaining before
+\#   FOOTER by the number of times FLEX was used on the page/col.
+\# *Notes:
+\#   .h is reliable for determining space remaining, but can't be used
+\#   for columns because it can't be zeroed from one col to the
+\#   next.  Workaround is to use nl for columns and compensate for
+\#   .br's, .sp's, and .ne's.  Here be dragons.
+\#
+.MAC CALCULATE_FLEX END
+.    nr flex:target-pos \\n[.p]+\\n[#VARIABLE_FOOTER_POS]-1
+.    nr flex:current-pos \\n[.h]-\\n[.v]
+.    if \\n[#COLUMNS] \{\
+.       ie \\n[.trunc] \
+.          nr flex:current-pos \\n[nl]-\\n[.v]-(\\n[.trunc]-1)
+.       el .nr flex:current-pos \\n[nl]-\\n[.v]
+.       if '\\n[.ev]'tbl*end' \{\
+.          nr flex:current-pos \\n[nl]-(\\n[.trunc]-1)
+.          if \\n[tbl*boxed] .nr flex:current-pos -.65v
+.       \}
+.       ie \\n[nl-from-heading] \{\
+.          nr flex:current-pos \\n[nl-from-heading]-\\n[.v]
+.          rr nl-from-heading
+.       \}
+.       el \{\
+.          if !\\n[.pe] \{\
+.             if \\n[nl]=(\\n[.p]+(\\n[#VARIABLE_FOOTER_POS]-1)) \
+.                nr flex-spaces -1
+.          \}
+.       \}
+.    \}
+.    nr flex:space-remaining \
+        \\n[flex:target-pos]-\\n[flex:current-pos]
+.    if \\n[flex-spaces] \{\
+.       nr flex-space:address@hidden \
+           \\n[flex:space-remaining]/\\n[flex-spaces]
+.       if dPDF.EXPORT \{\
+.          tm .ds flex-space:address@hidden \
+              \\n[flex-space:address@hidden
+.\" For debugging: catch edge-cases that result in negative
+.\" flex-spacing and don't apply flex to the page/column.
+.          if \\n[flex-space:address@hidden<0 \{\
+.             tm .ds flex-space:address@hidden 0
+.             tm .ds Negative flex space address@hidden 
(\\n[flex-space:address@hidden)
+.          \}
+.       \}
 .    \}
 .END
 \#
@@ -8740,9 +8908,8 @@ $\\*[DOC_]COVERTITLE_\\n+[#\\*[DOC_]COVERTITLE_NUM] 
\\$\\n[#\\*[DOC_]COVERTITLE_
 .    if '\\*[POSITION]'L' .ds POSITION LEFT
 .    if '\\*[POSITION]'C' .ds POSITION CENTER
 .    if '\\*[POSITION]'R' .ds POSITION RIGHT
-.    if \\n[#HDRFTR_\\*[POSITION]_CAPS]=1 \{\
+.    if \\n[#HDRFTR_\\*[POSITION]_CAPS]=1 \
 .       CAPS_SMALLCAPS_WARNING \\*[POSITION]
-.    \}
 .    ie '\\$1'' .nr #HDRFTR_\\*[POSITION]_SMALLCAPS 1
 .    el \
 .       nr #HDRFTR_\\*[POSITION]_SMALLCAPS 0
@@ -8779,7 +8946,8 @@ $\\*[DOC_]COVERTITLE_\\n+[#\\*[DOC_]COVERTITLE_NUM] 
\\$\\n[#\\*[DOC_]COVERTITLE_
 .       ds $HDRFTR_CENTER_OLD \\*[$HDRFTR_CENTER]
 .       ds $HDRFTR_CENTER_NEW \\$1
 .    \}
-.    ds $HDRFTR_CENTER \\$1
+.    ie '\\$1'TOC' .ds $TOC_HDRFTR_CENTER \\$2
+.    el .ds $HDRFTR_CENTER \\$1
 .END
 \#
 \# HDRFTR CENTER CAPS AND SMALLCAPS
@@ -8793,9 +8961,8 @@ $\\*[DOC_]COVERTITLE_\\n+[#\\*[DOC_]COVERTITLE_NUM] 
\\$\\n[#\\*[DOC_]COVERTITLE_
 \#   Default is on.
 \#
 .MAC HDRFTR_CENTER_SMALLCAPS END
-.    if \\n[#HDRFTR_CENTER_SMALLCAPS]=1 \{\
+.    if \\n[#HDRFTR_CENTER_SMALLCAPS]=1 \
 .       CAPS_SMALLCAPS_WARNING CENTER
-.    \}
 .    ie '\\$1'' .nr #HDRFTR_CENTER_SMALLCAPS 1
 .    el \
 .       nr #HDRFTR_CENTER_SMALLCAPS 0
@@ -8875,9 +9042,8 @@ $\\*[DOC_]COVERTITLE_\\n+[#\\*[DOC_]COVERTITLE_NUM] 
\\$\\n[#\\*[DOC_]COVERTITLE_
 \#   Default is on.
 \#
 .MAC HDRFTR_RIGHT_SMALLCAPS END
-.    if \\n[#HDRFTR_RIGHT_SMALLCAPS]=1 \{\
+.    if \\n[#HDRFTR_RIGHT_SMALLCAPS]=1 \
 .       CAPS_SMALLCAPS_WARNING RIGHT
-.    \}
 .    ie '\\$1'' .nr #HDRFTR_RIGHT_SMALLCAPS 1
 .    el \
 .       nr #HDRFTR_RIGHT_SMALLCAPS 0
@@ -9458,9 +9624,8 @@ $\\*[DOC_]COVERTITLE_\\n+[#\\*[DOC_]COVERTITLE_NUM] 
\\$\\n[#\\*[DOC_]COVERTITLE_
 .       ie \\n[#HDRFTR_COLOR]=1 \m[\\*[$HDRFTR_COLOR]]
 .       el \m[black]
 .    \}
-.    if \\n[#HDRFTR_RULE] \{\
+.    if \\n[#HDRFTR_RULE] \
 .       HDRFTR_RULE_INTERNAL
-.    \}
 .END
 \#
 \# +++HEADERS+++
@@ -9513,19 +9678,17 @@ $\\*[DOC_]COVERTITLE_\\n+[#\\*[DOC_]COVERTITLE_NUM] 
\\$\\n[#\\*[DOC_]COVERTITLE_
 \# *Arguments:
 \#   <none>
 \# *Function:
-\#   Prints header appropriate to DOC_TYPE, PRINTSTYLE, and COPYSTYLE.
-\# *Notes:
-\#   In order to convert the title string to caps in the header
-\#   (in the event that the user enters .TITLE in caps/lc), I've
-\#   used quad left, quad centre, and quad right to arrange the
-\#   three bits of the header, rather than .tl.  This allows the
-\#   use of the CAPS macro.  The downside is that I have to add
-\#   \\v'-(\\n[#LEAD]u*<n>) in order for -Tlatin1 output to align
-\#   the header/footer strings on the baseline.  The console output
-\#   still isn't brilliant, but at least it's comprehensible.
+\#   Resets margin notes, processes footnote and margin note
+\#   leftover, takes care of recto-verso, prepares for columns after
+\#   first, determines whether to flex-space the page,,outputs
+\#   deferred floats, and does some tbl magic.  If headers are
+\#   enabled, prints header appropriate to DOC_TYPE, PRINTSTYLE, and
+\#   COPYSTYLE.
 \#
 .MAC HEADER END
 .    vpt 0
+.    nr flex-spaces 0
+.    nr flex +1
 .    if \\n[#NEW_DOC_PT_SIZE] .nr #DOC_PT_SIZE \\n[#NEW_DOC_PT_SIZE]
 .    rr #NEW_DOC_PT_SIZE
 .    if \\n[#RESET_TRAPS] \{\
@@ -9541,6 +9704,7 @@ $\\*[DOC_]COVERTITLE_\\n+[#\\*[DOC_]COVERTITLE_NUM] 
\\$\\n[#\\*[DOC_]COVERTITLE_
 .    if \\n[#FN_DEPTH] .PROCESS_FN_LEFTOVER
 .    rr #RULED
 .    if \\n[#RESET_FN_NUMBER] .nr #FN_NUMBER 0 1
+.    if !\\n[#DIVERTED] .rr #PREV_FN_DEFERRED
 .    po \\n[#DOC_L_MARGIN]u
 .    if \\n[#RECTO_VERSO] \{\
 .       if !\\n[#TOC_RV_SWITCH]=2 \{\
@@ -9586,9 +9750,8 @@ $\\*[DOC_]COVERTITLE_\\n+[#\\*[DOC_]COVERTITLE_NUM] 
\\$\\n[#\\*[DOC_]COVERTITLE_
 .    sp -1v
 .    ie \\n[#HEADERS_ON] .PRINT_HDRFTR
 .    el \{\
-.       if \\n[#PAGE_NUM_V_POS]=1 \{\
+.       if \\n[#PAGE_NUM_V_POS]=1 \
 .          if \\n[#PAGINATE] .PRINT_PAGE_NUMBER
-.       \}
 .    \}
 .    sp |\\n[#T_MARGIN]u-\\n[#DOC_LEAD]u
 .    if \\n[#PRINT_STYLE]=1 \{\
@@ -9717,12 +9880,36 @@ $\\*[DOC_]COVERTITLE_\\n+[#\\*[DOC_]COVERTITLE_NUM] 
\\$\\n[#\\*[DOC_]COVERTITLE_
 .    ch address@hidden
 .    ie \\n[tbl*have-header] .rr @TOP
 .    el .wh \\n[nl]u+1u address@hidden
+.    if \\n[#FLEX_ACTIVE] \{\
+.       if \\n[#RESTORE_FLEX] \{\
+.          rr #NO_FLEX
+.          rr #RESTORE_FLEX
+.       \}
+.       if \\n[#RESTORE_COL_FLEX] \{\
+.          rr #NO_FLEX
+.          rr #RESTORE_COL_FLEX
+.       \}
+.    \}
+.\"  Don't flex the last page/col, or the page/col before a COLLATE,
+.\"  NEWPAGE, COL_NEXT, or BLANKPAGE.
+.    if !dPDF.EXPORT \{\
+.       if \\n[#FLEX_ACTIVE] \
+.          if !\\n[#NO_FLEX] \
+.             nr #RESTORE_FLEX 1
+.       if '\\*[last-page]'address@hidden' \
+.          if !\\n[#NO_FLEX] .nr #NO_FLEX 1
+.       if '\\*[pre-collate-\\n%]'address@hidden' \
+.          if !\\n[#NO_FLEX] .nr #NO_FLEX 1
+.       if '\\*[pre-newpage-\\n%]'address@hidden' \
+.          if !\\n[#NO_FLEX] .nr #NO_FLEX 1
+.       if d address@hidden .nr #NO_FLEX 1
+.    \}
 .    ie \\n[defer] .PROCESS_FLOATS
 .    el \{\
 .       if \\n[tbl*have-caption] \{\
 .          RESTORE_SPACE
-.          ie \\n[#MLA] .sp \n[tbl*label-lead-diff]u
-.          el .sp \n[tbl*caption-lead-diff]u
+.          ie \\n[#MLA] .sp \\n[tbl*label-lead-diff]u
+.          el .sp \\n[tbl*caption-lead-diff]u
 .       \}
 .    \}
 .\" So tables without TH that don't fit don't overprint first row
@@ -9732,7 +9919,7 @@ $\\*[DOC_]COVERTITLE_\\n+[#\\*[DOC_]COVERTITLE_NUM] 
\\$\\n[#\\*[DOC_]COVERTITLE_
 .       nop \&
 .       vpt
 .       rr \\n[tbl*no-header]
-.       SHIM
+.       SHIM_1
 .    \}
 .    el .vpt
 .    if \\n[#NEWPAGE] .rr #NEWPAGE
@@ -9740,10 +9927,12 @@ $\\*[DOC_]COVERTITLE_\\n+[#\\*[DOC_]COVERTITLE_NUM] 
\\$\\n[#\\*[DOC_]COVERTITLE_
 .       tbl*print-header
 .       rr tbl*interrupted
 .      \}
-.    el address@hidden
+.    el .if !r tbl*no-top-hook address@hidden
+.    rr tbl*no-top-hook
 .    if \\n[#QUOTE]=1 \
 .       if '\\*[$Q_QUAD]'LEFT' .po \\n[#Q_OFFSET]u
 .    if \\n[#QUOTE]=2 .po \\n[#BQ_OFFSET]u
+.    if r flex:force .rr flex:force
 .END
 \#
 \# ====================================================================
@@ -9807,13 +9996,16 @@ $\\*[DOC_]COVERTITLE_\\n+[#\\*[DOC_]COVERTITLE_NUM] 
\\$\\n[#\\*[DOC_]COVERTITLE_
 \# *Arguments:
 \#   <none>
 \# *Function:
-\#   Places footer at bottom of page if #FOOTERS=1, otherwise
-\#   places page number at bottom of page (if #PAGINATE=1).
-\#   Page numbers are in arabic or roman according to COPYSTYLE.
-\#   DRAFT starts the document at page 1 regardless of PAGENUMBER.
-\#   FINAL respects PAGENUMBER.
+\#   Gathers strings for flex-spacing, processes margin notes and
+\#   footnotes, prepares for move to next column or page.  Places
+\#   footer at bottom of page if #FOOTERS=1, otherwise places page
+\#   number at bottom of page (if #PAGINATE=1).  Page numbers are
+\#   in arabic or roman according to COPYSTYLE.  DRAFT starts the
+\#   document at page 1 regardless of PAGENUMBER.  FINAL respects
+\#   PAGENUMBER.
 \#
 .MAC FOOTER END
+.    CALCULATE_FLEX
 .    if \\n[#DOING_COVERTEXT] \{\
 .       tm1 "[mom]: COVERTEXT exceeds cover page depth.
 .       ab   [mom]: Aborting '\\n[.F]'.
@@ -9822,7 +10014,8 @@ $\\*[DOC_]COVERTITLE_\\n+[#\\*[DOC_]COVERTITLE_NUM] 
\\$\\n[#\\*[DOC_]COVERTITLE_
 .    rr #LB_4_HD
 .    rr #QUOTE_4_HD
 .    nr #SAVED_LEAD \\n[.v]
-.    ev PAGE_TRANSITION
+.    if !r pg-trans .nr pg-trans 0 1
+.    ev PAGE_TRANSITION\\n+[pg-trans]
 .    pdfmarksuspend
 .    ie !n .nop \X'ps: exec decornone'
 .    el .ul 0
@@ -9867,14 +10060,15 @@ $\\*[DOC_]COVERTITLE_\\n+[#\\*[DOC_]COVERTITLE_NUM] 
\\$\\n[#\\*[DOC_]COVERTITLE_
 .             nr #FROM_FOOTER 1
 .          \}
 .          nf
+.          ch FN_OVERFLOW_TRAP -\\n[#FN_OVERFLOW_TRAP_POS]u
 .          FOOTNOTES
 .          rm FOOTNOTES
-.          if d RUNON_FOOTNOTES    .rm RUNON_FOOTNOTES
+.          if d RUNON_FOOTNOTES   .rm RUNON_FOOTNOTES
 .          if \\n[#PRINT_STYLE]=1 .vs \\n[#SAVED_LEAD]u
 .          if \\n[#PRINT_STYLE]=2 .LS \\n[#SAVED_LEAD]u
 .          if '\\n[.z]'FN_OVERFLOW' \{\
-.              di
-.              nr #FN_OVERFLOW_DEPTH \\n[#DIVER_DEPTH]
+.             di
+.             nr #FN_OVERFLOW_DEPTH \\n[#DIVER_DEPTH]
 .          \}
 .          nr #FN_COUNT_AT_FOOTER \\n[#FN_COUNT]
 .          nr #FN_COUNT 0
@@ -9887,7 +10081,7 @@ $\\*[DOC_]COVERTITLE_\\n+[#\\*[DOC_]COVERTITLE_NUM] 
\\$\\n[#\\*[DOC_]COVERTITLE_
 .    \}
 .    nr @TOP 1
 .    ie \\n[#COLUMNS]=1 \{\
-.       ie \\n[#COL_NUM]=\\n[#NUM_COLS] .DO_FOOTER
+.       ie (\\n[#COL_NUM]=\\n[#NUM_COLS]):(\\n[#NEWPAGE]=1) .DO_FOOTER
 .       el \{\
 .          ie (\\n[#ENDNOTES]=1):(\\n[#BIBLIOGRAPHY]=1) \{\
 .             if \\n[#ENDNOTES] .sp |\\n[ec]u-\\n[#EN_LEAD]u
@@ -9895,9 +10089,32 @@ $\\*[DOC_]COVERTITLE_\\n+[#\\*[DOC_]COVERTITLE_NUM] 
\\$\\n[#\\*[DOC_]COVERTITLE_
 .          \}
 .          el \{\
 .            vs \\n[#SAVED_LEAD]u
-.            sp |\\n[dc]u
+.            rt \\n[dc]u
+.            nr flex-spaces 0
+.          \}
+.          if d address@hidden \{\
+.             rr #NO_FLEX
+.             rr #RESTORE_COL_FLEX
 .          \}
 .          po \\n[#COL_\\n+[#COL_NUM]_L_MARGIN]u
+.          if !dPDF.EXPORT \{\
+.             if \\n[#FLEX_ACTIVE] \{\
+.                if !\\n[#NO_FLEX] \{\
+.                   if '\\*[last-page]'address@hidden' \
+.                       nr #NO_FLEX 1
+.                   if '\\*[pre-collate]'address@hidden' \
+.                       nr #NO_FLEX 1
+.                   if '\\*[pre-newpage-\\n%]'address@hidden' \{\
+.                      nr #NO_FLEX 1
+.                      nr #RESTORE_FLEX 1
+.                   \}
+.                   if d address@hidden \{\
+.                      nr #NO_FLEX 1
+.                      nr #RESTORE_COL_FLEX 1
+.                   \}
+.                \}
+.             \}
+.          \}
 .          nr #L_MARGIN \\n[.o]
 .          if \\n[#FN_DEPTH] .PROCESS_FN_LEFTOVER
 .          vs \\n[#SAVED_LEAD]u
@@ -9949,6 +10166,12 @@ $\\*[DOC_]COVERTITLE_\\n+[#\\*[DOC_]COVERTITLE_NUM] 
\\$\\n[#\\*[DOC_]COVERTITLE_
 .                po \\n[#EPI_OFFSET]u
 .             \}
 .          \}
+.          ie \\n[tbl*interrupted] \{\
+.             tbl*print-header
+.             rr tbl*interrupted
+.            \}
+.          el .if !r tbl*no-top-hook address@hidden
+.          rr tbl*no-top-hook
 .          ie \\n[#EPIGRAPH] \{\
 .             ie !\\n[#EPI_ACTIVE] \{\
 .                ns
@@ -9973,9 +10196,10 @@ $\\*[DOC_]COVERTITLE_\\n+[#\\*[DOC_]COVERTITLE_NUM] 
\\$\\n[#\\*[DOC_]COVERTITLE_
 .          nop \&
 .          vpt
 .          rr \\n[tbl*no-header]
-.          SHIM
+.          SHIM_1
 .       \}
 .       el .vpt
+.       if '\\n[.ev]'caption' .rs
 .       if \\n[tbl*interrupted] .tbl*print-header
 .       rr tbl*interrupted
 .    \}
@@ -10013,9 +10237,6 @@ $\\*[DOC_]COVERTITLE_\\n+[#\\*[DOC_]COVERTITLE_NUM] 
\\$\\n[#\\*[DOC_]COVERTITLE_
 .END
 \#
 .MAC PRINT_FOOTER END
-.\" Have to change position of FN_OVERFLOW_TRAP or it screws up the
-.\" placement of page numbers (or footers).  It's reset to its original
-.\" position at the end of the macro.
 .    if r #SAVED_FOOTER_POS .ch FOOTER \\n[#SAVED_FOOTER_POS]u
 .    rr #SAVED_FOOTER_POS
 .    vpt 0
@@ -10025,7 +10246,6 @@ $\\*[DOC_]COVERTITLE_\\n+[#\\*[DOC_]COVERTITLE_NUM] 
\\$\\n[#\\*[DOC_]COVERTITLE_
 .       sp |\\n[#PAGE_LENGTH]u-\\n[#FOOTER_MARGIN]u
 .    el \
 .       sp |\\n[#PAGE_LENGTH]u-\\n[#FOOTER_MARGIN]u-\\n[#FOOTER_ADJ]u
-.    mk y
 .    UNDERLINE OFF
 .    po \\n[#DOC_L_MARGIN]u
 .    ll \\n[#DOC_L_LENGTH]u
@@ -10033,7 +10253,7 @@ $\\*[DOC_]COVERTITLE_\\n+[#\\*[DOC_]COVERTITLE_NUM] 
\\$\\n[#\\*[DOC_]COVERTITLE_
 .    if \\n[#PRINT_STYLE]=1 .TYPEWRITER
 .    if \\n[#PRINT_STYLE]=2 \{\
 .       fam  \\*[$HDRFTR_FAM]
-.       ft      R
+.       ft   R
 .       ps \\n[#DOC_PT_SIZE]u\\*[$HDRFTR_SIZE_CHANGE]
 .    \}
 .    nr #HDRFTR_PT_SIZE \\n[#PT_SIZE]
@@ -10187,6 +10407,7 @@ $\\*[DOC_]COVERTITLE_\\n+[#\\*[DOC_]COVERTITLE_NUM] 
\\$\\n[#\\*[DOC_]COVERTITLE_
 \#   If PARAHEAD given, HEADING must come after PP.
 \#
 .MAC HEADING END
+.    br
 .    if !\B'\\$1' \{\
 .       tm1 "[mom]: The first argument to \\$0 must be a numeric heading level.
 .       ab   [mom]: Aborting '\\n[.F]' at \\$0, line \\n[.c].
@@ -10212,18 +10433,18 @@ $\\*[DOC_]COVERTITLE_\\n+[#\\*[DOC_]COVERTITLE_NUM] 
\\$\\n[#\\*[DOC_]COVERTITLE_
 .      \}
 .    \}
 .\" Spacing
-.    if \\n[#Q_LEAD_DIFF_CHECK] .sp -1v
-.    br
+.    if \\n[#Q_LEAD_DIFF_CHECK] .sp -1
+.    if \\n[.t]<\\n[.v] .nr nl-from-heading \\n[nl]
 .    ie !\\n[#PARAHEAD] \{\
 .       if address@hidden \{\
 .          nr #HEAD 1
-.          mk \" .ne adds 1u so mark vertical position
-.          ie \\n[#HEAD_\\n[#LEVEL]_SPACE_AFTER] .ne \\n[#NUM_ARGS]+2
-.          el .ne \\n[#NUM_ARGS]+1
-.          rt
-.          vpt 0
-.          ie !\\n[#START] \
+.          ie !\\n[#START] \{\
+.             nr #HEADING_NEEDS \\n[#NUM_ARGS]v+\\*[$HEAD_\\n[#LEVEL]_NEEDS]+1v
+.             if \\n[#HEAD_\\n[#LEVEL]_SPACE_AFTER] .nr #HEADING_NEEDS +1v
+.             if \\n[.t]<\\n[#HEADING_NEEDS] .sp \\n[.t]u
+.             vpt 0
 .             if !\\n[#SPACE_ADDED] .if !\\n[#LINEBREAK] .sp
+.          \}
 .          el \{\
 .             ie !\\n[#PP] .rr #START
 .             el .sp
@@ -10233,8 +10454,17 @@ $\\*[DOC_]COVERTITLE_\\n+[#\\*[DOC_]COVERTITLE_NUM] 
\\$\\n[#\\*[DOC_]COVERTITLE_
 .       \}
 .       if \\n[#PP_SPACE] \
 .          if \\n[#QUOTE_4_HD] .sp .5v
-.       if !\\n[#SPACE_ADDED] .SHIM
-.       if \\n[#SPACE_ADDED] .rr #SPACE_ADDED
+.       ie !\\n[#SPACE_ADDED] \{\
+.          if !\\n[.ns] \{\
+.             ie !\\n[#NO_SHIM] \
+.                if !\\n[#HEAD_\\n[#LEVEL]_NO_SHIM] .SHIM
+.             el \{\
+.                if !\\n[#NO_FLEX] \
+.                   if !\\n[#HEAD_\\n[#LEVEL]_NO_FLEX] .FLEX 
+.             \}
+.          \}
+.       \}
+.       el .rr #SPACE_ADDED
 .       vpt
 .    \}
 .    el \{\
@@ -10570,9 +10800,8 @@ $\\*[DOC_]COVERTITLE_\\n+[#\\*[DOC_]COVERTITLE_NUM] 
\\$\\n[#\\*[DOC_]COVERTITLE_
 .       \}
 .       if !\\n[#HD_NUM_INDENT] .nr #HD_NUM_INDENT \w'\\*[$HD_NUM]'
 .    \}
-.    if !\\n[#PARAHEAD] \{\
+.    if !\\n[#PARAHEAD] \
 .       if \\n[#HEAD_\\n[#LEVEL]_SPACE_AFTER] .sp
-.    \}
 .    if \\n[#CAPS_OFF] \{\
 .       CAPS OFF
 .       rr #CAPS_OFF
@@ -10605,6 +10834,7 @@ $\\*[DOC_]COVERTITLE_\\n+[#\\*[DOC_]COVERTITLE_NUM] 
\\$\\n[#\\*[DOC_]COVERTITLE_
 .       sp -1
 .    \}
 .    vpt
+.    rr nl-from-heading
 .END
 \#
 \# HEADING_STYLE
@@ -10670,7 +10900,7 @@ $\\*[DOC_]COVERTITLE_\\n+[#\\*[DOC_]COVERTITLE_NUM] 
\\$\\n[#\\*[DOC_]COVERTITLE_
 .             tm1 "[mom]: The UNDERSCORE argument to \\$0 requires a rule gap.
 .             ab   [mom]: Aborting '\\n[.F]' at \\$0, line \\n[.c].
 .          \}
-.          ds $HEAD_\\n[#LEVEL]_UL_GAP    \\$1
+.          ds $HEAD_\\n[#LEVEL]_UL_GAP \\$1
 .          shift
 .       \}
 .       if '\\$1'NO_UNDERSCORE' \{\
@@ -10690,7 +10920,7 @@ $\\*[DOC_]COVERTITLE_\\n+[#\\*[DOC_]COVERTITLE_NUM] 
\\$\\n[#\\*[DOC_]COVERTITLE_
 .             tm1 "[mom]: The UNDERSCORE2 argument to \\$0 requires a rule gap.
 .             ab   [mom]: Aborting '\\n[.F]' at \\$0, line \\n[.c].
 .          \}
-.          ds $HEAD_\\n[#LEVEL]_UL2_GAP_1  \\$1
+.          ds $HEAD_\\n[#LEVEL]_UL2_GAP_1 \\$1
 .          shift
 .          if '\\$1'' \{\
 .             tm1 "[mom]: The UNDERSCORE2 argument to \\$0 requires an 
inter-rule gap.
@@ -10778,6 +11008,27 @@ $\\*[DOC_]COVERTITLE_\\n+[#\\*[DOC_]COVERTITLE_NUM] 
\\$\\n[#\\*[DOC_]COVERTITLE_
 .          nr #FROM_STYLE_\\n[#LEVEL] 1
 .          shift
 .       \}
+.       if '\\$1'NEEDS' \{\
+.          shift
+.          ds $HEAD_\\n[#LEVEL]_NEEDS \\$1
+.          shift
+.       \}
+.       if '\\$1'SHIM' \{\
+.          rr #HEAD_\\n[#LEVEL]_NO_SHIM
+.          shift
+.       \}
+.       if '\\$1'NO_SHIM' \{\
+.          nr #HEAD_\\n[#LEVEL]_NO_SHIM 1
+.          shift
+.       \}
+.       if '\\$1'FLEX' \{\
+.          rr #HEAD_\\n[#LEVEL]_NO_FLEX
+.          shift
+.       \}
+.       if '\\$1'NO_FLEX' \{\
+.          nr #HEAD_\\n[#LEVEL]_NO_FLEX 1
+.          shift
+.       \}
 .    \}
 .    rr #LEVEL
 .    if d$TOC .rm $TOC
@@ -11120,9 +11371,8 @@ $\\*[DOC_]COVERTITLE_\\n+[#\\*[DOC_]COVERTITLE_NUM] 
\\$\\n[#\\*[DOC_]COVERTITLE_
 \#   PRINTSTYLE TYPEWRITE without SINGLESPACE.
 \#
 .MAC PARA_SPACE END
-.    ie '\\$1'' \{\
+.    ie '\\$1'' \
 .       nr #PP_SPACE 1
-.    \}
 .    el \{\
 .       ie \B'\\$1' \{\
 .          nr #PP_SPACE 1
@@ -11145,16 +11395,12 @@ $\\*[DOC_]COVERTITLE_\\n+[#\\*[DOC_]COVERTITLE_NUM] 
\\$\\n[#\\*[DOC_]COVERTITLE_
 \#   PP_STYLE 1 = regular paras; 2 = blockquotes, epigraphs
 \#
 .MAC PP END
-.    br
 .    if \\n[#COVERTEXT_PP] \{\
 .       ie \\n[#INDENT_ACTIVE] .ti \\n[#INDENT]u+\\n[#PP_INDENT]u
 .       el .ti \\n[#PP_INDENT]u
 .       return
 .    \}
-.    if \\n[defer-pp-ind-reset] \{\
-.       sp -1
-.       rr defer-pp-ind-reset
-.    \}
+.    br
 .    if \\n[#DOC_TYPE]=4 \{\
 .       if !'\\n[.z]'' .di
 .       nr #TOTAL_FIELDS \\n[#FIELD]
@@ -11196,9 +11442,8 @@ $\\*[DOC_]COVERTITLE_\\n+[#\\*[DOC_]COVERTITLE_NUM] 
\\$\\n[#\\*[DOC_]COVERTITLE_
 .          ie \\n[#ENDNOTE] .vs \\n[#EN_LEAD]u
 .          el .vs \\n[#DOC_LEAD]u
 .          QUAD \\*[$DOC_QUAD]
-.          if \\n[#SLANT_ON] \{\
+.          if \\n[#SLANT_ON] \
 .             if \\n[#UNDERLINE_SLANT] .UNDERLINE
-.          \}
 .          if '\\*[$PP_FT]'I' \
 .             if \\n[#ITALIC_MEANS_ITALIC] .FT I
 .       \}
@@ -11243,7 +11488,7 @@ $\\*[DOC_]COVERTITLE_\\n+[#\\*[DOC_]COVERTITLE_NUM] 
\\$\\n[#\\*[DOC_]COVERTITLE_
 .       el \{\
 .          if \\n[#PP_SPACE] \{\
 .             ie \\n[#END_QUOTE] \{\
-.                ie !'\\*[$PP_SPACE_AMOUNT]'' .ALD \\*[$PP_SPACE_AMOUNT]
+.                ie !'\\*[$PP_SPACE_AMOUNT]'' .sp \\*[$PP_SPACE_AMOUNT]
 .                el .sp
 .                rr #END_QUOTE
 .                nr #NO_SPACE 1
@@ -11251,8 +11496,15 @@ $\\*[DOC_]COVERTITLE_\\n+[#\\*[DOC_]COVERTITLE_NUM] 
\\$\\n[#\\*[DOC_]COVERTITLE_
 .             \}
 .             el \{\
 .                if \\n[#NO_SPACE]=1 .rr #NO_SPACE
+.                if \\n[post-float] \{\
+.                   if (\\n[.t]-1)<\\*[$PP_SPACE_AMOUNT] \{\
+.                      ie \\n[#COLS] .COL_NEXT
+.                      el .NEWPAGE
+.                   \}
+.                   rr post-float
+.                \}
 .                if !\\n[nl]=\\n[#BASELINE_MARK] \{\
-.                   ie !'\\*[$PP_SPACE_AMOUNT]'' .ALD \\*[$PP_SPACE_AMOUNT]
+.                   ie !'\\*[$PP_SPACE_AMOUNT]'' .sp \\*[$PP_SPACE_AMOUNT]
 .                   el .sp
 .                   rr #BASELINE_MARK
 .                \}
@@ -11786,8 +12038,8 @@ $\\*[DOC_]COVERTITLE_\\n+[#\\*[DOC_]COVERTITLE_NUM] 
\\$\\n[#\\*[DOC_]COVERTITLE_
 .    REMOVE_INDENT
 .    ev
 .    nr #Q_LEAD_DIFF \\n[#LEAD]-\\n[#\\*[BQ]_LEAD_REAL]
-.    if !'\\n[.z]'FLOAT*DIV' \{\
-.       if !\\n[#NO_SHIM] \{\
+.    if !\\n[#NO_SHIM] \{\
+.       if !'\\n[.z]'FLOAT*DIV' \{\
 .          br
 .          nr #CALCULATE_ONLY 1
 .          nr #CURRENT_V_POS \\n[nl]+\\n[#Q_DEPTH]
@@ -11820,20 +12072,22 @@ $\\*[DOC_]COVERTITLE_\\n+[#\\*[DOC_]COVERTITLE_NUM] 
\\$\\n[#\\*[DOC_]COVERTITLE_
 .          \}
 .       \}
 .       el \{\
-.          ie \\n[#Q_DEPTH]<(\\n[#TRAP_DISTANCE]-1) \{\
-.             ie ((\\n[#TRAP_DISTANCE]-1)-\\n[#Q_DEPTH])<\\n[#DOC_LEAD] \{\
-.                ie !\\n[in-cutaround] .Q_NOFIT
-.                el .Q_FITS
-.             \}
-.             el \{\
-.                ie (\\n[#TRAP_DISTANCE]-\\n[#DOC_LEAD])<\\n[#DOC_LEAD] 
.Q_NOFIT
-.                el \{\
-.                   ie (\\n[#Q_DEPTH]+\\n[.v])=(\\n[#TRAP_DISTANCE]-1) .Q_NOFIT
+.          if !\\n[nl]=\\n[#PAGE_TOP] \{\
+.             ie \\n[#Q_DEPTH]<(\\n[#TRAP_DISTANCE]-1) \{\
+.                ie ((\\n[#TRAP_DISTANCE]-1)-\\n[#Q_DEPTH])<\\n[#DOC_LEAD] \{\
+.                   ie !\\n[in-cutaround] .Q_NOFIT
 .                   el .Q_FITS
 .                \}
+.                el \{\
+.                   ie (\\n[#TRAP_DISTANCE]-\\n[#DOC_LEAD])<\\n[#DOC_LEAD] 
.Q_NOFIT
+.                   el \{\
+.                      ie (\\n[#Q_DEPTH]+\\n[.v])=(\\n[#TRAP_DISTANCE]-1) 
.Q_NOFIT
+.                      el .Q_FITS
+.                   \}
+.                \}
 .             \}
+.             el .Q_NOFIT
 .          \}
-.          el .Q_NOFIT
 .       \}
 .       if \\n[#LINEBREAK] \{\
 .          vpt 0
@@ -11875,12 +12129,15 @@ $\\*[DOC_]COVERTITLE_\\n+[#\\*[DOC_]COVERTITLE_NUM] 
\\$\\n[#\\*[DOC_]COVERTITLE_
 .       el .in +\\*[$\\*[BQ]_OFFSET_VALUE]
 .    \}
 .    ie \\n[#START]=1 \{\
-.       ie !\\n[#Q_LEAD_DIFF]<0 .ALD \\n[#Q_SPACE_EQ]u
+.       ie !\\n[#Q_LEAD_DIFF]<0 \
+.          if !\\n[#NO_SHIM] .sp \\n[#Q_SPACE_EQ]u
 .       el .RLD 0-\\n[#Q_LEAD_DIFF]u
 .    \}
 .    el \{\
 .       if \\n[#PRINT_STYLE]=2 \
-.          ALD \\n[#Q_SPACE_EQ]u+(\\n[#Q_LEAD_DIFF]u/2u)
+.          ie !\\n[#NO_SHIM] \
+.             sp \\n[#Q_SPACE_EQ]u+(\\n[#Q_LEAD_DIFF]u/2u)
+.          el .if !\\n[#NO_FLEX] .FLEX
 .    \}
 .    if \\n[#QUOTE]=1 \{\
 .       if !'\\*[$Q_SPACE_ADJUST]'' .sp +\\*[$Q_SPACE_ADJUST]
@@ -11911,61 +12168,71 @@ $\\*[DOC_]COVERTITLE_\\n+[#\\*[DOC_]COVERTITLE_NUM] 
\\$\\n[#\\*[DOC_]COVERTITLE_
 .          rr reset-ll
 .       \}
 .    \}
-.    if \\n[#NO_SHIM]=1 \{\
-.       nr #RESTORE_NO_SHIM 1
-.       rr #NO_SHIM
-.    \}
-.if !'\\n[.z]'FLOAT*DIV' \{\
-.    if \\n[#PRINT_STYLE]=1 \
-.       if !\\n[.v]=\\n[#DOC_LEAD] .SHIM
-.    if \\n[#PRINT_STYLE]=2 \{\
-.       ie \\n[#START] \{\
-.          ie \\n[#PP_SPACE] .
-.          el \{\
-.             ALD \\n[#DOC_LEAD]u
-.             SHIM
+.    if !'\\n[.z]'FLOAT*DIV' \{\
+.       if \\n[#PRINT_STYLE]=1 \
+.          if !\\n[.v]=\\n[#DOC_LEAD] \{\
+.             ie !\\n[#NO_SHIM] .SHIM
+.             el \
+.                if !\\n[#NO_FLEX] .FLEX
 .          \}
-.       \}
-.       el \{\
-.          ie \\n[#HEAD]=1 \{\
-.             ALD \\n[#DOC_LEAD]u
-.             SHIM
+.       if \\n[#PRINT_STYLE]=2 \{\
+.          ie \\n[#START] \{\
+.             ie \\n[#PP_SPACE] .
+.             el \{\
+.                sp \\n[#DOC_LEAD]u
+.                ie !\\n[#NO_SHIM] .SHIM
+.                el \
+.                   if !\\n[#NO_FLEX] .FLEX
+.             \}
 .          \}
 .          el \{\
-.             ie \\n[#FULLSPACE_QUOTES] \{\
-.                ie \\n[#ENDNOTE] .ALD \\n[#EN_LEAD]u
-.                el !'\\n[.z]'FLOAT*DIV' .ALD \\n[#DOC_LEAD]u
+.             ie \\n[#HEAD]=1 \{\
+.                sp \\n[#DOC_LEAD]u
+.                ie !\\n[#NO_SHIM] .SHIM
+.                el \
+.                   if !\\n[#NO_FLEX] .FLEX
 .             \}
-.             el \
-.                if !'\\n[.z]'FLOAT*DIV' .ALD \\n[#DOC_LEAD]u/2u
-.             ie \\n[#Q_FITS] \{\
-.                ie (\\n[#Q_TOP]=\\n[#PAGE_TOP]):(address@hidden) \{\
-.                   if \\n[has-label] .sp \\n[#DOC_LEAD]u/2u
-.                   if !'\\n[.z]'FLOAT*DIV' \{\
-.                      nr #Q_AT_TOP 1
-.                      nr #DELAY_SHIM 1
+.             el \{\
+.                ie \\n[#FULLSPACE_QUOTES] \{\
+.                   ie \\n[#ENDNOTE] .ALD \\n[#EN_LEAD]u
+.                   el !'\\n[.z]'FLOAT*DIV' .ALD \\n[#DOC_LEAD]u
+.                \}
+.                el \
+.                   if !'\\n[.z]'FLOAT*DIV' .ALD \\n[#DOC_LEAD]u/2u
+.                ie \\n[#Q_FITS] \{\
+.                   ie (\\n[#Q_TOP]=\\n[#PAGE_TOP]):(address@hidden) \{\
+.                      if \\n[has-label] .sp \\n[#DOC_LEAD]u/2u
+.                      if !'\\n[.z]'FLOAT*DIV' \{\
+.                         nr #Q_AT_TOP 1
+.                         nr #DELAY_SHIM 1
+.                      \}
+.                   \}
+.                   el \{\
+.                      ie !\\n[#NO_SHIM] .SHIM
+.                      el \
+.                         if !\\n[#NO_FLEX] .FLEX
 .                   \}
 .                \}
-.                el .SHIM
-.             \}
-.             el \{\
-.                SHIM
+.                el \{\
+.                   if !\\n[#NO_SHIM] .SHIM
+.                   el \
+.                      if !\\n[#NO_FLEX] .FLEX
 .\" Make sure that Q_LEAD_DIFF is not added to the first line of
 .\" normal text at the top of any page following output of a quote
 .\" whose last line falls on B_MARGIN of the previous page.
-.                if \\n[#Q_LEAD_DIFF] \{\
-.                   if 
\\n[nl]=(\\n[#T_MARGIN]-\\n[#DOC_LEAD]+\\n[#Q_LEAD_DIFF]) \{\
-.                      PRINT \&
-.                      br
-.                      sp -1v-\\n[#Q_LEAD_DIFF]u
-.                      nr #Q_LEAD_DIFF_CHECK 1
+.                   if \\n[#Q_LEAD_DIFF] \{\
+.                      if 
\\n[nl]=(\\n[#T_MARGIN]-\\n[#DOC_LEAD]+\\n[#Q_LEAD_DIFF]) \{\
+.                         PRINT \&
+.                         br
+.                         sp -1v-\\n[#Q_LEAD_DIFF]u
+.                         nr #Q_LEAD_DIFF_CHECK 1
+.                      \}
 .                   \}
 .                \}
 .             \}
 .          \}
 .       \}
 .    \}
-.\}
 .    if \\n[#RESTORE_NO_SHIM] .nr #NO_SHIM 1
 .    rr #Q_SPACE_EQ
 .    if \\n[#LINENUMBERS]=2 \{\
@@ -12004,7 +12271,9 @@ $\\*[DOC_]COVERTITLE_\\n+[#\\*[DOC_]COVERTITLE_NUM] 
\\$\\n[#\\*[DOC_]COVERTITLE_
 .    ie !\\n[#ENDNOTE] .QUAD \\*[$DOC_QUAD]
 .    el .QUAD \\*[EN_QUAD]
 .    if r #DELAY_SHIM \{\
-.       SHIM
+.       ie !\\n[#NO_SHIM] .SHIM
+.       el \
+.          if !\\n[#NO_FLEX] .FLEX
 .       rr #DELAY_SHIM
 .    \}
 .    if \\n[#PRINT_STYLE]=1 \
@@ -12052,12 +12321,12 @@ $\\*[DOC_]COVERTITLE_\\n+[#\\*[DOC_]COVERTITLE_NUM] 
\\$\\n[#\\*[DOC_]COVERTITLE_
 .          \}
 .       \}
 .       if \\n[#DIVER_FN]=2 .rr #DIVER_FN
+.       if !\\n[#NO_FLEX] .FLEX
 .    \}
 .    rm $QUOTE_TYPE
 .END
 \#
 .MAC Q_NOFIT END
-.if r foo .ab
 .    rr #Q_FITS
 .    if \\n[#QUOTE]=1 \{\
 .       ds $QUOTE_TYPE Q
@@ -12074,8 +12343,9 @@ $\\*[DOC_]COVERTITLE_\\n+[#\\*[DOC_]COVERTITLE_NUM] 
\\$\\n[#\\*[DOC_]COVERTITLE_
 \\n[#DOC_LEAD]+(\\n[#DOC_LEAD]/4)\
 +\\n[#\\*[QUOTE_TYPE]_LEAD] \{\
 .          tm1 "[mom]: Insufficient room for caption and at least one line of 
\\*[quote-type]
-.          tm1 "       on page \\n[%] (line \\n[.c]).  Moving quote to next 
page.
-.          NEWPAGE
+.          tm1 "       on page \\n[%] (line \\n[.c]).  Moving quote to next 
page or column.
+.          ie \\n[#COLUMNS] .COL_NEXT
+.          el .NEWPAGE
 .       \}
 .    \}
 .    ie r#HEAD \
@@ -12084,11 +12354,11 @@ $\\*[DOC_]COVERTITLE_\\n+[#\\*[DOC_]COVERTITLE_NUM] 
\\$\\n[#\\*[DOC_]COVERTITLE_
 .       if \\n[#Q_DEPTH]=0 \
 .          if \\n[.ns] .rs
 .       ie \\n[#FULLSPACE_QUOTES] \{\
-.          ie \\n[#ENDNOTE] .ALD \\n[#EN_LEAD]u+\\n[#Q_LEAD_DIFF]u
-.          el .ALD \\n[#DOC_LEAD]u+\\n[#Q_LEAD_DIFF]u
+.          ie \\n[#ENDNOTE] .sp \\n[#EN_LEAD]u+\\n[#Q_LEAD_DIFF]u
+.          el .sp \\n[#DOC_LEAD]u+\\n[#Q_LEAD_DIFF]u
 .       \}
 .       el \{\
-.          ALD \\n[#DOC_LEAD]u
+.          sp \\n[#DOC_LEAD]u
 .          if address@hidden .rs
 .       \}
 .       ie \\n[#Q_LEAD_REAL] \
@@ -12097,9 +12367,11 @@ $\\*[DOC_]COVERTITLE_\\n+[#\\*[DOC_]COVERTITLE_NUM] 
\\$\\n[#\\*[DOC_]COVERTITLE_
 .       while \\n+[#Q_PARTIAL_DEPTH]<(\\n[#TRAP_DISTANCE]-1) \{\
 .
 .       \}
-.       ie \\n[#Q_LEAD_REAL] \
-.          nr #Q_PARTIAL_DEPTH -\\n[#Q_LEAD_REAL]
-.       el .nr #Q_PARTIAL_DEPTH -\\n[#BQ_LEAD_REAL]
+.       if !\\n[#Q_LEAD_REAL]=\\n[#DOC_LEAD] \{\
+.          ie \\n[#Q_LEAD_REAL] \
+.             nr #Q_PARTIAL_DEPTH -\\n[#Q_LEAD_REAL]
+.          el .nr #Q_PARTIAL_DEPTH -\\n[#BQ_LEAD_REAL]
+.       \}
 .       nr #Q_SPACE_EQ \
 (\\n[#TRAP_DISTANCE]-1)-\\n[#Q_PARTIAL_DEPTH]+(\\n[#Q_LEAD_DIFF]u/2u)
 .       if \\n[#FN_COUNT]>0 .nr #Q_SPACE_EQ (\\n[#Q_SPACE_EQ] / 2u)
@@ -12133,6 +12405,7 @@ $\\*[DOC_]COVERTITLE_\\n+[#\\*[DOC_]COVERTITLE_NUM] 
\\$\\n[#\\*[DOC_]COVERTITLE_
 .    ie '\\$1'' .nr #PAGINATE 1
 .    el \{\
 .      nr #PAGINATE 0
+.      rr #PAGE_NUM_V_POS
 .    \}
 .    if \\n[#HF_OFF]=1 \{\
 .       rr #PAGINATION_STATE
@@ -12605,6 +12878,19 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .    el .rm $FN_SPACE
 .END
 \#
+\# FOOTNOTE FIRST LINE INDENT
+\# --------------------------
+\# *Arguments:
+\#   <indent>
+\# *Function:
+\#   Indents first line of footnotes.
+\# *Notes:
+\#   Default is no indent.
+\#
+.MAC FOOTNOTE_INDENT END
+. nr #FN_INDENT \\$1
+.END
+\#
 \# RUN ON FOOTNOTES
 \# ----------------
 \# *Arguments:
@@ -12951,9 +13237,8 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .\" FN_IN_DIVER is output into FOOTNOTE in PROCESS_FN_IN_DIVER).
 .          if !\\n[#DONT_RULE_ME]=1 \{\
 .             if !\\n[#FN_DEPTH] \{\
-.                if \\n[#PRINT_STYLE]=1 \{\
+.                if \\n[#PRINT_STYLE]=1 \
 .                   if !\\n[#RUN_ON] .sp \\n[#DOC_LEAD]u
-.                \}
 .                ie \\n[#FN_RULE]=1 \{\
 .                   if !\\n[#RUN_ON] \{\
 .                      if \\n[#SINGLE_SPACE] .sp \\n[#DOC_LEAD]u
@@ -12971,9 +13256,8 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .       SS 0
 .\" Add footnote markers to footnote text...
 .       ie \\n[#FN_MARKERS] \{\
-.          if !'\\*[$FN_SPACE]'' \{\
+.          if !'\\*[$FN_SPACE]'' \
 .             if \\n[#FN_COUNT]>0 .ALD \\*[$FN_SPACE]
-.          \}
 .          if !\\n[#NO_FN_MARKER] \{\
 .\" ...but not if TERMINATE has been called.
 .             if !r#TERMINATE \{\
@@ -12984,36 +13268,35 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .                if \\n[#FN_MARKER_STYLE]=1 \{\
 .                   ie \\n[#COLUMNS]=1 \{\
 .                      \\n+[#FN_COUNT_FOR_COLS]
-.                      if \\n[#FN_COUNT_FOR_COLS]=1 .PRINT *\c
-.                      if \\n[#FN_COUNT_FOR_COLS]=2 .PRINT \[dg]\c
-.                      if \\n[#FN_COUNT_FOR_COLS]=3 .PRINT \[dd]\c
-.                      if \\n[#FN_COUNT_FOR_COLS]=4 .PRINT **\c
-.                      if \\n[#FN_COUNT_FOR_COLS]=5 .PRINT \[dg]\[dg]\c
-.                      if \\n[#FN_COUNT_FOR_COLS]=6 .PRINT \[dd]\[dd]\c
-.                      if \\n[#FN_COUNT_FOR_COLS]=7 .PRINT ***\c
-.                      if \\n[#FN_COUNT_FOR_COLS]=8 .PRINT \[dg]\[dg]\[dg]\c
-.                      if \\n[#FN_COUNT_FOR_COLS]=9 .PRINT \[dd]\[dd]\[dd]\c
-.                      if \\n[#FN_COUNT_FOR_COLS]=10 .PRINT ****\c
+.                      if \\n[#FN_COUNT_FOR_COLS]=1 .PRINT 
\h'0+\\n[#FN_INDENT]u'*\c
+.                      if \\n[#FN_COUNT_FOR_COLS]=2 .PRINT 
\h'0+\\n[#FN_INDENT]u'\[dg]\c
+.                      if \\n[#FN_COUNT_FOR_COLS]=3 .PRINT 
\h'0+\\n[#FN_INDENT]u'\[dd]\c
+.                      if \\n[#FN_COUNT_FOR_COLS]=4 .PRINT 
\h'0+\\n[#FN_INDENT]u'**\c
+.                      if \\n[#FN_COUNT_FOR_COLS]=5 .PRINT 
\h'0+\\n[#FN_INDENT]u'\[dg]\[dg]\c
+.                      if \\n[#FN_COUNT_FOR_COLS]=6 .PRINT 
\h'0+\\n[#FN_INDENT]u'\[dd]\[dd]\c
+.                      if \\n[#FN_COUNT_FOR_COLS]=7 .PRINT 
\h'0+\\n[#FN_INDENT]u'***\c
+.                      if \\n[#FN_COUNT_FOR_COLS]=8 .PRINT 
\h'0+\\n[#FN_INDENT]u'\[dg]\[dg]\[dg]\c
+.                      if \\n[#FN_COUNT_FOR_COLS]=9 .PRINT 
\h'0+\\n[#FN_INDENT]u'\[dd]\[dd]\[dd]\c
+.                      if \\n[#FN_COUNT_FOR_COLS]=10 .PRINT 
\h'0+\\n[#FN_INDENT]u'****\c
 .                   \}
 .                   el \{\
-.                      if \\n[#FN_COUNT]=1 .PRINT *\c
-.                      if \\n[#FN_COUNT]=2 .PRINT \[dg]\c
-.                      if \\n[#FN_COUNT]=3 .PRINT \[dd]\c
-.                      if \\n[#FN_COUNT]=4 .PRINT **\c
-.                      if \\n[#FN_COUNT]=5 .PRINT \[dg]\[dg]\c
-.                      if \\n[#FN_COUNT]=6 .PRINT \[dd]\[dd]\c
-.                      if \\n[#FN_COUNT]=7 .PRINT ***\c
-.                      if \\n[#FN_COUNT]=8 .PRINT \[dg]\[dg]\[dg]\c
-.                      if \\n[#FN_COUNT]=9 .PRINT \[dd]\[dd]\[dd]\c
-.                      if \\n[#FN_COUNT]=10 .PRINT ****\c
+.                      if \\n[#FN_COUNT]=1 .PRINT \h'0+\\n[#FN_INDENT]u'*\c
+.                      if \\n[#FN_COUNT]=2 .PRINT \h'0+\\n[#FN_INDENT]u'\[dg]\c
+.                      if \\n[#FN_COUNT]=3 .PRINT \h'0+\\n[#FN_INDENT]u'\[dd]\c
+.                      if \\n[#FN_COUNT]=4 .PRINT \h'0+\\n[#FN_INDENT]u'**\c
+.                      if \\n[#FN_COUNT]=5 .PRINT 
\h'0+\\n[#FN_INDENT]u'\[dg]\[dg]\c
+.                      if \\n[#FN_COUNT]=6 .PRINT 
\h'0+\\n[#FN_INDENT]u'\[dd]\[dd]\c
+.                      if \\n[#FN_COUNT]=7 .PRINT \h'0+\\n[#FN_INDENT]u'***\c
+.                      if \\n[#FN_COUNT]=8 .PRINT 
\h'0+\\n[#FN_INDENT]u'\[dg]\[dg]\[dg]\c
+.                      if \\n[#FN_COUNT]=9 .PRINT 
\h'0+\\n[#FN_INDENT]u'\[dd]\[dd]\[dd]\c
+.                      if \\n[#FN_COUNT]=10 .PRINT \h'0+\\n[#FN_INDENT]u'****\c
 .                   \}
 .                \}
 .                if \\n[#FN_MARKER_STYLE]=2 \{\
 .                   ds $FN_NUMBER \\n[#FN_NUMBER]
 .                   length #FN_NUMBER_LENGTH \\*[$FN_NUMBER]
-.                   if \\n[#COLUMNS]=1 \{\
+.                   if \\n[#COLUMNS]=1 \
 .                      \\n+[#FN_COUNT_FOR_COLS]
-.                   \}
 .                   if \\n[#NOT_YET_ADJUSTED]=1 \{\
 .                      nr #FN_NUMBER 1 1
 .                      rr #NOT_YET_ADJUSTED
@@ -13021,24 +13304,24 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .                   if \\n[#PRINT_STYLE]=1 \{\
 .                      ie \\n[#NO_SUPERSCRIPT] \{\
 .                         ie 
\\n[#FN_NUMBER_LENGTH]<\\n[#FN_NUMBER_PLACEHOLDERS] \
-.                            PRINT "\0(\\n[#FN_NUMBER])\|\c"
+.                            PRINT 
"\h'0+\\n[#FN_INDENT]u'\0(\\n[#FN_NUMBER])\|\c"
 .                         el \
-.                            PRINT "(\\n[#FN_NUMBER])\|\c"
+.                            PRINT 
"\h'0+\\n[#FN_INDENT]u'(\\n[#FN_NUMBER])\|\c"
 .                      \}
 .                      el \{\
 .                         ie 
\\n[#FN_NUMBER_LENGTH]<\\n[#FN_NUMBER_PLACEHOLDERS] \
 .                            PRINT \
-"\s-2\v'-\\n[.v]u/5u'\0\\n[#FN_NUMBER]\|\v'+\\n[.v]u/5u'\s+2\|\c"
+"\h'0+\\n[#FN_INDENT]u'\s-2\v'-\\n[.v]u/5u'\0\\n[#FN_NUMBER]\|\v'+\\n[.v]u/5u'\s+2\|\c"
 .                         el \
 .                            PRINT \
-"\s-2\v'-\\n[.v]u/5u'\\n[#FN_NUMBER]\|\v'+\\n[.v]u/5u'\s+2\|\c"
+"\h'0+\\n[#FN_INDENT]u'\s-2\v'-\\n[.v]u/5u'\\n[#FN_NUMBER]\|\v'+\\n[.v]u/5u'\s+2\|\c"
 .                      \}
 .                   \}
 .                   if \\n[#PRINT_STYLE]=2 \{\
 .                      ie \\n[#FN_NUMBER_LENGTH]<\\n[#FN_NUMBER_PLACEHOLDERS] \
-.                         PRINT "\*[SUP]\0\\n[#FN_NUMBER]\*[SUPX]\*[FU 3]\c"
+.                         PRINT 
"\h'0+\\n[#FN_INDENT]u'\*[SUP]\0\\n[#FN_NUMBER]\*[SUPX]\*[FU 3]\c"
 .                      el \
-.                         PRINT "\*[SUP]\\n[#FN_NUMBER]\*[SUPX]\*[FU 3]\c"
+.                         PRINT 
"\h'0+\\n[#FN_INDENT]u'\*[SUP]\\n[#FN_NUMBER]\*[SUPX]\*[FU 3]\c"
 .                   \}
 .                \}
 .             \}
@@ -13053,11 +13336,11 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .             \}
 .             if \\n[#REF]=1 \{\
 .                if !\\n[#RUN_ON]=1 \{\
-\!.                 ti +\\n[#REF_FN_INDENT]u
+\!.                 ti +\\n[#REF_FN_INDENT]uu
 .                \}
 .             \}
 .             ie \\n[#FN_LN_BRACKETS]=1 \{\
-.                ds $FN_LINENUMBER \v'-.085m'\\*[$FN_OPEN_BRACKET]\v'.085m'
+.                ds $FN_LINENUMBER 
\h'0+\\n[#FN_INDENT]u'\v'-.085m'\\*[$FN_OPEN_BRACKET]\v'.085m'
 .                ie \\n[#FN_MARK_2]=\\n[#FN_MARK] \
 .                   as $FN_LINENUMBER \
 \\n[#FN_MARK]\v'-.085m'\\*[$FN_CLOSE_BRACKET]\v'.085m'\h'.25m'
@@ -13071,14 +13354,13 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .                   ds $FN_LINENUMBER \\n[#FN_MARK]\\*[$FN_LN_SEP]
 .                el \
 .                   ds $FN_LINENUMBER \
-\\n[#FN_MARK]\v'-.1m'-\v'.1m'\\n[#FN_MARK_2]\\*[$FN_LN_SEP]
+\h'0+\\n[#FN_INDENT]u'\\n[#FN_MARK]\v'-.1m'-\v'.1m'\\n[#FN_MARK_2]\\*[$FN_LN_SEP]
 .                \}
 .             \}
-.             if !\\n[#NO_FN_MARKER] \
-.                PRINT \\*[$FN_LINENUMBER]\c
-.             rm $FN_LINENUMBER
-.             nr #FN_MARK 0
-.          \}
+.          if !\\n[#NO_FN_MARKER] \
+.             PRINT \\*[$FN_LINENUMBER]\c
+.          rm $FN_LINENUMBER
+.          nr #FN_MARK 0
 .       \}
 .    \}
 .    el \{\
@@ -13280,9 +13562,8 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .                         nr #VARIABLE_FOOTER_POS -\\n[#VFP_DIFF]
 .                         if \\n[#DIVERTED]=1 .nr #DIVERTED 3
 .                         if !\\n[#PREV_FN_DEFERRED]=1 \{\
-.                            ie \\n[#COLUMNS]=1 \{\
+.                            ie \\n[#COLUMNS]=1 \
 .                               if !\\n[#FROM_FOOTER] .
-.                            \}
 .                            el .nr #FN_DEPTH -\\n[#VFP_DIFF]
 .                         \}
 .                         if \\n[#DIVERTED]=3 \{\
@@ -13466,7 +13747,7 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .\" When #FROM_DIVERT_FN is 1, it signals to FOOTNOTE, when run from
 .\" within DIVERT_FN_LEFTOVER, to set #SPACE_REMAINING to the total
 .\" area allowable for running text.
-\#.    nr #FROM_DIVERT_FN 1
+.    nr #FROM_DIVERT_FN 1
 .END
 \#
 \# PROCESS_FN_LEFTOVER is called at the top of HEADER, and in
@@ -13485,7 +13766,7 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .       nr #VARIABLE_FOOTER_POS 0-\\n[#B_MARGIN]
 .    \}
 .    el \{\
-.       if \\n[#FN_DEFER]=1 .nr #VARIABLE_FOOTER_POS -\\n[#FN_DEPTH]
+.       if \\n[#FN_DEFER]=1 .nr #VARIABLE_FOOTER_POS 0-\\n[#B_MARGIN]
 .       if \\n[#FN_DEFER]=2 \{\
 .          nr #FN_DEPTH 0
 .          nr #VARIABLE_FOOTER_POS 0-\\n[#B_MARGIN]
@@ -13495,14 +13776,16 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .    ch FOOTER -\\n[#B_MARGIN]u
 .    if \\n[#FN_DEFER] \{\
 .       nr #NO_FN_MARKER 1
+.       rn FOOTNOTES DEFERRED-FOOTNOTE
+.       nr #FN_DEPTH 0
 .       FOOTNOTE
 .       nf
+.       DEFERRED-FOOTNOTE
 .       FOOTNOTE OFF
 .       ie \\n[#COLUMNS]=1 \{\
 .          if \\n[#COL_NUM]=\\n[#NUM_COLS] \{\
-.             if !\\n[#FROM_FOOTER] \{\
+.             if !\\n[#FROM_FOOTER] \
 .                if \\n[#FN_COUNT_FOR_COLS]=1 .nr #PREV_FN_DEFERRED 1
-.             \}
 .          \}
 .       \}
 .       el .nr #PREV_FN_DEFERRED 1
@@ -14077,9 +14360,8 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .             if '\\*[$EN_TITLE_QUAD]'RIGHT'  .RIGHT
 \!.           vpt 0
 .             sp -.25v
-.             ie \\n[#EN_TITLE_UNDERLINE] \{\
+.             ie \\n[#EN_TITLE_UNDERLINE] \
 .                UNDERSCORE "\\*[$EN_TITLE]"
-.             \}
 .             el \{\
 .                ie \\n[#PRINT_STYLE]=1 \
 .                   UNDERSCORE "\\*[$EN_TITLE]"
@@ -14283,8 +14565,6 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .       NUMBER_LINES RESUME
 .       nr #LINENUMBERS 1
 .    \}
-.
-.    PRINT_FOOTER
 .    rr #ENDNOTES
 .END
 \#
@@ -14401,9 +14681,8 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .       if \\n[#\\*[EN-OR-BIB]_STRING_SMALLCAPS] .SMALLCAPS
 .       ie \\n[#\\*[EN-OR-BIB]_STRING_UNDERLINE] \{\
 .          if \\n[#PRINT_STYLE]=2 .ds $TITLE_TYPE \\*[EN-OR-BIB]_STRING
-.          ie \\n[#PRINT_STYLE]=1 \{\
+.          ie \\n[#PRINT_STYLE]=1 \
 .             UNDERSCORE2 3p 2p "\\*[$\\*[EN-OR-BIB]_STRING]"
-.          \}
 .          el \{\
 .             ie \\n[#\\*[EN-OR-BIB]_STRING_UNDERLINE]=2 \
 .                UNDERSCORE2 \\*[$\\*[EN-OR-BIB]_UNDERLINE_GAP] 
\\*[$\\*[EN-OR-BIB]_RULE_GAP] "\\*[$\\*[EN-OR-BIB]_STRING]"
@@ -14452,25 +14731,15 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .    if '\\$0'BIBLIOGRAPHY_LEAD' .ds $SECTION BIB
 .    if '\\$0'ENDNOTE_LEAD' .ds $SECTION EN
 .    if '\\$0'TOC_LEAD' .ds $SECTION TOC
-.    ds $\\*[$SECTION]_LEAD \\$1
-.    ds $ADJUST_\\*[$SECTION]_LEAD \\$2
-.    if !\\n[#OK_PROCESS_LEAD] .return
-.    nr #\\*[$SECTION]_LEAD (p;\\$1)
 .    rr #ADJ_\\*[$SECTION]_LEAD
-.    als \\*[$SECTION]_LEAD DOC_LEAD
+.    ds $\\*[$SECTION]_LEAD \\$1
+.    rm $ADJUST_\\*[$SECTION]_LEAD
 .    if '\\$2'ADJUST' \{\
-.       nr #ORIG_DOC_LEAD \\n[#UNADJUSTED_DOC_LEAD]
-.       nr #RESTORE_ADJ_DOC_LEAD \\n[#ADJ_DOC_LEAD]
-.       nr #ADJ_DOC_LEAD 1
 .       nr #ADJ_\\*[$SECTION]_LEAD 1
-.       nr #NO_TRAP_RESET 1
-.       \\*[$SECTION]_LEAD \\n[#\\*[$SECTION]_LEAD]u ADJUST
-.       nr #\\*[$SECTION]_LEAD \\n[#DOC_LEAD]
-.       DOC_LEAD \\n[#ORIG_DOC_LEAD]u
-.       rr #NO_TRAP_RESET
-.       nr #ADJ_DOC_LEAD \\n[#RESTORE_ADJ_DOC_LEAD]
-.       rr #ORIG_DOC_LEAD
+.       ds $ADJUST_\\*[$SECTION]_LEAD ADJUST
 .    \}
+.    if !\\n[#OK_PROCESS_LEAD] .return
+.    nr #\\*[$SECTION]_LEAD (p;\\$1)
 .END
 .
 .ALIAS BIBLIOGRAPHY_LEAD _LEAD
@@ -14598,9 +14867,8 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .MAC BIBLIOGRAPHY_TYPE END
 .    ie '\\$1'LIST' \{\
 .       nr #BIB_LIST 1
-.       ie '\\$2'' \{\
+.       ie '\\$2'' \
 .          if '\\*[$BIB_LIST_SEPARATOR]'' .ds $BIB_LIST_SEPARATOR .
-.       \}
 .       el .ds $BIB_LIST_SEPARATOR \\$2
 .       ie '\\$3'' .ds $BIB_LIST_PREFIX
 .       el .ds $BIB_LIST_PREFIX \\$3
@@ -14681,6 +14949,7 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .       chop BIB
 .       BIB
 .    \}
+.    rr #BIBLIOGRAPHY
 .END
 \#
 \# ====================================================================
@@ -14783,10 +15052,10 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 \!.        ps \\n[#TOC_PS]u
 .       \}
 \!.     TAB 102
-\!.     PRINT \\*[LEADER]
+\!.     PRINT \fR\\*[LEADER]\f[]
 \!.     TN
 .       if \\n[#PRINT_STYLE]=2 \{\
-\!.        ps \\*[$TOC_PN_SIZE_CHANGE]u
+\!.        ps \\*[$TOC_PN_SIZE_CHANGE]
 .       \}
 \!.     PRINT \\n[#TOC_ENTRY_PN]
 \!.     TQ
@@ -15099,10 +15368,31 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .    if !'\\$1'' .ds $TOC_AUTHORS \\$1
 .END
 \#
-\# TABLE OF CONTENTS
-\# -----------------
+\# TABLE OF CONTENTS PAGE SETUP
+\# ----------------------------
 \# *Arguments:
-\#   none
+\#   <none> | <anything>
+\# *Function:
+\#   Some changes to the TOC layout (e.g. margins and page headers)
+\#   are not covered by the TOC and endnotes control macros.  This
+\#   macro permits access to any and all page setup macros not so
+\#   covered.
+\# *Notes
+\#   Wraps a diversion that ends when the macro is invoked with an
+\#   argument.  The contained formatting macros must be preceded by
+\#   '\!'.  The diversion is output before START in TOC.
+\#
+.MAC TOC_PAGE_SETTINGS END
+.    nr #TOC_PAGE_PARAMS 1
+.    ie '\\$1'' \
+.       di TOC_PAGE_PARAMS
+.    el .di
+.END
+\#
+\# TABLE OF CONTENTS
+\# -----------------
+\# *Arguments:
+\#   none
 \# *Function:
 \#   Takes care of the administrivia of setting up the TOC as if
 \#   it's a collated doc, then outputs the formatted TOC_ENTRIES
@@ -15112,6 +15402,10 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .    ie (address@hidden)&(\\n[.t]<=\\n[.v]) \
 '       br \" When last line of text is on or near b-margin.
 .    el .br \" All other cases
+.    if dPDF.EXPORT \
+.       if \\n[#FLEX_ACTIVE] \
+.          if !\\n[#NO_FLEX] \
+.             tm .ds address@hidden 1
 .    if \\n[#TOC_RV_SWITCH]=1 .nr #TOC_RV_SWITCH 2
 .    char \[leader] " .
 .    LEADER_CHARACTER \[leader]
@@ -15153,7 +15447,6 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .       TRAPS
 .       nr #IGNORE 1
 .    \}
-.    if \\n[#PRINT_STYLE]=2 .vs \\n[#TOC_LEAD]u
 .    if \\n[#FINIS] \{\
 .       if \\n[#FOOTERS_WERE_ON] .FOOTERS  \" Finally, turn footers on if they 
were on
 .       rr #FOOTERS_WERE_ON
@@ -15172,25 +15465,28 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .    ie \\n[#TOC_HEADER_V_POS] \
 .      DOCHEADER OFF \\n[#TOC_HEADER_V_POS]u-\\n[#DOC_LEAD]u 
 .    el .DOCHEADER OFF \\n[#T_MARGIN]u-\\n[#DOC_LEAD]u
-.    if (\\n[#PRINT_STYLE]=1)&(\\n[#SINGLE_SPACE]=1) \{\
+.    if (\\n[#PRINT_STYLE]=1)&(\\n[#SINGLE_SPACE]=1) \
 .       DOCHEADER OFF \\n[#T_MARGIN]u-(\\n[#DOC_LEAD]u*2u)
-.    \}
 .    if !r #TOC_START_PAGENUM .nr #TOC_START_PAGENUM 1
 .       PAGENUMBER \\n[#TOC_START_PAGENUM]
 .    if \\n[#LINENUMBERS]=2 .nr #LINENUMBERS 3
-.    L_MARGIN   \\n[#DOC_L_MARGIN]u
-.    LL         \\n[#DOC_L_LENGTH]u
-.    HEADER_FAMILY \\*[$TOC_FAM]
+.    L_MARGIN \\n[#DOC_L_MARGIN]u
+.    LL       \\n[#DOC_L_LENGTH]u
 .    HEADER_CENTER "\\*[$TOC_HEADER_STRING]
 .    if \\n[#SLANT_ON] .nop \\*[SLANTX]
 .    PAGENUM_STYLE \\*[$TOC_PN_STYLE]
 .    PAGENUM_FAMILY \\*[$TOC_PN_FAM]
+.    if r #TOC_PAGE_PARAMS .TOC_PAGE_PARAMS
+.    ie \\n[#ADJ_TOC_LEAD] \{\
+.       DOC_LEAD \\*[$TOC_LEAD] ADJUST
+.    el .DOC_LEAD \\*[$TOC_LEAD]
+.    \}
 .    START
 .    PDF_BOOKMARK 1 \\*[$TOC_HEADER_STRING]
 .    if \\n[#PRINT_STYLE]=1 .TYPEWRITER
 .    if \\n[#PRINT_STYLE]=2 \{\
-.       FAMILY  \\*[$TOC_HEADER_FAM]
-.       FT      \\*[$TOC_HEADER_FT]
+.       FAMILY \\*[$TOC_HEADER_FAM]
+.       FT     \\*[$TOC_HEADER_FT]
 .       ps \\n[#TOC_PS]u\\*[$TOC_HEADER_SIZE_CHANGE]
 .       if \\n[#TOC_HEADER_COLOR]=1 \
 .          gcolor \\*[$TOC_HEADER_COLOR]
@@ -15198,9 +15494,8 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .    QUAD \\*[$TOC_HEADER_QUAD]
 .    if \\n[#TOC_STRING_CAPS] .CAPS
 .    if \\n[#TOC_STRING_SMALLCAPS] .SMALLCAPS
-.    if \\n[#PRINT_STYLE]=1 \{\
+.    if \\n[#PRINT_STYLE]=1 \
 .       UNDERSCORE 3p "\\*[$TOC_HEADER_STRING]"
-.    \}
 .    if \\n[#PRINT_STYLE]=2 \{\
 .       ie \\n[#TOC_HEADER_UNDERLINE] \{\
 .          ds $TITLE_TYPE TOC_HEADER
@@ -15287,12 +15582,20 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .MAC COL_NEXT END
 .    if \\n[#COLUMNS] \{\
 .       nr #COL_NEXT 1
+.       vpt 0
+.       if !'\\$1'internal' \
+.          if dPDF.EXPORT \
+.             if \\n[#FLEX_ACTIVE] \
+.                if !\\n[#NO_FLEX] \
+.                   if \\n[#COL_NUM]>1 \
+.                      tm .ds address@hidden 1
 .       ie '\\$0'COL_NEXT' .br
 .       el \{\
 .          brp
 .          RLD 1v
 .       \}
-.       ie \\n[#COL_NUM]=\\n[#NUM_COLS] .bp
+.       vpt
+.       ie \\n[#COL_NUM]=\\n[#NUM_COLS] .NEWPAGE
 .       el .FOOTER
 .    \}
 .END
@@ -15351,30 +15654,36 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .    \}
 .    el .ds $LIST_ARG_1 \\$1
 .    if !r#DEPTH \{\
-.       nr #STORED_HL_INDENT \\n[#HL_INDENT]
-.       nr #STORED_T_INDENT  \\n[#T_INDENT]
+.       if \\n[#INDENT_ACTIVE] \{\
+.          nr #STORED_HL_INDENT \\n[#HL_INDENT]
+.          nr #STORED_T_INDENT  \\n[#T_INDENT]
+.          if \\n[#INDENT_LEFT_ACTIVE] \
+.             nr #STORED_L_INDENT \\n[#L_INDENT]
+.          if \\n[#INDENT_RIGHT_ACTIVE] \
+.             nr #STORED_R_INDENT \\n[#R_INDENT]
+.          if \\n[#INDENT_BOTH_ACTIVE] \{\
+.             nr #STORED_BL_INDENT \\n[#BL_INDENT]
+.             nr #STORED_BR_INDENT \\n[#BR_INDENT]
+.          \}
+.       \}
 .       nr #CURRENT_L_LENGTH \\n[.l]
 .       nr #DEPTH 0 1
 .       if \\n[#INDENT_ACTIVE]=1 \{\
-.          if \\n[#INDENT_LEFT_ACTIVE]=1 \{\
-.             nr #STORED_L_INDENT \\n[#L_INDENT]
+.          if \\n[#INDENT_LEFT_ACTIVE]=1 \
 .             nr #RESTORE_PREV_INDENT 1
-.          \}
 .          if \\n[#INDENT_BOTH_ACTIVE]=1 \{\
-.             nr #STORED_BL_INDENT \\n[#BL_INDENT]
-.             nr #STORED_BR_INDENT \\n[#BR_INDENT]
 .             IBX
 .             nr #ORIG_L_LENGTH \\n[.l]
 .             IB
 .             nr #RESTORE_PREV_INDENT 2
 .          \}
 .          if \\n[#INDENT_RIGHT_ACTIVE]=1 \{\
-.             nr #STORED_R_INDENT \\n[#R_INDENT]
 .             IRX
 .             nr #ORIG_L_LENGTH \\n[.l]
 .             IR
 .             nr #RESTORE_PREV_INDENT 3
-.             if \\n[#INDENT_LEFT_ACTIVE]=1 .nr #RESTORE_PREV_INDENT 4
+.             if \\n[#INDENT_LEFT_ACTIVE]=1 \
+.                nr #RESTORE_PREV_INDENT 4
 .          \}
 .       \}
 .    \}
@@ -15438,9 +15747,8 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .          if \\n[#NUM_ARGS]>=2 \{\
 .             ie '\\$2'NONE' .ds $SEPARATOR\\n[#DEPTH]
 .             el .ds $SEPARATOR\\n[#DEPTH] \\$2
-.             if \\n[#NUM_ARGS]=3 \{\
+.             if \\n[#NUM_ARGS]=3 \
 .                ds $PREFIX\\n[#DEPTH] \\$3
-.             \}
 .          \}
 .       \}
 .       if '\\*[$1ST_LETTER]'R' \{\
@@ -15464,6 +15772,13 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .          ds $SEPARATOR\\n[#DEPTH]
 .          ds $PREFIX\\n[#DEPTH]
 .       \}
+.       if '\\*[$LIST_ARG_1]'PLAIN' \{\
+.          nr #ARGS_TO_LIST 1
+.          ds $ENUMERATOR\\n+[#DEPTH]
+.          ds $ENUMERATOR_TYPE\\n[#DEPTH] plain
+.          ds $SEPARATOR\\n[#DEPTH]
+.          ds $PREFIX\\n[#DEPTH]
+.       \}
 .       if \\n[#NUM_ARGS]=1 \{\
 .          if !r#ARGS_TO_LIST \{\
 .             ie \\n[#DEPTH]=1 \{\
@@ -15541,6 +15856,7 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 \#   receive the text of an item.
 \#
 .MAC ITEM END
+.    if '\\*[$ENUMERATOR_TYPE\\n[#DEPTH]]'plain' .nop 
 .    if !r#DEPTH .return
 .    if \\n[#LINENUMBERS]=1 \{\
 .       NUMBER_LINES OFF
@@ -15945,25 +16261,20 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .   IQ CLEAR
 .   nr #HL_INDENT \\n[#STORED_HL_INDENT]
 .   nr #T_INDENT  \\n[#STORED_T_INDENT]
+.   nr #L_INDENT  \\n[#STORED_L_INDENT]
+.   nr #R_INDENT \\n[#STORED_R_INDENT]
+.   nr #BL_INDENT \\n[#STORED_BL_INDENT]
+.   nr #BR_INDENT \\n[#STORED_BR_INDENT]
 .   rr #STORED_HL_INDENT
-.   if \\n[#RESTORE_PREV_INDENT]=1 \{\
-.      nr #L_INDENT  \\n[#STORED_L_INDENT]
+.   if \\n[#RESTORE_PREV_INDENT]=1 \
 .      IL
-.      rr #STORED_L_INDENT
-.   \}
 .   if \\n[#RESTORE_PREV_INDENT]=2 \{\
-.      nr #BL_INDENT \\n[#STORED_BL_INDENT]
-.      nr #BR_INDENT \\n[#STORED_BR_INDENT]
 .      ll \\n[#ORIG_L_LENGTH]u
 .      IB
-.      rr #STORED_BL_INDENT
-.      rr #STORED_BR_INDENT
 .   \}
 .   if \\n[#RESTORE_PREV_INDENT]=3 \{\
-.      nr #R_INDENT \\n[#STORED_R_INDENT]
 .      ll \\n[#ORIG_L_LENGTH]u
 .      IR
-.      rr #STORED_R_INDENT
 .   \}
 .   if \\n[#RESTORE_PREV_INDENT]=4 \{\
 .      nr #R_INDENT \\n[#STORED_R_INDENT]
@@ -15971,8 +16282,6 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .      ll \\n[#ORIG_L_LENGTH]u
 .      IR
 .      IL
-.      rr #STORED_R_INDENT
-.      rr #STORED_L_INDENT
 .   \}
 .\" Clean up after exiting last depth of list
 .   nr #REMOVE 0 1
@@ -15984,6 +16293,11 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .      rm $ENUMERATOR_TYPE\\n[#REMOVE]
 .      rr #PAD_LIST_DIGITS\\n[#REMOVE]
 .   \}
+.   rr #STORED_L_INDENT
+.   rr #STORED_BL_INDENT
+.   rr #STORED_BR_INDENT
+.   rr #STORED_R_INDENT
+.   rr #STORED_R_INDENT
 .   rr #REMOVE
 .   rr #TOTAL_LISTS
 .   rr #QUIT
@@ -16035,6 +16349,7 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 \#   N.B.--the START macro must be used after every COLLATE
 \#
 .MAC COLLATE END
+.    if dPDF.EXPORT .tm .ds pre-collate-\\n% address@hidden
 .    if \\n[defer] .bp
 .    if \\n[#FORCE_RECTO] \
 .       if o .BLANKPAGE 1 DIVIDER
@@ -16060,9 +16375,9 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .    nr #PRE_COLLATE 1
 .    nr #POST_TOP 1
 .    nr #HEAD_1_NUM 0 1
-.    nr eqn*label-width     (\\n[eqn*label-num] >? \\n[eqn*label-width])
-.    nr fig*label-width     (\\n[fig*label-width] >? \\n[fig*label-width])
-.    nr tbl*label-width     (\\n[tbl*label-num] >? \\n[tbl*label-width])
+.    nr eqn*label-width (\\n[eqn*label-num] >? \\n[eqn*label-width])
+.    nr fig*label-width (\\n[fig*label-width] >? \\n[fig*label-width])
+.    nr tbl*label-width (\\n[tbl*label-num] >? \\n[tbl*label-width])
 .    if \\n[eqn*label-with-chapter]=1     .nr eqn*label-num 0 1
 .    if \\n[float*label-with-chapter]=1   .nr fig*label-num 0 1
 .    if \\n[pdf-img*label-with-chapter]=1 .nr fig*label-num 0 1
@@ -16096,7 +16411,7 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .      rs
 .      nop \&
 .    \}
-.    if '\\n[.ev]'PAGE_TRANSITION' .ev
+.    if '\\n[.ev]'P+AGE_TRANSITION\\n[pg-trans]' .ev
 .    if \\n[#DEFER_PAGINATION] .PAGINATE
 .    if !'\\*[$RESTORE_PAGENUM_STYLE]'' \{\
 .       PAGENUM_STYLE \\*[$RESTORE_PAGENUM_STYLE]
@@ -16140,6 +16455,7 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .    nr #LOOP 0 1
 .    while \\n+[#LOOP]<address@hidden \
 .       rr #TOC_HEAD_\\n[#LOOP]_INDENT_SET 1
+.    if \\n[#FLEX_ACTIVE] .rr #NO_FLEX
 .END
 \#
 \# NUMBER_LINES
@@ -16393,6 +16709,10 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 ..
 \#
 .MAC PROCESS_FLOATS END
+.    if \\n[#TAB_ACTIVE] \{\
+.       nr #RESTORE_TAB 1
+.       TQ
+.    \}
 .    if (\\n[float*defer]>0):(\\n[defer]=0) \{\
 .       if !\\n[tbl*no-top-hook] address@hidden
 .       rr tbl*no-top-hook
@@ -16404,7 +16724,7 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .       rs
 .       nop \&
 .       sp |\\n[#T_MARGIN]u-\\n[#DOC_LEAD]u
-.       if '\\*[float*type:1]'boxed-tbl' \{\
+.       if '\\*[float*type:\\n[defer]]'boxed-tbl' \{\
 .          ch address@hidden
 .          if (\\n[.t] >= 1)&(\\n[float-depth:1] > \\n[.t]) \
 .             tbl*float-warning
@@ -16415,9 +16735,8 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .       \}
 .       if \\n[float*pic] \{\
 .          if (\\n[pic*have-caption]=1)&(\\n[pic*caption-after-label]=0) \{\
-.             ie \\n[#COLUMNS] \{\
+.             ie \\n[#COLUMNS] \
 .                sp |\\n[dc]u-.5v
-.             \}
 .             el \
 .                sp |\\n[#T_MARGIN]u-\\n[#DOC_LEAD]u-.5v
 .          \}
@@ -16430,6 +16749,10 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .             sp |\\n[dc]u
 .          el \
 .             sp |\\n[#T_MARGIN]u-\\n[#DOC_LEAD]u
+.          if \\n[pdf-img:frame] \{\
+.             sp -(\\*[pdf-img:frame-weight]p*2u)
+.             rr pdf-img:frame
+.          \}
 .       \}
 .       nr defer-count \\n[defer]
 .       nr loop-count  0 1
@@ -16440,9 +16763,8 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .          vpt
 .          ch address@hidden
 .          rr @TOP
-.          if \\n[pdf-img*have-caption] \{\
+.          if \\n[pdf-img*have-caption] \
 .             if !\\n[pdf-img*caption-after-label] .sp -.5v
-.          \}
 .          rr pdf-img*have-caption
 .          rr pic*have-caption
 .          if '\\*[float*type:\\n[loop-count]]'table' \{\
@@ -16463,6 +16785,7 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .             rr tbl*no-top-hook
 .             output-float
 .          \}
+.          if !\\n[loop-count]=\\n[defer-count] .rr flexed
 .       \}
 .       rm FLOAT*DIV:\\n[loop-count]
 .       rr float-depth:\\n[loop-count]
@@ -16480,9 +16803,21 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .       rr float*defer
 .       ch FOOTER \\n[#VARIABLE_FOOTER_POS]u
 .       ch FN_OVERFLOW_TRAP -\\n[#FN_OVERFLOW_TRAP_POS]u
+.       if \\n[.t]<\\n[.v] .bp
 .       ev
-.       SHIM
-.       if \\n[#SHIM]>(\\n[#DOC_LEAD]-(\\n[#DOC_LEAD]/4)) 'sp -\\n[#DOC_LEAD]u
+.       ie !\\n[#NO_SHIM] .SHIM
+.       el \{\
+.          if !\\n[#NO_FLEX] \
+.             if !\\n[flexed] .FLEX 
+.       \}
+.       if !\\n[#NO_SHIM] \
+.          if \\n[#SHIM]>(\\n[#DOC_LEAD]-(\\n[#DOC_LEAD]/4)) \
+'             sp -\\n[#DOC_LEAD]u
+.       ie !\\n[flex:force] .ns
+.       el \{\
+.          rr flex:force
+.          if !\\n[#NO_FLEX] .FLEX
+.       \}
 .       nr tbl*have-header 0
 .       rr loop-count
 .       rr defer-count
@@ -16499,24 +16834,33 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .    rr float*eqn
 .    rr float*tbl
 .    rr float*pic
+.    if \\n[#RESTORE_TAB] \{\
+.       TAB \\n[#CURRENT_TAB]
+.       rr #RESTORE_TAB
+.    \}
 .END
 \#
 .MAC output-float END
 .    vpt 0
-.    nop \&
-.    sp -1
+.    if \\n[.ns] \{\
+.       rs
+.       nop \&
+.       sp -1
+.    \}
 .    if \\n[no-top-space] \{\
 .       ie !\\n[#COLUMNS] \{\
-.          sp |\\n[#T_MARGIN]u-\\n[#DOC_LEAD]u
+.          sp |\\n[#T_MARGIN]u-\\n[#DOC_LEAD]u+.5
 .          ns
 .       \}
 .       el .sp |\\n[dc]u
 .       if \\n[float*tbl] \{\
 .          rs
-.          if \\n[tbl*caption-top-lead-diff] \{\
+.          ie \\n[tbl*caption-top-lead-diff] \{\
 .             sp \\n[tbl*caption-top-lead-diff]u
 .             rr tbl*caption-top-lead-diff
 .          \}
+.          el \
+.             if '\\*[float*type:\\n[float*defer]]'boxed-tbl' .sp 2p
 .       \}
 .    \}
 .    if \\n[float*pic] \{\
@@ -16532,6 +16876,7 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .    if \\n[q-float] \
 .       if !\\n[has-caption] .sp \\n[#Q_LEAD_DIFF]u
 .    ns
+.    vpt
 .    FLOAT*DIV:\\n[loop-count]
 .    if \\n[no-top-space] \{\
 .       rs
@@ -16542,19 +16887,21 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .    if \\n[#COLUMNS] \
 .       if !'\\*[pic*space-adj]'' .sp -\\*[pic*space-adj]
 .    rm pic*space-adj
-.    if \\n[D-float:\\n[loop-count]] \{\
-.       sp \
--\\n[float-depth:\\n[loop-count]]u+\\n[D-float:\\n[loop-count]]u+\\n[#DOC_LEAD]u
+.    if \\n[D-float:\\n[loop-count]] \
 .       rr D-float:\\n[loop-count]
-.    \}
-.    if (\\n[float*tbl]=0)&(\\n[float*pic]=0)&\
+.    if !\\n[.t]<=(\\n[#DOC_LEAD]/2) \{\
+.       if (\\n[float*tbl]=0)&(\\n[float*pic]=0)&\
 (\\n[float*eqn]=0):(\\n[q-float]=1) \
-.       sp \\n[#DOC_LEAD]u/2u
-.    if !\\n[float*no-shim] \
-.       if !\\n[q-float] .SHIM
+.          sp \\n[#DOC_LEAD]u/2u
+.       if address@hidden \
+.          if !\\n[q-float] \
+.             if !\\n[#NO_SHIM] .SHIM
+.    \}
 .    rr float*tbl
 .    rr float*pic
 .    rr float*eqn
+.    rr D-float
+.    rr @no-shim
 .    rr q-float
 .    rm B_QUOTE
 .    rm P_QUOTE
@@ -16574,20 +16921,6 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 \#   a new page immediately.
 \#
 .MAC FLOAT END
-.\"  Case where upcoming .br breaks to a new page, causing a defered float
-.\"  to be output by HEADER and the defer register to be cleared.
-.    nr pagenum \\n%+\\n[#PAGE_NUM_ADJ]
-.    br
-.\" Clear .ns when a single line of running text precededs float
-.\" at the top of the page.
-.    if \\n[nl]=\\n[#PAGE_TOP] \{\
-.       vpt 0
-.       sp -1v
-.       sp
-.       ch address@hidden
-.       rr @TOP
-.       vpt
-.    \}
 .    if \\n[#NUM_ARGS]>0 \{\
 .       nr loop-count 0 1
 .       nr loop-counter \\n[#NUM_ARGS]
@@ -16606,35 +16939,114 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .             shift
 .          \}
 .          if '\\$1'NO_SHIM' \{\
-.             nr float*no-shim 1
+.             nr @no-shim 1
+.             shift
+.          \}
+.          if '\\$1'NO_FLEX' \{\
+.             nr @no-flex 1
+.             shift 1
+.          \}
+.          if '\\$1'TARGET' \{\
 .             shift
+.             ds float*target "\\$1
+.             shift 1
 .          \}
 .       \}
 .    \}
+.    ie \\n[float*started] .rr float*started
+.    el \{\
+.       while !'\\$1'' .shift \\$1
+.       nr float*started 1
+.    \}
 .    ie '\\$1'' \{\
+.\" Harmonize floats treated as defers and floats proper to the top
+.\" of the next page between passes when flex is enabled.
+.\"
+.\" Without this, floats near the bottom of the page may be deferred
+.\" on the first pass, but when flex-spacing moves the line just
+.\" before the float to the bottom of the page, the upcoming .br
+.\" causes the float to be proper to the next page instead of
+.\" deferred to it.
+.       nr floatnum +1
+.       ie !\\n[#NO_FLEX] \{\
+.\" Only on 2nd pass
+.          if !dPDF.EXPORT \{\
+.             ie d float\\n[floatnum]:no-defer .br
+.             el \{\
+.\" .v in the following is arbitrary.  Groff rounds down decimal
+.\" fractions so flex-spacing may be slightly short.  Since there
+.\" are no conditions under which a .t-1 (bottom margin) < .v
+.\" on the 1st pass doesn't cause a float to be deferred, all floats
+.\" on the second pass that meet the condition are also, correctly,
+.\" deferred.
+.                if (\\n[.t]-1)<\\n[.v] \
+.                   if address@hidden .nr no-break 1
+.             \}
+.          \}
+.\" Only on 1st pass
+.          ie !\\n[no-break] \{\
+.             ds pre-float:address@hidden address@hidden
+.             br
+.             ds post-float:address@hidden address@hidden
+.             if dPDF.EXPORT \{\
+.                if 
!'\\*[pre-float:address@hidden'\\*[post-float:address@hidden' \
+.                   tm .ds float\\n[floatnum]:no-defer 1
+.             \}
+.          \}
+.          el .rr no-break
+.       \}
+.       el .br
+.       if \\n[nl]=\\n[#PAGE_TOP] \
+.          RESTORE_SPACE
+.       ds ev-pre-float \\n[.ev]
 .       ev FLOAT
-.       evc 0
-.       nf
+.       evc \\*[ev-pre-float]
 .       di FLOAT*DIV
+.       if !'\\*[float*target]'' .PDF_TARGET "\\*[float*target]
+.       rm float*target
+.       nf
 .    \}
 .    el \{\
 .       br
+.\" So @no-shim persists if float output with output-float
+.       if r @no-shim .nr float*no-shim 1
 .       di
-.       if \\n[float*table] \
-.          if !\\n[tbl*have-header] .ev
-.       ev
+.       ie \\n[float*tbl] \
+.          if !\\n[tbl*have-header] .ev 0
+.       el .ev 0
 .       if \\n[tbl*boxed] \{\
+.          ch FOOTER \\n[#VARIABLE_FOOTER_POS]u+\\n[#DOC_LEAD]u
+.          ch FN_OVERFLOW_TRAP -\\n[#FN_OVERFLOW_TRAP_POS]u+\\n[#DOC_LEAD]u
 .          ie !\\n[#MLA] \{\
-.             ie (address@hidden):(address@hidden) .nr dn -.65v
+.             ie (address@hidden):(address@hidden):(\\n[tbl*autolabel]=1) .nr 
dn -.65v
 .             el .nr dn +.65v
 .          \}
-.          el \{\
+.          el \
 .             if address@hidden .nr dn -1.65v
-.          \}
 .       \}
-.       if (\\n[dn]>\\n[.t]):(\\n[D-float]>\\n[.t]) \{\
-.          ie address@hidden \
+.       if (\\n[dn]>\\n[.t]):(\\n[D-float]>\\n[.t]):(\\n[defer]>0) \{\
+.          if 
(\\n[dn]+(\\n[.v]*2)>(\\n[.p]-\\n[#TOP_MARGIN]-\\n[#DOC_LEAD]-\\n[#B_MARGIN])) 
\{\
+.             tm1 "[mom]: Floated element exceeds page depth.
+.             ab   [mom]: Aborting '\\n[.F]' at line \\n[.c].
+.          \}
+.\" Save depth of diversion here.  The .da zeroes it.
+.          nr dn-save \\n[dn]
+.          if address@hidden \{\
+.             da FLOAT*DIV
+\!.           FLEX
+\!.           nr flexed 1
+.             da
+.          \}
+.          nr dn \\n[dn-save]
+.          rr dn-save
+.          ch FOOTER \\n[#VARIABLE_FOOTER_POS]u
+.          ch FN_OVERFLOW_TRAP -\\n[#FN_OVERFLOW_TRAP_POS]u
+.          ev 0
+.          ie address@hidden \{\
+.             br
 .             if \\n[tbl*boxed] .rs
+.             rr tbl*boxed
+.          \}
 .          el \{\
 .             if !\\n[defer] .nr defer 0 1
 .             rn FLOAT*DIV FLOAT*DIV:\\n+[defer]
@@ -16655,21 +17067,33 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .                if \\n[defer]=1 .nr no-top-space 1
 .                ds float*type:\\n[defer] eqn
 .             \}
-.             if \\n[float*pic] \{\
+.             if \\n[float*pic] \
 .                ds float*type:\\n[defer] pic
-.             \}
-.             if \\n[float*img] \{\
+.             if \\n[float*img] \
 .                ds float*type:\\n[defer] img
-.             \}
 .             if \\n[D-float] .nr D-float:\\n[defer] \\n[D-float]
 .             nr float-depth:\\n[defer] \\n[dn]
 .             if \\n[#FORCE] \{\
-.                bp
+.                ie \\n[#COLUMNS] .COL_NEXT
+.                el .NEWPAGE
 .                rr #FORCE
 .             \}
+.             if r tbl*boxed .rr tbl*boxed
+.             br
 .             return \" output div after header
 .          \}
 .       \}
+.       nr dn-save \\n[dn]
+.       if address@hidden \{\
+.          da FLOAT*DIV
+\!.        FLEX
+\!.        nr flexed 1
+.          da
+.       \}
+.       nr dn \\n[dn-save]
+.       rr dn-save
+.       ch FOOTER \\n[#VARIABLE_FOOTER_POS]u
+.       ch FN_OVERFLOW_TRAP -\\n[#FN_OVERFLOW_TRAP_POS]u
 .       if !'\\*[float-adj]'' .sp \\*[float-adj]
 .       if \\n[.u] .nr fill 1
 .       if address@hidden \{\
@@ -16680,28 +17104,52 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .          if (\\n[#MLA]=1)&(address@hidden) \
 .             chop FLOAT*DIV
 .          if \\n[nl]=\\n[#PAGE_TOP] \{\
-.             if \\n[tbl*have-caption] \{\
+.             ie \\n[tbl*have-caption] \{\
 .                ie !\\n[#MLA] .sp \\n[tbl*caption-lead-diff]u
 .                el \{\
 .                   ch address@hidden
 .                   sp \\n[tbl*label-lead-diff]u-.5v
 .                \}
 .             \}
+.             el \{\
+.                ev protect
+.                evc FLOAT
+.                nf
+.                RESTORE_SPACE
+.                ie \\n[tbl*boxed] .sp |\\n[#PAGE_TOP]u+.25v+2p
+.                el .sp |\\n[#PAGE_TOP]u-.25v
+.             \}
+.          \}
+.       \}
+.       if \\n[float*img] \
+.          if \\n[pdf-img:frame] .sp -(\\*[pdf-img:frame-weight]p*2u)
+.       if !'\\n[.ev]'protect' \{\
+.          ev protect
+.          evc FLOAT
+.          nf
+.       \}
+.       if \\n[float*tbl] \{\
+.          if \\n[tbl*boxed] \{\
+.             ch FOOTER \\n[#VARIABLE_FOOTER_POS]u+\\n[#DOC_LEAD]u
+.             ch FN_OVERFLOW_TRAP -\\n[#FN_OVERFLOW_TRAP_POS]u+\\n[#DOC_LEAD]u
 .          \}
 .       \}
-.       ev protect
-.       evc FLOAT
-.       nf
 .       FLOAT*DIV
 .       ev
 .       if \\n[float*tbl] \{\
 .          ie \\n[tbl*boxed] \{\
-.             if \\n[dn]=\\n[bx-tbl-depth] .sp .35v
-.             if \\n[tbl*plain-boxed] .sp .5v
 .             ch FOOTER \\n[#VARIABLE_FOOTER_POS]u
 .             ch FN_OVERFLOW_TRAP -\\n[#FN_OVERFLOW_TRAP_POS]u
-.             rr tbl*boxed
-.             rr bx-tbl-depth
+.             ie \\n[nl]>(\\n[.p]+\\n[#VARIABLE_FOOTER_POS]) \{\
+.                ie \\n[#COLUMNS] .COL_NEXT
+.                el .NEWPAGE
+.             \}
+.             el \{\
+.                if \\n[dn]=\\n[bx-tbl-depth] .sp .35v
+.                if \\n[tbl*plain-boxed] .sp .5v
+.                rr tbl*boxed
+.                rr bx-tbl-depth
+.             \}
 .          \}
 .          el \{\
 .             if '\\*[tbl*label]'' \
@@ -16717,8 +17165,17 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .          rm tbl*label
 .          rm tbl*source
 .       \}
-.       if \\n[D-float] \
-.          sp -\\n[dn]u+\\n[#DOC_LEAD]u+\\n[D-float]u
+.       if \\n[D-float] \{\
+.          ie \\n[dn]=0 .sp \\n[D-float]u+\\n[#DOC_LEAD]u
+.          el \
+.             if \\n[dn]<\\n[D-float] \
+.                sp \\n[D-float]u+\\n[#DOC_LEAD]u-\\n[dn]u
+.\" Flex won't grab .h of D-floats without a dummy text line.
+.          vpt 0
+.          nop \&
+.          sp -1
+.          vpt 1
+.       \}
 .       if \\n[fill] \{\
 .          fi
 .          rr fill
@@ -16726,14 +17183,25 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .       rm FLOAT*DIV
 .       if !'\\*[float-adj]'' \
 .          if !\\n[no-adjust] .sp -\\*[float-adj]
-.       if !\\n[float*no-shim] .SHIM
+.       if !\\n[#NO_SHIM] \
+.          if address@hidden .SHIM
 .       rm float-adj
 .       rm no-adjust
 .       rr D-float
-.       rr float*no-shim
+.       rr @no-shim
+.       rr @no-flex
 .       rr #FORCE
 .       rm P_QUOTE
 .       rm B_QUOTE
+.       if \\n[float*img] .rr float*img
+.       if \\n[float*pic] .rr float*pic
+.       if \\n[float*eqn] .rr float*eqn
+.       rr float*target
+.       rm float*target
+.       if \\n[#NO_SHIM] \
+.          if !\\n[#NO_FLEX] .nr post-float 1
+.       ev \\*[ev-pre-float]
+.       rm ev-pre-float
 .    \}
 .END
 \#
@@ -16744,7 +17212,7 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 \# *Function:
 \#   Sets header/footer/footnotes/etc... traps.
 \#
-\#   Calculates the number of lines that actually fit on a
+\#   TRAPS calculates the number of lines that actually fit on a
 \#   page based on #B_MARGIN and resets page bottom trap to coincide
 \#   with the depth of that number of lines, or, if #ADJ_DOC_LEAD=1,
 \#   adjusts #DOC_LEAD so that the last line of text on a page falls
@@ -16765,7 +17233,7 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .END
 \#
 .MAC TRAPS END
-.    if !\\n[#UNADJUSTED_DOC_LEAD]  .nr #UNADJUSTED_DOC_LEAD address@hidden
+.    if !\\n[#UNADJUSTED_DOC_LEAD] .nr #UNADJUSTED_DOC_LEAD address@hidden
 .\" Remove all header/footer traps
 .    if !\\n[#NO_TRAP_RESET] \{\
 .       ch DO_T_MARGIN
@@ -16884,10 +17352,11 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .END
 \#
 \# This .em (for all DOC_TYPEs, except 4 [LETTER]) ensures that
-\# deferred footnotes that happen on the 2nd to last page get
-\# output.
+\# deferred footnotes and floats that happen on the 2nd to last page
+\# get output, and the last page/col isn't flexed.
 \#
 .MAC TERMINATE END
+.    if dPDF.EXPORT .tm .ds last-page address@hidden
 .    ie \\n[#FN_DEPTH] \{\
 .       ie \\n[#FN_DEFER] \{\
 .          br
@@ -16907,6 +17376,8 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .       ch FN_OVERFLOW_TRAP
 .       FOOTER
 .    \}
+.    if \\n[defer] \
+'       bp
 .END
 \#
 \# END MACRO FOR LETTERS
@@ -17303,6 +17774,8 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .ALIAS  ENDNOTES_HEADER_CENTRE ENDNOTES_HDRFTR_CENTER
 .
 .ALIAS  FOOTER_CENTER           HDRFTR_CENTER
+.ALIAS  TOC_PAGEFOOTER_CENTER   HDRFTR_CENTER
+.ALIAS  TOC_PAGEFOOTER_CENTRE   HDRFTR_CENTER
 .ALIAS  FOOTER_CENTER_CAPS      _HDRFTR_CAPS
 .ALIAS  FOOTER_CENTER_PAD       HDRFTR_CENTER_PAD
 .ALIAS  FOOTER_CENTER_SMALLCAPS _HDRFTR_SMALLCAPS
@@ -17323,6 +17796,8 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .ALIAS  FOOTER_VERSO            HDRFTR_VERSO
 .
 .ALIAS  HEADER_CENTER           HDRFTR_CENTER
+.ALIAS  TOC_PAGEHEADER_CENTER   HDRFTR_CENTER
+.ALIAS  TOC_PAGEHEADER_CENTRE   HDRFTR_CENTER
 .ALIAS  HEADER_CENTER_CAPS      _HDRFTR_CAPS
 .ALIAS  HEADER_CENTER_PAD       HDRFTR_CENTER_PAD
 .ALIAS  HEADER_CENTER_SMALLCAPS _HDRFTR_SMALLCAPS
@@ -17623,9 +18098,8 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .    \}
 .    if '\\n[\\*[label-type]*\\*[spec-type]-quad-on-ll]'' \
 .       nr \\*[label-type]*\\*[spec-type]-quad-on-ll 1
-.    if '\\*[spec-type]'caption' \{\
+.    if '\\*[spec-type]'caption' \
 .       nr default-left 1
-.    \}
 .END
 \#
 .MAC set-inline-specs END
@@ -17641,10 +18115,10 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .MAC SET_QUAD END
 .    ds label-type \\$0
 .    substring label-type 0 2
-.    if '\\*[label-type]'PDF'  .ds label-type pdf-img
-.    if '\\*[label-type]'TBL'  .ds label-type tbl
-.    if '\\*[label-type]'PIC'  .ds label-type pic
-.    if '\\*[label-type]'EQN'  .ds label-type eqn
+.    if '\\*[label-type]'PDF'   .ds label-type pdf-img
+.    if '\\*[label-type]'TBL'   .ds label-type tbl
+.    if '\\*[label-type]'PIC'   .ds label-type pic
+.    if '\\*[label-type]'EQN'   .ds label-type eqn
 .    ds spec-type \\$0
 .    substring spec-type -6 -10
 .    if '\\*[spec-type]'PTION' .ds spec-type caption
@@ -17717,8 +18191,12 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .       if !\\n[tbl*\\*[spec-type]-quad-on-ll] \{\
 .          ie \\n[tbl*center] \{\
 .             ie '\\*[spec-type]'label' \{\
-.                ll \\n[ll-pre-tbl]u-\\n[TW]u/2u+\\n[TW]u
-\!.                in \\n[ll-pre-tbl]u-\\n[TW]u/2u
+.\" Differentiate between a tbl label and a float label
+.                ie !'\\*[ev-current]'FLOAT' \{\
+.                   ll \\n[ll-pre-tbl]u-\\n[TW]u/2u+\\n[TW]u
+\!.                 in \\n[ll-pre-tbl]u-\\n[TW]u/2u
+.                \}
+.                el .sp -1
 .             \}
 .             el \{\
 .                ll \\n[TW]u
@@ -17865,6 +18343,8 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .                 get-label-type
 .                 ds \\*[label-type]*\\*[spec-type]-quad \\$1
 .                 substring \\*[label-type]*\\*[spec-type]-quad 0 0
+.                 if '\\$2'ON_LL' \
+.                    nr \\*[label-type]*\\*[spec-type]-quad-on-ll 1
 .             \}
 .          \}
 .          el \{\
@@ -17872,12 +18352,11 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .             substring \\*[label-type]*\\*[spec-type]-quad 0 0
 .             if \\n[\\*[label-type]*\\*[spec-type]-quad-on-ll] \
 .                rr \\*[label-type]*\\*[spec-type]-quad-on-ll 
+.             if '\\$2'ON_LL' \
+.                nr \\*[label-type]*\\*[spec-type]-quad-on-ll 1
 .          \}
-.          shift
-.          if '\\$1'ON_LL' \{\
-.             nr \\*[label-type]*\\*[spec-type]-quad-on-ll 1
-.             shift
-.          \}
+.          ie '\\$2'ON_LL' .shift 2
+.          el  .shift
 .       \}
 .       if '\\$1'COLOR' \{\
 .          shift
@@ -17980,13 +18459,25 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 \#   can only take one double-quoted text string.
 \#
 \# These strings allow users to create labels of the form
-\# 'Fig. \*[chapter].\*[label]', e.g. 'Fig. 1.1'
+\# 'Fig. \*[chapter].\*[fig-label]', e.g. 'Fig. 1.1'
+\#
+.ds chapter   \\n[#CH_NUM]
+.ds fig-label \\n+[fig*label-num]
+.ds tbl-label \\n+[tbl*label-num]
+.ds eqn-label \\n+[eqn*label-num]
 \#
-.ds chapter \\n[#CH_NUM]
-.ds label \\n+[lists*target]
 \#
 .MAC LABEL END
 .    br
+.    if \\n[.ns] \{\
+.       vpt 0
+.       rs
+.       nop \&
+.       sp -1
+.       vpt
+.    \}
+.    if r chop-space .sp -1
+.    rr chop-space
 .    if \\n[#QUOTE] .nr q-float 1
 .    if '\\$0'CAPTION' \{\
 .       ds labelcap caption
@@ -18017,6 +18508,9 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .          \}
 .       \}
 .    \}
+.    if \\n[D-float] \
+.       if \\n[.d]>\\n[D-float] \
+.          sp \\n[.d]u-\\n[D-float]u
 .    rr has-\\*[labelcap]
 .    nr has-\\*[labelcap] 1
 .    rr @bottom
@@ -18040,8 +18534,10 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .          el \
 .            if '\\n[.z]'FLOAT*DIV' .sp \\n[#DOC_LEAD]u/4u
 .       \}
-.       el \
+.       el \{\
 .          sp \\n[#DOC_LEAD]u/4u
+.          rr @bottom
+.       \}
 .    \}
 \!.  if \\\\n[deferred-float] \{\
 .       if !\\n[#QUOTE] .sp -(\\n[#DOC_LEAD]u/4u)
@@ -18055,6 +18551,7 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .    ie '\\*[labelcap]'label' \{\
 .       if \\n[to-list] \{\
 .\" Strip prefix from label if list-type is being autolabelled
+.\" Becomes $LIST_LABEL
 .          if '\\*[$LIST_OF]'FIGURES' \
 .             if r fig*label-num .STRIP_PRFX_SFFX "\\*[$FLOATING_LABEL]"
 .          if '\\*[$LIST_OF]'TABLES' \
@@ -18062,7 +18559,6 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .          if '\\*[$LIST_OF]'EQUATIONS' \
 .             if r eqn*label-num .STRIP_PRFX_SFFX "\\*[$FLOATING_LABEL]"
 .       \}
-.\"
 .       ds $FLOATING_LABEL \
 \F[\\\\*[floating*label-family]]\
 \f[\\\\*[floating*label-font]]\
@@ -18071,9 +18567,8 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 \\*[$FLOATING_LABEL]
 .    \}
 .    el \{\
-.       if !\\n[deferred-float] \{\
+.       if !\\n[deferred-float] \
 .          sp \\n[floating*caption-lead-diff]u
-.       \}
 .       if !'\\*[floating*caption-space]'' \
 .          sp \\*[floating*caption-space]
 .       while !'\\$1'' \{\
@@ -18099,11 +18594,8 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 \s[\\\\*[floating*caption-size-change]]\
 \m[\\\\*[floating*caption-color]]\
 \\*[$FLOATING_CAPTION]
-.       if !'\\*[$LIST_LABEL]'' \
-.          as $LIST_LABEL .\0
 .       if '\\*[$LIST_CAPTION]'' \
 .          ds $LIST_CAPTION \\*[$FLOATING_CAPTION]
-.       as $LIST_LABEL \\*[$LIST_CAPTION]
 .    \}
 .    if !'\\*[$FLOATING_LABEL]'' \{\
 .       sp \\n[floating*label-lead-diff]u
@@ -18150,7 +18642,7 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .          ds labelcap caption
 .       \}
 .       ie '\\*[$LIST_LABEL]'' .TO_\\*[$LIST_OF] "\\*[$FLOATING_LABEL]
-.       el .TO_\\*[$LIST_OF] "\\*[$LIST_LABEL]
+.       el .TO_\\*[$LIST_OF] "\\*[$LIST_LABEL]" "\\*[$LIST_CAPTION]
 .       rr to-list
 .       nr loop-counter 0 1
 .       nr loop-count 2
@@ -18212,9 +18704,9 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .    if !\\n[#MLA] \{\
 .       nr \\*[type]*caption-after-label 1
 .       if '\\$1'ALL' \{\
-.          if '\\$1'IMG' .nr pdf-img*caption-after-label 1
-.          if '\\$1'TBL' .nr tbl*caption-after-label 1
-.          if '\\$1'PIC' .nr pic*caption-after-label 1
+.          nr pdf-img*caption-after-label 1
+.          nr tbl*caption-after-label 1
+.          nr pic*caption-after-label 1
 .       \}
 .       if !'\\$2'' \{\
 .          ie !'\\$1'ALL' .rr \\*[type]*caption-after-label
@@ -18242,6 +18734,7 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .    if '\\$0'AUTOLABEL_IMAGES'    .ds label-type pdf-img
 .    if '\\$0'AUTOLABEL_PIC'       .ds label-type pic
 .    if '\\$0'AUTOLABEL_TABLES'    .ds label-type tbl
+.    if '\\$0'AUTOLABEL_IMAGES'    .nr fig*autolabel 1
 .    if !'\\$1'' \{\
 .       ds \\*[label-type]-label-args \\$1
 .       substring \\*[label-type]-label-args -1 -3
@@ -18271,6 +18764,10 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .       if '\\$1'PREFIX_CHAPTER' \{\
 .          nr \\*[label-type]*label-with-chapter 1
 .          shift 1
+.          if \B'\\$1' \{\
+.             nr #CH_NUM \\$1
+.             shift
+.          \}
 .       \}
 .    \}
 .    if '\\*[\\*[label-type]*label-prfx]'' \{\
@@ -18324,6 +18821,26 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .ALIAS AUTOLABEL_PIC       AUTOLABEL
 .ALIAS AUTOLABEL_TABLES    AUTOLABEL
 \#
+\# SET AUTOLABEL NUMBER
+\# --------------------
+\# *Argument:
+\#   FIG | TBL | PIC | EQN <n>
+\# *Function:
+\#   Sets the autolabel number for the corresponding label type.
+\# *Notes:
+\#   Used to set autolabel number when manual labelling of floats
+\#   (in conjunction with TO_LIST) disrupts auto-incrementing.
+\#   
+.MAC SET_AUTOLABEL END
+.    rm labelnum-type
+.    if '\\$1'FIG' .ds labelnum-type fig
+.    if '\\$1'TBL' .ds labelnum-type tbl
+.    if '\\$1'PIC' .ds labelnum-type pic
+.    if '\\$1'EQN' .ds labelnum-type eqn
+.    nr labelnum \\$2-1
+.    nr \\*[labelnum-type]*label-num \\n[labelnum] 1
+.END
+\#
 \# MLA STYLE
 \# ---------
 \# *Argument:
@@ -18341,9 +18858,8 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .       nr pic*caption-after-label 1
 .       rr tbl*caption-after-label
 .    \}
-.    el \{\
+.    el \
 .       rr #MLA
-.    \}
 .END
 \#
 .MAC address@hidden END
@@ -18358,7 +18874,7 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 \#   LIST_OF_FIGURES
 \#   LIST_OF_TABLES
 \# *Arguments:
-\#   TITLE_STRING <string> START_PAGENUM <pagenumber>
+\#   [ TITLE_STRING <string> ] [ START_PAGENUM <pagenumber> ]
 \# *Function:
 \#   Generates lists-of based on calling alias.
 \# *Notes:
@@ -18368,6 +18884,7 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 \#
 .MAC LISTS_OF END
 .    ds $LIST_TYPE \\$0
+.    nr #LISTS 1
 .    substring $LIST_TYPE -1 -4
 .    if '\\*[$LIST_TYPE]'URES' \{\
 .       ds $LIST_TYPE FIGURES
@@ -18394,6 +18911,10 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .          shift 2
 .       \}
 .    \}
+.    if dPDF.EXPORT \
+.       if \\n[#FLEX_ACTIVE] \
+.          if !\\n[#NO_FLEX] \
+.             tm .ds address@hidden 1
 .    char \[leader] " .
 .    LEADER_CHARACTER \[leader]
 .    if \\n[#LINENUMBERS]=1 \{\
@@ -18510,7 +19031,7 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .       if \\n[\\*[list-type]*label-width]<100  .nr label-width 2
 .       if \\n[\\*[list-type]*label-width]<10   .nr label-width 1
 .\" Calculate width of label-num tab
-.       nr label-width \w'\0'*(\\n[chapno-width]+\\n[label-width])+\w'.'
+.       nr label-width \w'\0'*(\\n[chapno-width]+\\n[label-width])
 .    \}
 .    if \\n[#SLANT_ON] .nop \\*[SLANTX]
 .    if \\n[#COLUMNS]=1 .nr #COLUMNS 0
@@ -18524,6 +19045,7 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .       nr #LINENUMBERS 1
 .       nn 1
 .    \}
+.    rr #LISTS
 .    pdfsync
 .END
 .\"
@@ -18751,19 +19273,17 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .       ds list-type eqn
 .       da LIST_OF_EQN
 \!.       nr #LISTS_PN_PADDING \\\\n[#EQN_PN_PADDING]
-.       nr label-width \s[\\n[#LISTS_PS]u]\w'\\$1'\s[0]
 .    \}
 .    if '\\$0'TO_FIGURES' \{\
 .       ds list-type fig
+.       ds label-type fig
 .       da LIST_OF_FIG
 \!.       nr #LISTS_PN_PADDING \\\\n[#FIG_PN_PADDING]
-.       nr label-width \s[\\n[#LISTS_PS]u]\w'\\$1'\s[0]
 .    \}
 .    if '\\$0'TO_TABLES' \{\
 .       ds list-type tbl
 .       da LIST_OF_TBL
 \!.       nr #LISTS_PN_PADDING \\\\n[#TBL_PN_PADDING]
-.       nr label-width \s[\\n[#LISTS_PS]u]\w'\\$1'\s[0]
 .    \}
 .    br
 .    nr #LISTS_ENTRY_PN \\n%+\\n[#PAGE_NUM_ADJ]
@@ -18782,7 +19302,7 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 \!.  PAD_MARKER ^
 \!.  vpt 0
 \!.  PAD \
-"\\*[ST100]\h'\\n[label-width]u'\\*[ST100X]\\*[ST101]\h'\w'\\$2'u'\\*[ST101X]\\\\*[$LISTS_PN\\*[_TYPEWRITE]]"
 \
+"\\*[ST100]\h'\\\\n[label-width]u'\\*[ST100X]\0\0\\*[ST101]\h'\w'\\$2'u'\\*[ST101X]\\\\*[$LISTS_PN\\*[_TYPEWRITE]]"
 \
 "\\*[PDFBOOKMARK.NAME]"
 \!.  PAD_MARKER #
 \!.  EOL
@@ -18801,14 +19321,16 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 \!.  TAB 100
 \!.  PDF_LINK \\*[list-type]:\\n[lists*target] "\\$1"
 \!.  TN
+\!.  vpt 0
 \!.  PDF_LINK \\*[list-type]:\\n[lists*target] "\\$2"
 \!.  TN
-\!.  PRINT \\*[LEADER]
+\!.  vpt 0
+\!.  PRINT \fR\\*[LEADER]\f[]
 \!.  TN
 .    if \\n[#PRINT_STYLE]=2 \{\
 \!.     FAMILY  \\\\*[$LISTS_PN_FAM]
 \!.     FT      \\\\*[$LISTS_PN_FT]
-\!.     ps \\\\*[$LISTS_PN_SIZE_CHANGE]u
+\!.     ps \\\\*[$LISTS_PN_SIZE_CHANGE]
 .    \}
 \!.  PRINT \\n[#LISTS_ENTRY_PN]
 \!.  TQ
@@ -18830,20 +19352,19 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .ds T&
 \#
 .MAC TS END
-.    di NULL \" Set rule weight for boxed tables
-\D't 500'
-.    di
 .    br
-.    if address@hidden \
-.       if \\n[.t]=1 .sp \\n[.t]u
+.    ie address@hidden \
+.       RESTORE_SPACE
+.    el .if \\n[.t]=1 .sp \\n[.t]u
 .    rr tbl*have-header
 .    rr float*tbl
+.    rr tbl*boxed
 .    if '\\n[.z]'FLOAT*DIV' .nr float*tbl 1
 .    if !'\\n[.z]'FLOAT*DIV' \{\
 .       if \\n[.t]=1 \{\
 .          if address@hidden \{\
-.             if \\n[#COL_NUM]=\\n[#NUM_COLS] \
-.                NEWPAGE
+.             ie \\n[#COLUMNS] .COL_NEXT internal
+.             el .NEWPAGE
 .          \}
 .       \}
 .    \}
@@ -18874,6 +19395,10 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .          nr tbl*no-shim 1
 .          shift
 .       \}
+.       if '\\$1'NO_FLEX' \{\
+.          nr tbl*no-flex 1
+.          shift
+.       \}
 .       if '\\$1'ADJUST' \{\
 .          ds tbl*space-adj \\$2
 .          shift 2
@@ -18893,6 +19418,11 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .          ds label-type tbl
 .          shift 2
 .       \}
+.       if '\\$1'TARGET' \{\
+.          ds target "\\$2
+.          PDF_TARGET "\\*[target]
+.          shift 2
+.       \}
 .    \}
 .    if \\n[tbl*boxed]=1 \{\
 .       if (\\n[tbl*have-label]=0)&(\\n[tbl*have-caption]=0)&\
@@ -18911,15 +19441,12 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .    \}
 .    ie address@hidden \{\
 .       if !'\\n[.z]'FLOAT*DIV' \{\
-.          vpt 0
-.          rr @TOP
-.          ch address@hidden
-.          rs
-.          nop \&
+.          RESTORE_SPACE
+.          nr @TOP 1
 .          if \\n[#COLUMNS] \
 .             if !'\\*[tbl*space-adj]'' \
 .                sp \\*[tbl*space-adj]-1v
-.          nr tbl*boxed 2
+.          if \\n[tbl*boxed] .nr tbl*boxed 2
 .          vpt
 .       \}
 .    \}
@@ -18928,15 +19455,23 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .    if !\\n[#MLA] \{\
 .      if (\\n[tbl*have-caption]=0):(\\n[tbl*caption-after-label]=1) \{\
 .         ie !'\\n[.z]'FLOAT*DIV' \{\
-.            sp .5v
-.            if \\n[tbl*boxed] .sp .25v
+.            ie !\\n[tbl*boxed]=2 \{\
+.               if \\n[tbl*have-header] .nr tbl*restore-header 1
+.               if address@hidden .sp .5v
+.               if \\n[tbl*boxed] .sp .25v
+.               if \\n[tbl*restore-header]=1 .nr tbl*have-header 1
+.            \}
+.            el \{\
+.               if !\\n[tbl*boxed] .ns
+.               sp .25v
+.            \}
 .         \}
-.         el .sp 1n
+.         el .sp .25v
 .      \}
 .    \}
-.    if '\\n[.z]'FLOAT*DIV' \{\
+.    if '\\n[.z]'FLOAT*DIV' \
 .       if \\n[defer]>0 .sp .5v
-.    \}
+.    if address@hidden .rr @TOP
 .    ds ev-current   \\n[.ev]
 .    nr ll-pre-tbl   \\n[.l]
 .    nr lead-pre-tbl \\n[.v]
@@ -18967,20 +19502,32 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .       di
 .       ev
 .       PDF_TARGET tbl:\\n+[lists*target]
+.       if \\n[#MLA] .if !\\n[tbl*have-caption] \
+.          address@hidden label caption \\n[.F] \\$0 \\n[.c]
 .       if !'\\n[.z]'FLOAT*DIV' \{\
 .          ie !\\n[tbl*boxed] \{\
 .             nr th*needs (u;\\n[dn]+\\n[tbl*needs]v)
 .             if \\n[th*needs]>\\n[.t] \{\
-.                ne \\n[dn]u+\\n[tbl*needs]
+.                if dPDF.EXPORT \
+.                   if \\n[#FLEX_ACTIVE] \
+.                      if !\\n[#NO_FLEX] \
+.                         tm .ds pre-newpage-\\n% address@hidden
+.                ne \\n[dn]u+\\n[tbl*needs]v
 .                nr address@hidden 1
 .             \}
 .          \}
 .          el \{\
 .             nr th*needs (u;\\n[dn]+2p+\\n[tbl*needs]v)
 .             if \\n[th*needs]>\\n[.t] \{\
-.                ne \\n[dn]u+2p+\\n[tbl*needs]
 .                if \\n[#COLUMNS] \
-.                   if !\\n[#COL_NUM]=\\n[#NUM_COLS] .nr tbl*no-top-hook 1
+.                   if !\\n[#COL_NUM]=\\n[#NUM_COLS] \
+.                      nr tbl*no-top-hook 1
+.                nr tbl*no-print-header 1
+.                if dPDF.EXPORT \
+.                   if \\n[#FLEX_ACTIVE] \
+.                      if !\\n[#NO_FLEX] \
+.                         tm .ds pre-newpage-\\n% address@hidden
+.                ne \\n[dn]u+\\n[tbl*needs]v
 .                nr address@hidden 1
 .             \}
 .          \}
@@ -18997,7 +19544,6 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .             rr address@hidden
 .          \}
 .          if \\n[tbl*have-caption] .TBL*CAPTION
-.          tbl*print-header
 .       \}
 .       el \{\
 .          nr tbl*header-ht \\n[dn]
@@ -19041,37 +19587,54 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .    nh
 .    nf
 .    rr tbl*no-header
-.    if !'\\n[.z]'FLOAT*DIV' \{\
-.       ie \\n[.t]<(\\n[.v]+(\\n[.v]/2u)) \{\
-.          if \\n[tbl*have-label] \{\
-.          rm tbl*header-div
-.          nr tbl*no-top-hook 1
-.          nr pgnum \\n%+\\n[#PAGE_NUM_ADJ]
-.          tm1 "[mom]: '\\n[.F]', macro \\$0, line \\n[.c]:
-.          tm1 "        Insufficient room for label, caption, and/or source 
after
-.          tm1 "        table on page \\n[pgnum].  Omitting, but continuing to 
process.
-.          NEWPAGE
-.          nr tbl*skip-source 1
-.          nr tbl*skip-label 1
-.          ch FN_OVERFLOW_TRAP -\\n[#FN_OVERFLOW_TRAP_POS]u
-.       \}
-.       \}
-.       el \{\
-.          if \\n[pre-tbl-vfp] \{\
-.            ch FOOTER 0+\\n[pre-tbl-vfp]u
-.            ch FN_OVERFLOW_TRAP -\\n[#FN_OVERFLOW_TRAP_POS]u
-.            rr pre-tbl-vfp
-.          \}
-.       \}
-.    \}
 .    if !'\\$1'' \{\
 .       if '\\$1'SOURCE' \{\
 .          nr tbl*have-source 1
 .          shift
 .       \}
 .    \}
+.    if !'\\n[.z]'FLOAT*DIV' \{\
+.       ch FOOTER \\n[#VARIABLE_FOOTER_POS]u
+.       ch FN_OVERFLOW_TRAP -\\n[#FN_OVERFLOW_TRAP_POS]u
+.       if \\n[.t]<(\\n[.v]/2u) \{\
+.          ie (\\n[tbl*have-label]=1):\
+(\\n[tbl*caption-after-label]=1):\
+(\\n[tbl*have-source]=1):\
+(\\n[tbl*autolabel]=1) \{\
+.             rm tbl*header-div
+.             nr tbl*no-top-hook 1
+.             ie \\n[tbl*autolabel] \
+.                if \\n[#MLA] \
+.                   if !\\n[tbl*have-source] .
+.             el \{\
+.                nr pgnum \\n%+\\n[#PAGE_NUM_ADJ]
+.                if \\n[#COLUMNS]=1 .ds col-num ", column \\n[#COL_NUM]
+.                tm1 "[mom]: '\\n[.F]', macro \\$0, line \\n[.c]:
+.                tm1 "        Insufficient room for label, caption, and/or 
source after
+.                tm1 "        table on page \\n[pgnum]\\*[col-num].  Omitting, 
but continuing to process table.
+.             \}
+.             nr tbl*skip-source 1
+.             nr tbl*skip-label 1
+.             rr tbl*have-caption
+.             ie \\n[#COLUMNS] \
+.                COL_NEXT internal
+.             el .NEWPAGE
+.          \}
+.          el \{\
+.\" Don't print tbl-header at top of next page or column if tbl
+.\" finishes without room for further input at bottom of page
+.             rm tbl*header-div
+.             nr tbl*no-print-header 1
+.             ie \\n[#COLUMNS] \
+.                COL_NEXT internal
+.             el .NEWPAGE
+.          \}
+.       \}
+.    \}
 .    if !\\n[#MLA] \{\
-.       if 
(\\n[tbl*have-label]=1):(\\n[tbl*autolabel]=1):(\\n[tbl*caption-after-label]=1) 
\{\
+.       if (\\n[tbl*have-label]=1):\
+(\\n[tbl*autolabel]=1):\
+(\\n[tbl*caption-after-label]=1) \{\
 .          ev label
 .          evc tbl*end
 .          ie \\n[#PRINT_STYLE]=1 .TYPEWRITER
@@ -19093,11 +19656,14 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .                ie !\\n[tbl*caption-after-label] .nop \
 \\*[tbl*label-prfx]\\*[chapno]\\n+[tbl*label-num]\\*[tbl*label-sffx]
 .                el \{\
-.                   nop 
\\*[tbl*label-prfx]\\*[chapno]\\n+[tbl*label-num]\\*[tbl*label-sffx]\|
+.                   nop \
+\\*[tbl*label-prfx]\\*[chapno]\\n+[tbl*label-num]\\*[tbl*label-sffx]\|
 .                   tbl*caption-style
 .                   vs \\n[.ps]u+\\n[tbl*caption-autolead]u
+.                   ds tbl*caption-old \\*[tbl*caption]
 .                   ds tbl*caption " \\*[tbl*caption]
 .                   nop \\*[tbl*caption]
+.                   ds tbl*caption \\*[tbl*caption-old]
 .                \}
 .             \}
 .             el \{\
@@ -19112,30 +19678,39 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .                   \}
 .                \}
 .             \}
-.             if \\n[tbl*autolabel] \
-.                ds tbl*label \\*[chapno]\\n[tbl*label-num]
-.             br
+.            br
 .          \}
 .          di
 .          ev
 .          nr pgnum \\n%+\\n[#PAGE_NUM_ADJ]
 .          ie !'\\n[.z]'FLOAT*DIV' \{\
-.             ie \\n[dn]>\\n[.t] \{\
+.             rr tbl*have-header
+.             rr tbl*have-caption
+.             ie (\\n[dn]-\\n[.v])>\\n[.t] \{\
+.                if \\n[#COLUMNS]=1 .ds col-num ", column \\n[#COL_NUM]
 .                tm1 "[mom]: '\\n[.F]', macro \\$0, line \\n[.c]:
 .                tm1 "        Insufficient room for label, caption, and/or 
source after
-.                tm1 "        table on page \\n[pgnum].  Omitting, but 
continuing to process.
+.                tm1 "        table on page \\n[pgnum]\\*[col-num].  Omitting, 
but continuing to process.
+.                ie \\n[#COLUMNS] \
+.                   COL_NEXT internal
+.                el .NEWPAGE
 .                if d tbl*header-div .rm tbl*header-div
 .                rr tbl*caption-top-lead-diff
 .                rr tbl*have-header
 .                nr tbl*skip-source 1
 .                nr tbl*skip-label 1
-.                NEWPAGE
 .             \}
 .             el .print-label
 .          \}
 .          el .print-label
 .       \}
 .    \}
+.    if \\n[tbl*autolabel] \{\
+.       ds tbl*label \\*[chapno]\\n[tbl*label-num]
+.       if dLABEL.REFS \
+.          tm .ds \\*[target] \\*[chapno]\\n[tbl*label-num]
+.       rm target
+.    \}
 .    if !'\\*[tbl*caption-short]'' .ds short -short
 .    ie !'\\*[tbl*label]'' \
 .       TO_TABLES "\\*[tbl*label]" "\\*[tbl*caption\\*[short]]"
@@ -19183,169 +19758,212 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .    \}
 .    ev
 .    if !\\n[tbl*plain] \{\
-.       ie \\n[tbl*plain-boxed] .sp 1
-.       el .sp .5v
+.       if !\\n[tbl*no-print-header] \{\
+.          ie \\n[tbl*plain-boxed] \{\
+.             ie \\n[#MLA] .if !\\n[tbl*have-source] .sp .5
+.             el .sp
+.          \}
+.          el \
+.             if !\\n[tbl*have-source] .sp .5
+.          if '\\n[.z]'FLOAT*DIV' .nr chop-space 1
+.       \}
 .    \}
 .    ll \\n[ll-pre-tbl]u
+.    if (\\n[nl]=\\n[dc]):(\\n[nl]=\\n[#PAGE_TOP]) .ns
 .    if !'\\*[tbl*space-adj]'' .sp -\\*[tbl*space-adj]u
-.    if !\\n[tbl*no-shim] .SHIM
+.    if \\n[#MLA] \
+.       sp .5v
+.    ie !\\n[tbl*no-shim] \{\
+.       ie !\\n[#NO_SHIM] \
+.          if !'\\n[.z]'FLOAT*DIV' .SHIM
+.       el \
+.          if !\\n[tbl*no-flex] \
+.             if !\\n[#NO_FLEX] \
+.                if !'\\n[.z]'FLOAT*DIV' .FLEX
+.    \}
+.    el \
+.       if !\\n[tbl*no-flex] \
+.          if !\\n[#NO_FLEX] \
+.             if !'\\n[.z]'FLOAT*DIV' .FLEX
 .    TBL*CLEANUP
 .END
 \#
 \# Utility macros for tbl
 \#
 .MAC TBL*CAPTION END
-.    if \\n[tbl*have-caption] \{\
-.       vs \\n[.ps]u+\\n[tbl*caption-autolead]u
-.       nr tbl*caption-lead-diff \\n[lead-pre-tbl]-\\n[.v]
-.       nr tbl*caption-top-lead-diff \\n[tbl*caption-lead-diff]
-.       ie !\\n[#MLA] \{\
-.          if !\\n[tbl*caption-after-label] \{\
-.             ie !'\\n[.z]'FLOAT*DIV' \{\
-.                ie (\\n[nl]=\\n[#PAGE_TOP]):(\\n[nl]=\\n[dc]) \{\
-.                   ie \\n[#COLUMNS] .sp |\\n[dc]u
-.                   el .sp |\\n[#T_MARGIN]u-\\n[#DOC_LEAD]u
-.                   sp \\n[tbl*caption-lead-diff]u
-.                \}
-.                el .sp .5v
-.             \}
-.             el .sp .5v
+.    ev caption
+.    evc \\*[ev-current]
+.    vs \\n[.ps]u+\\n[tbl*caption-autolead]u
+.    nr caption-lead \\n[.v]
+.    nr tbl*caption-lead-diff \\n[lead-pre-tbl]-\\n[.v]
+.    nr tbl*caption-top-lead-diff \\n[tbl*caption-lead-diff]
+.    ie !\\n[#MLA] \{\
+.       if !\\n[tbl*caption-after-label] \{\
+.          ie !'\\n[.z]'FLOAT*DIV' \{\
+.             ie (\\n[nl]=\\n[#PAGE_TOP]):(\\n[nl]=\\n[dc]) \{\
+.                ie \\n[#COLUMNS] .sp |\\n[dc]u
+.                el .sp |\\n[#T_MARGIN]u-\\n[#DOC_LEAD]u
+.                sp \\n[tbl*caption-lead-diff]u
+                \}
+.             el .sp \\n[#DOC_LEAD]u/2u
 .          \}
-.          ev caption
-.          evc \\*[ev-current]
-.          nh
+.          el .sp \\n[#DOC_LEAD]u/2u
 .       \}
-.       el \{\
-.          if !\\n[tbl*autolabel] \{\
-.             ie !\\n[tbl*have-label] \
-.                address@hidden caption label \\n[.F] \\$0 \\n[.c]
-.             el .ev label
-.          \}
+.       nh
+.    \}
+.    el \{\
+.       if !\\n[tbl*autolabel] \{\
+.          ie !\\n[tbl*have-label] \
+.             address@hidden caption label \\n[.F] \\$0 \\n[.c]
+.          el .ev label
 .       \}
-.       ie \\n[#PRINT_STYLE]=1 .nr tmp-ind 2m
-.       el .nr tmp-ind 1.25m
-.       ie \\n[#PRINT_STYLE]=1 .TYPEWRITER
-.       el \{\
-.          if !\\n[#MLA] \{\
-.             tbl*caption-style
-.             nr lead-current \\n[.v]
-.          \}
+.    \}
+.    ie \\n[#PRINT_STYLE]=1 .nr tmp-ind 2m
+.    el .nr tmp-ind 1.25m
+.    ie \\n[#PRINT_STYLE]=1 .TYPEWRITER
+.    el \{\
+.       if !\\n[#MLA] \{\
+.          tbl*caption-style
+.          nr lead-current \\n[.v]
 .       \}
-.       ie !\\n[#MLA] \{\
-.          ie !\\n[tbl*caption-after-label] \{\
-.             di tbl*caption-div
-\!.           in -\\n[ind-pre-tbl]u
-.             TBL*SET_CAPTION_QUAD \\*[tbl*caption-quad]
-.             nop \\*[tbl*caption]
-.             br
-.             di
-.             if !'\\n[.z]'FLOAT*DIV' \{\
-.                nr caption-needs 2
-.                if (\\n[dn]+(\\n[#DOC_LEAD]*(\\n[tbl*needs]*2)))>\\n[.t] \{\
-.                   nr pgnum \\n%+\\n[#PAGE_NUM_ADJ] 1
-.                   ie \\n[#COL_NUM]=\\n[#NUM_COLS] \{\
-.                      tm1 "[mom]: Table with caption at line \\n[.c] does not 
fit on page \\n[pgnum].
-.                      tm1 "       Shifting table to page \\n+[pgnum].
-.                      rr tbl*no-header
-.                      NEWPAGE
-.                   \}
-.                   el \{\
-.                      sp \\n[.t]u
-.                      sp |\\n[#PAGE_TOP]u+\\n[tbl*caption-lead-diff]u
-.                   \}
+.    \}
+.    ie !\\n[#MLA] \{\
+.       ie !\\n[tbl*caption-after-label] \{\
+.          di tbl*caption-div
+\!.        in -\\n[ind-pre-tbl]u
+.          TBL*SET_CAPTION_QUAD \\*[tbl*caption-quad]
+.          nop \\*[tbl*caption]
+.          br
+.          di
+.          evc 0
+.          if !'\\n[.z]'FLOAT*DIV' \{\
+.             ch FOOTER \\n[#VARIABLE_FOOTER_POS]u+\\n[#DOC_LEAD]u
+.             ch FN_OVERFLOW_TRAP -\\n[#FN_OVERFLOW_TRAP_POS]u+\\n[#DOC_LEAD]u
+.             nr caption-needs 2
+.             ie \\n[tbl*boxed] .nr tbl*lead \\n[.v]+3n
+.             el .nr tbl*lead \\n[.v]
+.             if \
+(\\n[dn]+(\\n[tbl*lead]*(\\n[tbl*needs]+1)))>=\\n[.t] \{\
+.                nr pgnum \\n%+\\n[#PAGE_NUM_ADJ]
+.                if \\n[#COLUMNS]=1 .ds col-num ", column \\n[#COL_NUM]
+.                tm1 \
+"[mom]: Table with caption at line \\n[.c] \
+does not fit on page \\n[pgnum]\\*[col-num].
+.                   tm1 \
+"       Shifting table to next page or column.
+.                ie (\\n[#COLUMNS]=1)&(\\n[#COL_NUM]=\\n[#NUM_COLS]) \{\
+.                   rr tbl*no-header
+.                   NEWPAGE
 .                \}
-.             \}
-.             if \\n[.u] .nr fill 1
-.             nf
-.             if \\n[.ns] .RESTORE_SPACE
-.             tbl*caption-div
-.             if \\n[#PRINT_STYLE]=1 .sp .5v
-.             if !'\\*[tbl*caption-space]'' \
-.                sp \\*[tbl*caption-space]
-.             if \\n[tbl*caption-lead-diff-adj] \{\
-.                sp -\\n[tbl*caption-lead-diff]u
-.                rr tbl*label-lead-diff-adj
-.             \}
-.             if \\n[fill] .fi
-.             rr fill
-.          \}
-.          el \{\
-.             if (\\n[tbl*have-label]=0) \{\
-.                if !\\n[tbl*autolabel] \{\
-.                   tm1 "[mom]: CAPTION_AFTER_LABEL enabled, but no label given
-.                   tm1 "       for table at line \\n[.c].
-.                   tm1 "       Skipping caption but continuing to process.
+.                el \{\
+.                   nr tbl*no-top-hook -1
+.                   sp \\n[.t]u
+.                   ie \\n[#COLUMNS] \
+.                      sp |\\n[dc]u+\\n[tbl*caption-lead-diff]u
+.                   el .sp |\\n[#PAGE_TOP]u+\\n[tbl*caption-lead-diff]u
 .                \}
 .             \}
+.             ch FOOTER \\n[#VARIABLE_FOOTER_POS]u
+.             ch FN_OVERFLOW_TRAP -\\n[#FN_OVERFLOW_TRAP_POS]u
 .          \}
+.          if \\n[.u] .nr fill 1
+.          nf
+.          if \\n[.ns] .RESTORE_SPACE
+.          tbl*caption-div
+.          if \\n[#PRINT_STYLE]=1 .sp .5v
+.          if !'\\*[tbl*caption-space]'' \
+.             sp \\*[tbl*caption-space]
+.          if \\n[tbl*caption-lead-diff-adj] \{\
+.             sp -\\n[tbl*caption-lead-diff]u
+.             rr tbl*label-lead-diff-adj
+.          \}
+.          if \\n[fill] .fi
+.          rr fill
 .       \}
 .       el \{\
-.          if (\\n[tbl*have-label]=1):(\\n[tbl*autolabel]=1) \{\
-.             ie !\\n[tbl*have-caption] \
-.                address@hidden label caption \\n[.F] \\$0 \\n[.c]
-.             el \{\
-.                ie !'\\n[.z]'FLOAT*DIV' \{\
-.                   ie (\\n[nl]=\\n[#PAGE_TOP]):(\\n[nl]=\\n[dc]) \{\
-.                      ie !\\n[#COLUMNS] .sp 
|\\n[#PAGE_TOP]u+\\n[tbl*caption-lead-diff]u
-.                      el .sp |\\n[dc]u+\\n[tbl*caption-lead-diff]u
-.                   \}
-.                   el .sp .5v
-.                \}
-.                el .sp .5v
-.             \}
-.             ev label
-.             evc \\*[ev-current]
-.             nh
-.             ie \\n[#PRINT_STYLE]=1 .TYPEWRITER
-.             el \{\
-.                tbl*label-style
-.                vs \\n[.ps]u+\\n[tbl*label-autolead]u
-.                nr tbl*label-lead-diff \\n[lead-pre-tbl]-\\n[.v]
-.             \}
-.             if \\n[tbl*label-with-chapter] \
-.                ds chapno \\n[#CH_NUM].
-.             TBL*SET_LABEL_QUAD \\*[tbl*label-quad]
-.             di tbl*mla-label-caption
-.             ie '\\*[tbl*label-quad]'L' \{\
-\!.              in -\\n[ind-pre-tbl]u
-\!.              in \\n[tmp-ind]u
-\!.              ti -\\n[tmp-ind]u
+.          if (\\n[tbl*have-label]=0) \{\
+.             if !\\n[tbl*autolabel] \{\
+.                tm1 "[mom]: CAPTION_AFTER_LABEL enabled, but no label given
+.                tm1 "       for table at line \\n[.c].
+.                tm1 "       Skipping caption but continuing to process.
 .             \}
-.             el \{\
-.                if \\n[tbl*label-quad-on-ll] \{\
-.                   if '\\n[tbl*label-quad]'L' \
-\!.                 in
+.          \}
+.       \}
+.    \}
+.    el \{\
+.       if (\\n[tbl*have-label]=1):(\\n[tbl*autolabel]=1) \{\
+.          ie !\\n[tbl*have-caption] \
+.             address@hidden label caption \\n[.F] \\$0 \\n[.c]
+.          el \{\
+.             ie !'\\n[.z]'FLOAT*DIV' \{\
+.                ie (\\n[nl]=\\n[#PAGE_TOP]):(\\n[nl]=\\n[dc]) \{\
+.                   ie !\\n[#COLUMNS] \
+.                      sp |\\n[#PAGE_TOP]u+\\n[tbl*caption-lead-diff]u
+.                   el .sp |\\n[dc]u+\\n[tbl*caption-lead-diff]u
 .                \}
+.                el .sp .5v
 .             \}
-.             ie \\n[tbl*autolabel] \
-.                nop \
-\\*[tbl*label-prfx]\\*[chapno]\\n+[tbl*label-num]\\*[tbl*label-sffx]
-.             el .if !'\\*[tbl*label]'' .nop \\*[tbl*label]
-.             if \\n[tbl*autolabel] \
-.                ds tbl*label \\*[chapno]\\n[tbl*label-num]
-.             br
-.             di
+.             el .sp .5v
 .          \}
-.          da tbl*mla-label-caption
+.          ev label
+.          evc \\*[ev-current]
+.          nh
 .          ie \\n[#PRINT_STYLE]=1 .TYPEWRITER
-.          el .tbl*caption-style
-.          if '\\*[tbl*caption-quad]'L' \{\
+.          el \{\
+.             tbl*label-style
+.             vs \\n[.ps]u+\\n[tbl*label-autolead]u
+.             nr tbl*label-lead-diff \\n[lead-pre-tbl]-\\n[.v]
+.          \}
+.          if \\n[tbl*label-with-chapter] \
+.             ds chapno \\n[#CH_NUM].
+.          TBL*SET_LABEL_QUAD \\*[tbl*label-quad]
+.          di tbl*mla-label-caption
+.          ie '\\*[tbl*label-quad]'L' \{\
+\!.           in -\\n[ind-pre-tbl]u
+\!.           in \\n[tmp-ind]u
 \!.           ti -\\n[tmp-ind]u
-\!.           fi
 .          \}
-.          nop \\*[tbl*caption]
+.          el \{\
+.             if \\n[tbl*label-quad-on-ll] \{\
+.                if '\\n[tbl*label-quad]'L' \
+\!.              in
+.             \}
+.          \}
+.          ie \\n[tbl*autolabel] \
+.             nop \
+\\*[tbl*label-prfx]\\*[chapno]\\n+[tbl*label-num]\\*[tbl*label-sffx]
+.          el .if !'\\*[tbl*label]'' .nop \\*[tbl*label]
+.          if \\n[tbl*autolabel] \
+.             ds tbl*label \\*[chapno]\\n[tbl*label-num]
 .          br
-\!.        in
-.          da
+.          di
+.       \}
+.       da tbl*mla-label-caption
+.       ie \\n[#PRINT_STYLE]=1 .TYPEWRITER
+.       el .tbl*caption-style
+.       if '\\*[tbl*caption-quad]'L' \{\
+\!.        ti -\\n[tmp-ind]u
+\!.        fi
 .       \}
+.       nop \\*[tbl*caption]
+.       br
+\!.     in
+.       da
 .       if !'\\n[.z]'FLOAT*DIV' \{\
+.          ch FOOTER \\n[#VARIABLE_FOOTER_POS]u+\\n[#DOC_LEAD]u
+.          ch FN_OVERFLOW_TRAP -\\n[#FN_OVERFLOW_TRAP_POS]u+\\n[#DOC_LEAD]u
 .          ie \\n[#MLA] .nr caption-needs 3
 .          el .nr caption-needs 2
-.          if 
(\\n[dn]+(\\n[#DOC_LEAD]*(\\n[tbl*needs]+\\n[caption-needs])))>\\n[.t] \{\
-.             nr pgnum \\n%+\\n[#PAGE_NUM_ADJ] 1
-.             ie \\n[#COL_NUM]=\\n[#NUM_COLS] \{\
-.                tm1 "[mom]: Table with caption at line \\n[.c] does not fit 
on page \\n[pgnum].
-.                tm1 "       Shifting table to page \\n+[pgnum].
+.          if \
+(\\n[dn]+(\\n[#DOC_LEAD]*\\n[tbl*needs])+(\\n[caption-needs]*\\n[caption-lead]))>\\n[.t]
 \{\
+.             nr pgnum \\n%+\\n[#PAGE_NUM_ADJ]
+.             if \\n[#COLUMNS] .ds col-num ", column \\n[#COL_NUM]
+.             tm1 \
+"[mom]: Table with caption at line \\n[.c] \
+does not fit on page \\n[pgnum]\\*[col-num].
+.             tm1 \
+"       Shifting table to next column or page.
+.             ie (\\n[#COLUMNS]=1)&(\\n[#COL_NUM]=\\n[#NUM_COLS]) \{\
 .                rr tbl*no-header
 .                if \\n[defer] .nr skip-th-warning 1
 .                NEWPAGE
@@ -19353,15 +19971,22 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .             el \{\
 .                nr tbl*no-top-hook 1
 .                sp \\n[.t]u
-.                if (\\n[tbl*caption-after-label]=1):(\\n[tbl*plain]) \
+.                if (\\n[tbl*caption-after-label]=1):(\\n[tbl*plain]=1) \
 .                   sp 1n-2p
 .             \}
 .          \}
+.          ch FOOTER \\n[#VARIABLE_FOOTER_POS]u
+.          ch FN_OVERFLOW_TRAP -\\n[#FN_OVERFLOW_TRAP_POS]u
 .       \}
 .       nf
 .       if (\\n[nl]=\\n[#PAGE_TOP]):(\\n[nl]=\\n[dc]) \
 .          nr tbl*label-lead-diff-adj 1
 .       ie (\\n[.t]>1)&(address@hidden) \{\
+.          if !\\n[#NO_FLEX] \{\
+.             NO_FLEX
+.             nr #RESTORE_FLEX 1
+.          \}
+.          if \\n[.ns] .rs
 .          sp \\n[tbl*label-lead-diff]u
 .       \}
 .       el \{\
@@ -19372,32 +19997,37 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .             el .sp .5v
 .       \}
 .       tbl*mla-label-caption
-.       ie \\n[#PRINT_STYLE]=1 .sp .5v
-.       el .sp .5n
-.       if \\n[tbl*label-lead-diff-adj] \{\
-.          sp -\\n[tbl*label-lead-diff]u
-.          rr tbl*label-lead-diff-adj
-.       \}
-.       br
-.       if !'\\*[tbl*caption-space]'' .sp \\*[tbl*caption-space]
 .    \}
-.    if !'\\n[.ev]'0' .ev
+.    ie \\n[#PRINT_STYLE]=1 .sp .5v
+.    el .sp .5n
+.    if \\n[tbl*label-lead-diff-adj] \{\
+.       sp -\\n[tbl*label-lead-diff]u
+.       rr tbl*label-lead-diff-adj
+.    \}
+.    br
+.    if !'\\*[tbl*caption-space]'' .sp \\*[tbl*caption-space]
+\!.  if \\\\n[float*tbl] .ev FLOAT
+.    ev \\*[ev-current]
 .END
 \#
 .MAC TBL*CLEANUP END
+.    if !'\\n[.ev]'\\*[ev-current]' .ev \\*[ev-current]
 .    if !'\\n[.z]'FLOAT*DIV' \{\
 .       rr tbl*center
 .       rm tbl*header-div
 .       rr tbl*caption-top-lead-diff
 .    \}
 .    rr tbl*have-header
+.    rr tbl*no-print-header
 .    if !'\\n[.z]'FLOAT*DIV' \{\
 .       rr tbl*have-caption
 .       rr tbl*have-label
 .    \}
+.    rr tbl*skip-label
+.    rr tbl*skip-source
 .    rr tbl*label-warning
 .    rr tbl*no-shim
-.    rr tbl*skip-source
+.    rr tbl*no-flex
 .    if !'\\n[.z]'FLOAT*DIV' \{\
 .       rm short
 .       rm tbl*caption
@@ -19410,31 +20040,36 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .    rr tbl*have-label
 .    rr tbl*plain
 .    if '\\*[tbl*label-sffx-tmp]'.' .ds tbl*label-sffx .
+.    if \\n[#RESTORE_FLEX] \{\
+.       NO_FLEX off
+.       rr #RESTORE_FLEX
+.    \}
 .END
 \#
 .MAC print-label END
 .    if \\n[.u] .nr fill 1
 .    nf
-.    if !\\n[tbl*skip-label] \{\
+.    if !\\n[tbl*skip-label] \
 .       tbl*label-div
-.    \}
 .    if \\n[fill] .fi
 .    rr fill
 .END
 \#
 .MAC address@hidden END
 .    if \\n[tbl*have-header] \{\
-.       nf
-.       rr @TOP
-.       ch address@hidden
-.       ev top-hook
-.       evc 0
-.       rs
-.       nop \&
-.       ie !\\n[tbl*boxed] .sp -1
-.       el .sp -1n
-.       tbl*print-header
-.       ev
+.       if !r tbl*no-print-header \{\
+.          nf
+.          rr @TOP
+.          ch address@hidden
+.          ev top-hook
+.          evc 0
+.          rs
+.          nop \&
+.          ie !\\n[tbl*boxed] .sp -1
+.          el .sp -1n
+.          tbl*print-header
+.          ev
+.       \}
 .    \}
 .END
 \#
@@ -19444,7 +20079,9 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .       nr fill 1
 .    \}
 .    if \\n[#COL_NUM]>1 \
-.       sp 2p
+.       if !\\n[tbl*have-caption] \
+.          if (address@hidden):(\\n[nl]=\\n[dc]) \
+.             sp 2p
 .    ie d tbl*header-div:\\n[loop-count] \
 .       tbl*header-div:\\n[loop-count]
 .    el .tbl*header-div
@@ -19452,14 +20089,12 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .       if \\n[tbl*center] .ce 1000
 .    mk #T
 .    if !'\\n[.z]'FLOAT*DIV' \{\
-.       nr pre-tbl-vfp 0+\\n[#VARIABLE_FOOTER_POS]
 .       ch FOOTER \\n[#VARIABLE_FOOTER_POS]u+\\n[#DOC_LEAD]u
 .       ch FN_OVERFLOW_TRAP -\\n[#FN_OVERFLOW_TRAP_POS]u+\\n[#DOC_LEAD]u
 .    \}
 .END
 \#
 .MAC address@hidden END
-.       if \\n[.ns] .rs
 .       rr #DIVERTED
 .       rr @TOP
 .       ch address@hidden
@@ -19534,10 +20169,6 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .                ds eqn*space-adj \\$2
 .                shift 2
 .             \}
-.             if '\\$1'NO_SHIM' \{\
-.                nr eqn*no-shim 1
-.                shift 1
-.             \}
 .             if '\\$1'LABEL' \{\
 .                ds eqn*label \\$2
 .                ds label-type eqn
@@ -19555,6 +20186,19 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .                ds eqn*caption-short \\$2
 .                shift 2
 .             \}
+.             if '\\$1'TARGET' \{\
+.                ds target "\\$2
+.                PDF_TARGET "\\*[target]
+.                shift 2
+.             \}
+.             if '\\$1'NO_SHIM' \{\
+.                nr @no-shim 1
+.                shift 1
+.             \}
+.             if '\\$1'NO_FLEX' \{\
+.                nr eqn*no-flex
+.                shift
+.             \}
 .          \}
 .       \}
 .       if '\\*[eqn*shift-label]'' .ds eqn*shift-label 0
@@ -19588,7 +20232,7 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .END
 \#
 .MAC EN END
-.    if !'\\n(.z'eqn*div' \{\
+.    if !'\\n[.z]'eqn*div' \{\
 .       @error mismatched EN
 .       return
 .    \}
@@ -19776,12 +20420,25 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .       if !\\n[continued] \{\
 .          sp \\*[DD]
 .          if !'\\*[eqn*space-adj]'' .sp -\\*[eqn*space-adj]u
-.          if !'\\n[.z]'FLOAT*DIV' \{\
-.             if !\\n[eqn*no-shim] .SHIM
+.          ie !\\n[eqn*no-shim] \{\
+.             ie !\\n[#NO_SHIM] \
+.                if !'\\n[.z]'FLOAT*DIV' .SHIM
+.             el \
+.                if !\\n[eqn*no-flex] \
+.                   if !\\n[#NO_FLEX] \
+.                      if !'\\n[.z]'FLOAT*DIV' .FLEX
 .          \}
+.          el \
+.             if !\\n[eqn*no-flex] \
+.                if !\\n[#NO_FLEX] \
+.                   if !'\\n[.z]'FLOAT*DIV' .FLEX
 .          if !'\\*[eqn*caption-short]'' .ds short -short
-.          if \\n[eqn*autolabel] \
+.          if \\n[eqn*autolabel] \{\
 .             ds eqn*label \\*[chapno]\\n[eqn*label-num]
+.                if dLABEL.REFS \
+.                   tm .ds \\*[target] \\*[chapno]\\n[eqn*label-num]
+.                rm target
+.          \}
 .          ie !'\\*[eqn*label]'' \
 .             TO_EQUATIONS "\\*[eqn*label]" "\\*[eqn*caption\\*[short]]"
 .          el .TO_EQUATIONS "\\*[eqn*caption\\*[short]]"
@@ -19812,17 +20469,17 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .MAC ADD_CAPTION END
 .    ie \\n[.t]<\\n[.v] \{\
 .       if !'\\n[.z]'FLOAT*DIV' \{\
-.          if \\n[#COL_NUM]=\\n[#NUM_COLS] \{\
-.             tm1 "[mom]: '\\n[.F]', macro EQ, line \\n[eqn-linenum]: 
Insufficient room for
-.             tm1 "        equation caption on page \\n[pgnum].
-.             tm1 "        Skipping caption, but continuing to process.
-.             if address@hidden \{\
-.                if \\n[#COL_NUM]=\\n[#NUM_COLS] \
-.                   NEWPAGE
-.             \}
-.             rr eqn-linenum
-.             rr pgnum
+.          if \\n[#COLUMNS]=1 .ds col-num ", column \\n[#COL_NUM]
+.          tm1 "[mom]: '\\n[.F]', macro EQ, line \\n[eqn-linenum]:
+.          tm1 "       Insufficient room for equation caption on page 
\\n[pgnum]\\*[col-num].
+.          tm1 "       Skipping caption but continuing to process.
+.          if address@hidden \{\
+.             ie \\n[#COLUMNS] \
+.                COL_NEXT internal
+.             el .NEWPAGE
 .          \}
+.          rr eqn-linenum
+.          rr pgnum
 .       \}
 .    \}
 .    el \{\
@@ -19948,19 +20605,15 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .          el .ds pic*scale-width \\$2
 .       \}
 .    \}
-. \" This is a bit confusing. pic is decorated with 2 args (width
-. \" and height), which are read during pre-processing but have to be
-. \" ignored when parsing args during main processing.  We shift pic's
-. \" args out of the way, then pop them off the arg stack because
-. \" they're not needed during macro processing.
+.\" This is a bit confusing. pic is decorated with 2 args (width
+.\" and height), which are read during pre-processing but have to be
+.\" ignored when parsing args during main processing.  We shift pic's
+.\" args out of the way, then pop them off the arg stack because
+.\" they're not needed during macro processing.
 .    while \B'\\$1' .shift
 .    nr loop-counter \\n[#NUM_ARGS]
 .    nr loop-count 0 1
 .    while \\n+[loop-count]<=\\n[loop-counter] \{\
-.       if '\\$1'NO_SHIM' \{\
-.          nr float*no-shim 1
-.          shift 1
-.       \}
 .       if '\\$1'LEFT' \{\
 .          nr pic*left 1
 .          shift 1
@@ -19980,6 +20633,19 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .          ds label-type pic
 .          shift 2
 .       \}
+.       if '\\$1'TARGET' \{\
+.          ds target "\\$2
+.          PDF_TARGET "\\*[target]
+.          shift 2
+.       \}
+.       if '\\$1'NO_SHIM' \{\
+.          nr @no-shim 1
+.          shift 1
+.       \}
+.       if '\\$1'NO_FLEX' \{\
+.          nr @no-flex 1
+.          shift 1
+.       \}
 .    \}
 .    ds pic*label-sffx-tmp \\*[pic*label-sffx]
 .    substring pic*label-sffx-tmp -1
@@ -20028,12 +20694,10 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .MAC PE END
 .    di
 .    nr pic*div-width \\n[dl]
-.    if address@hidden \{\
+.    if address@hidden \
 .       RESTORE_SPACE
-.    \}
 .    sp \\n[lead-pre-pic]u/2u
 .    if (\\n[pic*have-caption]=1)&(\\n[pic*caption-after-label]=0) \{\
-.       sp .5v
 .       ev caption
 .       evc \\*[ev-current]
 .       nh
@@ -20079,12 +20743,15 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .       sp \\n[lead-pre-label]u-\\n[.v]u
 .       if !'\\*[pic*label-space]'' .sp \\*[pic*label-space]
 .       if \\n[#PRINT_STYLE]=1 .sp .5v
-.       ie \\n[pic*autolabel] \
-.         nop \
+.       ie \\n[pic*autolabel] \{\
+.          nop \
 \\*[pic*label-prfx]\\*[chapno]\\n+[fig*label-num]\\*[pic*label-sffx]\|
-.       el .if !'\\*[pic*label]'' .nop \\*[pic*label]
-.       if \\n[pic*autolabel] \
 .          ds pic*label \\*[chapno]\\n[fig*label-num]
+.          if dLABEL.REFS \
+.             tm .ds \\*[target] \\*[chapno]\\n[fig*label-num]
+.          rm target
+.       \}
+.       el .if !'\\*[pic*label]'' .nop \\*[pic*label]
 .       fam
 .       ft
 .       ps
@@ -20250,9 +20917,8 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 \#
 .MAC HYPHENATE_REFS END
 .    ie '\\$1'' .nr #REF_HY 1
-.    el \{\
+.    el \
 .       if r #REF_HY .rr #REF_HY
-.    \}
 .END
 \#
 \# The remainder of the definitions in this section are modified
@@ -20455,9 +21121,8 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .de ref*add-A
 .ds eval*[A \\*([A
 .substring eval*[A -1
-.if '\\*[eval*[A]'.' \{\
+.if '\\*[eval*[A]'.' \
 .   if !'\\*[$REF_STYLE]'NOTE' .chop [A
-.\}
 .\" Per MLA, NOTE should not use idem, therefore if %i contains other than
 .\" idem (eg. ed., trans.), transpose it to after author's name
 .ie '\\*[$REF_STYLE]'NOTE' \{\
@@ -20537,9 +21202,8 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 ..
 \# %T Title of a chapter or article
 .de ref*add-T2
-.ie '\\*[$REF_STYLE]'NOTE' \{\
+.ie '\\*[$REF_STYLE]'NOTE' \
 .   ref*field T , \[lq] "" \[rq]
-.\}
 .el \{\
 .   ie '\\*([A'' \{\
 .      ref*field T . \[lq] "" \[rq]
@@ -20699,9 +21363,8 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 ..
 \# %V Volume (of a journal, or series of books); for journals, %N may be 
preferable
 .de ref*add-V
-.if \\n[ref*type]=1 \{\
+.if \\n[ref*type]=1 \
 .   ref*field V
-.\}
 .if \\n[ref*type]=2 \{\
 .   ie '\\*[$REF_STYLE]'NOTE' .ref*field V , "vol. "
 .   el \{\
@@ -20721,9 +21384,8 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 ..
 \# %S Series (books or journals)
 .de ref*add-S
-.if \\n[ref*type]=1 \{\
+.if \\n[ref*type]=1 \
 .   ref*field S
-.\}
 .if \\n[ref*type]=2 \{\
 .   ie '\\*[$REF_STYLE]'NOTE' \{\
 .      ie \\n([T .ref*field S
@@ -20753,9 +21415,8 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .      ref*field C
 .      rr [d
 .   \}
-.   el \{\
+.   el \
 .      ref*field C "" \*[FU 2](
-.   \}
 .   if \\n([T .nr ref*suppress-period \\n([T
 .\}
 .el \{\
@@ -20789,9 +21450,8 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .   ie '\\*[$REF_STYLE]'NOTE' .ref*field D ,
 .   el .ref*field D . " "
 .\}
-.if \\n[ref*type]=1 \{\
+.if \\n[ref*type]=1 \
 .   ref*field D "" "(" ")"
-.\}
 .if \\n[ref*type]=2 \{\
 .   ie '\\*[$REF_STYLE]'NOTE' .ref*field D , "" )
 .   el .ref*field D ,
@@ -20807,9 +21467,8 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .         substring eval*[D 0 -4
 .         ie '\\*[eval*[D]'1' .ds kern \*[BU3]
 .         el .ds kern \*[BU2]
-.         ie \\n[#PRINT_STYLE]=2 \{\
+.         ie \\n[#PRINT_STYLE]=2 \
 .           if '\\*[$REF_STYLE]'NOTE' .ref*field D "" (\\*[kern] )
-.         \}
 .         el .ref*field D
 .      \}
 .      rm eval*[D
@@ -20852,9 +21511,8 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .substring initial*cap 0 0
 .ds [O*string \\*([O
 .substring [O*string 1
-.if '\\*[$REF_STYLE]'BIBLIO' \{\
+.if '\\*[$REF_STYLE]'BIBLIO' \
 .   ds [O \E*[UC]\\*[initial*cap]\E*[LC]\\*[[O*string]
-.\}
 .ie '\\*[$REF_STYLE]'NOTE' .ref*field O ,
 .el \{\
 .   if \\n([O=1 .chop [O
@@ -21040,9 +21698,8 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .    \}
 .    nr #ARGS  0 1
 .    nr #COUNT 9
-.    while \\n+[#ARGS]<=\\n[#COUNT] \{\
+.    while \\n+[#ARGS]<=\\n[#COUNT] \
 .      ds $MN-arg\\n[#ARGS] @
-.    \}
 .    nr #FLAG 0 1
 .    nr #COUNT \\n[#NUM_ARGS]
 .    while \\n+[#FLAG]<=\\n[#COUNT] \{\
@@ -21170,18 +21827,16 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .    nr MN-right-width (n;\\$2)
 .    nr MN-right-start (\\n[.o] + \\n[.l] + \\n[MN-sep])
 .    if \\n[#COLUMNS]=1 \{\
-.      if !\\n[#NUM_COLS]=1 \{\
+.      if !\\n[#NUM_COLS]=1 \
 .        nr MN-right-start (\\n[#COL_2_L_MARGIN] + \\n[#COL_L_LENGTH] + 
\\n[MN-sep])
-.      \}
 .    \}
 .  \}
 .  el \{\
 .    nr MN-right-width \\n[MN-left-width]
 .    nr MN-right-start (\\n[.o] + \\n[.l] + \\n[MN-sep])
 .    if \\n[#COLUMNS]=1 \{\
-.      if !\\n[#NUM_COLS]=1 \{\
+.      if !\\n[#NUM_COLS]=1 \
 .        nr MN-right-start (\\n[#COL_2_L_MARGIN] + \\n[#COL_L_LENGTH] + 
\\n[MN-sep])
-.      \}
 .    \}
 .  \}
 .  ie \A'\\$4' \{\
@@ -21373,7 +22028,7 @@ E\\R'#CAP_HEIGHT \\n[.cht]'
 .            sp -(1v+\\n[#SHIM]u)
 .            rm MN-div-\\*[l-r]-\\n[MN-curr]
 .            tm1 "[mom]: \
-No room to start \\*[MN-pos] margin note #\\n[MN-curr] on page \\n[#P] on page 
\\n[#P].
+No room to start \\*[MN-pos] margin note #\\n[MN-curr] on page \\n[#P].
 .            tm1 "      Ignoring margin note.
 .            rr MN-shifted
 .         \}
@@ -21472,9 +22127,8 @@ No room to start \\*[MN-pos] margin note #\\n[MN-curr] 
on page \\n[#P] on page \
 .          \}
 .       \}
 .    \}
-.    if !\\n[PDFHREF_COLOR_SET]=1 \{\
+.    if !\\n[PDFHREF_COLOR_SET]=1 \
 .       nr PDFHREF_COLOR_SET 1
-.    \}
 .END
 \#
 \# AUTO_RELOCATE_TOC
@@ -21534,7 +22188,7 @@ No room to start \\*[MN-pos] margin note #\\n[MN-curr] 
on page \\n[#P] on page \
 .       nr PDF_LEV (\\n[LEVEL_REQ]*\\n[#PDF_BOOKMARKS_OPEN])
 .       ie '\\*[.T]'ps' \{\
 .           if !'\\*[PDF_NM]'' \{\
-.              pdfhref M -N\\*[PDF_NM2] -- \\*[PDF_TX]
+.              pdfhref M -N \\*[PDF_NM2] -- \\*[PDF_TX]
 .              if !dpdf:href.map .tm gropdf-info:href \\*[PDF_NM2] \\*[PDF_TX]
 .           \}
 .           pdfbookmark \\n[PDF_LEV] \\*[PDF_TX]
@@ -21705,7 +22359,8 @@ No room to start \\*[MN-pos] margin note #\\n[MN-curr] 
on page \\n[#P] on page \
 \# *Arguments:
 \#   [ -L -| -R | -C | -I <indent> ] \
 \#     <image file> <width> <height> \
-\#     [ SCALE <factor> ] [ ADJUST +|-<vertical shift> ]
+\#     [ SCALE <factor> ] [ ADJUST +|-<vertical shift> ] [ TARGET <pdf target> 
] \
+\#     [ NO_SHIM ]
 \# *Function:
 \#   Allows embedding of PDF images with the same arguments as PSPIC
 \#   plus SCALE and ADJUST options.
@@ -21713,7 +22368,6 @@ No room to start \\*[MN-pos] margin note #\\n[MN-curr] 
on page \\n[#P] on page \
 \#   <image file> <width> <height> are required.
 \#
 .MAC PDF_IMAGE END
-.    rr float*img
 .    if !'\\n[.z]'FLOAT*DIV' \{\
 .       nr pdf-img:float 1
 .       FLOAT
@@ -21782,8 +22436,20 @@ No room to start \\*[MN-pos] margin note #\\n[MN-curr] 
on page \\n[#P] on page \
 .          ds label-type pdf-img
 .          shift 2
 .       \}
+.       if '\\$1'TARGET' \{\
+.          ds target "\\$2
+.          PDF_TARGET "\\*[target]
+.          shift 2
+.       \}
 .       if '\\$1'NO_SHIM' \{\
-.          nr float*no-shim 1
+.          if !'\\n[.z]'FLOAT*DIV' .nr pdf-image*no-shim 1
+.          nr @no-shim 1
+.          shift 1
+.       \}
+.       if '\\$1'NO_FLEX' \{\
+.          if !'\\n[.z]'FLOAT*DIV' .nr pdf-image*no-flex 1
+.          nr @no-flex 1
+.          shift 1
 .       \}
 .    \}
 .    if !'\\*[pdf-img*label-sffx]'' \{\
@@ -21795,9 +22461,8 @@ No room to start \\*[MN-pos] margin note #\\n[MN-curr] 
on page \\n[#P] on page \
 .    PDF_TARGET fig:\\n+[lists*target]
 .    if '\\*[pdf-img:pos]'-C' \
 .       nr pdf-img:ind (\\n[.ll]-\\n[ind-pre-img]-\\n[pdf-img:width])/2
-.    if '\\*[pdf-img:pos]'-R' \{\
+.    if '\\*[pdf-img:pos]'-R' \
 .       nr pdf-img:ind \\n[.ll]-\\n[pdf-img:width]-\\n[ind-pre-img]
-.    \}
 .    di PDF*IMAGE
 .    if address@hidden \{\
 .       ch address@hidden
@@ -21886,23 +22551,28 @@ No room to start \\*[MN-pos] margin note 
#\\n[MN-curr] on page \\n[#P] on page \
 .       PDF_IMG*SET_LABEL_QUAD \\*[pdf-img*label-quad]
 .       sp \\n[lead-pre-label]u-\\n[.v]u
 .       if !'\\*[pdf-img*label-space]'' .sp \\*[pdf-img*label-space]
-.       ie \\n[pdf-img*autolabel] \
+.       ie \\n[pdf-img*autolabel] \{\
 .          nop \
 \\*[pdf-img*label-prfx]\\*[chapno]\\n+[fig*label-num]\\*[pdf-img*label-sffx]\|
-.       el .if !'\\*[pdf-img*label]'' .nop \\*[pdf-img*label]
-.       if \\n[pdf-img*autolabel] \
 .          ds pdf-img*label \\*[chapno]\\n[fig*label-num]
+.          if dLABEL.REFS \
+.             tm .ds \\*[target] \\*[chapno]\\n[fig*label-num]
+.          rm target
+.       \}
+.       el .if !'\\*[pdf-img*label]'' .nop \\*[pdf-img*label]
 .       fam
 .       ft
 .       ps
 .       gcolor
 .       if !'\\*[pdf-img*caption]'' \{\
 .          if \\n[pdf-img*caption-after-label] \{\
+.             ds pdf-img*caption-old \\*[pdf-img*caption]
 .             ds pdf-img*caption " \\*[pdf-img*caption]
 .             nop 
\\*[pdf-img*caption-specs]\\*[pdf-img*caption]\\*[revert-specs]
+.             ds pdf-img*caption \\*[pdf-img*caption-old]
 .          \}
 .       \}
-.       sp .5v
+.       br
 .       ev
 .       in 0
 .    \}
@@ -21929,6 +22599,13 @@ No room to start \\*[MN-pos] margin note #\\n[MN-curr] 
on page \\n[#P] on page \
 .    ie !'\\*[pdf-img*label]'' \
 .       TO_FIGURES "\\*[pdf-img*label]" "\\*[pdf-img*caption\\*[short]]"
 .    el .TO_FIGURES "\\*[pdf-img*caption\\*[short]]"
+.    if !\\n[pdf-img:float] \{\
+.       ie !\\n[#NO_SHIM] \
+.          if !\\n[pdf-img*no-shim] .SHIM
+.       el \
+.          if !\\n[#NO_FLEX] \
+.             if !\\n[pdf-img*no-flex] .FLEX
+.    \}
 .    PDF_IMAGE_CLEAN 
 .END
 \#
@@ -21996,9 +22673,11 @@ No room to start \\*[MN-pos] margin note #\\n[MN-curr] 
on page \\n[#P] on page \
 .    rr pdf-img:depth
 .    rr pdf-img:float
 .    rr pdf-img:float
-.    rr pdf-img:frame
+.    if !\\n[pdf-img:frame] \
+.       rr pdf-img:frame
 .    rr pdf-img:ind
 .    rr pdf-img:no-shim
+.    rr pdf-img:no-flex
 .    rr pdf-img:scale
 .\" Cutarounds not yet implemented
 .    if !\\n[defer] \



reply via email to

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