0

It is interesting that \emph will switch the shape of font automatically based on the current font is italic or not, e.g.,

\emph{This is \emph{non-italic} italic}.

will produce something like:

This is non-italic italic

There are some cases I would like do the same for the body of a theorem. As far as I know, the theorem style is defined as

\newtheoremstyle{mythm} % name
{\topsep}               % Space above
{\topsep}               % Space below
{\itshape}              % Body font
{}                      % Indent amount
{\scshape}              % Theorem head font
{.}                     % Punctuation after theorem head
{.5em}                  % Space after theorem head
{}                      % Theorem head spec (can be left empty, meaning ‘normal’)

An direct replace of the \itshape (option for Body font) by \emph is not working, I believe this is because \itshape is a switch (used by {\itshape text}) while \emph is a command (used by \emph{text}). The definition of \emph is (from latex by texdef -t latex -c minimal -F emph):

\emph :
\long macro:#1->\ifmmode \nfss@text {\em #1}\else \hmode@bgroup \text@command {#1}
\em \check@icl #1\check@icr \expandafter \egroup \fi

while

\itshape :
\long macro:->\not@math@alphabet \itshape \mathit \fontshape \itdefault \selectfont

Any idea?

THE MME

\documentclass{amsart}
\newtheoremstyle{mythm} % name
{\topsep}               % Space above
{\topsep}               % Space below
{\itshape}              % Body font
{}                      % Indent amount
{\scshape}              % Theorem head font
{.}                     % Punctuation after theorem head
{.5em}                  % Space after theorem head
{}                      % Theorem head spec (can be left empty, meaning ‘normal’)
\theoremstyle{mythm}
\newtheorem{thm}{Theorem}
\begin{document}
This is a test

\emph{This is \emph{non-italic} italic}.

\begin{thm}
  This is italic
\end{thm}
\itshape
This is a test
\begin{thm}
  This should be non-italic
\end{thm}
\end{document}
user19832
  • 1,585
  • 2
    The non-macro version of \emph is called \em. What exactly is your use case for this? To me it would seem to be strange to have an upright theorem al of a sudden – daleif Apr 04 '18 at 12:21
  • @daleif you r right, but replace \itshape with \em not work for me, I mean if the theorem is surrounded by italic fonts, then we should use the upright font shape instead. – user19832 Apr 04 '18 at 12:31
  • I still don't see the use case, all theorems should look the same. I had a look in the amsthm sources (loaded by amsart). It issues \normalfont in an internal component and thus counters the \itshape. Without it, it does work, but as a reader I'd find it strange that the body font is not the same for all theorems – daleif Apr 04 '18 at 12:35
  • why don't you just use \theoremstyle{definition}? it's identical in characteristics to \theoremstyle{plain} except for the fact that the body is upright roman. see Non italic text in theorems, definitions, examples for some commentary. – barbara beeton Apr 04 '18 at 15:15

1 Answers1

3

Internally amsthm (auto loaded by amsthm) issues a \normalfont at the start of every theorem construction, thus counter the external \itshape.

You can patch \@thm to remove it...:

\usepackage{etoolbox}
\makeatletter
\patchcmd\@thm{\normalfont}{}{}{\NOPE}
\makeatother

This will fail (aka run the non-existing \NOPE) if the patching fails

daleif
  • 54,450