0

I am using the classicthesis template.

I am trying to type the capital Greek letter Psi Ψ. However, it compiles as the symbol ̄ . This stops when I disable breqn. This occurs in the regular equation mode with just

\[\Psi\]

but I have encountered this with dmath and equation as well.

4
  • 1
    Welcome! Please, add a minimal example of code that shows the issue.
    – egreg
    May 22 at 20:19
  • Hello @egreg. I am having trouble trying to reproduce this issue on its own. Apologies for not including it. All I can tell for now is that breqn is clashing with something else but only using breqn isn't causing it. EDIT: Upon downloading a fresh copy of classicthesis, I still have an error when I use breqn but I can't identify where it comes from.
    – zaphod
    May 22 at 20:24
  • Check the font packages
    – egreg
    May 22 at 20:32
  • 1
    I can reproduce the issue with \usepackage{fourier}, which is definitely incompatible with breqn. Note that classicthesis has nothing to do with the issue. I'll never be tired of saying that breqn is a nice proof of concept, but it doesn't work.
    – egreg
    May 22 at 21:42

1 Answer 1

2

breqn documentation mentions the issue:

breqn documentation

breqn documentation 2


Normally you load the math font before breqn:

documentation of special math font for breqn

Unfortunately fourier is not one of the supported math fonts, you need to figure out what's going on then create your own support file.

Similar question: fourier - breqn corrupts fouriernc in TL 2016 - TeX - LaTeX Stack Exchange

The following is probably the proper way:

\documentclass{article}
\usepackage{amsmath}
\usepackage{fourier}
%\usepackage[fourier]{flexisym}  % it would suffice to do this if there were a `fourier.sym` support file
\usepackage{breqn}

\ExplSyntaxOn
\makeatletter
\cs_gset:cpx {mg@Greek}  {\hexnumber@\symotherletters}
\makeatother
\ExplSyntaxOff

\begin{document}

\[
    \Psi
\]

\end{document}

Basically, you can

  • read the existing support file (e.g. mathpazo.sym) to see what breqn/flexisym does with other math packages,
  • read the source code of fourier package to figure out the ⟨sym-font⟩ name (otherletters),
  • read around various source codes to figure out the little tricks that
    • LaTeX's mathgroup is TeX's fam,
    • \mg@⟨flexisym internal symbol font name⟩ stores the \mathgroup number of that symbol font name,
    • \sym⟨sym-font⟩ stores the mathgroup of that symbol font where ⟨sym-font⟩ is as in fntguide.

What if you load breqn before fourier instead?

You get some error messages on "commands already defined".

Internally, what's going on is that fourier runs \DeclareMathSymbol to redefine \Psi and many other commands, but the problem is

  • \DeclareMathSymbol only allow safely redefining a control sequence if the meaning includes the string mathchar,
  • breqn's definition of \Psi does not have it,
  • thus \DeclareMathSymbol raises an error and does not redefine the control sequence.

Is this LaTeX's fault or breqn's fault? I'm not sure, I can only trace the LaTeX code back to 2008 through GitHub log (https://github.com/latex3/latex2e/blob/develop/base/ltfssdcl.dtx#L1591), but breqn package is older than that. (Either way, TeX's lack of interface to check whether something is a math character forces LaTeX to use a string-in-meaning test which is fragile as you've seen)

Anyway, one way is to patch \DeclareMathSymbol: (you also need to similarly patch \DeclareMathDelimiter to avoid other error messages which is not done here):

\makeatletter
\def\originalDeclareMathSymbol#1#2#3#4{%
  \expandafter\in@\csname sym#3\expandafter\endcsname
     \expandafter{\group@list}%
  \ifin@
    \begingroup
      \count\z@=#4\relax
      \count\tw@\count\z@
      \divide\count\z@\sixt@@n
      \count@\count\z@
      \multiply\count@\sixt@@n
      \advance\count\tw@-\count@
      \if\relax\noexpand#1% is command?
%    \end{macrocode}
%    Store the command name with a space attached inside
%    \cs{reserved@@b} in case we look at a robust definition.
%    \begin{macrocode}
        \edef\reserved@b{\expandafter\noexpand
                         \csname\expandafter\@gobble\string#1\space\endcsname}%
%    \end{macrocode}
%    Test both \verb=#1= and \verb*=#1 = for containing \texttt{mathchar}.
%    \begin{macrocode}
        \edef\reserved@a
          {\noexpand\in@{\expandafter\@gobble\string\mathchar}%
                        {\meaning#1\expandafter\meaning\reserved@b}}%
        \reserved@a
%    \end{macrocode}
%    Drop  \verb*=#1 = in case it was defined before.
%    \begin{macrocode}
        \global\expandafter\let\reserved@b\@undefined
        \ifin@
          \expandafter\set@mathsymbol
             \csname sym#3\endcsname#1#2%
             {\hexnumber@{\count\z@}\hexnumber@{\count\tw@}}%
          \@font@info{Redeclaring math symbol \string#1}%
        \else
          \expandafter\ifx
            \csname\expandafter\@gobble\string#1\endcsname
            \relax
            \expandafter\set@mathsymbol
               \csname sym#3\endcsname#1#2%
               {\hexnumber@{\count\z@}\hexnumber@{\count\tw@}}%
          \else
            \@latex@error{Command `\string#1' already defined}\@eha
          \fi
        \fi
      \else
        \expandafter\set@mathchar
          \csname sym#3\endcsname#1#2
          {\hexnumber@{\count\z@}\hexnumber@{\count\tw@}}%
      \fi
    \endgroup
  \else
    \@latex@error{Symbol font `#3' is not defined}\@eha
  \fi
}
\ifx\originalDeclareMathSymbol\DeclareMathSymbol \else \errmessage{Unexpected definition of DeclareMathSymbol!!}\fi
\def\DeclareMathSymbol#1#2#3#4{%
  \expandafter\in@\csname sym#3\expandafter\endcsname
     \expandafter{\group@list}%
  \ifin@
    \begingroup
      \count\z@=#4\relax
      \count\tw@\count\z@
      \divide\count\z@\sixt@@n
      \count@\count\z@
      \multiply\count@\sixt@@n
      \advance\count\tw@-\count@
      \if\relax\noexpand#1% is command?
%    \end{macrocode}
%    Store the command name with a space attached inside
%    \cs{reserved@@b} in case we look at a robust definition.
%    \begin{macrocode}
        \edef\reserved@b{\expandafter\noexpand
                         \csname\expandafter\@gobble\string#1\space\endcsname}%
%    \end{macrocode}
%    Drop  \verb*=#1 = in case it was defined before.
%    \begin{macrocode}
        \global\expandafter\let\reserved@b\@undefined
        \expandafter\set@mathsymbol
           \csname sym#3\endcsname#1#2%
           {\hexnumber@{\count\z@}\hexnumber@{\count\tw@}}%
        \@font@info{Redeclaring math symbol \string#1}%
      \else
        \expandafter\set@mathchar
          \csname sym#3\endcsname#1#2
          {\hexnumber@{\count\z@}\hexnumber@{\count\tw@}}%
      \fi
    \endgroup
  \else
    \@latex@error{Symbol font `#3' is not defined}\@eha
  \fi
}
\makeatother

\documentclass{article}
%\usepackage[paperheight=5cm, paperwidth=5cm]{geometry}
%\errorcontextlines=10
\usepackage{amsmath}
\usepackage{breqn}
\usepackage{fourier}
\begin{document}

\[
    \Psi
\]

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .