3

The following MWE shows that the definition

\mm@macro{C}{\ensuremath{\mathset{C}}\xspace}

from line 267 of mismath.sty [2023/02/24 v2.5] —

\mm@macro{C}{\ensuremath{\mathset{C}}\xspace}

— causes an error when paired with loading babel [2023/02/13 3.86]with option russian [russianb.ldf 2021/01/10 1.3m; russian 2020/09/09 1.3k]:

\documentclass{article}
\usepackage{amsmath}
\usepackage{mathtools}

\usepackage[T2A,T1]{fontenc} 
\usepackage{substitutefont}
\usepackage[russian,english]{babel}
\substitutefont{T2A}{\rmdefault}{Tempora-TLF}

\usepackage{mismath}

\begin{document}
$1+2=3$
\end{document}

The purpose of the offending line in mismath.sty is ultimately to define \C to give a blackboard bold C.

The error is:

/usr/local/texlive/2022/texmf-dist/tex/latex/mismath/mismath.sty:267: LaTeX Err
or: There's no line here to end.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              
l.267 ...macro{C}{\ensuremath{\mathset{C}}\xspace}       

                                       

This is a new error not occurring with earlier versions of mismath and babel.

Is there some fix other than to make a copy of \mismath in which the offending line is commented out?

1
  • 1
    It's an error of mismath to try and define \C. In a wrong way, by the way, with \ensuremath and \xspace.
    – egreg
    Mar 1, 2023 at 17:49

3 Answers 3

5

tl;dr

There's a bug in mismath.sty: in the code of \mm@macro there's \\mm@warning{#1} that should be \mm@warning{#1}.


It's a common problem with packages that are essentially collections of macros to eventually clash with other packages.

In the specific case, the check done by \mm@macro should be delayed at begin document. When Cyrillic encodings are loaded, \C gets defined by hyperref. Similarly for \mm@operator. Even without hyperref there may be problems, because unicode-math does most of its job at begin document.

The code

\newcommand\mm@macro[2]{
    \@ifundefined{#1}{
        \expandafter\def\csname #1\endcsname{#2}
    }{\\mm@warning{#1}}
}
\newcommand\mm@operator[3][]{%
    \ifthenelse{\equal{#1}{}}{\def\tempa{#3}}{\def\tempa{#1}}
    \@ifundefined{\tempa}{
        \DeclareMathOperator{#2}{#3}
    }{\mm@warning{\tempa}}
}

should be

\newcommand\mm@macro[2]{%
  \AtBeginDocument{%
    \@ifundefined{#1}{%
        \expandafter\def\csname #1\endcsname{#2}%
    }{\mm@warning{#1}}%
  }%
}
\NewDocumentCommand\mm@operator{O{#3}mm}{%
  \AtBeginDocument{%
    \@ifundefined{#1}{%
        \DeclareMathOperator{#2}{#3}%
    }{\mm@warning{#1}}%
  }%
}

(note the wrong \\mm@warning in the code for \mm@macro), which is the actual source of the error you get.

Anyway, doing

\mm@macro{C}{\ensuremath{\mathset{C}}\xspace}

is of dubious usefulness: there's no gain whatsoever in using \xspace just to be able to type \C in text instead of $\C$ that's clearly segregates math.

9
  • 1
    Still, even with that fix, using $\C$ causes the error Command \C invalid in math mode on input line [xx]. (I actually use $\CC$ instead of $\C$ for complex number set.)
    – murray
    Mar 1, 2023 at 19:01
  • @murray You’re being warned that \C isn’t redefined bu the package.
    – egreg
    Mar 1, 2023 at 20:20
  • There is a gain: you don't need to type the $$ around the \C if you would not have needed the $$ anyway. // What would you recommend instead of \xspace? I know some people deprecate it but I have not yet come across a recommendation of an alternative.
    – Rosie F
    Mar 2, 2023 at 8:14
  • 1
    @RosieF not using $ is a disadvantage not an advantage. TeX is designed so it is clear whether you are in math or not, for human readers, for syntax highlighters, editors, ... I wrote xspace but I would not recommend it in general and stronger than that I would discourage its use in math. Mar 2, 2023 at 8:45
  • 1
    @RosieF I see no gain at all. I’ve seen so many times junk such as “Let x denote” instead of “Let $x$ denote”. Anything that encourages sloppiness is to be avoided.
    – egreg
    Mar 2, 2023 at 8:45
1

Thanks to Murray for the post and to egreg for the answer. A new release will be uploaded very soon with the bug corrected \mm@warning instead of \\mm@warning, and with a simple solution when using babel with russian: not defining \C in that case!

A first immediate solution is to use \let\C\relax just after loading mismath, and this is why I am not thrilled to use \AtBeginDocument for all my macros.

Another issue "dubious usefulness" pointed by Enrico Gregorio is the use with \ensuremath and \xspace: indeed it is for using \C (and the other commands for numbers sets) directly in text, what is very common.

Antoine Missier

1
0

The new release has been uploaded on CTAN and should become available in a few days. Thanks for this bug report.

1
  • The package update is already available from now on. Mar 2, 2023 at 10:59

You must log in to answer this question.

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