# Why can't I prevent page break?

I am newbie to Latex and I am just making some lists of some common commands and learning the syntax.

This is what I have at the end of my first page.

using left and right bracketing commands\\
$$3\left(\frac{2}{5}\right)$$
$$3\left[\frac{2}{5}\right]$$
$$3\left\{\frac{2}{5}\right\}$$


This produces three lines. On the first line is my comment. On the second and third line are the examples with parentheses and square brackets. But then the third example is output to the second page.

I have found the \nopagebreak and tried applying that. But I can't make it work.

using left and right bracketing commands\\
$$3\left(\frac{2}{5}\right)$$
$$3\left[\frac{2}{5}\right]$$
\nopagebreak $$3\left\{\frac{2}{5}\right\}$$


The last part still jumps to the second page. I'm not sure... should the \nopagebreak command sit on the same line in the code like that?

I tried placing it at the end, in front, and at the beginning of this paragraph (in the code). I also tried setting the argument to 4 to insist on preventing page break. Like \nopagebreak[4]. But that didn't help.

So how do I prevent page break at this point?

There is page number indicator (index) that sits in the foot of the page. This sits very high up on the page. So there is actually some real estate here, where the last example could sit, if Latex could only make the foot note margin smaller on all or for the current page, just somehow move the number in the foot note down a little.

So I'm curious why this is not working out for me. I can post a screenshot if that helps.

Edit 1: Here's a screenshot.

You can see how high up that number one is. There is more than enough space there to place both the fraction example and the page index.

Edit 2: Here is the whole working example.

\documentclass[11pt]{article}

\begin{document}
bracketing symbols;

parenthesis;
$$(x+1)$$

square brackets;
$$3[2+(x+1)]$$

curly brackets;\\
these are reserved symbols for coding in Latex\\
they are therefore normally not displayed
$${a,b,c}$$
so to display curly brackets in math mode\\
there needs to be a back slash in front\\
of each bracket
$$\{a,b,c\}$$

dollar sign;\\
the same is true for dollar sign\\
dollar signs are reserved to indicate\\
math mode in Latex\\
there needs to be a back slash in front of it

$$\12.55$$

adjusting bracketing symbols to the height\\
of tall objects like fractions;

typing in only the bracket signs\\
$$3(\frac{2}{5})$$
$$3[\frac{2}{5}]$$
$$3\{\frac{2}{5}\}$$%curly brackets require an additional back slash

using left and right bracketing commands\\
$$3\left(\frac{2}{5}\right)$$
$$3\left[\frac{2}{5}\right]$$
\nopagebreak $$3\left\{\frac{2}{5}\right\}$$

\end{document}


As you can see here I do have a document class and a begin and end command. In case you thought I forgot those.

-
Just FYI, you shouldn't use "": tex.stackexchange.com/questions/503/why-is-preferable-to –  kahen Mar 29 '13 at 13:13
Also, your question is answered by the UK TeX FAQ: tex.ac.uk/cgi-bin/texfaq2html?label=nopagebrk. \nopagebreak is a polite request. TeX is free to do as it damn well pleases if its algorithm determines that preventing a page break there would lead to too high "badness" –  kahen Mar 29 '13 at 13:15
You should not use \\  before displayed math, it sounds like your page layout is wrong, have you specified a4paper if you are using A4 (the default layout is US letter paper) or you could increase \textheight in the preamble or better use the geometry package. It is always worth posting a complete (small) document that shows the problem. –  David Carlisle Mar 29 '13 at 13:23
@kahen I don't understand any of that. Maybe I shouldn't use it, but I'm gonna do it anyway. It works and does what I want. Every single beginners guide to Latex is using single or double dollar sign to indicate math. So how can I ignore that and start using square brackets and things like that while following the tutorial? I need more knowledge to start making my own decisions about what commands/syntax/whatever to use and how to use it. I'm sure I will learn that when it comes to that one day. But thanks for the tip. –  sammyg Mar 29 '13 at 14:10
@DavidCarlisle Why is \\  not allowed? The format is A4, I remember choosing that option when I installed MikTex. Should I change that to Letter? –  sammyg Mar 29 '13 at 14:13

As mentioned in comments you are printing a document formatted for US letter paper on an A4 page. If you use

\documentclass[11pt,a4paper]{article}


Then it all fits on one page.

-
Thanks! This makes the whole "nopagebreak" thing excessive. –  sammyg Mar 29 '13 at 14:43

For this particular case, increasing the page size (as suggested by David Carlisle) eliminates the problem. In general, to avoid page breaks in unfortunate places, it's important to tell TeX exactly what you want. In your case, you can take advantage of the fact that certain environments from the amsmath package, including gathered, are placed in an unbreakable box which cannot split over two pages. In the following example, your expressions appear on the first page, but if you increase the height of the rule by even one point, all three move onto a new page.

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\rule{1pt}{461pt} \par %Try changing to 462pt
\begin{equation*}
\begin{gathered}
3\left(\frac{2}{5}\right) \\
3\left[\frac{2}{5}\right]\\
3\left\{\frac{2}{5}\right\}
\end{gathered}
\end{equation*}
\end{document}


As a general rule, if you want to typeset any mathematics whose structure is more complicated than a single equation, you should use amsmath. This package is part of any standard TeX distribution. Note that you can abbreviate \begin{equation*} and \end{equation*} to $ and $, respectively.

-
I'm not sure I got the "why" of it. Is it because I use dollar signs to indicate math mode? How would I know if I have the amsmath package? I often hear comments use this and that package, but how do I tell what packages I've got? I don't know, two fifths... I don't see that as too complicated math. –  sammyg Mar 29 '13 at 14:24
I meant complicated from the typesetting point of view. Three equations that must not span a page break is a simple example, but as you try to do more with LaTeX you will probably encounter more elaborate cases. All standard distributions include amsmath. –  Ian Thompson Mar 29 '13 at 14:28
Okay. Your "box" starts at \begin{equation*} and ends at \end{equation*} am I right? So that \usepackage{amsmath} is part of what is known as the preamble? I don't have to use any kind of start and end commands that uses amsmath for each line, I mean like "use amsmath here" and "stop amsmath here". That's what the \begin{equation*} and \end{equation*} are doing and they link/call the amsmath package? Is that how it works? –  sammyg Mar 29 '13 at 14:34
@Sammy --- I have edited my answer. \usepackage{amsmath} is part of the preamble. With this included, amsmath environments such as align, gather, multline, etc. are available anywhere in your document. The equation* environment is redefined by amsmath, so \begin{equation*} does indeed invoke amsmath code. –  Ian Thompson Mar 29 '13 at 16:39