The meaning of \C in xelatex and/or fontspec

fontspecxetex

For a long time, I've used \newcommand{\C}{\mathbb{C}} in the preamble of my documents compiled with pdflatex to shorten the command needed to create the symbol for the complex numbers. Now I have a document where I have to use an Opentype font. For this I've switched to xelatex as engine, and replaced \usepackage[T1]{fontenc} by \usepackage[OT1]{fontspec} to get it to work. (I dont't unterstand things well enough to really be able to say whether or why this is necessary.) Using the OTF font works like a charm, but now I get the error messages "Command \C already defined." for the \newcommand line and "Command \C unavailable in math mode" for every time it is used. So apparently something in the changes I did lead to \C being a predefined command that is not to be used in math mode. But when I use \C in normal mode, it does not produce any visible sign. What is it good for? Where is it defined? Is it safe to overwrite it with \renewcommand?

Edit: Working on a MWE, I found out that the problem is present for documentclass beamer, but not for documentclass article. So here is my MWE:

\documentclass{beamer}
%\usepackage{fontspec}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{amssymb}

\newcommand{\C}{\mathbb{C}}

\begin{document}
This $\C$ is the set of complex numbers.
\end{document}

works when compiled with pdflatex, while

\documentclass{beamer}
\usepackage{fontspec}
%\usepackage[T1]{fontenc}
%\usepackage[utf8]{inputenc}
\usepackage{amssymb}

\newcommand{\C}{\mathbb{C}}

\begin{document}
This $\C$ is the set of complex numbers.
\end{document}

produces the aforementioned errors when compiled with xelatex.

Best Answer

This definition comes from old copies of hyperref (texlive 2019 or early texlive 2020) in an updated texlive 2020 or texlive 2021 or texlive 2022 you get no error.

The change is a technical internal cleanup and not that relevant, nothing that bad will happen if you over-write the definition, other than the standard advice about not using the on-letter accent names as they may get used in bibliographies etc.

In Cyrillic T2A encoding \DeclareTextAccent{\C}

If you can use XeLaTeX and fontspec, you can also use unicode-math, which defines ℂ as \BbbC. Otherwise, \DeclareRobustCommand\C{\mathbb{C}} will overwrite any previous definition of \C This will probably work, but might break some package out there.