TransWikia.com

How can I manually indent environments like theorem, corollary, etc.?

TeX - LaTeX Asked by Carl Yocto on June 3, 2021

I am submitting a paper to a journal that requires labels like theorems, corollaries, proofs, and lemmas to be indented. Right now, these environments are flush to the left margin. How can I make this happen?

documentclass{article}
usepackage{amsmath}
usepackage{amsthm}
usepackage{cite}
usepackage{amsfonts}
usepackage{booktabs}
usepackage{graphicx}
usepackage{algorithm}
usepackage[noend]{algpseudocode}

% for the journal
usepackage[labelsep=period]{caption}
captionsetup[table]{name=TABLE}
renewcommand{thetable}{Roman{table}}
usepackage{indentfirst}
title{title}
author{
    people
}


newtheorem{theorem}{Theorem}
newtheorem{corollary}{Corollary}


begin{document}
maketitle    

begin{theorem}
theorem to be indented at the label
end{theorem}


begin{proof}
proof to be indented at the label
end{proof}

2 Answers

You can load amsthm and define your own style. My answer https://tex.stackexchange.com/a/17555/4427 lists the parameters for the plain style, so it's easy to modify them.

documentclass{article}
usepackage{amsthm}

usepackage{lipsum} % for mock text

newtheoremstyle{plainindent}
  {topsep}   % ABOVESPACE
  {topsep}   % BELOWSPACE
  {itshape}  % BODYFONT
  {parindent}% INDENT (empty value is the same as 0pt)
  {bfseries} % HEADFONT
  {.}         % HEADPUNCT
  {5pt plus 1pt minus 1pt} % HEADSPACE
  {}          % CUSTOM-HEAD-SPEC

theoremstyle{plainindent}
newtheorem{theorem}{Theorem}

begin{document}

lipsum[1][1-4]

begin{theorem}
lipsum[2][1-3]
end{theorem}

lipsum[3][1-4]

end{document}

enter image description here

If you also use theoremstyle{definition}, define a definitionindent style like plainindent, but with upshape for BODYFONT.

Here's how you can also indent proofs.

documentclass{article}
usepackage{amsthm}
usepackage{xpatch}

usepackage{lipsum} % for mock text

newtheoremstyle{plainindent}
  {topsep}   % ABOVESPACE
  {topsep}   % BELOWSPACE
  {itshape}  % BODYFONT
  {parindent}% INDENT (empty value is the same as 0pt)
  {bfseries} % HEADFONT
  {.}         % HEADPUNCT
  {5pt plus 1pt minus 1pt} % HEADSPACE
  {}          % CUSTOM-HEAD-SPEC
xpatchcmd{proof}{itshape}{hspace{parindent}itshape}{}{}

theoremstyle{plainindent}
newtheorem{theorem}{Theorem}

begin{document}

lipsum[1][1-4]

begin{theorem}
lipsum[2][1-3]
end{theorem}
begin{proof}
lipsum[2][4-6]
end{proof}

lipsum[3][1-4]

end{document}

enter image description here

Correct answer by egreg on June 3, 2021

Not sure this is exactly what you want, but the ntheorem package defines a theoremindent length:

documentclass{article}
usepackage{amsmath}%
usepackage{cite}
usepackage{amsfonts}
usepackage{booktabs}
usepackage{graphicx}
usepackage{algorithm}
usepackage[noend]{algpseudocode}

% for the journal
usepackage[labelsep=period]{caption}
captionsetup[table]{name=TABLE}
renewcommand{thetable}{Roman{table}}
usepackage{indentfirst}
title{title}
author{
    people
}
usepackage{showframe}
renewcommand{ShowFrameLinethickness}{0.2pt}
usepackage{ntheorem}
setlength{theoremindent}{1cm}
theoremseparator{.}
newtheorem{theorem}{Theorem}
newtheorem{corollary}{Corollary}

theoremstyle{nonumberplain}
theoremseparator{upshape:}
theoremheaderfont{itshape}
theorembodyfont{normalfont}

newtheorem{proof}{Proof}

begin{document}
maketitle

begin{theorem}
A theorem to be indented at the label. And all its contents is indented indeed.
end{theorem}

begin{proof}
proof to be indented at the label. Blah blah blah. Blahblah. Blahblah.
end{proof}

end{document} 

enter image description here

Edit:To indent only the theorems and proofs labels, I defined two new styles: indented and nonumberindented:

documentclass{article}
usepackage{amsmath}%
usepackage{cite}
usepackage{amsfonts}
usepackage{booktabs}
usepackage{graphicx}
usepackage{algorithm}
usepackage[noend]{algpseudocode}

% for the journal
usepackage[labelsep=period]{caption}
captionsetup[table]{name=TABLE}
renewcommand{thetable}{Roman{table}}
usepackage{indentfirst}
title{title}
author{
    people
}
usepackage{showframe}
renewcommand{ShowFrameLinethickness}{0.2pt}
usepackage{ntheorem}
usepackage{thmtools} 
makeatletter
newtheoremstyle{indented}%
{item[hskipparindent theorem@headerfont ##1 ##2theorem@separator]}%
 {item[hskipparindent theorem@headerfont ##1 ##2 (##3)theorem@separator]}
 newtheoremstyle{nonumberindented}%
{item[theorem@headerfonthskipparindent ##1theorem@separator]}%
{item[theorem@headerfonthskipparindent ##1 (##3)theorem@separator]}
makeatother
theoremstyle{indented}
theoremseparator{.}
newtheorem{theorem}{Theorem}
newtheorem{corollary}{Corollary}

theoremstyle{nonumberindented}

theoremseparator{,upshape:}
theoremheaderfont{itshape}
theorembodyfont{normalfont}

newtheorem{proof}{Proof}

begin{document}
maketitle

begin{theorem}
A theorem to be indented at the label. The theorem body is not indented .
end{theorem}

begin{proof}
proof to be indented only at the label. Blah blah blah. Blahblah. Blahblah.Blahblahblah. 
end{proof}

end{document} 

enter image description here

Answered by Bernard on June 3, 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