groff
[Top][All Lists]
Advanced

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

Re: Proper usage of .rd? Tutorial or Example?


From: onf
Subject: Re: Proper usage of .rd? Tutorial or Example?
Date: Tue, 03 Dec 2024 22:08:49 +0100

On Tue Dec 3, 2024 at 9:40 PM CET, onf wrote:
> There are several approaches that come to mind.
>
> [...]
>
> But if the number of items is variable (as is likely the case),
> it might be easier to generate the troff input directly without
> using the strings as an intermediary.
>
> Alternatively, if all you are seeking is a table, sourcing the data
> as a TSV inside a tbl block and using the soelim preprocessor is the
> easiest way to do it[...]

A tidy way to do this might also be to create a Makefile with
an inference rule like so:
  .SUFFIXES: .tsv .pdf
  .tsv.pdf:
        awk '{ print; sum += $$2 }; END { printf "Sum:\t%s\n", sum }' $< > 
data.tsv
        groff -bst -wall -Tpdf template.tr > $@

which generates the sum and then calls groff with the right flags
for you. If you have files 1.tsv, 2.tsv, etc., you can turn them
into invoices with the above Makefile like so:
  for f in *.tsv; do make "${f%.tsv}.pdf"; done

~ onf



reply via email to

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