0

I'm trying to get a theorem-derived environment to indent the entire block of text. What I have is

\theoremstyle{aside}  
\newtheorem{asides}{Aside}[chapter] 
\NewDocumentEnvironment{aside}{m o}
{\begin{adjustwidth}{1in}{0em}
\IfNoValueTF{#2}
    {\asides \label{#1} \addtheocontentsline[]{#1}{Aside}}
    {\asides[#2] \label{#1} \addtheocontentsline[#2]{#1}{Aside}}
    \ignorespaces
\end{adjustwidth}
}
{\endasides}

where you type \begin{aside}{label}[Title] and it puts it into the TOC based on a discussion here: AMS theorems in table of contents

The whole {aside} block should indent. However, what's happening is that only the header indents and nothing else. (When I try to adjust the indent in the {aside} environment style, the same thing happens}.

Necarion
  • 121
  • You have put \end{adjustwidth} in the begin code for the aside environment, ie. before the body starts. This means that in the body the normal indentation is restored, just as you observe. I think the \end{adjustwidth} must be put in the end code, i.e. just before \endasides. I haven't tested it, though. – Pieter van Oostrum Nov 25 '16 at 23:28
  • If I swap the } with the \endadjustwidth (} \end{adjustwidth} {\endasides}), I end up with the error Extra \endgroup. \end{adjustwidth – Necarion Nov 26 '16 at 21:32
  • That's not what I meant. ...\ignorespaces} {\end{adjustwidth}\endasides} instead. – Pieter van Oostrum Nov 26 '16 at 22:34

2 Answers2

2

You're placing wrongly \end{adjustwidth}.

\documentclass{report}
\usepackage{xparse}
\usepackage{chngpage}
\usepackage{amsthm}

\usepackage{lipsum}

% guess
\NewDocumentCommand{\addtheocontentsline}{omm}{%
  \addcontentsline{toc}{subsection}{%
    #3 \protect\ref{#2}%
    \IfValueT{#1}{ (#1)}%
  }%
}


%\theoremstyle{aside} % no idea what this should be
\newtheorem{asides}{Aside}[chapter] 
\NewDocumentEnvironment{aside}{mo}
  {%
   \adjustwidth{1in}{0pt}
   \IfNoValueTF{#2}
     {\asides\addtheocontentsline{#1}{Aside}}
     {\asides[#2]\addtheocontentsline[#2]{#1}{Aside}}%
   \label{#1}%
  }
  {%
   \endasides
   \endadjustwidth
   \addvspace{\topsep}
  }

\begin{document}

\tableofcontents

\chapter{First}

\lipsum[2]

\begin{aside}{foo}[Whatever]
\lipsum[3]
\end{aside}

\lipsum[4]

\end{document}

I had to guess a definition for \addtheocontentsline.

enter image description here

egreg
  • 1,121,712
0

Here is how one could do it very easily with the ntheorem package:

\theoremstyle{plain}
\theoremheaderfont{\bfseries}
\theorembodyfont{\itshape}
\theoremindent=1in

\newtheorem{asides}{Aside}[chapter] 

The package defines a customisable \listtheorems command, analog of \listoffigures, except the heading has to be defined.

Bernard
  • 271,350