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

Equation with numbering on the right and text on the left

Postby schlenkwad » Wed Dec 10, 2014 2:25 pm

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?

Tags:

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

Postby Stefan Kottwitz » Wed Dec 10, 2014 3:03 pm

Welcome to the forum!

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

  1. \documentclass[fleqn]{article}
  2. \usepackage{amsmath}
  3. \setlength{\mathindent}{0pt}
  4. \begin{document}
  5. \section{Test}
  6. \begin{equation}
  7. y = f(x)
  8. \end{equation}
  9. \end{document}


Stefan
Site admin

schlenkwad
Posts: 4
Joined: Wed Dec 10, 2014 2:13 pm

Postby schlenkwad » Wed Dec 10, 2014 6:07 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.
  1. \documentclass[fleqn]{article}
  2. \usepackage{amsmath}
  3. \setlength{\mathindent}{0pt}
  4. \begin{document}
  5. \section{Test}
  6.  
  7. \begin{equation}
  8. \text{left hand text}\qquad\qquad\qquad\qquad\qquad y = f(x)
  9. \end{equation}
  10. \end{document}
Attachments
equationTest.tex
(222 Bytes) Downloaded 92 times

User avatar
Johannes_B
Site Moderator
Posts: 3805
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Wed Dec 10, 2014 6:25 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.

schlenkwad
Posts: 4
Joined: Wed Dec 10, 2014 2:13 pm

Postby schlenkwad » Wed Dec 10, 2014 7:33 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.

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

Postby Stefan Kottwitz » Wed Dec 10, 2014 8:15 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:

  1. \documentclass{article}
  2. \usepackage{amsmath}
  3. \begin{document}
  4. \section{Test}
  5. \begin{flalign}
  6. \text{It follows that } && y &= f(x) &
  7. \end{flalign}
  8. \end{document}


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

Stefan
Site admin

User avatar
Johannes_B
Site Moderator
Posts: 3805
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Wed Dec 10, 2014 8:19 pm

\intertext and \shortintertext from amsmath are meant for that.
  1. \documentclass{article}
  2. \usepackage{mathtools}
  3. \usepackage{blindtext}
  4. \begin{document}
  5. \section{Test}
  6. \blindtext
  7. \begin{gather}
  8. E = mcc
  9. \shortintertext{it follows that }
  10. y = f(x)
  11. \end{gather}
  12. \blindtext
  13. \begin{gather}
  14. E = mcc
  15. \intertext{it follows that }
  16. y = f(x)
  17. \end{gather}
  18. \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

Postby schlenkwad » Wed Dec 10, 2014 8:22 pm

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: 3805
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Wed Dec 10, 2014 9:12 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.


Return to “Math & Science”

Who is online

Users browsing this forum: No registered users and 8 guests