## LaTeX forum ⇒ Math & Science ⇒ Equation with numbering on the right and text on the left

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Posts: 4
Joined: Wed Dec 10, 2014 2:13 pm

### Equation with numbering on the right and text on the left

I wish to write a \begin{equation}\end{equation} line where the equation number shows on the right margin, AND have text flushleft on the same line.

I have tried:
{Sample text}\parbox{length}{$$eq text$$}

This is a hit and miss method, where the length of parbox has to be adjusted by trial and error. Does anyone know of a LaTeX canned solution?

Tags:

Stefan Kottwitz
Posts: 9164
Joined: Mon Mar 10, 2008 9:44 pm
Welcome to the forum!

You could to use the fleqn option (flush left equation).

\documentclass[fleqn]{article}\usepackage{amsmath}\setlength{\mathindent}{0pt}\begin{document}\section{Test}\begin{equation}   y = f(x)\end{equation}\end{document}

Stefan

Posts: 4
Joined: Wed Dec 10, 2014 2:13 pm
Thank you Stefan_K for the idea. That is not quite it.

I need text be be left justified on the same line, with the equation material in the center, and the equation number right justified.

See my example for equationTest.
\documentclass[fleqn]{article}\usepackage{amsmath}\setlength{\mathindent}{0pt}\begin{document}\section{Test} \begin{equation}\text{left hand text}\qquad\qquad\qquad\qquad\qquad  y = f(x)\end{equation}\end{document}
Attachments
equationTest.tex

Johannes_B
Site Moderator
Posts: 3883
Joined: Thu Nov 01, 2012 4:08 pm
What kind of text is this? Personally, i cannot recall having seen this in a science book.

What happens, if the text is a bit longer? Or on the other hand, what happens if the equation gets longer?
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

Posts: 4
Joined: Wed Dec 10, 2014 2:13 pm
Johannes_B, it would be something like:

and f(x)=sin(x)+cos(x) (1.1)

or, it could be more verbose, like:

it follows that f(x)=sin(x)+cos(x) (1.1)

where the word "and" or the words "it follows that" would be left justified, and the equation numbers would be right justified. This would not be used for long phrases.

Stefan Kottwitz
Posts: 9164
Joined: Mon Mar 10, 2008 9:44 pm
Also I suggest to look into good math books to see if this style of writing is used anywhere. Can you tell me a book where you saw it? I would be interested to know it.

Here's a suggestion showing at least a way:

\documentclass{article}\usepackage{amsmath}\begin{document}\section{Test}\begin{flalign}\text{It follows that } && y &= f(x) &\end{flalign}\end{document}

I just think this style is unusual and hard too integrate with the text flow without manual intervention.

Stefan

Johannes_B
Site Moderator
Posts: 3883
Joined: Thu Nov 01, 2012 4:08 pm
\intertext and \shortintertext from amsmath are meant for that.
\documentclass{article}\usepackage{mathtools}\usepackage{blindtext}\begin{document}\section{Test}\blindtext\begin{gather}	E = mcc	\shortintertext{it follows that }	y = f(x)\end{gather}\blindtext\begin{gather}	E = mcc	\intertext{it follows that }	y = f(x)\end{gather}\end{document}
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

Posts: 4
Joined: Wed Dec 10, 2014 2:13 pm
Thank you very much. This is great!

For one, "Heat and Thermodynamics", 7th Ed. ISBN 0-07-114816-7.

Johannes_B
Site Moderator
Posts: 3883
Joined: Thu Nov 01, 2012 4:08 pm
Yeah, intertexts are quite common. But they don't end up on the same time.

You see, a bit of context is always good.
Glad that everything worked out fine.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.