Conflicto entre amscd y Unicode-Math

Oct 12 2020

Después de cambiar al paquete unicode-math, el paquete amscd para diagramas conmutativos ya no funciona. No recibo mensajes de error, pero los símbolos como @ y <se muestran en la salida.

Adjunto un ejemplo casi mínimo, que funcionó antes.

\documentclass[12pt]{article}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{unicode-math}
\usepackage{amscd}
\newcommand\xbf[1]{#1}
\newcommand\fg[1]{#1}
\newcommand\obf[1]{#1}
\newcommand\R{{R}}
\begin{document}
Diagram:
  \begin{equation*}
  \begin{CD}
    \obf{\omega} \in \R^{3\times 3} @<\xbf{Ad}_{\xbf{B}}<< \obf{\Omega} \in \R^{3\times 3} \\
    @A\hat{\ }AA @AA\hat{\ }A\\
    \fg{\omega}=\xbf{B}\fg{\Omega} \in\R^3 @<\xbf{B}<< \fg{\Omega}\in \R^3
  \end{CD}
  \end{equation*}
\end{document}

Respuestas

4 egreg Oct 12 2020 at 22:14

El amscdpaquete funciona

\mathcode`@="8000

para hacer que las @matemáticas sean activas. También se ejecuta \CDatal iniciar un CDentorno, donde \CDatestá definido por

\gdef\CDat{\let @=\Iat}

en un contexto donde @está activo. No es importante saber qué \Iates, solo que es esencial que las @matemáticas sean activas y tengan el significado \Iatdurante el procesamiento del CDentorno.

Desafortunadamente, unicode-mathnormaliza los códigos matemáticos en \begin{document}, por lo que @se olvida la configuración del código matemático de .

De hecho, puede mejorar la definición del CDentorno para independizarse de las condiciones circundantes (lo que también debería haber hecho el amscdpaquete, pero existen razones históricas para que no sea así).

\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{amscd}
\usepackage{unicode-math}

\begingroup\lccode`~=`@ \lowercase{\endgroup
  \def\CDat{\let~\Iat\mathcode`@="8000\relax}%
}

\newcommand\xbf[1]{#1}
\newcommand\fg[1]{#1}
\newcommand\obf[1]{#1}
\newcommand\R{{R}}

\begin{document}
Diagram:
  \begin{equation*}
  \begin{CD}
    \obf{\omega} \in \R^{3\times 3} @<\xbf{Ad}_{\xbf{B}}<< \obf{\Omega} \in \R^{3\times 3} \\
    @A\hat{\ }AA @AA\hat{\ }A\\
    \fg{\omega}=\xbf{B}\fg{\Omega} \in\R^3 @<\xbf{B}<< \fg{\Omega}\in \R^3
  \end{CD}
  \end{equation*}
\end{document}

Alternativamente, con la última versión de LaTeX (2020-10-01), puede reemplazar las tres líneas de código de \begingroupa }con

\AtBeginEnvironment{CD}{\mathcode`@="8000\relax}

aunque esto me atrae menos.

Con tikz-cd:

\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{unicode-math}
\usepackage{tikz-cd}

\newcommand\xbf[1]{#1}
\newcommand\fg[1]{#1}
\newcommand\obf[1]{#1}
\newcommand\R{{R}}

\begin{document}

Diagram:
\begin{equation*}
  \begin{tikzcd}
  \obf{\omega} \in \R^{3\times 3} &
  \obf{\Omega} \in \R^{3\times 3} \arrow[l,"\xbf{Ad}_{\xbf{B}}"']
  \\
  \fg{\omega}=\xbf{B}\fg{\Omega} \in\R^3  \arrow[u,"\hat{\ }"] &
  \fg{\Omega}\in \R^3 \arrow[l,"\xbf{B}"'] \arrow[u,"\hat{\ }"]
  \end{tikzcd}
\end{equation*}

\end{document}

3 UlrikeFischer Oct 12 2020 at 20:44

Parece funcionar de nuevo si restablece el código matemático de @:

\documentclass[12pt]{article}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amscd}
\usepackage{unicode-math}
\newcommand\xbf[1]{#1}
\newcommand\fg[1]{#1}
\newcommand\obf[1]{#1}
\newcommand\R{{R}}
\begin{document}


Diagram:
  \begin{equation*}\mathcode`\@="8000
  \begin{CD}
    \obf{\omega} \in \R^{3\times 3} @<\xbf{Ad}_{\xbf{B}}<< \obf{\Omega} \in \R^{3\times 3} \\
    @A\hat{\ }AA @AA\hat{\ }A\\
    \fg{\omega}=\xbf{B}\fg{\Omega} \in\R^3 @<\xbf{B}<< \fg{\Omega}\in \R^3
  \end{CD}
  \end{equation*}
\end{document}