
下面的 MWE 表明定義
\mm@macro{C}{\ensuremath{\mathset{C}}\xspace}
摘自mismath.sty
[2023/02/24 v2.5] 第 267 行 —
\mm@macro{C}{\ensuremath{\mathset{C}}\xspace}
babel
— 與載入[2023/02/13 3.86] 和選項russian
[ russianb.ldf
2021/01/10 1.3m ]配對時會導致錯誤;俄文 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}
中違規行的目的mismath.sty
最終是定義\C
黑板粗體 C。
錯誤是:
/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}
mismath
這是早期版本的和中不會出現的新錯誤babel
。
除了複製其中\mismath
有問題的行被註解掉之外,還有其他解決方案嗎?
答案1
太長了;博士
mismath.sty
: 的程式碼中有一個錯誤,\mm@macro
應該\\mm@warning{#1}
是\mm@warning{#1}
。
對於本質上是巨集集合的套件來說,這是一個常見問題,最終會與其他套件發生衝突。
在特定情況下,檢查\mm@macro
應延遲到開始文件時進行。當載入西里爾字母編碼時,\C
由 定義hyperref
。同樣對於\mm@operator
.即使沒有也hyperref
可能有問題,因為unicode-math
它的大部分工作都是在開始記錄時完成的。
程式碼
\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}}
}
應該
\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}}%
}%
}
\\mm@warning
(請注意程式碼中的錯誤\mm@macro
),這是您收到的錯誤的實際來源。
無論如何,做
\mm@macro{C}{\ensuremath{\mathset{C}}\xspace}
\xspace
其用處值得懷疑:僅僅為了能夠輸入文字而使用它並沒有任何好處,\C
而不是$\C$
明顯地隔離數學。
答案2
感謝默里的貼文和埃格雷格的回答。很快就會上傳一個新版本,並糾正錯誤\mm@warning
而不是\\mm@warning
,並且在將 babel 與俄語一起使用時有一個簡單的解決方案:\C
在這種情況下不定義!
第一個立即解決方案是在載入mismath之後立即使用\let\C\relax
,這就是為什麼我不高興使用\AtBeginDocument
我的所有巨集。
Enrico Gregorio 指出的另一個「可疑的有用性」問題是與\ensuremath
and 的使用\xspace
:實際上,它是直接在文本中使用 \C (以及數字集的其他命令),這是非常常見的。
安托萬·米西爾
答案3
新版本已上傳至 CTAN,幾天後即可發布。感謝您提供此錯誤報告。