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

Discussion Overview

The discussion revolves around formatting LaTeX equations to prevent them from overflowing the boundaries of a PDF document. Participants explore various methods for wrapping complex mathematical expressions, focusing on the use of parentheses and line breaks. The conversation includes technical aspects of LaTeX typesetting, particularly in relation to large equations.

Discussion Character

  • Technical explanation
  • Mathematical reasoning
  • Debate/contested

Main Points Raised

  • One participant inquires about preventing a complex equation from wrapping outside the PDF margins.
  • Another suggests using \right. to balance \left and proposes using multi-line environments like align for better formatting.
  • Some participants mention using size commands like \big, \Big, \bigg, and \Bigg to control the size of parentheses.
  • There are suggestions to split the equation over multiple lines or to use smaller text with the \small command.
  • A participant introduces the idea of using a phantom expression to match the depth of parentheses without increasing their width.
  • Concerns are raised about the size of parentheses, with suggestions to avoid using elastic parentheses indiscriminately and to use specific sizing commands instead.
  • Another participant proposes adjustments to the equation for clarity, such as moving parentheses and inserting multiplication indicators.

Areas of Agreement / Disagreement

Participants express differing opinions on the best methods for formatting equations, with no consensus reached on a single approach. Various techniques are proposed, and some participants challenge the effectiveness of certain methods.

Contextual Notes

Limitations include unresolved preferences for specific LaTeX commands and the subjective nature of aesthetic choices in typesetting equations. The discussion does not resolve which method is superior for all cases.

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
2K