使 $\C$ 更容易用於複數:與 T2A、mismath 和 babel 衝突

使 $\C$ 更容易用於複數:與 T2A、mismath 和 babel 衝突

我強烈傾向於使用 來$\C$表示複數集合,就像我用來$\R$表示實數一樣 - 無論是使用\mathbb還是\mathbf

其他幾個套件使用它們自己的\C: t2aenc.def(調用自\usepackage[T2A,T1]{fontenc});的定義。 mismath.sty;以及hyperref.sty它所呼叫的任一或某個包。

我的解決方法如下面的 MWE 所示。

問題:有沒有更簡單的方法來實現這一點——無需反覆重新定義\C

筆記:

  • 我不太可能需要\Cfrombabel使用 T2A。我不確定如何hyperref使用\C. (用於塞爾維亞-克羅埃西亞語和斯洛維尼亞語中的雙音。)
  • 我正在使用 pdflatex 和不是xelatex 或 lualatex!

來源 MWE:

\documentclass{article}
\usepackage[T2A,T1]{fontenc}
\usepackage[russian,french,german,polish,main=english]{babel}

% Avoid \lll clash with def in amssymb.sty:
\makeatletter
    \let\polish@l=\ll
    \let\polish@L=\LLL
    \let\lll\relax \let\LLL\relax % undefine them
    \def\plll{\polish@l}
    \def\pLLL{\polish@L}
\makeatother
\usepackage{amsmath,amssymb}

% Choose ONE of the following two defs:
%\newcommand{\numsys}[1]{\mathbb{#1}}
\newcommand{\numsys}[1]{\mathbf{#1}}

% First 
\makeatletter
\def\my@textormath{%
  \ifmmode
    \expandafter\@secondoftwo
  \else
    \expandafter\@firstoftwo
  \fi}
    \ifcsname C\endcsname
      \let\oldC\C
      \def\C{\my@textormath{\oldC}{\numsys{C}}}
    \fi
\makeatother

\usepackage{mismath} % defines \Z, \Z, \Q, \R, \C with mathbf

\usepackage[pdftex]{hyperref}
\makeatletter
\def\my@textormath{%
  \ifmmode
    \expandafter\@secondoftwo
  \else
    \expandafter\@firstoftwo
  \fi}
\@ifpackageloaded{hyperref}{% then
    \let\newerC\C
    \def\C{\my@textormath{\newerC}{\numsys{C}}}}%
  {}
\makeatother

\renewcommand{\N}{\numsys{N}}
\renewcommand{\Z}{\numsys{Z}}
\renewcommand{\Q}{\numsys{Q}}
\renewcommand{\R}{\numsys{R}}

\begin{document}

$\N \subset \Z \subset \Q \subset \R \subset \C$

\end{document}

相關貼文: 可以使用 $ \C$ 表示具有 T2A 編碼的複數嗎?

答案1

如果您希望您的定義獲勝,請盡可能晚地添加

  \AtBeginDocument{\def\C{\numsys{C}}}

相關內容