4

In the following code:

\documentclass{article}
\usepackage[letterspace= -150]{microtype}
\usepackage{amsmath}


\DeclareFontFamily{U}{BOONDOX-calo}{\skewchar\font=45 }
\DeclareFontShape{U}{BOONDOX-calo}{m}{n}{
  <-> s*[1.05] BOONDOX-r-calo}{}
\DeclareFontShape{U}{BOONDOX-calo}{b}{n}{
  <-> s*[1.05] BOONDOX-b-calo}{}
\DeclareMathAlphabet{\mathcalboondox}{U}{BOONDOX-calo}{m}{n}
\SetMathAlphabet{\mathcalboondox}{bold}{U}{BOONDOX-calo}{b}{n}
\DeclareMathAlphabet{\mathbcalboondox}{U}{BOONDOX-calo}{b}{n}
\usepackage[mathscr]{eucal}
\renewcommand{\cal}{\mathscr}
\newcommand{\scr}{\mathcalboondox}

\begin{document}

 Hilbert functor \textls{$\scr{Hilb}$}$_X: \textbf{\textsf{Scheme}}^\text{op} \to \textbf{\textsf{Set}}$ s.t. for $U \in \textbf{\textsf{Scheme}}$, we have $\textls{$\scr{Hilb}$}_X(U) = \text{Hom}(U, \text{Hilb}_X)$.

 $$\textls{$\scr{Hilb}$}$$
 $$\textls{$asdf$ asdf $asdf$}$$
\textls{$asdf$} \textls{\text{$asdf$}}
\end{document}

only the first “Hilb” in script font has the desired letter spacing. The other two, in math mode, do not. I assume there is some issue in the math mode only, but I don’t know what. I have looked at Problem with microtype's `\textls` and math mode and Microtype gives wrong letterspacing in math mode, but their issue seems to be about something bad happening after trying to exit the ‘lsstyle’ environment. Even https://ctan.math.illinois.edu/macros/latex/contrib/microtype/microtype.pdf has the words “math mode” only 6 times, and I don’t think my issue is addressed. If it matters, let’s just say I’m working in Overleaf, so whatever compiler Overleaf uses is the relevant one.

EDIT: I added some more experiments (“asdf” lines above) and found that \textls does not seem to work on things in math mode. A commenter already pointed this out, but leaves the “correct” spacing of the first “Hilb” unexplained. Even if \textls was not “meant” to handle math mode, it clearly had worked once, so even if it is “against the rules”, I am wondering if I can get it to work again.

enter image description here

EDIT2: if instead I do \usepackage[tracking=allmath, letterspace= -150]{microtype} then ALL the text including the math mode stuff is set so that the letter space is smaller. So clearly the microtype package has the power to change the letter spacing in math mode... it just, doesn’t want to?

enter image description here

EDIT3: per Robert's suggestion, I load microtype with the verbose option (verbose=true next to letterspace=...) and attach the log file: https://notepad.ltd/jyxrxf4t.

10
  • 1
    Letters in math mode have predefined side bearings that will make them appear to be individual variables in a math context. They are not intended to be used as words in text. This is a built in design decision. Overleaf has nothing to do with it, and microtype isn't really intended to modify math spacing in this way. Commented Oct 4, 2021 at 1:34
  • @barbarabeeton that is unfortunate... is there another package I can use, or some other sort of workaround?
    – D.R
    Commented Oct 4, 2021 at 2:30
  • Unfortunately, I think the most reasonable thing to do is choose a different font. It's also possible (at least with pdf(la)tex to create a "virtual font", using the same glyphs, but redefining the dimensions so that the text spacing is more "normal". Not an easy path though. Commented Oct 4, 2021 at 2:47
  • I've seen your edit. What engine do you use -- pdftex, xetex or luatex? I will try to experiment, but not tonight. I'm not registered with Overleaf, and I don't know what they use. It should be reported at the beginning of your log file. Commented Oct 4, 2021 at 2:52
  • 1
    OK, thanks, so you're using microtype version 2.7d, which is quite old. Updating to the current version 2.8c (or to the latest texlive) should fix the problem, unfortunately I don't know how you would do that in Overleaf. But there are some wizards around here who should be able to help...
    – Robert
    Commented Oct 5, 2021 at 0:44

1 Answer 1

3

I would avoid a math alphabet for this.

\documentclass{article}
\usepackage{lmodern}
\usepackage{amsmath}
\usepackage{fixcmex}
\usepackage{microtype}

\DeclareFontFamily{U}{BOONDOX-calo}{\skewchar\font=45 }
\DeclareFontShape{U}{BOONDOX-calo}{m}{n}{
  <-> s*[1.05] BOONDOX-r-calo}{}
\DeclareFontShape{U}{BOONDOX-calo}{b}{n}{
  <-> s*[1.05] BOONDOX-b-calo}{}
\DeclareRobustCommand{\scrvar}[1]{%
  \text{\textls[-100]{\usefont{U}{BOONDOX-calo}{m}{n}#1}}%
}


\DeclareMathAlphabet{\mathsfbf}{\encodingdefault}{\sfdefault}{b}{n}

\newcommand{\Hilbs}{\scrvar{Hilb}}
\newcommand{\Hilbr}{\mathrm{Hilb}}
\newcommand{\Scheme}{\mathsfbf{Scheme}}
\newcommand{\Set}{\mathsfbf{Set}}
\newcommand{\op}{^{\mathrm{op}}}
\DeclareMathOperator{\Hom}{Hom}

\begin{document}

Hilbert functor $\Hilbs_X\colon \Scheme\op \to \Set$ s.t.\@ for $U \in \Scheme$, 
we have $\Hilbs_X(U) = \Hom(U, \Hilbr_X)$.

\end{document}

enter image description here

2
  • So basically by not defining a math font, we avoid \textls's problems with the math mode?
    – D.R
    Commented Oct 4, 2021 at 20:13
  • @D.R That's the idea.
    – egreg
    Commented Oct 5, 2021 at 6:53

You must log in to answer this question.

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