0

My strong preference is to use $\C$ to denote the set of complex numbers, just as I use $\R$ to denote the real numbers — whether with \mathbb or \mathbf.

Several other packages use their own definitions of \C: t2aenc.def (called from \usepackage[T2A,T1]{fontenc}); mismath.sty; and either hyperref.sty or some package it calls.

My workaround for this shown in the MWE below.

Question: Is there a simpler method to accomplish this — without repeatedly redefining \C?

Notes:

  • It is very unlikely I'll ever need the \C from babel's use of T2A. I'm unsure of how hyperref uses \C. (It's for a double-grave accent in Serbo-Croatian and Slovenian.)
  • I am using pdflatex and not xelatex or lualatex!

Source 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}

Related post: Possible to use$ \C$ for complex numbers with T2A encoding?

3
  • 1
    If you want your definition to win do as late as possible \AtBeginDocument{\def\C{\numsys{C}}}. – Ulrike Fischer Aug 5 '19 at 21:00
  • I do want mine to win, and this works! Please make as an answer. (Do you happen to know how/where the \C is used by hypreref, just in case I'm overlooking something I might actually need there?) – murray Aug 5 '19 at 21:07
  • hyperref adds a definition for the accent command for the bookmarks. if you don't need the command in this sense, it shouldn't matter. – Ulrike Fischer Aug 5 '19 at 21:13
2

If you want your definition to win add as late as possible

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.