Does someone know how to do higher roots (cube roots, 4th roots, etc) in groff eqn? Been searching around the docs and cant seem to find the answer
Groff Eqn - How to do higher roots (cube root, etc)
291 Views Asked by Lucas Summers At
3
There are 3 best solutions below
0
On
I would recommend using eqn macros like this
.EQ
define exp % "" sup fwd 30 %
define cube % "" sup fwd 30 3 sqrt %
define root % { "" sup fwd 30 $1 sqrt $2 } %
exp 3 sqrt 11
cube 11
root(3,11)
.EN
0
On
I was able to make a simple macro for nth index roots, this way:
.EQ
root {x} sup 3
.EN
Just add this wherever in your code, before using it:
.EQ
define root % sqrt special Rt %
.EN
.de Rt
. ds 0s \
\Z'\h'0.3n'\\*(0s'\
\h'-0.1n-\\n(0hu'\
\v'\\n(0du-1n'
..
And then to use it:
.EQ
root {x} sup 3
.EN
It won't be very pretty always, see: ugly-roots-image
But for 1-digit indexes and regular roots it should be fine. The ugly roots is more of a general problem with groff anyway.
In simple cases you can use a subscripted number before the root sign:
but this does not look too good depending on the equation:
An alternative is to use left-justified
pile, which also has a large gap:so often the best is to use the
eqnlocal motion commands,up,back,sizeto play with the position to get the wanted result: