3

I'm have a defined a couple of math delimiters via \DeclarePairedDelimiter, however, they seem to create some problems with respect to the spacing with some fonts. For example the following codes yields an overlap between the P and the left bracket.

enter image description here

Is there a way to fix the definition of \DeclarePairedDelimiter such that I can use it right away in all my documents?

% !TeX TS-program = lualatex
\documentclass{article}
\usepackage{mathtools,unicode-math,xparse}
\unimathsetup{math-style=ISO,bold-style=ISO,sans-style=italic}
\setmathfont{XITS Math}

\DeclarePairedDelimiter\parens{\lparen}{\rparen}

\newcommand{\powerset}[1]{\mathcal{P}\parens*{#1}}
\newcommand{\powersetlr}[1]{\mathcal{P}\left(#1\right)}

\begin{document}
    \begin{align}
        \powerset{XX}\\
        \powersetlr{XX}
    \end{align}
\end{document}
2
  • 1
    You may have come across a kerning error (bug?) in the XITS Math font family. I suggest you switch to the Stix Two Math font (available online here). No such kerning problems with the Stix Two text and math fonts...
    – Mico
    Jul 10, 2018 at 19:21
  • I can't reproduce the problem with XeLaTeX. With LuaLaTeX it's a different problem.
    – egreg
    Jul 10, 2018 at 20:07

3 Answers 3

3

If you can at all switch from the XITS math font to the Stix Two math font, the kerning problems are removed automatically. The Stix Two text and math fonts are not distributed automatically with TeXlive, but they may be downloaded free of charge from stixfonts.org.

enter image description here

% !TeX TS-program = lualatex
\documentclass{article}
\usepackage{mathtools,mleftright,unicode-math} 
% "Stix Two" text and math fonts: see http://stixfonts.org/
\setmathfont{Stix Two Math}[math-style=ISO,StylisticSet=1]

\DeclarePairedDelimiter\parens()
\newcommand{\powerset}[1]{\mathcal{P}\parens*{#1}}
\newcommand{\powersetlr}[1]{\mathcal{P}\mleft(#1\mright)}

\begin{document}
    \begin{align*}
        &\mathcal{P}(XX)\\
        &\mathcal{P}\parens{XX}\\
        &\powerset{XX}\\
        &\powersetlr{XX}
    \end{align*}
\end{document}
5

With LuaLaTeX there's a different treatment of italic correction. You can restore the “old” one (which LaTeX expects) by adding \mathoption old 1.

\documentclass{article}
\usepackage{mathtools,unicode-math,xparse}
\unimathsetup{math-style=ISO,bold-style=ISO,sans-style=italic}
\setmathfont{XITS Math}

\DeclarePairedDelimiter\parens{\lparen}{\rparen}

\newcommand{\powerset}[1]{\mathcal{P}\/\parens*{#1}}
\newcommand{\powersetlr}[1]{\mathcal{P}\left(#1\right)}

\mathoption old 1

\begin{document}
    \begin{align}
        \powerset{XX}\\
        \powersetlr{XX}
    \end{align}
\end{document}

enter image description here

4

You can define \powerset with the \DeclarePairedDelimiterXPP which allows for a pre-code and a post-code before and after the delimiters.

This code works well with xelatex, not so well with lualatex, perhaps due to the kerning problem mentioned by @Mico:

\documentclass{article}
\usepackage{mathtools,unicode-math,xparse}%
\unimathsetup{math-style=ISO,bold-style=ISO,sans-style=italic}
 \setmathfont{XITS Math}
\DeclarePairedDelimiterXPP\powerset[1]{\mathcal{P}}\lparen\rparen{}{#1}
\newcommand{\powersetlr}[1]{\mathcal{P}\left(#1\right)}

\begin{document}

    \begin{align}
        \powerset*{X^{X^2}}\\
        \powersetlr{XX}
    \end{align}

\end{document}

With xelatex:

enter image description here

With lualatex:

enter image description here

You must log in to answer this question.

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