如何使 NewTx 定理中的某些文本不倾斜(强调)?

如何使 NewTx 定理中的某些文本不倾斜(强调)?

使用newtx表示字体,使用 表示定理thmtools,我希望类定理环境的主体倾斜。使用newtx,指定 表示\thfamily可以实现bodyfont这一点。

不过我还是想让定理主体内的某些文字保持直立,\emph像平常一样使用。

但这不起作用。如何修复?

\documentclass{article}
\usepackage{amsthm}

\usepackage[thmslshape]{newtx}

\usepackage{thmtools}
\swapnumbers

% see newtexdoc.pdf, page 12, end of Section 5:
\newcommand\thmbodyfont{\thfamily} 

\makeatletter
\declaretheoremstyle[
  headfont=\sffamily\bfseries,
  headpunct={\sffamily\bfseries.},
  postheadspace=0.5em plus 2pt minus 2pt,
  notefont=\sffamily\mdseries,
  headformat=\NAME\NUMBER\let\thmt@space\@empty\NOTE,
  bodyfont=\thmbodyfont,
  spaceabove=12pt,spacebelow=12pt,
]{thmstyle}
\makeatother

\declaretheorem[name=Theorem, style=thmstyle, numberwithin=section]{theorem}


\begin{document}

\begin{theorem}
If the domain of a continuous \emph{open} surjection is locally compact,
then so is its range.
\end{theorem}


Compare:

{\slshape If the domain of a continuous \emph{open} surjection is locally compact,
then so is its range.}

\emph{If the domain of a continuous \emph{open} surjection is locally compact,
then so is its range.}

\end{document}

使用 newtx 强调倾斜理论字体的问题

答案1

你基本上不能。倾斜的定理字体有

\DeclareFontFamily{OT1}{ntxth-tlf}{\ntx@spacing}
\DeclareFontShape{OT1}{ntxth-tlf}{m}{it}{<-> \ntx@scaled ntxth-\ntx@thrmshape-tlf-ot1}{}
\DeclareFontShape{OT1}{ntxth-tlf}{m}{n}{<->ssub * ntxth-tlf/m/it}{}
\DeclareFontShape{OT1}{ntxth-tlf}{m}{sc}{<->ssub * ntxth-tlf/m/it}{}

以及其他类似的替换。这意味着\emph将切换到直立字体\OT1/ntxth-tlf/m/n/10,结果与倾斜字体相同。

解决方法:进行手术\emph

\documentclass{article}
\usepackage{amsthm}

\usepackage[thmslshape,trueslanted]{newtxtext}
\usepackage{newtxmath}
\usepackage{thmtools}
\swapnumbers

\NewCommandCopy{\latexemph}{\emph}
\RenewDocumentCommand{\emph}{m}{%
  \ifthfamily
    \expandafter\textnormal
  \else
    \expandafter\latexemph
  \fi{#1}%
}
\newif\ifthfamily
\AddToHook{cmd/thfamily/before}{\thfamilytrue}

\makeatletter
\declaretheoremstyle[
  headfont=\sffamily\bfseries,
  headpunct={\sffamily\bfseries.},
  postheadspace=0.5em plus 2pt minus 2pt,
  notefont=\sffamily\mdseries,
  headformat=\NAME\NUMBER\let\thmt@space\@empty\NOTE,
  bodyfont=\thfamily,
  spaceabove=12pt,spacebelow=12pt,
]{thmstyle}
\makeatother

\declaretheorem[name=Theorem, style=thmstyle, numberwithin=section]{theorem}


\begin{document}

\begin{theorem}
If the domain of a continuous \emph{open} surjection is locally compact,
then so is its range (with upright parentheses).
\end{theorem}

Compare:

{\slshape If the domain of a continuous \emph{open} surjection is locally compact,
then so is its range.}

\emph{If the domain of a continuous \emph{open} surjection is locally compact,
then so is its range.}

\end{document}

我们将 重新定义\emph为标准命令,除非\thfamily生效,否则当它确实 时\textnormal。检查可以更详细,但我希望在这些情况下你不会在强调中强调。

在此处输入图片描述

答案2

这是你想要的吗?

在此处输入图片描述

\documentclass{article}
\usepackage{amsthm}

\usepackage[trueslanted]{newtx} % <-- added option

\usepackage{thmtools}
\swapnumbers

% see newtexdoc.pdf, page 12, end of Section 5:
% \newcommand\thmbodyfont{\thfamily} % <-- no needed anymore

\makeatletter
\declaretheoremstyle[
  headfont=\sffamily\bfseries,
  headpunct={\sffamily\bfseries.},
  postheadspace=0.5em plus 2pt minus 2pt,
  notefont=\sffamily\mdseries,
  headformat=\NAME\NUMBER\let\thmt@space\@empty\NOTE,
  bodyfont=\slshape, %                 <-- using default slshape command
  spaceabove=12pt,spacebelow=12pt,
]{thmstyle}
\makeatother

\declaretheorem[name=Theorem, style=thmstyle, numberwithin=section]{theorem}


\begin{document}

\begin{theorem}
If the domain of a continuous \emph{open} surjection is locally compact,
then so is its range.
\end{theorem}


Compare:

{\slshape If the domain of a continuous \emph{open} surjection is locally compact,
then so is its range.}

\emph{If the domain of a continuous \emph{open} surjection is locally compact,
then so is its range.}

\end{document}

相关内容