4

Consider the following MWE:

\documentclass[11pt]{report}

\usepackage{framed}
\usepackage{pstricks}
\usepackage{color}
\usepackage[framed,thmmarks,thref, hyperref]{ntheorem}

\usepackage{etoolbox}

\definecolor{proofback}{rgb}{0.95,0.95,0.95}

\theoremheaderfont{\sc}
\theorembodyfont{\upshape}
\theoremstyle{nonumberplain} 
\theoremsymbol{\raisebox{-5mm}{ \rule{1ex}{1ex} }}
\shadecolor{proofback}
\newshadedtheorem{proof}{Proof}

\begin{document}

\begin{proof}
    test test
\end{proof}
some normal text
\end{document}

This gives the following output: enter image description here

As per title I would like to remove the indentation after the end of the proof. As a solution I thought I could use something like

\let\oldendproof\endproof
\def\endproof{\oldendproof \leavevmode\vspace{-\baselineskip} \\  \noindent}

Adding these two lines, indeed, leads to

enter image description here

However, the problem is that, in case there is a proof followed directly by a theorem this solution creates an unnecessary amount of space:

\begin{proof}
    test test
\end{proof}
\begin{proof}
    another test
\end{proof}

enter image description here

while, without my hack, the rendered pdf looks like

enter image description here

I suspect this is due to the fact that I'm leaving vertical mode, but I know very little about how latex works internally. Any idea of how I can remove the indentation after a proof without this side effect? I know I can simply add a \noindent just after the end of the proof, but I was looking for some "automatic" and general solution that doesn't force me to do so. I'm compiling using xelatex.

Manlio
  • 480
  • 3
  • 13
  • Not a duplicate but rather similar. – campa Oct 18 '16 at 08:46
  • Yes I already tried that solution too, but unfortunately doesn't solve the problem of the extra space in case of multiple theorems (in my example I have two proofs but it think it would be the same for every newly-defined theorem environment) – Manlio Oct 18 '16 at 08:49
  • the tombstone on all these examples is on a line by itself. that is usually something to be avoided, but not being a user of ntheorem, i can't suggest how to avoid it. – barbara beeton Oct 18 '16 at 13:14

2 Answers2

3

You can re-use the suppression after heading code:

enter image description here

\documentclass[11pt]{report}

\usepackage{framed}
\usepackage{pstricks}
\usepackage{color}
\usepackage[framed,thmmarks,thref, hyperref]{ntheorem}

\usepackage{etoolbox}

\definecolor{proofback}{rgb}{0.95,0.95,0.95}

\theoremheaderfont{\sc}
\theorembodyfont{\upshape}
\theoremstyle{nonumberplain} 
\theoremsymbol{\raisebox{-5mm}{ \rule{1ex}{1ex} }}
\shadecolor{proofback}
\newshadedtheorem{proof}{Proof}

\makeatletter
\let\oldendproof\endproof
\def\endproof{\oldendproof\aftergroup\@afterindentfalse\aftergroup\@afterheading}
\makeatother
\begin{document}

\begin{proof}
    test test
\end{proof}
some normal text



\begin{proof}
    test test
\end{proof}


some normal text

\end{document}
David Carlisle
  • 757,742
2

Here is a solution with \theorempostwork. I don't think you need pstricksfor shaded theorems: using\fcolorbox` will do. Also, I modified the values of some parameters for a better vertical spacing (in my opinion).

\documentclass[11pt]{report}
\usepackage[showframe]{geometry}%
\usepackage{framed}
\usepackage{xcolor}%
\usepackage[framed,thmmarks,thref, hyperref]{ntheorem}

\definecolor{proofback}{rgb}{0.95,0.95,0.95}

\theoremheaderfont{\scshape}
\theorembodyfont{\upshape}
\theoremstyle{nonumberplain}
\theoremsymbol{\raisebox{-5mm}{ \rule{1ex}{1ex} }}
\colorlet{shadecolor}{proofback}
\def\theoremframecommand{\colorbox{shadecolor}}
\theoremframepostskip{2ex}
\theoreminframepostskip{0.6ex}
\theorempostwork{\noindent\hspace*{-\fontdimen2\font}}
\newshadedtheorem{proof}{Proof}

\usepackage{hyperref}%

 \begin{document}

\begin{proof}
  test test
\end{proof}
Some normal text

\end{document} 

enter image description here

Bernard
  • 271,350
  • This doesn't work if \end{proof} is followed by a blank line or a display such as another theorem or heading, you would get a spurious white paragraph from the \noindent and then indented text – David Carlisle Oct 18 '16 at 11:27