dryabov / rmathbr

Repeating of math hyphenation mark in inline equations
http://d-ryabov.livejournal.com/723.html
8 stars 0 forks source link

Bug/incompatibility: \coloneq in tikz-cd diagrams hangs LaTeX #11

Open typomaster2 opened 3 months ago

typomaster2 commented 3 months ago

The command \coloneq used with tikz-cd diagrams leads to an endless compilation when the package rmathbr is enabled. There seem to be no issue when rmathbr is not used.

For example, without \usepackage{rmathbr}, the following code

\documentclass[12pt]{article}
\usepackage{tikz-cd}
\usepackage{babel}
\usetikzlibrary{babel}                  
\usepackage{amsmath}
\usepackage{mathtools}                  % for coloneq
%\usepackage{rmathbr}                   % currently disabled (enable for hanging compilation)           

\begin{document}

    \begin{figure}[!htbp]
        \centering
        \begin{equation*}
            \begin{tikzcd}
                {} & \arrow[dl, bend right=30, "{u}"'] \mathcal{U} \arrow[d, "{f}"] \arrow[d, dashed, bend left=80, "{g}"] \\
                P \arrow[r, bend left=20, "{I \coloneq I_1}"] & \arrow[l, bend left=20, "{J}"] Q 
            \end{tikzcd}
        \end{equation*}
    \end{figure}

\end{document}

yields the expected diagram:

image

However, with \usepackage{rmathbr} enabled (uncommented), the compilation potentially goes on forever.

I am using up-to-date versions of the packages and engines. You may try other colon-related things in the diagrams, they also seem to not work one way or another with rmathbr in tikz-cd diagrams, for example, the bare colon : instead of \coloneq.

dryabov commented 3 months ago

A fix for breqn from https://tex.stackexchange.com/questions/460746/tikz-cd-problems-whilst-also-using-breqn-package#answer-460750 works with rmathbr too:

\makeatletter
\def\fixtikzforbreqn#1#2{%
  \protected\edef#1{\noexpand\ifmmode\mathchar\the\mathcode`#2 \noexpand\else#2\noexpand\fi}%
}
\fixtikzforbreqn\tikz@nonactivesemicolon;
\fixtikzforbreqn\tikz@nonactivecolon:
\fixtikzforbreqn\tikz@nonactivebar|
\fixtikzforbreqn\tikz@nonactiveexlmark!
\makeatother
typomaster2 commented 3 months ago

Ah! Perfect. Thank you very much, this seems to work well. Close / leave open as you please.