1

I am trying to achieve a goal extremely similar to that requested in Custom theorem numbering. There egreg explains how to create a custom theorem environment. However, one must specify whether it is to be a Theorem, Proposition or whatever. He uses the following code.

\usepackage{amsthm}

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

\newcustomtheorem{customthm}{Theorem} \newcustomtheorem{customlemma}{Lemma}

I would not like to make this final decision, but rather have an environment customgen which when called with title uses that title. Consider the following, using egreg's command.

\begin{customthm}{CUSTOM_LABEL}
    This is Theorem CUSTOM_LABEL
\end{customthm}

This creates an environment which starts Theorem CUSTOM_LABEL. I would like

\begin{customgen}{CUSTOM_TITLE}
   This may or may not be a theorem
\end{customgen}

to start CUSTOM_TITLE.

I can nearly achieve this by replacing the [2] with [1] and commenting out the command \renewcommand\customgenericname{#2}. However, there is extra whitespace on the left. I don't know how to get rid of that.

Sam OT
  • 1,329

1 Answers1

2

It's much simpler than that.

\documentclass{article}
\usepackage{amsthm}

\newtheorem{customthminner}{\customthmname}[section] \newcommand{\customthmname}{} \newenvironment{customthm}[1] {\renewcommand{\customthmname}{#1}\customthminner} {\endcustomthminner}

\begin{document}

\section{Famous theorems}

\begin{customthm}{Gauss's lemma} Blah blah \end{customthm}

\begin{customthm}{Fermat's last theorem} Blah blah \end{customthm}

\end{document}

enter image description here

If you don't want numbering, use \newtheorem* (and no optional argument).

egreg
  • 1,121,712
  • I see, thanks. I expected that something simpler would work, I just couldn't make it work myself! – Sam OT Jul 16 '21 at 20:32