groff
[Top][All Lists]
Advanced

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

Re: drawing requests following the line


From: G. Branden Robinson
Subject: Re: drawing requests following the line
Date: Thu, 5 Sep 2024 02:26:10 -0500

Hi Philippe,

At 2024-09-05T03:25:56+0200, Philippe PITTOLI via wrote:
> I've a question regarding drawing requests.
> 
> I would like for example to underline or highlight some text even
> when it is spanning over multiple lines (or pages).  Thus, I suppose
> the best way would be to perform a drawing request that somewhat
> "follows the line".
> 
> As far as I understand, some macros actually prevent hyphenation
> to avoid dealing with the (yet very common) "corner case" of a
> carriage return (or a page change).
> 
> Any tips or alternative solutions?

Have you tried the approaches in the "Underlining" section of groff(7)?

Underlining
       In RUNOFF (see roff(7)), underlining, even of lengthy passages,
       was straightforward because only fixed‐pitch printing devices
       were targeted.  Typesetter output posed a greater challenge.
       There exists a groff request .ul (see above) that underlines
       subsequent source lines on terminal devices, but on typesetters,
       it selects an italic font style instead.  The ms macro package
       (see groff_ms(7)) offers a macro .UL, but it too produces the
       desired effect only on typesetters, and has other limitations.

       One could adapt ms’s approach to the construction of a macro as
       follows.
              .de UNDERLINE
              . ie n \\$1\f[I]\\$2\f[P]\\$3
              . el \\$1\Z'\\$2'\v'.25m'\D'l \w'\\$2'u 0'\v'-.25m'\\$3
              ..
       If doclifter(1) makes trouble, change the macro name UNDERLINE
       into some 2‐letter word, like Ul.  Moreover, change the form of
       the font selection escape sequence from \f[P] to \fP.

   Underlining without macro definitions
       If one does not want to use macro definitions, e.g., when
       doclifter gets lost, use the following.
              .ds u1 before
              .ds u2 in
              .ds u3 after
              .ie n \*[u1]\f[I]\*[u2]\f[P]\*[u3]
              .el \*[u1]\Z'\*[u2]'\v'.25m'\D'l \w'\*[u2]'u 0'\v'-.25m'\*[u3]
       When using doclifter, it might be necessary to change syntax
       forms such as \[xy] and \*[xy] to those supported by AT&T troff:
       \*(xy and \(xy, and so on.

       Then these lines could look like
              .ds u1 before
              .ds u2 in
              .ds u3 after
              .ie n \*[u1]\fI\*(u2\fP\*(u3
              .el \*(u1\Z'\*(u2'\v'.25m'\D'l \w'\*(u2'u 0'\v'-.25m'\*(u3

       The result looks like
              before in after

   Underlining by overstriking with \(ul
       The \z escape sequence writes a glyph without advancing the
       drawing position, enabling overstriking.  Thus, \zc\(ul formats c
       with an underrule glyph on top of it.  Video terminals implement
       the underrule by setting a character cell’s underline attribute,
       so this technique works in both nroff and troff modes.

       Long words may then look intimidating in the input; a clarifying
       approach might be to use the input line continuation escape
       sequence \newline to place each underlined character on its own
       input line.  Thus,
              .nf
              \&\fB: ${\fIvar\fR\c
              \zo\(ul\
              \zp\(ul\c
              \&\fIvalue\fB}
              .fi
       produces
              : ${var__value}
       as output.

Regards,
Branden

Attachment: signature.asc
Description: PGP signature


reply via email to

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