--- master-groff/groff/contrib/hdtbl/examples/chess_board.roff	2023-09-06 17:13:27.000000000 +0000
+++ groff/contrib/hdtbl/examples/chess_board.roff	2023-10-13 15:23:27.000000000 +0000
@@ -40,13 +40,13 @@ along with this program.  If not, see <h
 .PN 4 ".TD bgc=tan3" ".TD bgc=wheat"
 .TD hl= val=m hal=l \\\\n(*x
 .nr *x -1
 ..
 .af *y a
 .H Chessboard
-.TBL border=0 csp=.05n bgc= cols=10 width=1.6c tal=c
+.TBL border=0 csp=.05n bgc= cols=10 width=1.5c tal=c
 .TR vl= hal=c\" height=1c
 .TD hl=
 .nr *y 0
 .PN 8 .TD ".nr *y +1" \\\\n(*y
 .TD hl=
 .PN 4 .r1 .r2
--- master-groff/groff/contrib/hdtbl/examples/color_boxes.roff	2023-09-06 17:13:27.000000000 +0000
+++ groff/contrib/hdtbl/examples/color_boxes.roff	2023-10-13 15:23:27.000000000 +0000
@@ -27,24 +27,27 @@ along with this program.  If not, see <h
 .
 .\" Seed the random number generator for reproducible builds.
 .random-seed 131545532 19201711
 .
 .H Horizontal Rules and Boxes .br with Randomly Colored Border and Background
 .PN 25 Text before horizontal rule.
+.br \" Separate the text from the table
 .TBL border=.5n bc=green bgc=red width=7c tal=c csp=.2n cpd=.3n .TR .TD .ETB
 .PN 10 Text after horizontal rule and before table.
 .de ctab
 .nr ? 0 1
-.PN 5 .random# ".defcolor color\En+? rgb \E*[#random]" 
+.PN 5 .random# ".defcolor color\En+? rgb \E*[#random]"
 .TD ".TBL border=1c bc=color1 csp=0 cpd=0 height=3c bgc=color2" .TR .TD .ETB
 ..
 .
+.br \" Separate the text from the table
 .TBL tal=c border= csp=0 cpd=0 cols=5 width=3c
 .PN 2 .TR ".PN 5 .ctab"
-.ETB 
+.ETB
 .PN 15 Text after table.
+.br \" Separate the text from the table
 .TBL border=.5n bc=color1 bgc=color2 width=15c tal=c csp=.2n cpd=.3n .TR .TD .ETB
 .PN 25 Text after horizontal rule.
 .
 .\" Local Variables:
 .\" mode: nroff
 .\" fill-column: 72
--- master-groff/groff/contrib/hdtbl/examples/color_nested_tables.roff	2023-09-06 17:13:27.000000000 +0000
+++ groff/contrib/hdtbl/examples/color_nested_tables.roff	2023-10-13 15:23:27.000000000 +0000
@@ -31,23 +31,25 @@ along with this program.  If not, see <h
 .\" Seed the random number generator for reproducible builds.
 .random-seed 131545532 19201711
 .
 .PN 15 Text before first table.
 .nr # 0 1
 *****
+.br \" Separate the text from the table
 .PN 39 .random# ".defcolor c\\n[#] rgb \\\\*[#random] " \
   ".TBL csp=0 cpd=0 border=1n bc=c\\n[#]" \
   ".if \\\\n+#=1 .CPTN val=b Nested Tables with Randomly Colored Border" \
   .TR .TD
 .PN 39 .ETB
 .PN 15 Text after first table.
 .
 .bp
 .
 .PN 15 Text before second table.
 *****
+.br \" Separate the text from the table
 .nr # 0 1
 .PN 39 .random# ".defcolor c\\n[#] rgb \\\\*[#random] " \
   ".TBL csp=0 cpd=1n border= bgc=c\\n[#]" \
   ".if \\\\n+#=1 .CPTN val=b Nested Tables with Randomly Colored Background" \
   .TR .TD
 .PN 39 .ETB
--- master-groff/groff/contrib/hdtbl/examples/color_table_cells.roff	2023-09-06 17:13:27.000000000 +0000
+++ groff/contrib/hdtbl/examples/color_table_cells.roff	2023-10-13 15:23:27.000000000 +0000
@@ -29,24 +29,27 @@ along with this program.  If not, see <h
 .
 .\" Seed the random number generator for reproducible builds.
 .random-seed 131545532 19201711
 .
 .H Horizontal Rules and Randomly Colored Table Cells
 .PN 15 Text before HR.
+.br \" Separate the text from the table
 .TBL border=.5n bc=green bgc=red width=7c tal=c csp=.2n cpd=.3n .TR .TD .ETB
 .PN 10 Text after HR and before Table.
 .
 .nr ? 0 1
 .de ctab
 .TR height=\nl/10
-.PN 8 .random# ".defcolor c\\\\n+? rgb \E*[#random]" ".TD bgc=c\\\\n?" 
+.PN 8 .random# ".defcolor c\\\\n+? rgb \E*[#random]" ".TD bgc=c\\\\n?"
 ..
+.br \" Separate the text from the table
 .TBL tal=c border= csp=0 cpd=0 cols=8 width=\nl/10
 .PN 8 .ctab
-.ETB 
+.ETB
 .PN 10 Text after table.
+.br \" Separate the text from the table
 .TBL border=.5n bc=c1 bgc=c2 width=15c tal=c csp=.2n cpd=.3n .TR .TD .ETB
 .PN 15 Text after HR.
 .
 .\" Local Variables:
 .\" mode: nroff
 .\" fill-column: 72
--- master-groff/groff/contrib/hdtbl/examples/color_transitions.roff	2023-09-06 17:13:27.000000000 +0000
+++ groff/contrib/hdtbl/examples/color_transitions.roff	2023-10-13 15:23:27.000000000 +0000
@@ -23,35 +23,39 @@ along with this program.  If not, see <h
 ..
 .
 .if !d sopath \
 .  ds sopath
 .
 .so \*[sopath]examples/common.roff
+.nr #cc 0
 .
 .de ctab
 .nr #cc 0
-.PN 21 ".nr #cc +.05f" ".defcolor \En[t*#] rgb \\$1 \\$2 \\$3" ".TBL border= csp=0 cpd=.5n bgc=\\\\n[t*#] bc=" .TR .TD
-.PN 21 .ETB
+.\" .PN 21 makes #cc > 1 but must be 0 to 1.
+.PN 20 ".nr #cc +.05f" ".defcolor \En[t*#] rgb \\$1 \\$2 \\$3" ".TBL border= csp=0 cpd=.5n bgc=\\\\n[t*#] bc=" .TR .TD
+.PN 20 .ETB
 ..
 .PN 30 Before table.
+.br \" Separate the text from the table
 .TBL cols=3 width=33% border= csp=0 cpd=0 bgc=
 .CPTN val=b Color Transitions
-.TR 
+.TR
 .TD ".ctab 0+\En[#cc]u \En[#cc]u \En[#cc]u"     \"	black -> white
 .TD ".ctab 1f-\En[#cc]u 1f-\En[#cc]u 1f-\En[#cc]u"\"	white -> black
 .TD ".ctab 1f \En[#cc]u \En[#cc]u"              \"	red   -> white
-.TR 
+.TR
 .TD ".ctab 0 1f-\En[#cc]u \En[#cc]u"            \"	green   -> blue
 .TD ".ctab 1f 1f-\En[#cc]u 1f"                  \"	white   -> magenta
 .TD ".ctab 1f \En[#cc]u 1f"                     \"	magenta -> white
-.TR 
+.TR
 .TD ".ctab 0+\En[#cc]u \En[#cc]u 1f-\En[#cc]u"  \"	blue   -> yellow
 .TD ".ctab 1f-\En[#cc]u 1f-\En[#cc]u \En[#cc]u" \"	yellow -> blue
 .TD ".ctab 1f 0+\En[#cc]u 0"                    \"	red    -> yellow
-.xTD ".ctab 0+\En[#cc]u 1f-\En[#cc]u 1f-\En[#cc]u"\"	cyan   -> red
-.ETB 
+.\" Alternative to some other color transition
+.\".TD ".ctab 0+\En[#cc]u 1f-\En[#cc]u 1f-\En[#cc]u"\"	cyan   -> red
+.ETB
 .PN 30 After table.
 .
 .\" Local Variables:
 .\" mode: nroff
 .\" fill-column: 72
 .\" End:
--- master-groff/groff/contrib/hdtbl/examples/col_rowspan_colors.roff	2023-09-06 17:13:27.000000000 +0000
+++ groff/contrib/hdtbl/examples/col_rowspan_colors.roff	2023-10-13 15:23:27.000000000 +0000
@@ -27,12 +27,13 @@ along with this program.  If not, see <h
 .
 .\" Seed the random number generator for reproducible builds.
 .random-seed 131545532 19201711
 .de color#
 .nr # +1
 .random#
+.\".tm col_rowspan_colors.roff: color_component is \\*[#random]
 .defcolor c\\n# rgb \\*[#random]
 ..
 .
 .de brt
 .nr # 0
 .color#
@@ -65,12 +66,13 @@ along with this program.  If not, see <h
 .
 .t*pv 1.2 1.2 "" x
 .PN 10 Text before table.
 .in 1c
 .PN 8 Indented text before table.
 *** *** ***
+.br \" Separate the text from the table
 .TBL width=90% border=1n csp=1n cpd=1n bgc=wheat tal=c .TR .TD
 .TBL  border= cols=11 width=1c tal=c csp=0 cpd=0 \"cols must be odd
 .CPTN val=b Randomly Colored Table Cells with Colspan/\%Rowspan
 .brt
 .ETB .ETB
 .PN 15 Text after table.
--- master-groff/groff/contrib/hdtbl/examples/common.roff	2023-09-06 17:13:27.000000000 +0000
+++ groff/contrib/hdtbl/examples/common.roff	2023-10-31 15:53:31.000000000 +0000
@@ -21,13 +21,15 @@ You should have received a copy of the G
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 ..
 .
 .
 .ds common common.roff\"		name for diagnostic messages
-.mso hdtbl.tmac\"			load table macros
+.if !d TBL \{\
+.  mso hdtbl.tmac\"			load table macros
+.\}
 .
 .\"	******************************************************************
 .\"	**	Some macros and the page setup used by the examples	**
 .\"	******************************************************************
 .
 .\"	******************************************************************
@@ -148,14 +150,17 @@ along with this program.  If not, see <h
 .    \}
 .  \}
 .
 .  \" strip leading zero, if any
 .  ds * \\*[hex#]\"
 .  substring * 0 0
-.  if "\\*[*]"0" \
-.    substring hex# 1 -1
+.  if "\\*[*]"0" \{\
+.    length HL \\*[hex#]
+.    if (\\n[HL]>1) \
+.      substring hex# 1 -1
+.  \}
 .
 .  if (\\$1 < 0) \
 .    ds hex# -\\*[hex#]\"
 .
 .  if !"\\$3"" \{\
 .    ie !\A\\$3 \
@@ -251,15 +256,16 @@ along with this program.  If not, see <h
 .ev 99
 .lt \n[t*l]u
 .ev
 .
 .
 .de HM
-.  sp |.5i				\"	print header in top margin
+.  sp |.5i			\"	print header in top margin
 .  tl \\*[t*HM]
 .  sp |\\n[tH]u
+.  nr M# 0			\"	used in hdmisc.tmac, macro t*SP (SP)
 .  ev
 ..
 .
 .
 .de BM
 .  ev 99
@@ -267,13 +273,14 @@ along with this program.  If not, see <h
 .  tl \\*[t*BM]
 .  bp
 ..
 .
 .
 .de EM
-.  rm BM			\"	no page number at bottom of last page
+.\" Avoid warning about undefined macro BM
+.  ds BM \" instead of .rm BM;	no page number at bottom of last page
 .  t*EM
 ..
 .
 .
 .wh 0 HM
 .wh 0-1.5i BM
--- master-groff/groff/contrib/hdtbl/examples/fonts_n.in	2023-09-06 17:13:27.000000000 +0000
+++ groff/contrib/hdtbl/examples/fonts_n.in	2023-10-31 16:01:10.000000000 +0000
@@ -60,20 +60,20 @@ along with this program.  If not, see <h
 .  while !"\\*[*args]"" \{\
 .    pops *$1 *args
 .
 .    if "\\*[*$1]"all" \{\
 .      ds *args \\*[*f] \\*[*args]
 .      pops *$1 *args
-.      nr *all 1 
+.      nr *all 1
 .    \}
 .
 .    if \\n[*all] \{\
 .      if "\\*[*$1]"." \
 .        nr *all 0
 .      if !F \\*[*$1] \
-.        continue 
+.        continue
 .    \}
 .
 .    t*index "\\*[*f]" \\*[*$1]
 .
 .    ie (\\n[.y] > 18) \
 .      if !F \\*[*$1] \{\
@@ -89,57 +89,58 @@ along with this program.  If not, see <h
 .      nr * \\n[.f]
 .      ft \\*[*$1]
 .      nr ** \\n[.f]
 .      ft
 .
 .      if (\\n[**] == \\n[*]) \
-.        continue 
+.        continue
 .    \}
 .
 .    if \\n[t*cptn] \
 .      bp
 .
 .    tm \\*[fonts_n]: listing font '\\*[*$1]'...
 .
 .    TBL border=.1n bc=red cpd=0 csp=.1n bgc=
 .      CPTN groff font \\*[*$1] \
             .br \
             val=b ".pso @EGREP@ internalname \\*[fontpath]/dev\*[.T]/\\*[*$1]"
