2

I have defined a new theorem style using amsthm package and I have noticed that the \parindentI have included in the definition of the style in the line of code with comment indentation amount adds indentation to the head of the theorem instead of the body text of the theorem which is more desirable. I have noticed also that if I use the predefined default style of amsthm it adds indentation to the body of theorem and not to the head as I want. To make my wish clear: I want the head of the theorem with no indentation and the body text of the theorem with indentation. What I am doing wrong and how to control the indentation of the body text of the theorem in the definition of a new theorem style? Looking at the documentation of amsthm package I didn't find anything to help me.

The code:

\documentclass[12pt]{article}
\usepackage[a4paper, total={180mm,257mm},left=15mm,top=20mm]{geometry}
\usepackage[T1]{fontenc}
\usepackage{amsthm}
\newtheorem{thm}{Theorem}[section]
\newtheoremstyle{mythm}%⟨name⟩
{3pt}%⟨Space above⟩
{3pt}%⟨Space below⟩
{}%⟨Body font⟩
{\parindent}%⟨Indent amount)
{\bfseries\slshape}% ⟨Theorem head font⟩
{:}%⟨Punctuation after theorem head⟩
{\newline}%⟨Space after theorem head⟩
{}%⟨Theorem head spec (can be left empty, meaning ‘normal’)⟩
\theoremstyle{mythm}
\newtheorem{pytha}{Theorem of Pythagoras}[section]
\begin{document}
\section{First Section}

\begin{pytha}
Let $ABC$ right triangle with $\angle A=90^{\circ}$. Then for the sides of the triangle $AB, AC$ and $BC$ is true that: \begin{equation} (BC)^{2}=(AB)^2+(AC)^{2} \end{equation} \end{pytha}

\begin{thm}(Theorem of Pythagoras)

Let $ABC$ right triangle with $\angle A=90^{\circ}$. Then for the sides of the triangle $AB, AC$ and $BC$ is true that:
\begin{equation}
    (BC)^{2}=(AB)^2+(AC)^{2}
\end{equation}

\end{thm} \end{document}

miltos
  • 2,605
  • Please note that the default theorem isn't adding any indentation to the theorem body; you are doing it by adding the empty line after \begin{thm}. – campa Aug 16 '22 at 07:51
  • @campa Do you know why the same is not happening in the new theorem style I have defined, as it includes the \newline command? – miltos Aug 16 '22 at 10:50
  • \newline starts a new line and not a new paragraph, so there is no indentation. But I fear I simply don't understand your requirements. Why hard-coding the name "Theorem of Pythagoras" in a new theorem environment? You'll probably be using it only once. And the indentation after the theorem head is very uncommon, it's like the indentation after a sectioning title. French typographic conventions? – campa Aug 16 '22 at 10:56
  • @ campa It has nothing to do with Theorem of Pythagoras, it was just to visualize the indentation, it would be a theorem with no name at all just a number or even unnumbered. I would like to know how to control that indentation in the newtheorem style definition, and if I want it to use it (no French typographic conventions :-) ) and if I don't want to use it to make it so. Just for completeness. – miltos Aug 16 '22 at 11:04
  • 2
    You might find this useful: https://tex.stackexchange.com/a/447684/82917 – campa Aug 16 '22 at 11:31

1 Answers1

-1

You can add the changepage package to your preamble and use the adjustwidth environment. Change the <indent param> field to suit your needs.

\begin{thm}(Theorem of Pythagoras)
\begin{adjustwidth}{<indent param>}{}
    Let $ABC$ right triangle with $\angle A=90^{\circ}$. Then for the sides of the triangle $AB, AC$ and $BC$ is true that:
    \begin{equation}
        (BC)^{2}=(AB)^2+(AC)^{2}
    \end{equation}
\end{adjustwidth}
\end{thm}

EDIT

You can create a custom environnement:

\newenvironment{indented}[1]{
    \begin{thm}[#1]\phantom\newline\vspace{-\baselineskip}\begin{adjustwidth}{<indent space>}{}}
    {\end{adjustwidth}\end{thm}}

And use it like that :

\begin{indented}{Pythagoras}
    Let $ABC$ right triangle with $\angle A=90^{\circ}$. Then for the sides of the triangle $AB, AC$ and $BC$ is true that:
    \begin{equation}
        (BC)^{2}=(AB)^2+(AC)^{2}
    \end{equation}
\end{indented}

Other solution for your comment below

\newenvironment{indented}[1]{
    \setlength\parindent{<change it to set indent amount>}
    \begin{thm}[#1]\phantom\newline\vspace{-\baselineskip}\begin{adjustwidth}{0cm}{}\hspace{\parindent}}
    {\end{adjustwidth}\end{thm}}
Elyo
  • 386
  • Thank you for your help! Yes it works, but I have two more questions:
    (a) What about if I want indentation only for the first line of body text? (this is for \parindent), and (b) Can I achieve these without calling other packages, only working with amsthm?
    – miltos Aug 16 '22 at 08:48
  • For (b), I really don't know. Maybe by using ntheorems to declare your theorem environments. For (a), since my solution is ugly (the part to delete the empty line), deleting the adjustwidth environnement messes everything up. Set the parameter <indent space> to 0cm and see the modification in the post above. This solution is very ugly. – Elyo Aug 16 '22 at 09:05