How to add fractional spacing in equation?

Is it possible to use fractional spacing in an equation?
When breaking a long equation in multiple lines, I tried adding #h(1fr) to the start of a new line to make it effectively right aligned but nothing changes.
Is this possible, or should I use another method?

1 Like

This is an example of what I’m trying to achieve, one way or another:


The second line should be right aligned, and will overlap vertically with the first line, which is left aligned.

I am aware that I can fake this look by using alignment points &, but that requires manual tweaking per equation, and which also depends on things like font, page width etc., so not robust at all.

Hello @yuyttenhove, and welcome! I am confused as to what you’re asking. From the reference image, I can achieve it by writing

$
  partial/(partial t) (rho' e'_"tot") + 1/a^2 bold(nabla)' & dot (e'_"tot" bold(upsilon)' + P'bold(upsilon)')\
  & = - rho' bold(upsilon)' dot bold(nabla) ' (1/2 a accent(a, dot.double) r^('2)) - (1/(a^(3(gamma-1))) - 1/a^2) bold(upsilon)' dot bold(nabla)' P'
$

Can you develop this point?

Note that “When equations include multiple alignment points (&), this creates blocks of alternatingly right- and left-aligned columns.”.

Hi, @quachpas, thank you very much for your answer.

I’m generally using left aligned equations in my document, but when breaking a long equation like this, I want the second line to be right aligned, i.e. automatically moved to the right as much as possible (preferably leaving some padding for the equation numbers).

This can be done approximately using manual alignment, like you demonstrated, but I would prefer a solution that automatically adapts to e.g. changing line width.

I came up with this hacky solution:

// Usefull to add right aligned lines in equations. This does break alignment points though!
#let right_align_padded(body, padding: 4em, inset: 0.4em) = {
  block(width: 100%, breakable: true, spacing: 1.2em, inset: inset, pad(right: padding - inset)[
    #set align(right)
    #show math.equation.where(block: false): math.display
    #body
  ])
}
$
  partial/(partial t) (rho' e'_"tot") + 1/a^2 bold(nabla)'  dot (e'_"tot" bold(upsilon)' + P'bold(upsilon)') \
  #right_aligned_padded[$= - rho' bold(upsilon)' dot bold(nabla) ' (1/2 a accent(a, dot.double) r^('2)) - (1/(a^(3(gamma-1))) - 1/a^2) bold(upsilon)' dot bold(nabla)' P'$]
$

But I am hoping there would be a cleaner solution.