0

Ever since I knew that one could simply spell out equations to groff in plain english through the use of the eqn macro, I wanted to take my time and learn it. Every now and then I type some really serious math in LaTeX (by what I mean that I spend so much time in this business. On the one side it has brought me so many benefits, like: text editors (s?ed|n?vim?); regex; (vimscript|lua); tree-sitter, lsp and snippets; it also got me into the world of mechanical keyboards and qmk/via. And this is just to name a few things). On the other side, the fact that I've been on a quest to find the perfect workflow suggests by itself that this task is very time consuming. One thing that I've learnt with my journey is to never give up sharpening that saw (for one, the time that I spend nowadays is considerably lower when compared to what I used to spend 4 years ago, when I started digging this rabbit hole).

I like the fact that I can define macros with eqn, which is analogous to defining my own commands in LaTeX. I can also create tables, figures and table of contents, number equations, make references and citations. Only two things remain open so that can I make up my mind and move definitely into eqn. Those are:

  1. How do I get complex symbols like, for example, \nabla, to display correctly using groff and eqn?
  2. In the very likely event that I need to convert my sources into LaTeX, are there any standard tools? Maybe pandoc can do this, but how?

P.S. At first, I planned on posting this question on stackoverflow but, when the website saw my tags, it redirected me to this very forum. I'm sorry if this is not the right place for making this kind of question.

  • Almost certainly both of your questions would be better answered by experts in groff. i would suggest trying the groff mailing list where they presumably hang out. – Willie Wong Dec 26 '23 at 02:52
  • In general, export anything never is a good workflow. Always there are high taxes to pay. Pandoc can read man pages (roff man), so pandoc -f man -t latex foo.groff maybe help (...or not, is just a not tested idea,sorry). You can also use groff to output html and eqn to output MathML, and then I guess that padoc -f html -t latex foo.html could be more useful (but probably, not too much). – Fran Dec 27 '23 at 00:57

1 Answers1

1

Below the answer to the first question about Nabla. I don't know the answer to the second question.

The Nabla is an upside down Greek capital letter Delta. Therefore you can use https://lists.gnu.org/archive/html/groff/2000-08/msg00068.html (from the Groff mailing list mentioned in comments) to reverse the Delta character, i.e., \[*D].

Note that instead of setting \v (the vertical position) in Groff/eqn I used Postscript x y translate directly, as this does not increase the bounding box - in the original solution from the mailing list the height of the character consists of the full rotation around the baseline, i.e., two lines, which causes the fraction to be too high. For other sizes (like superscripts) you may need to adjust the translate values though.

Example equation taken from https://tex.stackexchange.com/a/527873 :

.ds Nabla "\h'\w'X'u'\X'ps: exec gsave currentpoint \
0 -6.5 translate 2 copy translate -180.0000 rotate neg exch neg exch \
translate'\[*D]\X'ps: exec grestore'\h'-\w'X'u'
.char \(Nb \*[Nabla]

.EQ s = sqrt { { sum from i=1 to N ( x sub i - x bar ) sup 2 } over { (Nb - 1 } } .EN

Result, compiled with groff -e example.tr > example.pdf:

enter image description here

Marijn
  • 37,699