groff
[Top][All Lists]
Advanced

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

Re: Regarding groff, soelim, and macros


From: Tadziu Hoffmann
Subject: Re: Regarding groff, soelim, and macros
Date: Tue, 14 Nov 2023 15:51:18 +0100
User-agent: Mutt/1.11.4 (2019-03-13)


> Can we create documents that have chapters, sections,
> that are in separate files? How can we do this?

Use the method you already described that works: source the files
directly from the main document, not from within a macro.


> Now if I run this main file using
> (cat main.tr | groff -p -s > main.ps)
> I get the document with the picture.
> But if I instead uncomment the source macro and call this
> macro (.source ch1.tr) instead of (.so ch1.tr), it fails with
> (soelim:stdin:2: can't open '\$1': No such file or directory).

soelim and the other preprocessors run *before* troff (see the
pictures in the soelim manual page), i.e., *before* your macro
is evaluated.[*]  This means that:

 1. when soelim runs, the only line it sees is ".so \\$1",
    which it can't really process because you (probably)
    do not have a file called "\$1".

 2. when troff runs, all the preprocessors have already
    finished, so that when troff evaluates your macro,
    the requested file *will* sourced, but it will *not*
    be preprocessed.

The only way to achieve what you want from within a macro at
troff runtime is to use the "sy" (system) request to execute a
shell command that runs the required preprocessors on the file
and redirects the output to a temporary file, which you can
then source.  But this opens up an entirely new can of worms.



[*] To see in detail how the files are transformed, try the
following series of commands and examine the temporary files:

  soelim <main.tr >tmp1
  pic <tmp1 >tmp2
  tbl <tmp2 >tmp3
  eqn <tmp3 >tmp4
  troff <tmp4 >tmp5
  grops <tmp5 >main.ps





reply via email to

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