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}.

  • 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. – Piet 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. – Piet van Oostrum Nov 26 '16 at 22:34
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

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.

  • I actually want the aside entries to go in the main ToC rather than in a custom secondary list. – Necarion Nov 26 '16 at 21:34

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.