3

I'm trying to make an indented theorem environment as in A theoremstyle with complete indentation using amsthm.

Here's a minimal (non-)working example:

\documentclass{article}
\usepackage{amsthm}
\usepackage[english]{babel}
\usepackage{blindtext}

\makeatletter
  \newtheoremstyle{indent}
  {3pt}% space before
  {3pt}% space after
  {
    \setlength{\leftskip}{2.5em}
    \setlength{\rightskip}{2.5em}
    \addtolength{\@totalleftmargin}{2.5em}
  }% body font
  {}% indent
  {\bfseries}% header font
  {.}% punctuation
  {.5em}% after theorem header
  {}% header specification (empty for default)
\makeatother
\theoremstyle{indent}\newtheorem{theorem}{Theorem}

\begin{document}

\blindtext

\begin{theorem}[correct spacing]
\blindtext
\begin{itemize}
\item This is ok.
\item \blindtext
\end{itemize}
\end{theorem}

\end{document}

Whether or not I add that extra rightskip, my problem is that as soon as an item in a list within my theorem gets longer than one line (as in the third blindtext) it extends over the original right margin of the page, a case not considered in the original post.

Any suggestions?

4

I would go for a slightly different approach, along the lines of the second and third answers in A theoremstyle with complete indentation using amsthm.

Using the etoolbox and the changepage package as follows

\AtBeginEnvironment{theorem}{\begin{adjustwidth}{2.5em}{2.5em}}
\AtEndEnvironment{theorem}{\end{adjustwidth}}

we get

screenshot

which I think is the desired result.

% arara: pdflatex
\documentclass{article}
\usepackage{amsthm}
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage{etoolbox}
\usepackage{changepage}

  \newtheoremstyle{indent}
  {3pt}% space before
  {3pt}% space after
  { }% body font
  {}% indent
  {\bfseries}% header font
  {.}% punctuation
  {.5em}% after theorem header
  {}% header specification (empty for default)
\theoremstyle{indent}\newtheorem{theorem}{Theorem}

\AtBeginEnvironment{theorem}{\begin{adjustwidth}{2.5em}{2.5em}}
\AtEndEnvironment{theorem}{\end{adjustwidth}}


\begin{document}

\blindtext

\begin{theorem}[correct spacing]
\blindtext
\begin{itemize}
\item This is ok.
\item \blindtext
\end{itemize}
\end{theorem}

\end{document}
|improve this answer|||||
  • Thanks, that works - ubuntu users like me also have to install the latest etoolbox, since the one included in texlive-full doesn't support \AtBeginEnvironment yet it seems (1.8 -> 2.1). – Bristol May 27 '13 at 15:22
  • @Bristol great! make sure you're not using an old version from the repositories- have a look here: How to install "vanilla" TeXLive on Debian or Ubuntu? – cmhughes May 27 '13 at 15:23
  • This solution seems to annihilate the effect of the second argument, that the "space after" the environment. It should probably be reincorporated in the \AtEndEnvironment{theorem}{} instruction? And it also affects the "space before" I believe... – pluton Aug 16 '19 at 21:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.