3

When used directly after the an equation, the samepage environment inserts a leading space. Is this the intended behavior? How do I remove it?

Compare the output of

\documentclass[a4paper,notitlepage]{article}
%
\usepackage{amsmath}
%
\begin{document}
%
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis
nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
%
\begin{equation*}
    1+1=2.
\end{equation*}
%
\begin{samepage}
%
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat.
%
\end{samepage}
%
\end{document}
%

with the output of

\documentclass[a4paper,notitlepage]{article}
%
\usepackage{amsmath}
%
\begin{document}
%
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis
nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
%
\begin{equation*}
    1+1=2.
\end{equation*}
%
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat.
%
\end{document}
%

The difference is that in the latter case the samepage environment is not used. The first produces

screenshot

(leading space!)

while the second produces

screenshot1

(no leading space!).

1

1 Answer 1

3

This is the behaviour, although it might not have been intended. Do get around it, use

\begin{samepage}%
  ...
\end{samepage}

While you've used the end-of-line % elsewhere, it's needed on the same line as \begin{samepage} to remove the unwanted space. See What is the use of percent signs (%) at the end of lines? Alternatively, the following definition within your preamble would achieve the same result:

\let\oldsamepage\samepage
\def\samepage{\oldsamepage\ignorespaces}

According to the source2e documentation, samepage is considered unsupported since LaTeX2e (see p 343 of the documentation). So, one should just deal with it...

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .