Avoiding mathabx symbol clashes when using LaTeX

In this post, I describe how to include the non-standard LaTeX maths symbols \ggcurly, \llcurly, \curlywedge, \curlyvee from the package mathabx, without overwriting the default maths symbols such as \neq.

Example with overwritten symbols

I'm currently working on a paper that requires some maths symbols (\ggcurly, \llcurly, \curlywedge, \curlyvee) that aren't included in the default LaTeX font set. These symbols are included in the mathabx package, a set of three font sets (matha, mathb and mathx) that include some of the more unusual maths symbols. Unfortunately the mathabx fonts clash with the default font for many of the more common maths symbols, for example \neq. Here's some sample LaTeX that loads mathabx and uses the symbols in question, plus their negation:

\documentclass{article}
\usepackage{amsfonts}
\usepackage{mathabx}
\begin{document}
$= \exists \leq < \ll \geq > \gg \preceq \prec \llcurly \succeq \succ \ggcurly$

$\neq \not\!\exists \not\leq \not< \not\ll \not\geq \not> \not\gg \not\preceq
\not\prec \not\llcurly \not\succeq \not\succ \not\ggcurly$

$\wedge \vee \curlywedge \curlyvee$
\end{document}

The problem is that mathabx also redefines some of the existing symbols, such as \ll, \gg, \neq, and I prefer the original versions. I don't like the vertical negation line in \neq, and the modified versions of \gg and \ll look too much like double angle quotes. Here's the output so you can see for yourself:

Example LaTeX using mathabx fonts for all symbols

Attempted fixes

To fix this, first I thought I'd try reversing the order of the \usepackage directives to include mathabx before amsfonts, so that the amsfonts version of the symbols would be used in case of conflicts. That didn't work, because mathabx depends on amsfonts, and so amsfonts has to be included first.

Having tried and failed with that approach, I found this post on a similar problem, which demonstrates including only some of matha, mathb and mathx, instead of all three. This also didn't help though, as \curlyvee and \curlywedge are in matha, while \ggcurly and \llcurly are in mathb. While it means I could skip mathx, most of the conflicting symbols are in matha, which I couldn't skip.

Finally I found two stackexchange threads that helped me solve the problem. The answer is to not import mathabx at all, but simply to copy the bits out of the mathabx.sty and mathabx.dcl files corresponding to the symbols you want. It's a bit of a fiddle, particularly if you want a number of symbols, but the results look much better.

Example with correct symbols

Here's the new version of the sample tex:

\documentclass{article}
\usepackage{amsfonts}
\DeclareFontFamily{U}{mathb}{\hyphenchar\font45}
\DeclareFontShape{U}{mathb}{m}{n}{
      <5> <6> <7> <8> <9> <10> gen * mathb
      <10.95> mathb10 <12> <14.4> <17.28> <20.74> <24.88> mathb12
}{}
\DeclareSymbolFont{mathb}{U}{mathb}{m}{n}
\DeclareMathSymbol{\llcurly}{3}{mathb}{"CE}
\DeclareMathSymbol{\ggcurly}{3}{mathb}{"CF}
\DeclareFontFamily{U}{matha}{\hyphenchar\font45}
\DeclareFontShape{U}{matha}{m}{n}{
      <5> <6> <7> <8> <9> <10> gen * matha
      <10.95> matha10 <12> <14.4> <17.28> <20.74> <24.88> matha12
      }{}
\DeclareSymbolFont{matha}{U}{matha}{m}{n}
\DeclareMathSymbol{\curlywedge} {2}{matha}{"4E}
\DeclareMathSymbol{\curlyvee} {2}{matha}{"4F}
\begin{document}
$= \exists \leq < \ll \geq > \gg \preceq \prec \llcurly \succeq \succ \ggcurly$

$\neq \not\!\exists \not\leq \not< \not\ll \not\geq \not> \not\gg \not\preceq
\not\prec \not\llcurly \not\succeq \not\succ \not\ggcurly$

$\wedge \vee \curlywedge \curlyvee$
\end{document}

Here's the output:

Example LaTeX using mathabx fonts only for non-standard symbols

If you want to try a similar trick, the mathabx.dcl and mathabx.sty files are included in the package texlive-fonts-extra on Ubuntu, and can be found under /usr/share/texmf-texlive/tex/generic/mathabx. You'll need the DeclareFontFamily, DeclareFontShape and DeclareSymbolFont declarations from mathabx.sty, and the individual DeclareMathSymbol declarations from mathabx.dcl.

Remaining problems

Even with this workaround there is still some kind of clash going on, as (for example) the \nexists symbol no longer works in the second example. It's easy to avoid this using \not\exists etc. instead, so I haven't got round to investigating further.

Attachment Size
with-mathabx.png2.6 KB 2.6 KB
without-mathabx.png2.87 KB 2.87 KB

Comments

Add new comment

CAPTCHA