groff
[Top][All Lists]
Advanced

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

Re: [groff] seeking fixed-width breakable space


From: Tadziu Hoffmann
Subject: Re: [groff] seeking fixed-width breakable space
Date: Fri, 1 Mar 2019 12:33:21 +0100
User-agent: Mutt/1.9.1 (2017-09-22)


> [...] it would create a nonbreaking space and then a
> breakpoint, which would result in that space appearing at
> the end of the line, which would misalign the right margin
> in fully justified text.  I'm looking for a fixed-width
> space that can be *replaced* by a line break (the typical
> behavior for a breakable space) -- that is, the space no
> longer appears, either at the end of the current line or
> the start of the next -- rather than a line break happening
> before or after an unpaddable space, as would happen with
> \:\| or \|\:.

A simple way to achieve this is:

  .\"
  .\" ----------------------------------------------------------------
  .de Text
  \Z'\m[red]\v'-0.7v'\D'l 0 7v'\h'\\n(.lu'\D'l 0 -7v'\m[]'\
  I'm looking for a fixed-width space that can be replaced
  by a line break (the typical behavior for a
  .di XX
  breakable space)
  .br
  .di
  .XX
  \(em that is,\p the space no longer appears, either at the
  end of the current line or the start of the next \(em
  rather than a line break happening before or after
  an unpaddable space.
  ..
  .\" ----------------------------------------------------------------
  .po 2.5c
  .ps 20
  .vs 22
  .sp 3
  .ll 21c-6c
  .Text
  .sp
  .ll 21c-5c
  .Text
  .br

This fails, however, if there is a current indent, because the
indent becomes part of the diverted text.  To prevent this, we
can process the unpadded text with zero indent, in a separate
environment to avoid interference with the running text:

  .\"
  .\" ----------------------------------------------------------------
  .de unpad
  .ev 1
  .evc 0
  .in 0
  .di XX
  \\$*
  .br
  .di
  .ev
  .XX
  ..
  .\" ----------------------------------------------------------------
  .de Text
  \Z'\m[green]\v'-0.7v'\h'-\\n(.iu'\D'l 0 7v'\h'\\n(.iu'\m[]\
  \m[red]\D'l 0 -7v'\h'\\n(.lu-\\n(.iu'\D'l 0 7v'\m[]'\
  I'm looking for a fixed-width space that can be replaced
  by a line break (the typical behavior for a
  .unpad breakable space)
  \(em that is,\p the space no longer appears, either at the
  end of the current line or the start of the next \(em
  rather than a line break happening before or after
  an unpaddable space.
  ..
  .\" ----------------------------------------------------------------
  .po 2c
  .ps 20
  .vs 22
  .sp 3
  .in 1c
  .ll 21c-5c
  .Text
  .sp
  .ll 21c-4c
  .Text
  .br





reply via email to

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