LaTeX Efficient Latex Wrapping: Avoiding PDF Overflow | Formula Included

  • Thread starter Thread starter Dustinsfl
  • Start date Start date
  • Tags Tags
    Latex Pdf
AI Thread Summary
To prevent LaTeX equations from overflowing in a PDF, users can utilize various techniques, such as employing the \left and \right commands correctly, or using multi-line environments like align. Adjusting the size of parentheses with commands like \big, \Big, or \phantom can also help maintain visual consistency. Additionally, splitting complex equations across multiple lines is recommended for clarity. Overall, careful formatting and sizing of elements can enhance the presentation of mathematical expressions in documents.
Dustinsfl
Messages
2,217
Reaction score
5
How can I get this to not wrap outside of my pdf

$
\left(-\frac{1}{6 a}(-2 a (-2 + k) + \frac{2\ 2^{1/3} a \left(-3 + a (1 + k)^2\right)}{\left(9 a^2 (-2 + k)-2 a^3 (1 + k)^3 + 3 \sqrt{3} \sqrt{a^3 \left(4 + 4 a^2 (1 + k)^3-a \left(-8 + 20 k + k^2\right)\right)}\right)^{1/3}} + 2^{2/3} \left(9 a^2 (-2 + k)- 2 a^3 (1 + k)^3 + 3 \sqrt{3} \sqrt{a^3 \left(4 + 4 a^2 (1 + k)^3-a \left(-8 + 20 k + k^2\right)\right)}\right)^{1/3}, \frac{p}{a(1 + p)}\right)$
 
Physics news on Phys.org
There are multiple ways to do that. The only real trick is that you're probably using \left and \right to control the size of the parentheses at the beginning and end, correct? If so, you can use \right. to "fulfill" a \left(, and you can use a \left. to "fulfill" a \right). In the middle, to break the line, you can either just use multiple double dollar signs, or use a multi-line environment like align.

Example:

Code:
$$\left( stuff \right.$$
$$\left. stuff \right)$$

An aligned environment might work like this:

Code:
\begin{align*}
&\left( stuff \right.\\
&\left. stuff \right)
\end{align*}

So, in your case, the code

Code:
$$\left(-\frac{1}{6 a}(-2 a (-2 + k) + \frac{2\ 2^{1/3} a \left(-3 + a (1 + k)^2\right)}{\left(9 a^2 (-2 + k)-2 a^3 (1 + k)^3 + 3 \sqrt{3} \sqrt{a^3 \left(4 + 4 a^2 (1 + k)^3-a \left(-8

 + 20 k + k^2\right)\right)}\right)^{1/3}}\right.$$

 $$\left.+ 2^{2/3} \left(9 a^2 (-2 + k)- 2 a^3 (1 + k)^3 + 3 \sqrt{3} \sqrt{a^3 \left(4 + 4 a^2 (1 + k)^3-a \left(-8 + 20 k + k^2\right)\right)}

\right)^{1/3}, \frac{p}{a(1 + p)}\right)$$

produces

$$\left(-\frac{1}{6 a}(-2 a (-2 + k) + \frac{2\ 2^{1/3} a \left(-3 + a (1 + k)^2\right)}{\left(9 a^2 (-2 + k)-2 a^3 (1 + k)^3 + 3 \sqrt{3} \sqrt{a^3 \left(4 + 4 a^2 (1 + k)^3-a \left(-8

+ 20 k + k^2\right)\right)}\right)^{1/3}}\right.$$

$$\left.+ 2^{2/3} \left(9 a^2 (-2 + k)- 2 a^3 (1 + k)^3 + 3 \sqrt{3} \sqrt{a^3 \left(4 + 4 a^2 (1 + k)^3-a \left(-8 + 20 k + k^2\right)\right)}

\right)^{1/3}, \frac{p}{a(1 + p)}\right).$$

Not sure how to fix the beginning and ending parentheses differing in size. I would probably write this portion of your paper a little differently, so that I didn't have to display such an ugly equation in one piece.
 
Last edited:
Ackbach said:
...

Not sure how to fix the beginning and ending parentheses differing in size. I would probably write this portion of your paper a little differently, so that I didn't have to display such an ugly equation in one piece.

You don't have to use elastic parentheses, you can force their size with \big \Big, \bigg \Bigg :

$$ \Bigg( \Big( \big( ( x^2+y^2 ) \big) \Big) \bigg)\Bigg)$$

You can also pair there by appending l and r for right and left ...

CB
 
Last edited:
dwsmith said:
How can I get this to not wrap outside of my pdf

$
\left(-\frac{1}{6 a}(-2 a (-2 + k) + \frac{2\ 2^{1/3} a \left(-3 + a (1 + k)^2\right)}{\left(9 a^2 (-2 + k)-2 a^3 (1 + k)^3 + 3 \sqrt{3} \sqrt{a^3 \left(4 + 4 a^2 (1 + k)^3-a \left(-8 + 20 k + k^2\right)\right)}\right)^{1/3}} + 2^{2/3} \left(9 a^2 (-2 + k)- 2 a^3 (1 + k)^3 + 3 \sqrt{3} \sqrt{a^3 \left(4 + 4 a^2 (1 + k)^3-a \left(-8 + 20 k + k^2\right)\right)}\right)^{1/3}, \frac{p}{a(1 + p)}\right)$

You clould split over multiple lines (recommended) the text as described elsewhere in this thread, or just make it smaller with \small :

$ \small
\left(-\frac{1}{6 a}(-2 a (-2 + k) + \frac{2\ 2^{1/3} a \left(-3 + a (1 + k)^2\right)}{\left(9 a^2 (-2 + k)-2 a^3 (1 + k)^3 + 3 \sqrt{3} \sqrt{a^3 \left(4 + 4 a^2 (1 + k)^3-a \left(-8 + 20 k + k^2\right)\right)}\right)^{1/3}} + 2^{2/3} \left(9 a^2 (-2 + k)- 2 a^3 (1 + k)^3 + 3 \sqrt{3} \sqrt{a^3 \left(4 + 4 a^2 (1 + k)^3-a \left(-8 + 20 k + k^2\right)\right)}\right)^{1/3}, \frac{p}{a(1 + p)}\right)$

CB
 
CaptainBlack said:
You don't have to use elastic parentheses, you can force their size with \big \Big, \bigg \Bigg :

$$ \Bigg( \Big( \big( ( x^2+y^2 ) \big) \Big) \bigg)\Bigg)$$

You can also pair there by appending l and r for right and left ...

CB

I tried that with dwsmith's expression, but even \Bigg wasn't big enough to "capture" the rather large depth (top-to-bottom) of it. It looked kinda weird to me.

I have another idea for parenthesis sizing: use a phantom expression. (You can right-click and do Show Source to get the LaTeX code here.)$$\left(-\frac{1}{6 a}(-2 a (-2 + k) + \frac{2\ 2^{1/3} a \left(-3 + a (1 + k)^2\right)}{\left(9 a^2 (-2 + k)-2 a^3 (1 + k)^3 + 3 \sqrt{3} \sqrt{a^3 \left(4 + 4 a^2 (1 + k)^3-a \left(-8

+ 20 k + k^2\right)\right)}\right)^{1/3}}\right.$$

$$\left.\phantom{\frac{1^{1/3}}{\sqrt{\left(1^{2}\right)^{2}}^{1/3}}}+ 2^{2/3} \left(9 a^2 (-2 + k)- 2 a^3 (1 + k)^3 + 3 \sqrt{3} \sqrt{a^3 \left(4 + 4 a^2 (1 + k)^3-a \left(-8 + 20 k + k^2\right)\right)}

\right)^{1/3}, \frac{p}{a(1 + p)}\right)$$

I chose the phantom expression to match the first line's greatest depth in as little width as possible. Here's the phantom expression:

Code:
\phantom{\frac{1^{1/3}}{\sqrt{\left(1^{2}\right)^{2}}^{1/3}}}.

If I didn't wrap the phantom expression around it, I'd get

$$\frac{1^{1/3}}{\sqrt{\left(1^{2}\right)^{2}}^{1/3}}.$$
 
Ackbach said:
I tried that with dwsmith's expression, but even \Bigg wasn't big enough to "capture" the rather large depth (top-to-bottom) of it. It looked kinda weird to me.

I have another idea for parenthesis sizing: use a phantom expression. (You can right-click and do Show Source to get the LaTeX code here.)$$\left(-\frac{1}{6 a}(-2 a (-2 + k) + \frac{2\ 2^{1/3} a \left(-3 + a (1 + k)^2\right)}{\left(9 a^2 (-2 + k)-2 a^3 (1 + k)^3 + 3 \sqrt{3} \sqrt{a^3 \left(4 + 4 a^2 (1 + k)^3-a \left(-8

+ 20 k + k^2\right)\right)}\right)^{1/3}}\right.$$

$$\left.\phantom{\frac{1^{1/3}}{\sqrt{\left(1^{2}\right)^{2}}^{1/3}}}+ 2^{2/3} \left(9 a^2 (-2 + k)- 2 a^3 (1 + k)^3 + 3 \sqrt{3} \sqrt{a^3 \left(4 + 4 a^2 (1 + k)^3-a \left(-8 + 20 k + k^2\right)\right)}

\right)^{1/3}, \frac{p}{a(1 + p)}\right)$$

I chose the phantom expression to match the first line's greatest depth in as little width as possible. Here's the phantom expression:

Code:
\phantom{\frac{1^{1/3}}{\sqrt{\left(1^{2}\right)^{2}}^{1/3}}}.

If I didn't wrap the phantom expression around it, I'd get

$$\frac{1^{1/3}}{\sqrt{\left(1^{2}\right)^{2}}^{1/3}}.$$
To my eye, nearly all of those parentheses look too big. I would avoid the indiscriminate use of \left and \right, and write the first of those two lines as
$$\left(-\frac{1}{6 a}(-2 a (-2 + k) + \frac{2\ 2^{1/3} a \bigl(-3 + a (1 + k)^2\bigr)}{\Bigl(9 a^2 (-2 + k)-2 a^3 (1 + k)^3 + 3 \sqrt{3} \sqrt{a^3 \bigl(4 + 4 a^2 (1 + k)^3-a (-8 + 20 k + k^2)\bigr)}\Bigr)^{1/3}}\right.$$
with something similar (including a \phantom to get the correct size of the final closing parenthesis correct) for the second line.
 
Opalg said:
To my eye, nearly all of those parentheses look too big. I would avoid the indiscriminate use of \left and \right, and write the first of those two lines as
$$\left(-\frac{1}{6 a}(-2 a (-2 + k) + \frac{2\ 2^{1/3} a \bigl(-3 + a (1 + k)^2\bigr)}{\Bigl(9 a^2 (-2 + k)-2 a^3 (1 + k)^3 + 3 \sqrt{3} \sqrt{a^3 \bigl(4 + 4 a^2 (1 + k)^3-a (-8 + 20 k + k^2)\bigr)}\Bigr)^{1/3}}\right.$$
with something similar (including a \phantom to get the correct size of the final closing parenthesis correct) for the second line.


Nice! Perhaps even another improvement would be to move one of the parentheses in the denominator to the right a little, and maybe move the 1/3 exponent in a little. I would also definitely insert a cdot in the numerator to indicate a multiplication (otherwise it might look like the number 22). Or you could just combine the exponents. Result:

$$\left(-\frac{1}{6 a}(-2 a (-2 + k) + \frac{2^{4/3} a \bigl(-3 + a (1 + k)^2\bigr)}{\Bigl(9 a^2 (-2 + k)-2 a^3 (1 + k)^3 + 3 \sqrt{3} \sqrt{a^3 \bigl(4 + 4 a^2 (1 + k)^3-a (-8 + 20 k + k^2)\bigr)}\;\:\Bigr)^{\!\!1/3}}\right.$$

This has to be a Mathematica result, right dwsmith?
 
Back
Top