0

Suppose I have a simple code like the following one:

\begin{theorem}
  This is (theorem 1).
\end{theorem}

When you compile this code, you find that the two brackets are italized. Is there a way to make them normal ?!.

Thanks in advance.

4
  • 1
    Can you make a minimal working example which shows us which of the theorem packages you use and which style you selected? Jan 21, 2023 at 16:54
  • Unfortunately, there's no "theorem font" which should really have upright punctuation. So the easiest way to make the brackets (or braces or parentheses) upright is to put them within \textup or math. Jan 21, 2023 at 17:58
  • The newpx and newtx packages have a theoremfont option that does what you're looking for
    – mbert
    Nov 9, 2023 at 1:21
  • Can you type a code please? @mbert Nov 10, 2023 at 4:26

1 Answer 1

2

The newtx and newpx font packages have a theoremfont option that produces italic text and upright delimiters in the plain style of amsthm. In other settings, the "theorem" font family can be accessed with \thfamily. Here is a sample taken from newtxdoc.tex:

\documentclass{article}

\usepackage{amsthm}
\usepackage[theoremfont]{newtxtext} % or newpxtext
\usepackage{newtxmath} % or newpxmath

\newtheorem{theorem}{Theorem}

\begin{document}

\begin{theorem}
This is Theorem Italic: text numbers are upright---12345;
punctuation is in many cases upright (also, parens (), braces
\{\} and brackets []). What about question marks and
exclamations? Also upright! [These fit better with math
mode punctuation and figures, like: for all $x\in[0,1]$,
let $f(x)\coloneq \exp(\alpha x)$].
\end{theorem}

{\itshape normal italics: ()[]?!123}

{\thfamily theorem italics: ()[]?!123}
\end{document}

With newtx

newtx

With newpx

newpx

I do not recommend this

If you want to achieve this effect with other fonts such as Computer Modern, you can resort to hacks like the one below. It uses the embrac package and borrows some of its internal code to define the \hussein_embrac_text:n command which makes the delimiters in its argument upright.* The command \embracifytheorem{<theorem>} redefines <theorem> so that it grabs its body and passes it to \hussein_embrac_text:n. This means it cannot contain any verbatim material.

*: We can't pass the body to the usual \textit, \emph, etc. because they are not "long" macros by default, i.e. they cannot contain \par.

\documentclass{article}

\usepackage{embrac}
\usepackage{amsthm}
\usepackage{xcolor}

\ExplSyntaxOn
\cs_new_protected:Npn \hussein_embrac_text:n #1
  {
    \tl_set:Nn \l__embrac_tmpa_tl {#1}
    \embrac_replace_brackets:N \l__embrac_tmpa_tl
    \l__embrac_tmpa_tl
  }

\NewDocumentCommand { \embracifytheorem } { m }
  {
    \NewEnvironmentCopy { origenv_#1 } { #1 }
    \RenewDocumentEnvironment { #1 } { O{} +b }
      {
        \begin{origenv_#1}[##1]
        \hussein_embrac_text:n { ##2 }
        \end{origenv_#1}
      }
      {}
  }
\ExplSyntaxOff

% you can adjust or remove these to your liking
\AddOpEmph{?}[0pt,1pt]
\AddOpEmph{!}[0pt,1pt]
\AddOpEmph{:}[0pt,1pt]

\newtheorem{theorem}{Theorem}
\embracifytheorem{theorem}

\begin{document}

\begin{theorem}
This is \textcolor{red}{hacked} Theorem Italic: text numbers
are \textcolor{red}{not} upright---12345;
punctuation is in many cases upright (also, parens (), braces
\{\} and brackets []). What about question marks and
exclamations? Also upright! [These fit better with math
mode punctuation and figures, like: for all $x\in[0,1]$,
let $f(x)= \exp(\alpha x)$].
\end{theorem}

\end{document}

cm

3
  • Good. But these packages change the font entirely. This is not the usual font in tex. Nov 12, 2023 at 4:16
  • @HusseinEid Yes these packages can do this because they define entirely new fonts. To do this with macros is difficult. See here, for example
    – mbert
    Nov 12, 2023 at 5:14
  • @HusseinEid See edit for a hack
    – mbert
    Nov 12, 2023 at 5:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .