Math & ScienceMy formula is too long

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
quasar987
Posts: 4
Joined: Tue Jan 13, 2009 6:03 am

My formula is too long

Post by quasar987 »

Hi,

I am working on slides and when I enter the following code,

Code: Select all

\begin{displaymath}
f(x)=
\begin{cases} 
n & \text{if } x \in \mathbb{Q} \ \text{and } x=m/n \ \text{where } n>0 \ \text{and } gcd(m,n)=1 \\
0 & \text{otherwise}
\end{cases}
\end{displaymath}
the forumla is too long for the width of the slide. What I would like to do is write the condition "if x \in [...] gcd(m,n)=1" on two lines nicely.

How would I do something like that?

Thanks!

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

My formula is too long

Post by localghost »

You can try something like the following.

Code: Select all

\begin{displaymath}
  f(x)=
  \begin{cases}
    n & \text{if } x \in \mathbb{Q} \ \text{and } x=m/n \ \text{where } \\
    & n>0 \ \text{and } gcd(m,n)=1 \\
    0 & \text{otherwise}
  \end{cases}
\end{displaymath}
Where to exactly set the line break is up to you.


Best regards
Thorsten¹
quasar987
Posts: 4
Joined: Tue Jan 13, 2009 6:03 am

Re: My formula is too long

Post by quasar987 »

Oh, perfect! Thanks.
Post Reply