How make a Custom theorem with upright body tex

newtheoremtheorems

I need a theorem environment with a custom numbering, so I did

\newtheorem{innercustomgeneric}{\customgenericname}
\providecommand{\customgenericname}{}

\newcommand{\newcustomtheorem}[2]{
  \newenvironment{#1}[1]
  {
    \renewcommand\customgenericname{#2}
    \renewcommand\theinnercustomgeneric{##1}
    \innercustomgeneric
  }
  {\endinnercustomgeneric}
}

\newtheoremstyle{customthm}
{}
{}
{\textbf}
{}
{\bfseries}
{.}
{.5em}
{}
\theoremstyle{customthm}
\newcustomtheorem{customthm}{Theorem}

this, but still it gives me italic shpae body text.

What should I change to make it upright text?

Best Answer

There are (at least) two problems with the code.

  • The third argument of \newtheoremstyle needs to be a font declaration, not a font macro taking an argument. Replace \textbf by \bfseries.

This will make the text of all theorem-like environments bold-face and upright, if the theorem-like environment has been defined after setting the style with \theoremstyle{customthm}.

  • \newtheorem{innercustomgeneric}{\customgenericname} defines the theorem-like environment innercustomgeneric at a point where the default theorem style takes effect -- which is italic. Move the two lines

    \newtheoremstyle{customthm}...
    \theoremstyle{customthm}
    

up to a place before \newtheorem{innercustomgeneric}.

It is not completely clear what your overall goal is, but my feeling is that there might be better ways to achieve it. So, if you run into further problems, it might be worth to explain the whole plan, such that we might come up with a alternate solution.

enter image description here

\documentclass{article}
\usepackage{amsthm}
\newtheoremstyle{customthm}
{}
{}
{\bfseries}
{}
{\bfseries}
{.}
{.5em}
{}
\theoremstyle{customthm}
\providecommand{\customgenericname}{}
\newtheorem{innercustomgeneric}{\customgenericname}
\newcommand{\newcustomtheorem}[2]{
  \newenvironment{#1}[1]
  {
    \renewcommand\customgenericname{#2}
    \renewcommand\theinnercustomgeneric{##1}
    \innercustomgeneric
  }
  {\endinnercustomgeneric}
}
\newcustomtheorem{customthm}{Theorem}
\begin{document}
\begin{customthm}{5}
  My custom theorem
\end{customthm}
\end{document}