Vim typesetting [Was: Re: vim is no text editor, it's a multipurpose UI and I wish it

56 views
Skip to first unread message

dva...@internode.on.net

unread,
Mar 11, 2025, 4:05:05 AMMar 11
to vim...@googlegroups.com
On 03.03.25 12:49, Marc Chantreux wrote:
> I'm very found of :make, quickfix, ctags and filename-modifiers and I
> share most of what you said (I just droped pandoc for lowdown but this
> is off topic).
>
> so I have a makefile with
>
> %.pdf: %.md ; lowdown -tms $< | groff -ms -mfr -Tpdf -Kutf8 > $@

Yes, make, quickfix, ctags have served me well for several decades -
"*nix _is_ the IDE."

Does anyone know an easy way to make groff generate multipage PS or PDF
output? Around 40 years ago, I used "mpage" to portrait two A5 pages
onto landscape A4, even double sided, so I could print a compact manual
on an A4 printer. (ISTR that we then used a few coats of PVA glue to
bind the folded pages, making a little booklet.)

I figure I can use a handful of lines of Awk to preprocess my Vimmed
source text to troff directives like ".I", and ".B" - not sure if
anything else is useful, except selecting font and size.

Why groff? Well, Latex and Lout documentation seems to be exclusively
language specification, and at 70, reams of that takes too long to climb
on top of. All I need is a couple of pages of examples, hold the fries.
This is a superb start, I think:

But multipage would be nifty.



Boyko Bantchev

unread,
Mar 11, 2025, 5:39:38 AMMar 11
to vim...@googlegroups.com
On Tue, 11 Mar 2025 at 10:04, dvalin via vim_use
<vim...@googlegroups.com> wrote:
>
> Does anyone know an easy way to make groff generate multipage PS or PDF
> output? Around 40 years ago, I used "mpage" to portrait two A5 pages
> onto landscape A4, even double sided, so I could print a compact manual
> on an A4 printer. (ISTR that we then used a few coats of PVA glue to
> bind the folded pages, making a little booklet.)

In order to extract, reorder, and merge PDF pages and to produce
n-up PDFs I use a lot qpdf and pdfjam together. It doesn't matter
whether those PDFs come from LaTeX, groff or anything else.

Marc Chantreux

unread,
Mar 11, 2025, 9:28:21 AMMar 11
to dvalin via vim_use
hello,

On Tue, Mar 11, 2025 at 08:04:49AM +0000, dvalin via vim_use wrote:
> Does anyone know an easy way to make groff generate multipage PS or PDF
> on an A4 printer.

as:
* it's very off topic
* roff *is* multipage (like ready for book edition), I don't understand your question

so I won't reply here. don't hesitate to post on a groff mailing list:

https://lists.gnu.org/mailman/listinfo/groff/

the ping is pretty fast on them.

> Why groff?

groff is to latex what vim is to emacs: the first is expected to
communicate with pipes, the other "be extended" (so it is getting
fater and fater over time).

regards
--
Marc Chantreux

Steve Litt

unread,
Mar 11, 2025, 3:29:19 PMMar 11
to vim...@googlegroups.com
Marc Chantreux said on Tue, 11 Mar 2025 14:28:05 +0100


>> Why groff?
>
>groff is to latex what vim is to emacs: the first is expected to
>communicate with pipes, the other "be extended" (so it is getting
>fater and fater over time).

How do I specify the font size when using groff? It defaults to a very
small font size.

Thanks,

SteveT

Steve Litt

http://444domains.com

dva...@internode.on.net

unread,
Mar 12, 2025, 1:58:37 AMMar 12
to vim...@googlegroups.com
On 11.03.25 15:29, Steve Litt wrote:
> How do I specify the font size when using groff? It defaults to a very
> small font size.

Yep, seems to default to 10p, which is too small for me too.
Disclaimer: I began learning about groff, from scratch, last night, so the following is merely the result of study - not checked out in practice.

There are several standard macro libraries. One which seems to be not incompatible with general fontified typesetting, up to doing a book, I suspect. It becomes available with the groff parameter "-ms".

But even common troff syntax allows setting internal registers, using:

.nr reg value     # Set reg to value. If reg doesn’t exist, GNU troff creates it.

Registers include:
\n[PS]      # type size of the body text. Default: 10p. Effective: next paragraph.

which fills the request, but these might also be of interest:
\n[VS]      # vertical spacing (type size plus leading). Default: 12p. Effective: next paragraph.
\n[LL]      # line length, in inches. Effective: next paragraph.
\n[PD]      # space between paragraphs. Default: 0.3v (1v on low-res devices). Effective: next paragraph.
\*[FAM]     # font family used. Effective: next paragraph.
              Default: defined by the output device; often ‘T’ (see ms Body Text)

That seems do be some of what you're looking for. There are doubtless other ways to do it, but at my current level, I'm happy to start with one.

If you add a "title" line, either as header or footer, it'll default to proportionality, IIRC, but be separately settable. (I was happy to find a simple way to put page numbers into the L, M, or Right part of a title line, just before midnight.)

Some others are:
\n[PO] # page offset (i.e., the left margin). Effective: next page.
\n[LT] # title line length, if different, in inches.
\n[HM] # header top margin height. Default: 1i. Effective: next page.
\n[FM] # footer bottom margin. Default: 1i. Effective: next page.
\*[CF] # center footer text. Default: empty. Effective: next footer.
\*[RF] # right footer text. Default: empty. Effective: next footer.

There are more at:

My plan is to use a few lines of Awk to convert e.g. {this stuff} to italics, by substituting:
<- newline
.I  this stuff
<- newline

before piping to groff. (If I ever have to escape a real '{', then I'll figure out how to do it.)

A few one-minute hacks seem likely to be more than enough to implement a custom markup language with minimal overhead, negligible workflow intrusion, and minimal impact on source text readability. (As opposed to the ugly troff stuff.)
~

Marc Chantreux

unread,
Mar 12, 2025, 5:45:06 AMMar 12
to vim...@googlegroups.com
On Tue, Mar 11, 2025 at 03:29:05PM -0400, Steve Litt wrote:
> >groff is to latex what vim is to emacs: the first is expected to
> >communicate with pipes, the other "be extended" (so it is getting
> >fater and fater over time).

> How do I specify the font size when using groff? It defaults to a very
> small font size.

same answer i did to Davlin: please join the groff list if you have
roff questions. however I have 2 ressources I want to share because it
helped me a lot in first place:

https://wolfram.schneider.org/bsd/7thEdManVol2/trofftut/trofftut.pdf
apropos groff (espacially groff_tmac, groff_ms and groff.7)

to come back to vim:
* 'sect can handle roff sections which is really helpful.
* I started a vim mode for roff edition to get a short description of the
request under the cursor appear in the status bar. It did not goes far
because I find out :Man groff_tmac and :Man groff_* was good enough
for me. I can resurect the thing if you want me to.

\s(22\fCHave a nice day\s0\fP


--
Marc Chantreux
Pôle CESAR (Calcul et services avancés à la recherche)
Université de Strasbourg
14 rue René Descartes,
BP 80010, 67084 STRASBOURG CEDEX
03.68.85.60.79

Anton Shepelev

unread,
Mar 12, 2025, 1:23:13 PMMar 12
to vim...@googlegroups.com
dvalin:

> Does anyone know an easy way to make groff gener-
> ate multipage PS or PDF output?

GNU Troff can certaily generate multipage output,
and the majority of packates support this, incliding
-ms, -mm, and -mom, and I think -man as well.

> Around 40 years ago, I used "mpage" to portrait
> two A5 pages onto landscape A4, even double sided,
> so I could print a compact manual on an A4 print-
> er.

I have done the same, but much more recently, with
MS Word, Adobe PageMakes, LaTeX, and GNU Troff. I
had a script to generate the correct page-numbeer
sequeces, but with Groff and PostScript I use psnup
and psbook from psutils:

<https://github.com/rrthomas/psutils>

> I figure I can use a handful of lines of Awk to
> preprocess my Vimmed source text to troff direc-
> tives like ".I", and ".B"

You can write *roff directly as it is meant to. It
feels good. If, however, you need very little ex-
cept .I and .B, then you might prefer writing
Markdown[1] and processing your text with something
like Pandoc[2].

> Why groff? Well, Latex and Lout documentation
> seems to be exclusively language specification,
> and at 70, reams of that takes too long to climb
> on top of.

I am much younger, but have done the same: tried La-
TeX, found it too hard, moved on to Groff and never
regretted it. *roff is so simple that I have been
writing my own macros routinely. For example, I
typeset the CoreOps newsletter, where most of spe-
cial formatting, including text wrapping around ta-
ble and code "displays" is my own:

<https://corewar.co.uk/coreops/coreops02.txt>

I have also produced A5 booklet with a manual to a
thing I wrote for work, but I would rather not show
it publicly.

I have never been able to write a single LaTeX macro
(or whatever they are called), and had to rely on
existing packages, which felt bad -- too much out of
my control.

> This is a superb start, I think:
> <https://josh8.com/blog/typesetting_with_groff.html>
> But multipage would be nifty.

This is one is about the -ms package, which of
course supports multipage documents.

Groff has a great and very friendly community. Do
try its mailing list.

This message is typeset in groff, using my own quote
macros.
____________________
1. <https://commonmark.org/>
2. <https://pandoc.org/>

dva...@internode.on.net

unread,
Mar 12, 2025, 11:45:04 PMMar 12
to vim...@googlegroups.com
On 11.03.25 15:29, Steve Litt wrote:
> How do I specify the font size when using groff? It defaults to a very
> small font size.

For any future navigator of this thread:

Steve, this works for me, to go from default 10p to 40p:

.ps 40

A following .PP seems not to be needed, although ISTR reading that this
stuff takes from the next paragraph.

And that's without using any of the macro libraries, so basic troff.

(Further groff stuff taken to that list.)


dva...@internode.on.net

unread,
Mar 13, 2025, 12:14:36 AMMar 13
to vim...@googlegroups.com
On 12.03.25 20:22, Anton Shepelev wrote:
> I  have  done the same, but much more recently, with
> MS Word, Adobe PageMakes, LaTeX, and GNU  Troff.   I
> had  a  script  to generate the correct page-numbeer
> sequeces, but with Groff and PostScript I use  psnup
> and psbook from psutils:
>

I'll try digging into that; it sounds interesting. Groff seems to have a % operator, which does page numbering when used as L, M, or Right field in a title, header, or footer.
...
> I have also produced A5 booklet with a manual  to  a
> thing  I wrote for work, but I would rather not show
> it publicly.

Any hints which might expedite hitting that target, even if only partial in effect, would be very helpful here. (Offlist, perhaps, as some seem to think that Vimmers shouldn't look over the edge of the groove.)
...
> This  is  one  is  about  the  -ms package, which of
> course supports multipage documents.

I'll pursue that on the groff list, bit by bit.
...
> This message is typeset in groff, using my own quote macros.

Something like that was revealed by the spacing introduced to justify the "A5 booklet" line. ;-) I'll have to see whether justification is intrinsic, or I have to fiddle with config, especially if I omit macro libraries as ill-defined murk interfering with my groffing.


Reply all
Reply to author
Forward
0 new messages