2

While using groff and pic it is possible to do:

$ cat test.ms
.TL
Test

.NH 1 
Test Header

.PS
circle
arrow
box
.PE
$ cat test.ms | groff -ms -p > test.ps

Which generates a valid test.ps file containing the processed figure in pic.

In larger documents, for mainteinability, it might be desirable to keep the picture pic description in a separate file and invoke such file from the main .ms file.

While trying to get this working I have found that .so can source an external file, but I am finding issues to set up this configuration of embeding external .pic files into the main .ms file as shown here:

$ cat test2.pic
.PS
circle
arrow
box
.PE
$ cat test2.ms
.TL
Test

.NH 1 
Test Header

.so test2.pic
$ cat test2.ms | groff -ms -p > test2.ps
test2.pic:1: macro error: bad arguments to PS (not preprocessed with pic?)
$ 

Which would be the way to achieve this inclusion of .pic code in the main macro .ms files as external files?

muru
  • 69,900
  • 13
  • 192
  • 292
M.E.
  • 589
  • 4
  • 14
  • 1
    What does `s`, the parameter to `-m` have? Your commands return: `troff: fatal error: can't find macro file s ` – Eduardo Trápani May 07 '21 at 23:58
  • `-ms` tells `groff` to use `ms` macro package. Notice that I am using `groff`. It might be that `troff` has a different syntax for using `ms` macros. I have noticed that `troff` can not invoke other arguments such as `-p` (preprocess with pic) – M.E. May 08 '21 at 00:30
  • 1
    Note, you can also include pic files by giving the filename to the PS macro, eg `.PS – meuh May 08 '21 at 12:56
  • I did not know that. Maybe it makes even more sense. – M.E. May 08 '21 at 14:37

1 Answers1

2

You need to add the soelim preprocessor, that will eliminate the .so commands by including the actual files.

In your case this should it (note the added -s flag):

cat test2.ms | groff -ms -p -s > test2.ps
Eduardo Trápani
  • 12,032
  • 1
  • 18
  • 35