Mon Jul 1 20:13:15 2019

Problems and solutions to typesttings problems with Groff's eqn

When typesetting equations with groff(1) and eqn(1) I encontered two


  1. Big brackets, braces, and parentheses where missing in the PDF output
  2. Mathematical symbols like double-struck letters (ℕ, ℙ, ℚ, ℝ, ℤ) where missing. Naively inserting the unicodes with \[u...] resulted in warning messages about missing characters.


  1. Choose PostScript as output, and convert the resulting file using ps2pdf with the -dPDFSETTINGS=/prepress option:
    % preconv | eqn -Tps | groff -ms -Tps >
    % ps2pdf -dPDFSETTINGS=/prepress article.pdf
  2. The default fonts that come with groff(1) don't seem to contain all needed characters/symbols. So I chose to convert suitable TrueType fonts to .afm (Adobe Font Metrics File). In my case a subset of the DejaVu font which contains DejaVuMathTeXGyre.ttf. The conversion requires two programs, one is ttf2afm which is part of print/tex-basic-engines, and the other one afmtodit which is part of textproc/groff.
    # pkg install tex-basic-engines
    # mkdir /usr/local/share/groff/site-font/devps
    # cd /usr/local/share/groff/site-font/devps
    # echo "Create font for eqn(1)"
    # ttf2afm /usr/local/share/fonts/dejavu/DejaVuMathTeXGyre.ttf \
              -o dejavumath.afm
    # afmtodit -e text.enc dejavumath.afm textmap DVM
    # echo "Create Roman font"
    # ttf2afm /usr/local/share/fonts/dejavu/DejaVuSerif.ttf \
              -o dejavuserif.afm
    # afmtodit -e text.enc dejavuserif.afm textmap DVSR
    # echo "Create Bold font"
    # ttf2afm /usr/local/share/fonts/dejavu/DejaVuSerif-Bold.ttf \
              -o dejavuserif-bold.afm
    # afmtodit -e text.enc dejavuserif-bold.afm textmap DVSB
    # echo "Create Italic font"
    # tf2afm /usr/local/share/fonts/dejavu/DejaVuSerif-Italic.ttf \
              -o dejavuserif-italic.afm
    # afmtodit -e text.enc dejavuserif-italic.afm textmap DVSI
    # echo "Create Bold-Italic font"
    # ttf2afm /usr/local/share/fonts/dejavu/DejaVuSerif-BoldItalic.ttf \
              -o dejavuserif-bolditalic.afm
    # afmtodit -e text.enc dejavusans-mono.afm textmap DVBI
    # echo "Create Constant Width font"
    # ttf2afm /usr/local/share/fonts/dejavu/DejaVuSansMono.ttf \
              -o dejavusans-mono.afm
    # afmtodit -e text.enc dejavusans-mono.afm textmap DVCW
    # echo "Remove .afm files"
    # rm -f *.afm
Using the fonts in groff(1) documents
\." Use DejaVu font family
.fam DVS
delim ##
.B Lemma
.sp 1
Let # R ~ := ~ left { r: ax == r ~ (m), ~ a, x, m ~ \[mo] ~ ℕ, ~, m > 1, ~
gcd(a, m) = 1 right }#, then #|R| = m#.
And here a monospace example:
.ft CW
This is mono spaced.
#Groff #eqn #FreeBSD #Font #ttf2afm #math #Typesetting

Previous post | Index | Hashtags