Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question
add comment

1 Answer

up vote 4 down vote accepted

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

share|improve this answer
    
Small hint: amsmath should be loaded before fontspec –  Marco Daniel Mar 30 '13 at 17:49
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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