-.      TR 
+.      TR
 .        TD
+.\" max second argument to fsz is 1.5 for a letter sized page
 .          TBL cols=12 border=.1n bc=red csp=.1n cpd=.2n fgc=red4 bgc=beige \
-               hal=c fsz='1.2 1.2' fst=\\*[*$1]
+               hal=c fsz='1.2 1.5' fst=\\*[*$1]
 .            nr c# 0-1 1
 .            nr y# 0-1 1
 .            TR fst=HB fgc=blue
 .              TD
 .                nr x# 0-1 1
 .                \" following 4 'PN's instead of 4 while-loops as in
 .                \" font_x.roff; short and easy to write, but a little
 .                \" bit slower.
 .              PN 10 .TD \
                  \&..\\\\n+[x#]
 .              TD
 .
-.            PN 27 .TR \
+.            PN 26 .TR \
                ".TD fgc=blue fst=HB" \
                  \\\\n+[y#]. \
                ".PN 10 .TD \
                  "".if c \N'\En+[c#]' \
                    \N'\En[c#]'""" \
                ".TD fgc=blue fst=HB" \
                  \\\\n[y#].
 .
-.            TR fst=HB fgc=blue 
-.              TD 
+.            TR fst=HB fgc=blue
+.              TD
 .                nr x# 0-1 1
 .              PN 10 .TD \
                  \&..\\\\n+[x#]
-.              TD 
-.          ETB 
-.    ETB 
+.              TD
+.          ETB
+.    ETB
 .  \}
 ..
 .
 .fontdump all
 .
 .\" Local Variables:
--- master-groff/groff/contrib/hdtbl/examples/mixed_pickles.roff	2023-09-06 17:13:27.000000000 +0000
+++ groff/contrib/hdtbl/examples/mixed_pickles.roff	2023-11-01 15:55:11.000000000 +0000
@@ -33,26 +33,27 @@ along with this program.  If not, see <h
 .
 .H Table with Mixed Content: \
    .br \
    EPS Image, eqn Equation, tbl Table, and pic Picture
 .
 Call groff with options \-t, \-e, and \-p!
+.br \" Separate the text from the table
 .
 .TBL width=90% tal=c csp=.2n cpd=0
 .  TR
 .    TD
 .      TBL width='25% 75%' csp=.5n cpd=.5n hal=c
-.        TR 
+.        TR
 .          TD hl=d vl=d rowspan=2 bgc=red4 fgc=linen fsz=1.2 fst=HB val=m
 .            PSPIC -I -\\n[.l]u gnu.eps
 .            sp .5
 .            nop eps image with \fI.PSPIC\fP
 .          TD bgc=linen
 .
 .EQ
-int from 0 to 1 {( ln x ) sup 2} over {sqrt {1 - x sup 2}} dx approx 0.245 
+int from 0 to 1 {( ln x ) sup 2} over {sqrt {1 - x sup 2}} dx approx 0.245
 .EN
 .
 .            nop \0\0\0\0\0equation with \fIeqn\fP
 .
 .        TR
 .          TD hl=d
@@ -60,38 +61,40 @@ int from 0 to 1 {( ln x ) sup 2} over {s
 .TS
 tab(@), center, doublebox, nospaces;
 c c c | c c c
 r rI lB | r rI lB.
 Bit @ Code @ Warning @ Bit @ Code @ Warning
 =
-0 @   1 @ char      @    10 @   1024 @ reg
-1 @   2 @ number    @    11 @   2048 @ tab
-2 @   4 @ break     @    12 @   4096 @ right-brace
-3 @   8 @ delim     @    13 @   8192 @ missing
-4 @  16 @ el        @    14 @  16384 @ input
-5 @  32 @ scale     @    15 @  32768 @ escape
-6 @  64 @ range     @    16 @  65536 @ space
-7 @ 128 @ syntax    @    17 @ 131072 @ font
-8 @ 256 @ di        @    18 @ 262144 @ ig
-9 @ 512 @ mac       @    19 @ 524288 @ color
+0 @   1 @ char      @    11 @   2048 @ tab
+1 @   2 @ number    @    12 @   4096 @ right-brace
+2 @   4 @ break     @    13 @   8192 @ missing
+3 @   8 @ delim     @    14 @  16384 @ input
+4 @  16 @ el        @    15 @  32768 @ escape
+5 @  32 @ scale     @    16 @  65536 @ space
+6 @  64 @ range     @    17 @ 131072 @ font
+7 @ 128 @ syntax    @    18 @ 262144 @ ig
+8 @ 256 @ di        @    19 @ 524288 @ color
+9 @ 512 @ mac       @    20 @ 1048576 @ file
+10 @1024 @ reg      @    
 .TE
 .
 .            sp .5
 .            nop table with \fItbl\fP
-.        TR 
+.        TR
 .          TD colspan=2 bgc=azure2 fgc=blue4
 .
 .PS
+.\" change length of arrow from 0.42 inches to 0.36 in to fit in a A4 sized page
 ellipse "document";
-arrow 0.42;
+arrow 0.36;
 box width 0.6 "\fIgpic\/\fP(1)"
-arrow 0.42;
+arrow 0.36;
 box width 1.25 "\fIgtbl\/\fP(1) or \fIgeqn\/\fP(1)" "(optional)" dashed;
-arrow 0.42;
+arrow 0.36;
 box width 0.65 "\fIgtroff\/\fP(1)";
-arrow 0.42;
+arrow 0.36;
 ellipse "PostScript"
 .PE
 .
 .            sp .5
 .            nop picture with \fIpic\fP
 .      ETB
--- master-groff/groff/contrib/hdtbl/examples/rainbow.roff	2023-09-06 17:13:27.000000000 +0000
+++ groff/contrib/hdtbl/examples/rainbow.roff	2023-10-13 15:23:27.000000000 +0000
@@ -27,15 +27,21 @@ along with this program.  If not, see <h
 .
 .so \*[sopath]examples/common.roff
 .
 .nr *n 25
 .nr *# 0 1
 .
+.\" Avoid warnings about undefined variables
+.\".nr #cc 0
+.
 .de ctab
 .  nr #cc 0
-.  PN \\$1 \
+.\" Avoid invalid values of colors (valid 0 to 1)
+.  nr loopindex (\\$1 - 1)
+.\".  tm loopindex is \\n[loopindex]
+.  PN \\n[loopindex] \
      ".nr #cc +(1f / \\$1)" \
      ".defcolor \En[t*#] rgb \\$2 \\$3 \\$4" \
      ".TBL csp=\n[t*l]/(12*\\$1+2) border= cpd=0 bgc=\\\\n[t*#] bc=" \
        ".if (\\\\n+[*#] == 1) \
           .CPTN Rainbow Colors \[em] Nested Tables with Colored Backgrounds \
                 val=b" \
@@ -47,22 +53,30 @@ along with this program.  If not, see <h
 .ctab \n[*n] 1-\En[#cc]u  0           1              \" magenta -> blue
 .ctab \n[*n] 0            \En[#cc]u   1              \" blue    -> cyan
 .ctab \n[*n] 0            1           1-\En[#cc]u    \" cyan    -> green
 .ctab \n[*n] \En[#cc]u    1           0              \" green   -> yellow
 .ctab \n[*n] 1            1-\En[#cc]u 0              \" yellow  -> red
 .
-.PN 6*\n[*n] .ETB
+.\".PN 6*\n[*n] .ETB
+.\" No space in first argument of PN or quote it
+.PN "6*(\n[*n] - 1)" .ETB
 .
 .bp
 .
 .nr *n 25
 .nr *# 0 1
 .
+.\" Avoid warnings about undefined variables
+.\".nr #cc 0
+.
 .de ctab
 .  nr #cc 0
-.  PN \\$1 \
+.\" Avoid invalid values of colors (valid 0 to 1)
+.  nr loopindex (\\$1 - 1)
+.\".  tm loopindex is \\n[loopindex]
+.  PN \\n[loopindex] \
      ".nr #cc +(1f / \\$1)" \
      ".defcolor \En[t*#] rgb \\$2 \\$3 \\$4" \
      ".TBL border=\n[t*l]/(12*\\$1+2) csp=0 cpd=0 bc=\\\\n[t*#] bgc=" \
        ".if (\\\\n+[*#] == 1) \
           .CPTN Rainbow Colors \[em] Nested Tables with Colored Borders \
                 val=b" \
@@ -74,13 +88,15 @@ along with this program.  If not, see <h
 .ctab \n[*n] 1-\En[#cc]u  1           0               \" yellow  -> green
 .ctab \n[*n] 0            1           \En[#cc]u       \" green   -> cyan
 .ctab \n[*n] 0            1-\En[#cc]u 1               \" cyan    -> blue
 .ctab \n[*n] \En[#cc]u    0           1               \" blue    -> magenta
 .ctab \n[*n] 1            0           1-\En[#cc]u     \" magenta -> red
 .
-.PN 6*\n[*n] .ETB
+.\".PN 6*\n[*n] .ETB
+.PN 6*(\n[*n]-1) .ETB
+
 .
 .\" Local Variables:
 .\" mode: nroff
 .\" fill-column: 72
 .\" End:
 .\" vim: set filetype=groff textwidth=72:
--- master-groff/groff/contrib/hdtbl/examples/short_reference.roff	2023-09-06 17:13:27.000000000 +0000
+++ groff/contrib/hdtbl/examples/short_reference.roff	2023-10-13 15:23:27.000000000 +0000
@@ -34,13 +34,13 @@ using the macros themselves.
 .br
 .nr t*csp .3n
 .nr t*cpd .3n
 .ds t*ff HN
 .ds t*val m
 .ds t*hal l
-.xig
+.\"ig
 .TBL "width=10% 40% 25% 25%" border= "fsz=1 .8"
 .CPTN Base- Optional- and Utility-Macros val=b
 .TR
 .TH Macro .TH Description .TH Predecessors .TH Successors 
 .TR 
 .TD \&.TBL .TD Begin a new table .TD \&.TD \&.TH \%.ETB cell content
@@ -63,13 +63,13 @@ using the macros themselves.
 .TD \&.TBL \&.TR \&.TD \&.TH \%.ETB cell content
 .TR
 .TD \&.t*free 
 .TD colspan=3 val=t Utility macro to free held tables. Use it outside any table.
 .ETB
 .bp
-.x.
+.\"x.
 .TBL "fsz=1 .8" "width=20% 32% 8% 8% 8% 8% 8% 8%" border=
 .TR
 .TH Argument .TH Value .TH \&.TBL .TH \&.CPT .TH \&.TR .TH \&.TH .TH \&.TD .TH \&.ETB
 .TR 
 .TD border=\fI[n]\fP 
 .TD border thickness .TD .ce X .TD .TD .TD .TD .TD
