[NTG-context] Rule under length of last line

Taco Hoekwater taco at elvenkind.com
Mon Jul 31 19:47:18 CEST 2006


Duncan Hothersall wrote:
> We generate the ConTeXt code from XML, so ideally a solution wouldn't
> require the last line to be set separately, but would just work whether
> the heading was single or multiple line. What I'm really looking for is
> a subsection setup that will automatically do this whatever length of title.

It is easier than you think:

   \def\Myway#1%
     {#1\vrule height 0pt depth 6pt width 0pt}% title + force 6pt
      \optimizedisplayspacingtrue\setlastlinewidth % core-mat macro
      \global\advance\lastlinewidth-\hangindent\par % adjust
      \hrule width \the\lastlinewidth}

   \setuphead[section][textcommand=\Myway]

The key element is \setlastlinewidth, which measures the width
of the final line of the current paragraph.

Cheers, Taco



More information about the ntg-context mailing list