Firstly, below skip should be positive, negative values are ignored. You can clear the spacing provided as standard by writing
\makeatletter
\def\thm@space@setup{\thm@preskip=0pt
\thm@postskip=0pt}
\makeatother
before your \newtheoremstyle
. You can adjust this by changing the values 0pt
or using the parameters in the \newtheoremstyle
.
Try
\newenvironment{pf}{\noindent\textit{Proof.}\begin{mdseries}}{\end{mdseries}}
for your proof environment. If this is too simplistic, e.g. if you wish to have the \qed
features of the AMS environment, then you can use the following adaption of the AMS proof code
\makeatletter
\newenvironment{pf}[1][\proofname]{\par
\pushQED{\qed}%
\normalfont \topsep0\p@\relax
\trivlist
\item[\hskip\labelsep\itshape
#1\@addpunct{.}]\ignorespaces
}{%
\popQED\endtrivlist\@endpefalse
}
\makeatother
The important point is setting the value of \topsep
to zero.
Lastly, the proposition number is wrong because you have asked it to be numbered within thm
s! You should write
\newtheorem{prop}[thm]{Proposition}
with [thm]
placed between the other arugments not at the end.
Here is this all put in to one sample document.
\documentclass{article}
\usepackage{amsthm}
\makeatletter
\def\thm@space@setup{\thm@preskip=0pt
\thm@postskip=0pt}
\makeatother
\newtheoremstyle{newstyle}
{} %Aboveskip
{} %Below skip
{\mdseries} %Body font e.g.\mdseries,\bfseries,\scshape,\itshape
{} %Indent
{\bfseries} %Head font e.g.\bfseries,\scshape,\itshape
{.} %Punctuation afer theorem header
{ } %Space after theorem header
{} %Heading
\theoremstyle{newstyle}
\newtheorem{thm}{Theorem}[section]
\newtheorem{prop}[thm]{Proposition}
\newtheorem{lem}{Lemma}
\newtheorem{cor}{Corollary}
\makeatletter
\newenvironment{pf}[1][\proofname]{\par
\pushQED{\qed}%
\normalfont \topsep0\p@\relax
\trivlist
\item[\hskip\labelsep\itshape
#1\@addpunct{.}]\ignorespaces
}{%
\popQED\endtrivlist\@endpefalse
}
\makeatother
\begin{document}
Some text to indicate the spacing.
\begin{thm}
First theorem, with sufficiently long text so that it spills on to a
second line.
\end{thm}
Some text to indicate the spacing. Fill-up text make this spill on to
an extra line. Fill-up text make this spill on to an extra line.
More text.
\begin{prop}
A proposition, with sufficiently long text so that it spills on to a
second line.
\end{prop}
\begin{pf}
Proof of the proposition with \verb+pf+ environment and sufficiently
long text so that it spills on to a second line.
\end{pf}
\begin{prop}
Another proposition, with sufficiently long text so that it spills
on to a second line.
\end{prop}
\begin{proof}
The original proof environment and sufficiently long text so that it
spills on to a second line.
\end{proof}
\end{document}
The thmtools
package provides for a "List of theorems". However it doesn't provide by default to print "Chapter n" and there's the additional problem that only chapters where a definition is set should appear.
So here it is: I have to patch the command that thmtools
uses for annotating a chapter break in the .loe
file. Instead of \addvspace{10pt}
I make it add more.
In this way, each chapter in the .loe
file is surrounded by
\thmlopatch@chapter
...
\thmlopatch@endchapter
and so it's possible to typeset the part represented by ...
in a box in order to see if something results. Since we'll call
\listoftheorems[ignoreall,show={tdefn}]
only definitions will survive. If something is in the box, then the contents is retypeset preceded by "Chapter n".
Also the way the optional name is typeset is changed (\thmformatoptarg
).
\documentclass[a4paper]{book}
\usepackage{amsthm,thmtools}
\usepackage{xcolor}
\usepackage{framed}
\colorlet{shadecolor}{lightgray!25}
\newtheorem{thm}{Theorem}[chapter]
\newtheoremstyle{definitionsty}{3pt}{3pt}{\slshape}{}{\bfseries}{.}{.5em}{}
\theoremstyle{definitionsty}
\newtheorem{tdefn}{Definition}[chapter]
\newenvironment{defn}
{\begin{shaded}\begin{tdefn}}
{\end{tdefn}\end{shaded}}
\usepackage{etoolbox}
\makeatletter
\patchcmd\thmtlo@chaptervspacehack
{\addtocontents{loe}{\protect\addvspace{10\p@}}}
{\addtocontents{loe}{\protect\thmlopatch@endchapter\protect\thmlopatch@chapter{\thechapter}}}
{}{}
\AtEndDocument{\addtocontents{loe}{\protect\thmlopatch@endchapter}}
\long\def\thmlopatch@chapter#1#2\thmlopatch@endchapter{%
\setbox\z@=\vbox{#2}%
\ifdim\ht\z@>\z@
\hbox{\bfseries\chaptername\ #1}\nobreak
#2
\addvspace{10\p@}
\fi
}
\def\thmlopatch@endchapter{}
\makeatother
\renewcommand{\thmtformatoptarg}[1]{ -- #1}
\renewcommand{\listtheoremname}{List of definitions}
\begin{document}
\frontmatter
\listoftheorems[ignoreall,show={tdefn}]
\mainmatter
\chapter{X}
\begin{defn}[My hilarious definition]
bla bla
\end{defn}
\chapter{Y}
\begin{thm}
b
\end{thm}
\chapter{Z}
\begin{defn}[My hilarious definition 2]
bla bla
\end{defn}
\begin{thm}
a
\end{thm}
\end{document}
Note that in chapter 2 there's a theorem and no definition, so it won't be listed in the "list of definitions".
If you want to customize the appearance of the entries in the list, then add
\def\ll@tdefn{%
\protect\thmtopatch@numbernametext
\ifx\@empty\thmt@shortoptarg\else[\thmt@shortoptarg]\fi
{\csname the\thmt@envname\endcsname}%
{\thmt@thmname}%
}
\newcommand\thmtopatch@numbernametext[3][]{%
#3 #2%
\if\relax\detokenize{#1}\relax\else\space -- #1\fi
}
before \makeatother
in the code above. This will print
Definition 1.1 – My hilarious definition ........ 1
In the definition of \thmtopatch@numbernametext
, #1
stands for the (optional) name ("My hilarious definition"), #2
for the environment's name ("Definition") and #3
for the number.
For an output of the form
1.1 – My hilarious definition ............ 1
you might define
\newcommand\thmtopatch@numbernametext[3][]{%
#2 -- %
\if\relax\detokenize{#1}\relax #3\else #1\fi
}
so that a definition without the optional name argument will be printed generically as
3.1 – Definition .................. 42
Best Answer
Here's a MWE that demonstrates how the
answers
package can be used in this context. It preserves all of the numbering, as requested in your first bullet. Sadly I haven't managed to copy the original formulation of the theorem (your second bullet); perhaps someone else will be able to build from this though.