2

I am writing a document using the book class, which, by design, does not indent the first line of the chapter/section/subsection. I noticed that if I start a chapter with a framed theorem then, for some reason, the initial \noindent is postponed to the first line after the theorem. The same does not happen if I use a non-framed theorem instead. Here's a mwe:

\documentclass[oneside]{book} \usepackage{framed} \usepackage[framed]{ntheorem} \newframedtheorem{theorem}{theorem} \newtheorem{plainthm}{theorem} \begin{document} \section{section} \begin{theorem} This is a theorem \end{theorem} some text \begin{theorem} this is another theorem \end{theorem} some other text \section{other section} \begin{plainthm} This is a plainthm \end{plainthm} some text \begin{plainthm} this is another plainthm \end{plainthm} some other text \end{document} 

This is the output: output

While this does not seem a very important issue (I doubt I will ever begin a section with a theorem), I would like to understand why this is happening (I guess it has something to do with the fact that framed theorems are drawn within boxes) and what is the "proper" way to fix this. I can think of several workarounds (like adding a dummy line and a negative \vskip before the framed theorem), but I am interested in a more flexible solution (e.g. something that doesn't break I change the documentclass).

2 Answers 2

2

With all possible reservations about framed theorems, particularly the ugly format provided by ntheorem, you need to ensure \if@afterindent is set to true.

I suggest to have a look at tcolorbox, for this kind of job.

The theorem environment just after the section title will set the conditional to true, but as it's done inside an environment, the setting doesn't go past \end{theorem}.

\documentclass[oneside]{book} \usepackage{framed} \usepackage[framed]{ntheorem} %\usepackage{etoolbox} % with an older LaTeX version \newframedtheorem{theorem}{theorem} \newtheorem{plainthm}{theorem} \makeatletter \AfterEndEnvironment{theorem}{\@afterindenttrue} \makeatother \begin{document} \section{section} \begin{theorem} This is a theorem \end{theorem} some text \begin{theorem} this is another theorem \end{theorem} some other text \section{other section} \begin{plainthm} This is a plainthm \end{plainthm} some text \begin{plainthm} this is another plainthm \end{plainthm} some other text \end{document} 

enter image description here

2

Simply add a \leavevmode after the end of the environment:

\documentclass[oneside]{book} \usepackage{framed} \usepackage[framed]{ntheorem} \newframedtheorem{theorem}{theorem} \newtheorem{plainthm}{theorem} \begin{document} \section{section} \begin{theorem} This is a theorem \end{theorem}\leavevmode some text \begin{theorem} this is another theorem \end{theorem} some other text \section{other section} \begin{plainthm} This is a plainthm \end{plainthm} some text \begin{plainthm} this is another plainthm \end{plainthm} some other text \end{document} 

enter image description here

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.