Tuesday, September 25, 2007

Supressing page breaks in LaTeX

I wanted to keep together a paragraph and following quote on a document written in LaTeX. However, the \nopagebreak command does not work properly in this case. Indeed, \nopagebreak does not suppress the page breaks that are deliberately inserted around environments like {quote}. The solution was enclosing the text I want to keep in the same page within {samepage} environment. Something like this:

\begin{samepage}
Lorem ipsum dolor sit amet, consectetuer adipiscing elit:
\begin{quote}
Quisque leo.
\end{quote}
\end{samepage}

18 comments:

Spencer said...

I'm sure you have no idea who I am, but I want you to know that you're my hero right now.

Kes said...

^^^agreed

Fridrik said...

For the third time, you're a hero

ale fener said...

Oh my god you are my hero too.

Pomax said...

interestingly, even two years down the road, this little blogpost is an important and invaluable find. Thank you.

Will said...

I suppose I should throw my gratitude in. You're my hero, as well.

Vedang said...

I tip my hat as well

Dimitri said...

That helped, thanks!

Arphartus said...

I'm gonna just add my name to the list of hero worshippers!!!!

Andy said...

Good stuff, thank you! (and you're my hero,too.)

benja said...

You're my hero as well. Thanks! -B

Clayton said...

Holy *** this is so exactly what I was looking for.

Andrie said...

You are a superhero

Ana Belén Sánchez Prieto said...

It did not work with me. I use ledmac-ledpar to typeset a double text parallelly. Does any one know another way to play the same trick?

Mark said...

Thanks!

The Fox said...

5 years later and this post is still badass. Thanks man

ithinu said...

This post is like a lamppost in the dark.

Ben Pfluger said...

I just wanted to say that for me, samepage does not workthat well. The text came by far too close to the page numbers.