# Theorem-like environment with optional title

I'm using the amsthm packages for theorems. I would like to define an environment paragraph which should resemble the look of a theorem environment (definition theoremstyle), but it shouldn't say 1.1 Paragraph.. Instead of Paragraph it should say nothing, or the content of an optional argument. Let me illustrate what I mean:

\begin{definition}
Lorem.
\end{definition}

\begin{paragraph}
Ipsum.
\end{paragraph}

\begin{paragraph}[Optional Title]
Dolor.
\end{paragraph}


This should produce output as follows:

1.1 Definition. Lorem.

1.2. Ipsum

1.3 Optional Title. Dolor.

Getting this done roughly isn't too difficult, but I would like to get it as close to the original theorem environments as possible. So the spacing after 1.2. should be exactly the same as the spacing after 1.1 Definition., and similarly for the space above and below the environments and whatever else subtle things are handled by amsthm, which I might not even recognize. How can this be done?

• Welcome to TeX.SE. The command \paragraph is defined by most document classes. It's thus not a good idea to define a theorem-like environment called paragraph. Please do tell us how to you try to define the paragraph environment at present, as well as which document class you employ.
– Mico
Sep 2, 2021 at 17:22

You want to define your own theorem styles.

\documentclass{article}
\usepackage{amsthm}

\makeatletter
\newtheoremstyle{swapdef}
{\topsep}   % ABOVESPACE
{\topsep}   % BELOWSPACE
{\upshape}  % BODYFONT
{0pt}       % INDENT (empty value is the same as 0pt)
{5pt plus 1pt minus 1pt} % HEADSPACE
\newtheoremstyle{para}
{\topsep}   % ABOVESPACE
{\topsep}   % BELOWSPACE
{\upshape}  % BODYFONT
{0pt}       % INDENT (empty value is the same as 0pt)
{5pt plus 1pt minus 1pt} % HEADSPACE
\makeatother

\theoremstyle{swapdef}
\newtheorem{definition}{Definition}[section]
\theoremstyle{para}
\newtheorem{para}[definition]{}

\begin{document}

\section{Test}

\begin{definition}
Lorem.
\end{definition}

\begin{para}
Ipsum.
\end{para}

\begin{para}[Optional Title]
Dolor.
\end{para}

\begin{definition}[Name]
Lorem.
\end{definition}

\end{document}