TransWikia.com

Custom theorem title in place

TeX - LaTeX Asked on April 24, 2021

I want to do something like this:

begin{theorem}[Actual name of theorem]
This theorem states that...
end{theorem}

and it should render:

Actual name of theorem. This theorem states that...

I changed the name of theorem by creating a theorem-like environment, but I want to do this one in line, without creating a new environment.

One Answer

It is unclear from the question whether no new environment is to be created, on the one hand, or whether multiple new environments, one for each separate named theorem, are to be created.

Assuming the latter, perhaps something like this?

documentclass{book}

usepackage{amsthm}
usepackage{thmtools}

declaretheorem[name=Theorem,numberwithin=chapter]{theorem}

makeatletter
declaretheoremstyle[
  headfont=bfseries,
  headindent=-0.25em,
  postheadspace=0.5em,
  notefont=bfseries, 
  notebraces={}{},
  headformat=NOTEthmt@spaceNUMBER,
  bodyfont=mdseriesitshape,
  spaceabove=12pt,spacebelow=12pt,
]{namedthmstyle}
makeatother

declaretheorem[
  style=namedthmstyle,
  name=Theorem,
  title = {},
  numberlike=theorem
]{namedtheorem}

begin{document}

chapter{The whole thing}

begin{namedtheorem}[Theorem of Pythagoras]

The square on the hypotenuse of a right triangle equals the sum of the squares other two sides.

end{namedtheorem}

begin{namedtheorem}[Fermat's Last Theorem]

For $n > 2$, there are no positive integers $a, b, c$ for which $a^{n} + b^{n} = c^{n}$.

end{namedtheorem}

end{document}

Named theorems

Note that I had to "fake" making the namedtheorem name typeset essentially flush with the left margin by using headindent=-0.25em. Surely there's a better—and more precise—way to accomplish that.

Answered by murray on April 24, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP