1

Boondox calligraphic math font and Arev math font do not have the same height for their upper-case letters and their lower-case letters.

Adapting the answer of Fake small caps with XeTeX/fontspec?, I used scalebox to define and correct the heights so that they match for upper-case and lower-case letters. See below the implementation of the new macro \mathcalbd that includes the height correction and the basic macro \mathcalbdnocorr that excludes the correction.

Two problems occur:

  • subscripts and superscripts are not supported
  • there is a conflict with package bm
\documentclass{article}

\usepackage{graphicx} \usepackage{arevmath} \usepackage{amsmath} % \usepackage{bm}

\DeclareFontFamily{U}{BOONDOX-calo}{\skewchar\font=45} \DeclareFontShape{U}{BOONDOX-calo}{m}{n}{<-> BOONDOX-r-calo}{} \DeclareFontShape{U}{BOONDOX-calo}{b}{n}{<-> BOONDOX-b-calo}{} \makeatletter \DeclareMathAlphabet{\m@thcalbd}{U}{BOONDOX-calo}{m}{n} \SetMathAlphabet{\m@thcalbd}{bold}{U}{BOONDOX-calo}{b}{n} % https://tex.stackexchange.com/questions/55664/ \def\calfont@helper#1 #2\relax{% @calfont@helper#1\relax\relax% \if\relax#2\relax\else\ @calfont@helper#2\relax\fi} \def@calfont@helper#1#2\relax{% \ifcat\relax#1#1% for escape sequences \else% \ifnum#1=\lccode#1\relax% \mathchoice% {\scalebox{1.20529}{$\m@th\m@thcalbd{#1}$}}% {\scalebox{1.20529}{$\m@th\m@thcalbd{#1}$}}% {\scalebox{.90396}{$\m@th\mkern-1.5mu\m@thcalbd{#1}$}}% {\scalebox{.70308}{$\m@th\mkern-1.1mu\m@thcalbd{#1}$}}%
\else\m@thcalbd{#1}\fi% \fi% \ifx\relax#2\relax\else@calfont@helper#2\relax\fi} \newcommand{\mathcalbd}[1]{\bgroup\calfont@helper#1 \relax\relax\egroup} \newcommand{\mathcalbdnocorr}[1]{\m@thcalbd{#1}} \makeatother

\begin{document}

Without height correction: $A\mathcalbdnocorr{A} a\mathcalbdnocorr{a}$

With height correction: $A\mathcalbd{A} a\mathcalbd{a}$

\bigskip

Two problems with the \verb+\mathcalbd+ macro: \begin{enumerate} \item \verb+\mathcalbd{A_a}+ does not work while \verb+\mathcalbdnocorr{A_a}+ does ($\mathcalbdnocorr{A_a}$). Same is true for superscripts.

\item \verb+\boldsymbol{\mathcalbd{A}}+ ($\boldsymbol{\mathcalbd{A}}$) does not work if package \texttt{bm} is loaded \end{enumerate}

\end{document}

enter image description here

user94293
  • 4,254

1 Answers1

2

You may use two font families, with different scaling factors, for uppercase and lowercase.

\documentclass{article}

\usepackage{arevmath} \usepackage{amsmath} \usepackage{bm}

\DeclareFontFamily{U}{BOONDOX-calo}{\skewchar\font=45 } \DeclareFontShape{U}{BOONDOX-calo}{m}{n}{<-> s[1.1] BOONDOX-r-calo}{} \DeclareFontShape{U}{BOONDOX-calo}{b}{n}{<-> s[1.1] BOONDOX-b-calo}{} \DeclareFontFamily{U}{BOONDOX-calo-scaled}{\skewchar\font=45 } \DeclareFontShape{U}{BOONDOX-calo-scaled}{m}{n}{<-> s[1.20529] BOONDOX-r-calo}{} \DeclareFontShape{U}{BOONDOX-calo-scaled}{b}{n}{<-> s[1.20529] BOONDOX-b-calo}{} \DeclareMathAlphabet{\mathcalupper}{U}{BOONDOX-calo}{m}{n} \SetMathAlphabet{\mathcalupper}{bold}{U}{BOONDOX-calo}{b}{n} \DeclareMathAlphabet{\mathcallower}{U}{BOONDOX-calo-scaled}{m}{n} \SetMathAlphabet{\mathcallower}{bold}{U}{BOONDOX-calo-scaled}{b}{n}

\ExplSyntaxOn \NewDocumentCommand{\mathcalbd}{m} {{ \tl_set:Nn \l_tmpa_tl { #1 } \regex_replace_all:nnN { [a-z] } { { \c{mathcallower}{\0} } } \l_tmpa_tl \mathcalupper{ \tl_use:N \l_tmpa_tl } }} \ExplSyntaxOff

\begin{document}

With height correction: $A\mathcalbd{A} a\mathcalbd{a}$

Subscript: $\mathcalbd{A_a} X_{a\mathcalbd{a}}$

Bold: $\bm{A} \bm{\mathcalbd{A}} \bm{a}\bm{\mathcalbd{a}}$

Bold with subscripts: $\bm{\mathcalbd{A_a}}$

\end{document}

enter image description here

egreg
  • 1,121,712