Writing Fractions in LaTeX Easily

  • Context: LaTeX 
  • Thread starter Thread starter cookiemnstr510510
  • Start date Start date
  • Tags Tags
    Fractions Latex
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
11 replies · 6K views
cookiemnstr510510
Messages
162
Reaction score
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.
 
on Phys.org
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   Reactions: cookiemnstr510510
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?
 
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?
 
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   Reactions: cookiemnstr510510
$$\frac{a}{b}$$
 
  • Like
Likes   Reactions: berkeman
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!
 
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!
 
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   Reactions: cookiemnstr510510