Writing Fractions in LaTeX Easily

In summary, the conversation discussed the use of latex to write mathematical equations, specifically fractions. The user was able to successfully write a fraction using the code \frac{a}{b} but was unsure of the steps needed to make it work. The conversation also mentioned the use of \dfrac and \tfrac to control the size and style of fractions in different environments. A helpful resource for latex was also provided.
  • #1
cookiemnstr510510
162
14
Hello all, So I've been trying to write some basic equations out like 1/2 but would like it to appear in a horizontal fashion (like 1 over 2). I have been reading threads on how to use latex, I've tried to look at others equations, right click and have the latex code shown to me so i can re-create, but it doesn't work when I try. for example:
if I want to type a/b this is what I've tried:
\frac{a}{b}
\left (\frac a b \right)
I just want to know how to write a fraction.
Any help will be appreciated as I want to make my equations easier for all you wonderful homework helpers!
And sorry if I'm posting in the incorrect area, didn't see another forum to post.
 
Physics news on Phys.org
  • #2
Does your first code snippet not work? This is what I get when I type \frac{a}{b} within the latex brackets: $$\frac{a}{b}$$ Is that not what you're looking for?
 
  • #3
cookiemnstr510510 said:
Hello all, So I've been trying to write some basic equations out like 1/2 but would like it to appear in a horizontal fashion (like 1 over 2). I have been reading threads on how to use latex, I've tried to look at others equations, right click and have the latex code shown to me so i can re-create, but it doesn't work when I try. for example:
if I want to type a/b this is what I've tried:
\frac{a}{b}
\left (\frac a b \right)
I just want to know how to write a fraction.
Any help will be appreciated as I want to make my equations easier for all you wonderful homework helpers!
And sorry if I'm posting in the incorrect area, didn't see another forum to post.
Here's a short summary: https://www.physicsforums.com/help/latexhelp/
Both of your versions work: ##\frac{a}{b}## without and ##\left (\frac a b \right)## with extra brackets. You can also use \dfrac which gives ##\dfrac{a}{b}##.
 
  • Like
Likes cookiemnstr510510
  • #4
Okay just realized that I probably cannot just type in \frac{a}{b} into my text field. I guess my question now is what are the steps I'm missing?
 
  • #5
Matterwave said:
Does your first code snippet not work? This is what I get when I type \frac{a}{b} within the latex brackets: $$\frac{a}{b}$$ Is that not what you're looking for?
what does within latex brackets mean?
 
  • #6
You have to brace the expression between double dollar signs for new line latex and double pound signs for in line latex. Quote my post to see how it's written.
 
  • Like
Likes cookiemnstr510510
  • #7
$$\frac{a}{b}$$
 
  • Like
Likes berkeman
  • #8
Matterwave said:
You have to brace the expression between double dollar signs for new line latex and double pound signs for in line latex. Quote my post to see how it's written.
GOT IT! thanks a bunch!
 
  • #9
fresh_42 said:
Here's a short summary: https://www.physicsforums.com/help/latexhelp/
Both of your versions work: ##\frac{a}{b}## without and ##\left (\frac a b \right)## with extra brackets. You can also use \dfrac which gives ##\dfrac{a}{b}##.
Thanks!
 
  • #10
cookiemnstr510510 said:
Okay just realized that I probably cannot just type in \frac{a}{b} into my text field. I guess my question now is what are the steps I'm missing?
## for inline formuals ## and $$ for extra lines $$.
 
  • Like
Likes cookiemnstr510510
  • #11
No problem. :)
 
  • Like
Likes cookiemnstr510510
  • #12
fresh_42 said:
Here's a short summary: https://www.physicsforums.com/help/latexhelp/
Both of your versions work: ##\frac{a}{b}## without and ##\left (\frac a b \right)## with extra brackets. You can also use \dfrac which gives ##\dfrac{a}{b}##.
Just to expand a bit on this: \frac always gives you a fraction with sized determined by the environment. In an inline environment it will give you ##\frac{a}{b}## whereas in a display environment it will give you
$$
\frac{a}{b}
$$
Then there are the two commands \dfrac (display mode fraction) which will always give you a display style fraction, even inline, as ##\dfrac{a}{b}## and the \tfrac (text mode fraction) which will always give you an inline style fraction, even in a display environment
$$
\tfrac{a}{b}
$$
Personally I tend to avoid fractions in inline text and instead use ##a/b##.
 
  • Like
Likes cookiemnstr510510

Related to Writing Fractions in LaTeX Easily

1. How do I write fractions in LaTeX?

To write fractions in LaTeX, use the \frac command and enclose the numerator in curly braces followed by the denominator in curly braces. For example: \frac{3}{4} will display as $\frac{3}{4}$.

2. Can I write mixed numbers in LaTeX?

Yes, you can write mixed numbers in LaTeX using the \dfrac command and enclosing the whole number and fraction in curly braces. For example: \dfrac{2}{3} will display as $\dfrac{2}{3}$.

3. How can I change the size of my fractions in LaTeX?

To change the size of your fractions in LaTeX, you can use the \displaystyle command before the fraction. This will make the fraction appear larger and more prominent. For example: \displaystyle\frac{1}{2} will display as $\displaystyle\frac{1}{2}$.

4. Can I write complex fractions in LaTeX?

Yes, you can write complex fractions in LaTeX by nesting the \frac command within another \frac command. For example: \frac{\frac{3}{4}}{\frac{5}{6}} will display as $\frac{\frac{3}{4}}{\frac{5}{6}}$.

5. How do I align fractions in LaTeX?

To align fractions in LaTeX, you can use the & symbol before the \frac command to indicate where you want the fractions to align. For example: \frac{1}{2} & \frac{3}{4} will display as $\frac{1}{2} & \frac{3}{4}$ with the fractions aligned at the = sign.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
953
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
13
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
7
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
9
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
7
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
9
Views
3K
Back
Top