3

I have two equations, each with a left part and a right part. The first equation has an extra-long left part, and the second equation has an extra-long right part.

I want to align the left part to the left margin and the right part to the right margin for each equation. This is what I have tried, but it is not working:

\begin{flalign} & \text{Short left} & \text{Very long right-hand side expression that extends far} && \\ & \text{Very long left-hand side expression that extends far} & \text{Short right} && \end{flalign} 

and the output:

example

As you can see, in the output, the length of each equation line extends far beyond the right margin (where the equation numbers are located).

I want the left part to start at the left margin and the right part to end at the right margin, on the same line with the equation number.

Please help :)

4 Answers 4

2

Basically you want to overlap the long items.

\documentclass{article} \usepackage{mathtools} \begin{document} \begin{flalign} & \text{Short left} &&& \mathllap{\text{Very long right-hand side expression that extends far}} \\ & \mathrlap{\text{Very long left-hand side expression that extends far}} &&& \text{Short right} \end{flalign} \end{document} 

demo

1
  • I don't really know how it works, but this is actually the simplest solution. Thanks! Commented Mar 18 at 12:26
2

You can put the second column in a right-aligned box:

\begin{flalign} & \text{Short left} &\makebox[0mm][r]{Very long right-hand side expression that extends far} \\ & \text{Very long left-hand side expression that extends far} &\makebox[0mm][r]{Short right} \end{flalign} 

enter image description here

1

I'd define a specific command for this: \lreq takes two mandatory arguments, the left and right part respectively, and an optional argument that can be used for fine tuning.

\documentclass{article} \usepackage{amsmath} \usepackage{showframe}% just for showing the text block margins \newcommand{\lreq}[3][4em]{% &\makebox[\dimeval{\displaywidth-#1}][s]{$\displaystyle#2$\hfil$\displaystyle#3$}% } \begin{document} \begin{align} \lreq{\text{Short left}}{\text{Very long right-hand side expression that extends far}} \\ \lreq{\text{Very long left-hand side expression that extends far}}{\text{Short right}} \end{align} \begin{align} \lreq[6em]{\text{Short left}}{\text{Very long right-hand side expression that extends far}} \\ \lreq[6em]{\text{Very long left-hand side expression that extends far}}{\text{Short right}} \end{align} \end{document} 

output

0

Try:

\documentclass{article} \usepackage{amsmath} \begin{document} \begin{flalign} \text{Short left} && \text{Very long right-hand side expression that extends far} & \end{flalign} \begin{flalign} \text{Very long left-hand side expression that extends far} && \text{Short right} & \end{flalign} \end{document} 
1
  • 1
    Thanks! I tried it before, however it will have a lot of space between each equation. Do you have any work aroud without using the \vspace{} between each equation? Commented Mar 17 at 18:36

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.