4

I use LuaLaTeX, fontspec and XITS maths font. Additionally, I had a problem with theorem environment and long headers so I based my solution on this. My problem is that I now get a different font for the \mathcal{S} when I use optional name. Any ideas why?

\documentclass{article}
\usepackage{fontspec}
\usepackage{amsmath}
\usepackage[math-style=ISO]{unicode-math}
\setmathfont{XITS Math}
\setmathfont[range={\mathcal,\mathbfcal},StylisticSet=1]{XITS Math} 

\usepackage[thmmarks,amsmath,amsthm,hyperref]{ntheorem}
\makeatletter
\newtheoremstyle{Myplain}%
  {\item[\hskip\labelsep \theorem@headerfont ##1\ ##2.\theorem@separator]}%
  {\item[\hskip\labelsep \theorem@headerfont ##1\ ##2]\theorem@headerfont (##3).\theorem@separator\normalfont\itshape}
\newtheoremstyle{nonumberMyplain}%
  {\item[\theorem@headerfont\hskip\labelsep ##1\theorem@separator]}%
  {\item[\theorem@headerfont\hskip \labelsep ##1]\theorem@headerfont (##3).\theorem@separator\newline\normalfont\itshape}
\makeatother

\theoremstyle{Myplain}

\usepackage{thmtools}
\declaretheorem[numberwithin=section]{theorem}

\begin{document}

\section{Title}
\begin{theorem}[A a a very very very very long long name theorem theorem name name]
A named theorem $\mathcal{S}$.
\end{theorem}

\begin{theorem}
Unnamed theorem $\mathcal{S}$.
\end{theorem}

\end{document}
4

It seems that ntheorem issues a \mathversion{bold} command for the head, that you don't protect with a group. This is evident if you say $\mathcal{S}=a+b$ in the theorem's body.

Just add braces to the style definition when you use \theorem@headerfont.

\documentclass{article}
\usepackage{fontspec}
\usepackage{amsmath}
\usepackage[math-style=ISO]{unicode-math}
\setmathfont{XITS Math}
\setmathfont[range={\mathcal,\mathbfcal},StylisticSet=1]{XITS Math} 

\usepackage[thmmarks,amsmath,amsthm,hyperref]{ntheorem}

\makeatletter
\newtheoremstyle{Myplain}%
  {\item[\hskip\labelsep {\theorem@headerfont ##1\ ##2.}\theorem@separator]}%
  {\item[\hskip\labelsep {\theorem@headerfont ##1\ ##2}]%
         {\theorem@headerfont (##3).}\theorem@separator
          \normalfont\itshape}
\newtheoremstyle{nonumberMyplain}%
  {\item[{\theorem@headerfont\hskip\labelsep ##1}\theorem@separator]}%
  {\item[{\theorem@headerfont\hskip \labelsep ##1}]{\theorem@headerfont (##3).}%
         \theorem@separator\newline\normalfont\itshape}
\makeatother

\usepackage{thmtools}

\declaretheorem[
  style=Myplain,
  numberwithin=section,
]{theorem}

\begin{document}

\section{Title}
\begin{theorem}[A a a very very very very long long name theorem theorem name name]
A named theorem $\mathcal{S}=a+b$.
\end{theorem}

\begin{theorem}
Unnamed theorem $\mathcal{S}$.
\end{theorem}

\end{document}

enter image description here

  • Small hint: amsmath should be loaded before fontspec – Marco Daniel Mar 30 '13 at 17:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.