1

MWE:

\documentclass{article}

\usepackage{amsthm, amsmath}

\usepackage{unicode-math}

\setmathfont[,Scale=1,FakeStretch=1,FakeBold=0]{NewCMMath-Book.otf} \setmathfont[range={"0028, "0029},Scale=1,FakeStretch=1,FakeBold=0]{CenturymodernTT-Regular.otf}

\begin{document}

Some random text
    \begin{align*}
        \log x\left(\pi(x)-\pi\left(\frac{x}{2}\right)\right)
    \end{align*}

1234567890

\end{document}

I have looked at questions that sound similar but aren't really e.g.

applying math formatting to a non-math font

Unicode math at TeX primitive level

Output

Notice how delimiter does not work with parentheses. I think it's because the font does not have math script and does not have the corresponding scaled brackets defined in the font file itself. Is there a way to make use of the delimiter of the usual CM font for this parentheses?

I have tried some scaling mechanism but I did not like the output very much because of alignment issues. To clarify, I would like to use the parentheses like this:

Desired output

I was able to produce this by editing specific glyphs inside the font. First, I took the NewCM math font, replaced some glyphs with old looking ones. Then I replaced some brackets by some old glyphs and added transformations such as scaling, moving vertically, etc. Unfortunately, even though I edited brackets from v1 to v7 in the glyph table, it did not cover all possible cases which makes the output look like this:

current output after modifying brackets

See how some brackets work but some don't (probably the ones that require the most scaling).

Hopefully that gives a good idea of what I want to achieve and what I have tried.

Masum
  • 1,009

1 Answers1

2

It's unclear what you want.

To begin with, you cannot borrow the parentheses from a non-math font and hope they scale with \left and \right: in order to do this, the font must support the feature and have a MATH table.

Second problem: you say

Is there a way to make use of the delimiter of the usual CM font for this parentheses?

Let's see a few examples.

With NewCMMath only

\documentclass{article}
\usepackage{amsthm, amsmath}
\usepackage{unicode-math}

\setmathfont{NewCMMath-Book.otf}

\begin{document}

Some random text \begin{equation} \log x\left(\pi(x)-\pi\left(\frac{x}{2}\right)\right) \end{equation}

1234567890

\end{document}

enter image description here

With Latin Modern Math for the parentheses

\documentclass{article}
\usepackage{amsthm, amsmath}
\usepackage{unicode-math}

\setmathfont{NewCMMath-Book.otf} \setmathfont{Latin Modern Math}[range={"0028, "0029}]

\begin{document}

Some random text \begin{equation} \log x\left(\pi(x)-\pi\left(\frac{x}{2}\right)\right) \end{equation}

1234567890

\end{document}

enter image description here

With legacy Computer Modern for the parentheses

\documentclass{article}
\usepackage{amsthm, amsmath}
\usepackage{unicode-math}

\setmathfont{NewCMMath-Book.otf}

\DeclareSymbolFont{CMoperators}{OT1}{cmr} {m}{n} \SetSymbolFont{operators}{bold}{OT1}{cmr} {bx}{n} \DeclareSymbolFont{CMlargesymbols}{OMX}{cmex}{m}{n}

\DeclareMathDelimiter{(}{\mathopen} {CMoperators}{"28}{CMlargesymbols}{"00} \DeclareMathDelimiter{)}{\mathclose}{CMoperators}{"29}{CMlargesymbols}{"01}

\begin{document}

Some random text \begin{equation} \log x\left(\pi(x)-\pi\left(\frac{x}{2}\right)\right) \end{equation}

1234567890

\end{document}

enter image description here

Conclusion

I see no difference at all in the three pictures.

egreg
  • 1,121,712
  • I have updated the post to clarify the question and what I have tried a bit better. Please check. I suppose I tried to directly edit the math table using this font which does not fix the output everywhere. So I thought maybe I could make the \left(\right) command use the bracket from this font for scaling rather the usual CM one. Now I am starting to think I need to edit the math table with this font for the remaining brackets. – Masum Mar 26 '24 at 19:20