1

I would like a double square intersection symbol in my Overleaf document without having to change the main font (I am using the AMS packages and the standard Latin Modern).

While an answer given in the hyperlink suggests \usepackage{mathabx} (producing the desired outcome), it makes me change my entire font class. How can I extract the symbol from this package and make sure it is the same size as the other symbols (such as \cap, \cup, etc.)?

Thanks!

2

1 Answer 1

2

Here's the procedure for mathabx.

  1. Look in the manual of mathabx for the symbol name: it is \sqdoublecap

  2. Look in mathabx.dcl for the command to find

    \DeclareMathSymbol{\sqdoublecap} {2}{mathb}{"5E}

  3. Look in mathabx.sty for the symbol font mathb to find

    \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}
    \DeclareFontSubstitution{U}{mathb}{m}{n}
    

We have all the ingredients.

Add to your document preamble

\DeclareFontFamily{U}{mathb}{}
\DeclareFontShape{U}{mathb}{m}{n}{
  <-5.5> mathb5
  <5.5-6.5> mathb6
  <6.5-7.5> mathb7
  <7.5-8.5> mathb8
  <8.5-9.5> mathb9
  <9.5-11> mathb10
  <11-> mathb12
}{}
\DeclareSymbolFont{mathb}{U}{mathb}{m}{n}
\DeclareFontSubstitution{U}{mathb}{m}{n}

\DeclareMathSymbol{\sqdoublecap}{2}{mathb}{"5E}
\DeclareMathSymbol{\sqdoublecup}{2}{mathb}{"5F}

Why the changes?

  • \hyphenchar\font makes no sense for symbol fonts;
  • the fonts are available in Type1 format, so we can define them at any size, not just at the traditional fixed sizes.

I also added \sqdoublecup for symmetry.

Full example.

\documentclass{article}
\usepackage{amsmath}

% import from mathabx
\DeclareFontFamily{U}{mathb}{}
\DeclareFontShape{U}{mathb}{m}{n}{
  <-5.5> mathb5
  <5.5-6.5> mathb6
  <6.5-7.5> mathb7
  <7.5-8.5> mathb8
  <8.5-9.5> mathb9
  <9.5-11> mathb10
  <11-> mathb12
}{}
\DeclareSymbolFont{mathb}{U}{mathb}{m}{n}
\DeclareFontSubstitution{U}{mathb}{m}{n}

\DeclareMathSymbol{\sqdoublecap}{2}{mathb}{"5E}
\DeclareMathSymbol{\sqdoublecup}{2}{mathb}{"5F}
% end import

\begin{document}

$A\sqcap B\sqdoublecap C$

$A\sqcup B\sqdoublecup C$

\end{document}

enter image description here

Oh, well, it's not the same size as \sqcap, is it?

OK, let's measure the symbols: add

\sbox0{$\sqcap$}\the\ht0

\sbox0{$\sqdoublecap$}\the\ht0

and see that you get 5.55557pt for the former and 6.83167pt for the latter. If we divide we get, approximately, 0.8132. So we can apply this magnification, changing

<-5.5> mathb5

into

<-5.5> s*[0.8132] mathb5

and similarly for the other lines. We get now

enter image description here

Darn! It's too small! A problem of bounding boxes, apparently. Now we have to gauge by eye. Let's try with 0.87

\documentclass{article}
\usepackage{amsmath}
\usepackage{xcolor}% just for the final comparison

% import from mathabx
\DeclareFontFamily{U}{mathb}{}
\DeclareFontShape{U}{mathb}{m}{n}{
  <-5.5> s*[0.87] mathb5
  <5.5-6.5> s*[0.87] mathb6
  <6.5-7.5> s*[0.87] mathb7
  <7.5-8.5> s*[0.87] mathb8
  <8.5-9.5> s*[0.87] mathb9
  <9.5-11> s*[0.87] mathb10
  <11-> s*[0.87] mathb12
}{}
\DeclareSymbolFont{mathb}{U}{mathb}{m}{n}
\DeclareFontSubstitution{U}{mathb}{m}{n}

\DeclareMathSymbol{\sqdoublecap}{2}{mathb}{"5E}
\DeclareMathSymbol{\sqdoublecup}{2}{mathb}{"5F}
% end import

\begin{document}

$A\sqcap B\sqdoublecap C$

$A\sqcup B\sqdoublecup C$

{\ooalign{\color{red}$\sqcap$\cr$\sqdoublecap$\cr}}

\end{document}

The last line superimposes the two symbols, one red colored.

enter image description here

Not exactly the same height and width, but the differences are negligible.

Important

If you're short of symbol fonts (there are only 16 available families with pdftex and a few are already taken), you can remove the \DeclareSymbolFont and \DeclareMathSymbol lines, replacing them with

\DeclareRobustCommand{\sqdoublecap}{\mathbin{\text{\usefont{U}{mathb}{m}{n}\symbol{"5E}}}}
\DeclareRobustCommand{\sqdoublecup}{\mathbin{\text{\usefont{U}{mathb}{m}{n}\symbol{"5F}}}}

that doesn't waste a symbol font for just a couple of symbols.

1
  • This was extremely helpful. Thank you very much. Dec 2, 2022 at 15:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .