Aliging long text/formula in Latex so they appear multi line and take less space

I’m making this post it took me a while to find this, and thought I’d share.

The function for this is \atop, though you can use \splitfrac{}{} for this as well.

Example:
image

with \atop it looks like this
image

\splitfrac{}{} adds a small indent like this
image

Both can be used for more than 2 lines though you’ll have to use the functions multiple times with multiple {}, and it can get kinda janky.

1 Like

You can also use the various multiline functions to do something similar. They go around your latex like this:

$$ \begin{align}
x + y = z
\end{align} $$

You can do multiple lines as well, they are separated by two back slashes \\

$$ \begin{align}
x + y = z \\
a + b = c \\
d + e = f \\
\end{align} $$

You can also change around the point at which each line is aligned using & symbols. This is a bit difficult to show here in the forum, but if you paste this into your vault you should see what I mean.

$$ \begin{align}
x + y = z & \\
& a + b = c \\
d + e =& f \\
\end{align} $$

\begin{align} is also not the only function you can use here! I use a mixture, with align being the most useful, but \begin{gather} will let you do a multi-line latex entry where every line is aligned to the centre.

If you’re interested, this page (MathJax basic tutorial and quick reference - Mathematics Meta Stack Exchange) is a pretty handy index of many of the things you can do with the math block in obsidian. It’s a bit overwhelming, so I normally just search for what I want to do rather than trying to learn everything at once. ChatGPT can also be quite helpful with this, as it can setup many of these equations for you.

1 Like

I actually have a copy of that post you linked in my vault as a mathjax/latex cheatsheet lol.
But thank you for the tips!

The line break is nice. But I should have clarified that using \atop lets you stack individual segments of a formula/equation like this

${xxxxxxxx\atop xxxxxxxxx} + {yyyyyyyy\atop yyyyyyyy} = zzzzzzzzzzzzzz$

image

1 Like