TransWikia.com

Latex vs Groff for mathematics formatting

TeX - LaTeX Asked on August 3, 2021

I am a physics undergraduate and I often have to write Latex documents. However, I recently heard of Groff which, from what I have gathered, is much lighter and more minimal than Latex. Is it any good for writing maths? Or is it limited like Markdown?

3 Answers

Equations in roff

roff (or groff or any other implementation) doesn't actually support mathematics typesetting. To this end you have to use a preprocessor which transforms equations in your document into something that groff can read. I'm only aware of the eqn preprocessor for equations but there might be others.

One obvious downside of eqn (or groff in general) is that most commands have to appear on a line by themselves, which is very disruptive when writing. That's not really a problem for displayed equations but becomes very annoying for inline math.

LaTeX vs groff

Also the output quality of groff with eqn is not on par with LaTeX (neither is anything else in my opinion).

On top of that LaTeX comes with a lot more features than groff, such as automatic cross-referencing, bibliography management, and multilingual support out-of-the-box. On top of that it is extended by great macro packages, such as amsmath for maths, siunitx for units, beamer for presentation slides, tikz for inline vector graphics, microtype for microtypographical features, and many more.

Other “features” of LaTeX are that scientific journals usually accept submissions in LaTeX and your supervisor might know LaTeX, so you can write your manuscript together. A lot of software can import and export formulas in LaTeX syntax, including Mathematica and even MS Word!

Furthermore, the LaTeX community is much larger than for groff (does it even exist?) and you can enjoy corporate support in the form of online editors such as Overleaf.

I could probably keep going as to why LaTeX is superior to any other non-commercial typesetting system (to any commercial one as well probably). Before going on to comparing output quality, let me answer your two specific questions.

Specific questions

Is it any good for writing maths?

No, the output quality is not on par with LaTeX and the equation syntax (in my opinion) is unintuitive and convoluted. For example spaces matter in some situations, but not in other, sometimes you need to wrap things in {} or "".

Or is it limited like Markdown?

Not really. While Markdown is really a flat static text format, groff at least supports macros but they don't seem to be as powerful as TeX macros (which are famously Turing-complete).

Output quality

LaTeX

[ s = sqrt{frac{sum_{i=1}^N (x_i - bar{x})^2}{N - 1}} ]

enter image description here

groff with eqn

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

Process with

groff -e test.tr > test.pdf

enter image description here

Correct answer by Henri Menke on August 3, 2021

TeX is also used much more frequently than roff or eqn, including on websites and message boards. For example, the math sites here on SX use MathJax, which is based on LaTeX. If you ever want to publish a paper, you’ll also need to know it.

Answered by Davislor on August 3, 2021

I prefer Groff (with -ms) because the commands are shorter and easier to read, especially if you make your own macros. This is because, in eqn, whitespace is used as syntax rather than curly brackets.

E.g. the eqn

cos theta + roman i sin theta

is the same as the LaTeX

costheta + mathrm{i}sintheta.

A Groff install is normally about 10MB, compared to a LaTeX install's size of about half a GB. Groff is more modular and in general follows the UNIX philosophy better.

Ask on the GNU Groff mailing list if you need help:

https://lists.gnu.org/archive/html/groff/

Example (with macros)

.LP
By expanding out the brackets of $pq$, we find that
.L q_vec_mul
.EQ "*[q_vec_mul]"
pq
=
[[ s _ 1 s _ 2 - #v _ 1 . #v _ 2
,~~
s _ 1 #v _ 2 + s _ 2 #v _ 1 + #v _ 1 * #v _ 2 ]] .
.EN

groff eqn example

Limitations

In terms of limitations, Groff can do most of what LaTeX can do, but some things like blackboard fonts aren't there by default so you have to add them yourself.

Also, as people have pointed out, the equations look nicer in LaTeX, and it is also more commonly used nowadays.

However, you can use the -Tdvi groff option and then dvipdf the output to produce a PDF with a TeX look.

Answered by kleinbottle4 on August 3, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP