1

The MTProII fonts provide two sets of curly braces, the straight extensible ones and the curly desinged braces that extend up to 4in high.... and that is all very dandy, except that when using the {cases} construct from the amsmath it (automatically) sometimes chooses one type and sometimes choose another in a mix that does not look very nice:

\documentclass{report}

\usepackage{amsmath} \usepackage{mtpro2} \begin{document}

[ \begin{cases} a_n=2 a_{n-1}+1, \quad \forall,n\geq 2,\ a_1=1.\ \end{cases} ]

[ \begin{cases} a_n=a_{n-1}+a_{n-2},\quad \forall,n\geq 3,\ a_1=1,\ a_2=1,\ \end{cases} ]

\end{document}

enter image description here

Is this an error in the package that loads the fonts or something that could be controlled from the outside?

I have been looking at the code, but cannot quite locate the place where this is controlled.

Is it possible to handle this differently by using fontspec and avoiding the package mtpro2?

I am aware of the question/answer here, but that deal with a different problem -- not the automatic choice of cases.

Paulo Ney
  • 2,405
  • isn't this just the usual thing that a font has so many designed size characters then switches to the straight extender, does the font really have a designed left brace that big? LaTeX doesn't control this at all it just uses \left\{ and gets whatever the font supplies. – David Carlisle Sep 30 '20 at 13:58
  • @DavidCarlisle definitely the font supplies both -- as you can see in the file above. – Paulo Ney Sep 30 '20 at 14:08
  • Ah OK I see egreg's answer that you link to. OK so that basically is the answer here too. The font switches to the straight form as you show but there are larger designed size ones available, – David Carlisle Sep 30 '20 at 14:12
  • @DavidCarlisle I understand that I can choose them by hand -- no problem there, but the question is why amslatex is choosing one is or another depending on the size. – Paulo Ney Sep 30 '20 at 14:35
  • latex has no control over this, it just does \left\{ and the font specifies what is returned. The designer of the mtpro fonts has (unusually) made some additional glyphs which are not in the chained sequence that makes up the variable sized delimiter. TeX has no access to the information at all. – David Carlisle Sep 30 '20 at 14:38
  • @DavidCarlisle I would like to understand better your statement "latex has no control over this, it just does \left\{ and the font specifies what is returned". I am having a hard time believe it. What mechanism a font has to recognize what is \left\{ and specify what is used? One of the character (above) is NOT even in the font, how can it choose to return it? – Paulo Ney Oct 13 '20 at 04:18
  • the complete definition of \lbrace is \DeclareMathDelimiter{\lbrace}{\mathopen}{symbols}{"66}{largesymbols}{"08} which is a latex macro equivalent to the primitive definition in plain tex \def\lbrace{\delimiter"4266308 } so all tex knows is a normal { is character hex 66 from math family 4 and if you use \left and need something bigger then use the character 8 from math family 3. How or if the cmex font that is family 3 specifies how to construct a larger brace is in the font metrics and not accessible to tex macros – David Carlisle Oct 13 '20 at 06:42

1 Answers1

4

First the output (code below):

cases

Short answer

Use the patch mtpro2-patch.tex I developed over the years (my “shameless plug”).

\documentclass{report}

\usepackage{amsmath} \usepackage{mtpro2}

\input{mtpro2-patch}% https://github.com/RuixiZhang42/font-pairing-guide/blob/master/mtpro2-patch.tex

\begin{document} Every \verb|cases| uses curly brace: [ \begin{cases} a_n=2 a_{n-1}+1, \quad \forall,n\geq 2,\ a_1=1.\ \end{cases} \qquad \begin{cases} a_n=a_{n-1}+a_{n-2},\quad \forall,n\geq 3,\ a_1=1,\ a_2=1,\ \end{cases} ]

\straightbraces Now, every \verb|cases| uses straight brace: [ \begin{cases} a_n=2 a_{n-1}+1, \quad \forall,n\geq 2,\ a_1=1.\ \end{cases} \qquad \begin{cases} a_n=a_{n-1}+a_{n-2},\quad \forall,n\geq 3,\ a_1=1,\ a_2=1,\ \end{cases} ]

\end{document}

Long answer

The following provides essentially a brief documentation for one small part of mtpro2-patch.tex.

\documentclass{report}

\usepackage{amsmath} \usepackage{mtpro2}

\makeatletter % First, we need a test to see which braces are in force. % The mtpro2 package provides 3 sets of braces. We treat % curly braces as one type, while morphed and straight % braces as another type. \expandafter\def\csname mtp2@lcbrace\endcsname {\delimiter"4266308 }% define our own left curly brace \newcommand*@ifcurlybraces{% \expandafter\ifx\csname mtp2@lcbrace\endcsname\lbrace \expandafter@firstoftwo \else \expandafter@secondoftwo \fi } % Next, we redefine the cases environment. % If curly braces are in force, we use the \LEFTRIGHT construction. % Otherwise, we use the \left...\right construction. \newsavebox\mtp@matrix@cases \renewenvironment{cases}{% \matrix@check\cases \setbox\mtp@matrix@cases\hbox\bgroup$% \let@ifnextchar\new@ifnextchar \def\arraystretch{1.1}% less than 1000/\delimiterfactor, my personal preference \array{@{}l@{\quad}l@{}}% }{% \endarray \m@th$\egroup @ifcurlybraces{% \LEFTRIGHT@\lbrace.{,\copy\mtp@matrix@cases}% }{% \left\lbrace\copy\mtp@matrix@cases\right.% }% } \makeatother

\begin{document} Every \verb|cases| uses curly brace: [ \begin{cases} a_n=2 a_{n-1}+1, \quad \forall,n\geq 2,\ a_1=1.\ \end{cases} \qquad \begin{cases} a_n=a_{n-1}+a_{n-2},\quad \forall,n\geq 3,\ a_1=1,\ a_2=1,\ \end{cases} ]

\straightbraces Now, every \verb|cases| uses straight brace: [ \begin{cases} a_n=2 a_{n-1}+1, \quad \forall,n\geq 2,\ a_1=1.\ \end{cases} \qquad \begin{cases} a_n=a_{n-1}+a_{n-2},\quad \forall,n\geq 3,\ a_1=1,\ a_2=1,\ \end{cases} ]

\end{document}

Ruixi Zhang
  • 9,553
  • Is there and English page for the patch? Going to https://github.com/RuixiZhang42/font-pairing-guide has an English call, but clicking on it leads to a 404. – Paulo Ney Jan 21 '21 at 05:31
  • @PauloNey Sorry, you can blame that on my procrastination and laziness… That repo is severely under-documented, but the patch file itself contains comments written in English. If you are not comfortable inputting the entire patch file, you can use the code in my long answer to get the desired result. The entire patch file contains fixes for other bugs in amsmath and LaTeX kernel (some of these bugs are not officially recognized by the kernel team, and may never get fixed for backward compatibility reasons), so the patch file can change your old documents. – Ruixi Zhang Jan 21 '21 at 17:34
  • @PauloNey I have updated README-EN.md. Feel free to give my patch file a try :) – Ruixi Zhang Jan 21 '21 at 22:27
  • This is great and fixed my issue. Thanks! – TheProgrammer Nov 27 '23 at 02:25