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}
(it seems this works everywhere apart from acrobat reader)
This is based on the example by @DavidCarlisle.
The cmtt
visible space character seems to be labelled differently in different cmtt
variants. For cm-super (which is loaded here when I use \usepackage[T1]{fontenc}
), the respective character is named uni2423
which seems to cause problems with evince
when copying that character.
So I rigorously defined everything which looks like space to a non-break space.
You might want to restrict this to verbatim ;-)
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{color}
\input{glyphtounicode}
\pdfglyphtounicode{visiblespace}{A0}
\pdfglyphtounicode{blank}{A0}
\pdfglyphtounicode{visualspace}{A0}
\pdfglyphtounicode{uni2423}{A0}
\pdfgentounicode=1
\begin{document}\showoutput
\makeatletter
\def\@xobeysp{\textcolor{white}{\char32}}
\makeatother
\begin{verbatim}
def myfunction(x):
return x
\end{verbatim}
\end{document}
I am inclined to consider the fact that apparently no (consecutive or beginning-of-line) spaces can be copied from Acrobat a bug.
Or is this specified anywhere?
At least it's completely the same with official Adobe documents like the PDF Reference.
So I consider this answer valid no matter what :-)
Best Answer
You must have something equivalent to
which makes
If you remove the
\hspace
and remove the setting of\parfillskip
which is specifying that the last line of the pargarph must reach the right margin, then you get