LaTeX forum ⇒ Math & Science ⇒ Breaking math expression Topic is solved

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Singularity
Posts: 155
Joined: Sat Jan 22, 2011 9:55 pm

Breaking math expression

How can I get a long expression to break across lines within a paragraph?

I have (well, had) \everymath{\displaystyle}.

I have a long line that I do not want to put on its own line
Given the relation $R$ on $A=\set{1,2,3,4,5,6,7,8}$ defined by $R=\set{(1,1),(1,2),(1,4),(1,8),(2,2),(2,4),(2,8),(3,3),(3,6),(4,4),(4,8),(5,5),(6,6),(7,7),(8,8)}$, determine whether it is
(a) etc....

The relation R is too long to fit on a line and prints right through the margin and on thin air.

I have tried inserting a \\.
I have tried turning off the \everymath command.
I have tried \textstyle{R={...}}.

I've also tried replace \set with \{ and \}.
But nothing seems to make it break.

MWE
2. \usepackage{amsfonts,amsmath,amssymb,amsthm,mathtools,commath}
3.
4. %\everymath{\displaystyle}
5. \setlength{\parindent}{0pt}
6. \setlength{\parskip}{\baselineskip}
7.
8. \begin{document}
9. Given the relation $R$ on $A=\set{1,2,3,4,5,6,7,8}$ defined by $\textstyle{R=\set{(1,1),(1,2),(1,4),(1,8),(2,2),(2,4), \\ (2,8),(3,3),(3,6),(4,4),(4,8),(5,5),(6,6),(7,7),(8,8)}}$, determine whether it is
10. \begin{enumerate}
11. \item Reflexive
12. \item Antisymmetric
13. \item Transitive
14. \item A partial ordering on $A$
15. \end{enumerate}
16.
17. \end{document}

Tags:

Johannes_B
Site Moderator
Posts: 4044
Joined: Thu Nov 01, 2012 4:08 pm
In the middle i wasn't sure if you want a matrix. Do you want a matrix? Usually, displayed formulas are used for big equations.
2. \usepackage{amsfonts,
3. amsmath,
4. amssymb,
5. amsthm,
6. mathtools,
7. commath,
8. showframe
9. }
10.
11. %\everymath{\displaystyle}
12. \setlength{\parindent}{0pt}
13. \setlength{\parskip}{\baselineskip}
14.
15. \begin{document}
16. Given the relation $R$ on $A=\set{1,2,3,4,5,6,7,8}$ defined by
17. $R=\{(1,1),(1,2),(1,4),(1,8),(2,2),(2,4),\linebreak (2,8),(3,3),(3,6),(4,4),(4,8),(5,5),(6,6),(7,7),(8,8)\}$
18. determine whether it is
19.
20. Given the relation $R$ on $A=\set{1,2,3,4,5,6,7,8}$ defined by
21. $22. R=\begin{Bmatrix}(1,1),(1,2),(1,4),(1,8),(2,2),(2,4), \\ (2,8),(3,3),(3,6),(4,4),(4,8),(5,5),(6,6),(7,7),(8,8)\end{Bmatrix}, 23.$
24. determine whether it is
25. \begin{enumerate}
26. \item Reflexive
27. \item Antisymmetric
28. \item Transitive
29. \item A partial ordering on $A$
30. \end{enumerate}
31.
32. \end{document}
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

Singularity
Posts: 155
Joined: Sat Jan 22, 2011 9:55 pm
Thanks. Not looking for a matrix. In math terms (if you're curious), it's a set of ordered pairs, which is not the same as a matrix. Your first solution is what I want.

I see you used \linebreak. This is good for the time being. Is there a way to automate it, so that LaTeX chooses an appropriate linebreak (like it does for everything else)?

Singularity
Posts: 155
Joined: Sat Jan 22, 2011 9:55 pm
It seems that when I turn \everymath{\displaystyle} back on, it blocks the \linebreak.

Is there a way to turn off \displaystyle temporarily? I've tried \textstyle but no luck. If not, I can probably get away without it this (and most) documents (mostly, I hate the displaystyle \sigma and \int, etc.

Johannes_B
Site Moderator
Posts: 4044
Joined: Thu Nov 01, 2012 4:08 pm
I don't experience any difficulties with \displaystyle, though using it everywhere is a bad thing. I think i have said that multiple times by now.

There is also a way to split at commas, the following is adapted directly from egreg's answer at TeX.SX.

2. \usepackage{amsfonts,
3. amsmath,
4. amssymb,
5. amsthm,
6. mathtools,
7. commath,
8. showframe
9. }
10.
11. \everymath{\displaystyle}
12. \setlength{\parindent}{0pt}
13. \setlength{\parskip}{\baselineskip}
14.
15.
16. \newcommand{\splitatcommas}{%
17. \begingroup
18. \begingroup\lccode~=, \lowercase{\endgroup
19. \edef~{\mathchar\the\mathcode, \penalty0
20. \noexpand\hspace{0pt plus 1em}}%
21. }\mathcode,="8000 #1%
22. \endgroup
23. }
24.
25. \begin{document}
26. Given the relation $R$ on $A=\set{1,2,3,4,5,6,7,8}$ defined by
27. $\displaystyle 28. R=\{\splitatcommas{(1,1),(1,2),(1,4),(1,8),(2,2),(2,4),(2,8),(3,3),(3,6),(4,4),(4,8),(5,5),(6,6),(7,7),(8,8)}\}$
29. determine whether it is
30. \begin{enumerate}
31. \item Reflexive
32. \item Antisymmetric
33. \item Transitive
34. \item A partial ordering on $A$
35. \end{enumerate}
36.
37. \end{document}
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

Singularity
Posts: 155
Joined: Sat Jan 22, 2011 9:55 pm
I can't figure out why it won't work in my file. I'm posting the whole thing here -- even though it's not exactly an MWE -- hoping someone can help me.

The \linebreak is on line 275 (with wordwrap turned off). It will be question 7 in the output.

Test 2 (Sets, Fcns, Combinatorics).tex

I can't attach the image files, they are too big.

Thanks,
J

Johannes_B
Site Moderator
Posts: 4044
Joined: Thu Nov 01, 2012 4:08 pm
It is the \left{ \right} pair. That always means: unbreakable.

There is a reason i substituted the \set command. It uses the same mechanism, resulting in an unbreakable box.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

Stefan Kottwitz
Posts: 9443
Joined: Mon Mar 10, 2008 9:44 pm
Long equations even with left and right delimiters can be broken automatically, if you would use a dmath environment of the breqn package.

Stefan