Is it possible to make square brackets in the body of a theorem appear upright — when using the declaration bodyfont=\mdseries\itshape
in the definition of a theoremstyle with thmtools
?
The method of using the package embrac
(Copy theoremfont option from newtxtext) does not work, because as the embrac
documentation says, it affects only \emph
, \textit
, and textsl
but not \itshape
or \slshape
.
In particular: is there a way to avoid using \itshape
(or \slshape
) yet still obtain italic (or slant, respectively) in the body of a theorem when the theoremstyle is defined using thmtools
? (except for the desired upright brackets, of course).
Example:
\documentclass{article}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{embrac}
\usepackage{thmtools}
\makeatletter
\declaretheoremstyle[
headfont= \sffamily\bfseries,
headpunct={\sffamily\bfseries.},
postheadspace=0.5em,
notefont=\sffamily\bfseries,
headformat=\NAME\NUMBER\let\thmt@space\@empty\NOTE,
bodyfont=\mdseries\itshape,
spaceabove=12pt,spacebelow=12pt,
]{thmstyle}
\makeatother
\theoremstyle{thmstyle}% default
\declaretheorem[name=Theorem,numberwithin=section]{theorem}
\begin{document}
\section{A section}
\begin{theorem}
Let $A$ and $B$ be subsets [see section 2] of a set $X$.Then
\[
X \setminus (A \cup B) = (X \setminus A) \cap (X \setminus B).
\]
\end{theorem}
\end{document}
I am aware of the answer to How to get upright parentheses in the whole document?, which, as it says, will break things.
\textup[
or\textup]
. Braces around the square brackets aren't necessary, since\textup
operates on only the next token, and a single character here is the token. (A long time ago, there was a discussion about creating a "theorem font", italic with upright punctuation. But it never happened, as the complications weren't easy to work around.)\textup
, but I was hoping for something more high-level -- a way to do what thetheoremfont
option ofnewtxtext
does automatically.\itshape
orslshape
as value for optionbodyfont
in\declaretheoremstyle
fromthmtools
(i.e., somehow use\textit
or\textsl
there), so thatembrac
would work.scholax
package includes a style optiontheoremfont
that does make text parentheses, brackets, and braces upright. The method seems to be simply:\DeclareRobustCommand\thfamily {\not@math@alphabet\thfamily\relax \fontfamily\thdefault\selectfont} \AtEndPreamble{\patchcmd{\th@plain}{\itshape}{\thfamily}{}{}} % \newcommand*{\thdefault}{\rmdefault}
scholax
does not seem to work if I usethmtools
and declare the theorem style body font to be\slshape
.