How to Represent Complex Fractions in LaTeX?

In summary: Of course it didn’t, spaces are mostly irrelevant to math mode (for good reason).For integrals, using the physics package might be helpful to some extent. One may use \dd{} from that package, which manages the spacing automatically, and also makes the d upright.
  • #1
topsquark
Science Advisor
Insights Author
Gold Member
MHB
2,021
796
TL;DR Summary
Exploring different ways to represent a complex fraction using LaTeX
I know of two reasonable ways to represent a complex fraction:
\dfrac{ \left ( \dfrac{a}{b} \right ) }{ \left ( \dfrac{c}{d} \right ) }
##\dfrac{ \left ( \dfrac{a}{b} \right ) }{ \left ( \dfrac{c}{d} \right ) }##

and
\dfrac{ ^a / _b }{ ^c / _d }
##\dfrac{ ^a / _b }{ ^c / _d }##

What I am wondering is if there is a way to write
##\dfrac{ \dfrac{a}{b} }{ \dfrac{c}{d} }##
by making a longer middle division line?

Thanks!

-Dan
 
Physics news on Phys.org
  • #2
Hey Dan,

One way to make the middle line longer, is to add latex spaces to numerator or denominator.
For instance:
\dfrac{\;\dfrac ab\;}{\dfrac cd}
##\dfrac{\;\dfrac ab\;}{\dfrac cd}##
 
  • Informative
  • Like
Likes topsquark and berkeman
  • #3
I like Serena said:
add latex spaces to numerator or denominator
Sometimes I have to add explicit "~" characters to force spaces in LaTeX, but other times just " " spaces seem to work. I haven't figured out why yet...
 
  • Like
Likes topsquark
  • #4
berkeman said:
Sometimes I have to add explicit "~" characters to force spaces in LaTeX, but other times just " " spaces seem to work. I haven't figured out why yet...
Can you give some examples?
 
  • #5
berkeman said:
Sometimes I have to add explicit "~" characters to force spaces in LaTeX, but other times just " " spaces seem to work. I haven't figured out why yet...
Regular spaces are generally used as separator. For instance in \dfrac ab the space is not an actual space, but instead it's a separator. That separator only "becomes" a space, if that is needed to separate both sides. In that case multiple spaces are collapsed to a single space.
If we actually "want" a space where that is not already natural, we have to use one of the latex spaces like:
\! \, \: \; \quad \qquad, which are increasingly wide spaces. The first one is a negative space. The "~" is special in that it creates a non-breaking space, so that it won't "wrap".
 
  • Like
  • Informative
Likes Orodruin, berkeman and topsquark
  • #6
Orodruin said:
Can you give some examples?
Just a quick example:
$$v(t) = L \frac{di(t)}{dt}$$
$$v(t) = L~\frac{di(t)}{dt}$$
from:
1662414182567.png
 
  • #7
The classical example is an integral: $$\int f(x,y) dx dy$$
Often \, is inserted (despite already having spaces) before the infinitesimals to get a more natural formula:$$\int f(x,y)\,dx\,dy$$
A "~" also works of course.
 
  • Like
Likes pbuk and topsquark
  • #8
berkeman said:
Just a quick example:
$$v(t) = L \frac{di(t)}{dt}$$
$$v(t) = L~\frac{di(t)}{dt}$$
from:
View attachment 313827
I meant examples of where you would expect a space but there was none.

I like Serena said:
A "~" also works of course.
Compare the following:
$$
\int f(x,y)~dx~dy \qquad \int f(x,y)\,dx\,dy
$$
The non-breaking space ~ is a regular sized space (it is equivalent in size to the regular \ ) as compared to \, which is 3 mu. The latter is typically what you want. The non-breaking space ~ should be used when you have a space where you do not wish to create a (line or page) break. In an equation it is essentially equivalent to the regular space "\ " (which has its own uses in text as well, such as not creating a too large space after an abbreviation, i.e., LaTeX will interpret "cf. last chapter" as there being an end of sentence after cf. whereas "cf.\ last chapter" will not).
 
  • Like
Likes I like Serena and topsquark
  • #9
Orodruin said:
I meant examples of where you would expect a space but there was none.
In the first LaTeX line, I put a " " space after the L, but it did not render. It took the explicit "~"space after the L to get it to render.
 
  • #10
berkeman said:
In the first LaTeX line, I put a " " space after the L, but it did not render. It took the explicit "~"space after the L to get it to render.
Of course it didn’t, spaces are mostly irrelevant to math mode (for good reason).
 
  • #11
For integrals, using the physics package might be helpful to some extent. One may use \dd{} from that package, which manages the spacing automatically, and also makes the d upright.
$$\require{physics}
\int f(x,y) \dd{x} \dd{y}$$
 
  • Like
Likes topsquark

1. What is a complex fraction in LaTeX?

A complex fraction in LaTeX is a mathematical expression that contains fractions within fractions. It is commonly used to represent a division of two polynomials or rational expressions.

2. How do I create a complex fraction in LaTeX?

To create a complex fraction in LaTeX, you can use the \frac{}{} command. The first set of curly braces will contain the numerator and the second set will contain the denominator. For example, \frac{3x+4}{2x-1} will create a complex fraction with 3x+4 as the numerator and 2x-1 as the denominator.

3. Can I use parentheses in a complex fraction in LaTeX?

Yes, you can use parentheses in a complex fraction in LaTeX to indicate the order of operations. For example, \frac{(2x+1)(x-3)}{x^2-16} will create a complex fraction with (2x+1)(x-3) as the numerator and x^2-16 as the denominator.

4. How do I simplify a complex fraction in LaTeX?

To simplify a complex fraction in LaTeX, you can use the \cancel{} and \cdot commands. First, use \cancel{} to cross out any common factors in the numerator and denominator. Then, use \cdot to multiply any remaining factors in the numerator and denominator. For example, \frac{2x\cancel{(x+1)}}{\cancel{(x+1)}(x-3)} will simplify to \frac{2x}{x-3}.

5. Are there any other commands or packages that can help with complex fractions in LaTeX?

Yes, there are a few other commands and packages that can help with complex fractions in LaTeX. The \dfrac{}{} command can be used to create a larger fraction, and the amsmath package provides the \cfrac{}{} command to create a continued fraction. You can also use the cancel package for more complex simplifications.

Similar threads

  • Differential Equations
Replies
16
Views
894
  • Precalculus Mathematics Homework Help
Replies
5
Views
957
  • Math POTW for Secondary and High School Students
Replies
1
Views
807
  • Atomic and Condensed Matter
Replies
0
Views
483
  • Introductory Physics Homework Help
Replies
1
Views
753
Replies
3
Views
726
  • Advanced Physics Homework Help
Replies
2
Views
1K
Replies
10
Views
2K
  • Math Proof Training and Practice
2
Replies
61
Views
6K
  • General Math
5
Replies
142
Views
7K
Back
Top