Math & ScienceEquation 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).
Post Reply
schlenkwad
Posts: 4
Joined: Wed Dec 10, 2014 2:13 pm

Equation with numbering on the right and text on the left

Post by schlenkwad »

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}{\begin{equation} eq text \end{equation}}

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?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

User avatar
Stefan Kottwitz
Site Admin
Posts: 10359
Joined: Mon Mar 10, 2008 9:44 pm

Equation with numbering on the right and text on the left

Post by Stefan Kottwitz »

Welcome to the forum!

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

Code: Select all

\documentclass[fleqn]{article}
\usepackage{amsmath}
\setlength{\mathindent}{0pt}
\begin{document}
\section{Test}
\begin{equation}
  y = f(x)
\end{equation}
\end{document}
Stefan
LaTeX.org admin
schlenkwad
Posts: 4
Joined: Wed Dec 10, 2014 2:13 pm

Equation with numbering on the right and text on the left

Post by schlenkwad »

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.

Code: Select all

\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
(222 Bytes) Downloaded 539 times
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Re: Equation with numbering on the right and text on the lef

Post by Johannes_B »

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.
schlenkwad
Posts: 4
Joined: Wed Dec 10, 2014 2:13 pm

Re: Equation with numbering on the right and text on the lef

Post by schlenkwad »

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.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10359
Joined: Mon Mar 10, 2008 9:44 pm

Equation with numbering on the right and text on the left

Post by Stefan Kottwitz »

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:

Code: Select all

\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
LaTeX.org admin
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Equation with numbering on the right and text on the left

Post by Johannes_B »

\intertext and \shortintertext from amsmath are meant for that.

Code: Select all

\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.
schlenkwad
Posts: 4
Joined: Wed Dec 10, 2014 2:13 pm

Re: Equation with numbering on the right and text on the lef

Post by schlenkwad »

Thank you very much. This is great!

For one, "Heat and Thermodynamics", 7th Ed. ISBN 0-07-114816-7.
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Re: Equation with numbering on the right and text on the lef

Post by Johannes_B »

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.
Post Reply