[Tex/LaTex] Titlesec, runin shape and amsthm

amsthmnumberingtitlesec

I'm trying to have an old fashioned style of (sub)section numbering as in EGA (Eléments de Géométrie Algébrique, by A.Grothendieck and J.Dieudonné). For a LaTeX written example, see here.

I did it with the use of the titlesec package, and the following problem arrises : if a section has the shape runin and an amsthm environment follows immediately, the environment creates a line break as usual, which I do not want.

Here is a minimal working example :

\documentclass{article}

\usepackage{titlesec}
\usepackage{amsthm}

\titleformat{\subsection}[runin]{\normalsize\bfseries}{(\thesubsection)}{5pt}{}

\newtheorem*{thm}{Theorem}

\begin{document}

\section{A section}
\subsection{}
\begin{thm}
  Foo bar.
\end{thm}

\end{document}

In this MWE, the line break after (1.1) to begin the thm environment : I would like Theorem to be right after (1.1) on the same line.

How can I do that ?

Best Answer

The style is really old fashioned. ;-)

Define thm to share the subsection counter and modify how the theorem headers are printed.

\documentclass{article}

\usepackage{titlesec}
\usepackage{amsthm}

\makeatletter
\def\thmhead#1#2#3{%
  (\thmnumber{\@upn{#2})\@ifnotempty{#1}{ }}%
  \thmname{#1}%
  \thmnote{ {\the\thm@notefont(#3)}}}
\makeatother

\titleformat{\subsection}[runin]{\normalsize\bfseries}{(\thesubsection)}{5pt}{}

\newtheorem{thm}[subsection]{Theorem}

\begin{document}

\section{A section}

Some introductory text.

\subsection{}
A subsection

\begin{thm}
  Foo bar.
\end{thm}

\begin{thm}[Someone]
  Foo bar.
\end{thm}

\end{document}

enter image description here

Related Question