# How do you make a formula stay between the page borders

I'm re-platforming a math paper I'm writing from Word to TeXShop and one formula extends into the right page boarder. The LaTex I am using is:

(I pasted the image above because the brackets [ ] didn't show up when I pasted the text here.)

In Word, it looks like this:

In MathJax on Mathematics Stack Exchange it looks like this:

In TeXShop it looks like this:

I have include some text in the last image to show how it extends beyond the normal word-wrap on the page. Ideally, I would like to keep the formula on one line to save vertical space. Is there a way to shrink the equation horizontally or do I have to break it up into two parts?

• unrelated but don't use $$ in latex and never use \\  in display math. It would be more readable if you used the amsmath multline enviornment to split it over two lines, but you could use \small or \footnotesize or whatever size is needed if you really must keep it on one line – David Carlisle Sep 4 '19 at 20:20 • I don't mean to sound sarcastic, but the answer is, "you edit it." You have to decide whether or not to shrink the font, or to break it across lines and where, or whether to re-express it with condensing substitutions. These are all stylistic decisions left to you, the author. – Steven B. Segletes Sep 4 '19 at 20:21 • @StevenB.Segletes apparently in Word and MathJax "you don't edit it" because the engine does the line breaking for you at heuristically suitable positions - something like breqn, but then more robust. – Marijn Sep 4 '19 at 20:31 • @David CarlisleI learned about LaTeX vs MathJax just two days ago. I tried your suggestion of using single dollar signs and it worked though I did have to keep \\ at the end to make a new line for readability between the equation and the following text. I would be interested in how to post a text block ( {} as you described, e.g. If I wanted to post$$\sqrt[3]{1234}$$, how would I use it to display the square brackets here? I'm marking Mico's answer as correct because he also provided useful info and to close this question because it has been answered, Thanks. – poetasis Sep 4 '19 at 21:30 • No: single  is for inline math, you should use $...$ for display math and do not use \\  to post code highlight the code and then use the {} button, (mathjax is not running on this site so tex in the page does not display as formatted math) – David Carlisle Sep 4 '19 at 21:36 ## 1 Answer Some comments and observations: • In TeX and LaTeX, an unnumbered displayed equation encased by $$ ... $$ can only occupy a single line -- no line breaks possible. • MathJax uses input syntax very similar to that of TeX and LaTeX, but it's based on a completely different underlying engine. Just because something happens to "work" (however that term may be defined) in Mathjax offers no guarantee that it'll work just the same in a LaTeX document. • Don't use $$ to initiate and terminate display math mode in a LaTeX document. For much more information on this subject, please see the posting Why is $...$ preferable to $$...$$?

• Last but not least, what then can you do to split the long equation across two lines? I suggest you load the amsmath package and use either an align* or a multline* environment. Both environments are showcased in the following screenshot.

• Aside: I strongly recommend studying the user guide of the amsmath package to familiarize yourself with the multi-line displayed equation environments provided by this package.

\documentclass{article} % or some other suitable document class
\usepackage{amsmath}    % for 'align*' and 'multline*' environments
\begin{document}

\newcommand\termA{\frac{D}{8(2n-1)}}
\newcommand\termB{\sqrt{\frac{D^2}{64(2n-1)^2}-\frac{(2n-1)^6}{1728}}}

\begin{align*}
k_D &=      \sqrt[3]{\termA+\termB} \\

• Maybe multline? – egreg Sep 4 '19 at 22:08
• @egreg - A very good suggestion. :-) I've edited my answer to show the output of both align* and multline*. – Mico Sep 4 '19 at 22:26