Efficient Latex Wrapping: Avoiding PDF Overflow | Formula Included

  • Context: LaTeX 
  • Thread starter Thread starter Dustinsfl
  • Start date Start date
  • Tags Tags
    Latex Pdf
Click For Summary
SUMMARY

The discussion focuses on efficient LaTeX wrapping techniques to prevent equations from overflowing in PDFs. Key strategies include using \right. and \left. to manage parentheses size, employing multi-line environments like align, and utilizing the \phantom command for proper sizing. Users also recommend using fixed-size parentheses with commands like \big, \Big, \bigg, and \Bigg to control appearance. The conversation highlights the importance of formatting for clarity in complex mathematical expressions.

PREREQUISITES
  • Understanding of LaTeX syntax and commands
  • Familiarity with multi-line environments in LaTeX, such as align
  • Knowledge of mathematical notation and formatting conventions
  • Experience with PDF generation from LaTeX documents
NEXT STEPS
  • Research LaTeX multi-line environments, specifically the align environment
  • Learn about the use of \phantom for controlling spacing in LaTeX
  • Explore fixed-size parentheses commands in LaTeX, including \big and \Bigg
  • Investigate best practices for formatting complex equations in LaTeX
USEFUL FOR

Mathematicians, researchers, and students who frequently use LaTeX for typesetting complex equations and want to improve the presentation of their work in PDF format.

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?
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
Replies
10
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
Replies
2
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 3 ·
Replies
3
Views
1K