Math & ScienceNumbering in-line Equations

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
pottertl
Posts: 7
Joined: Wed Jan 05, 2011 10:33 pm

Numbering in-line Equations

Post by pottertl »

I'm creating a document where I want to be able to do three things:
  1. equation numbers for in-line math
  2. equations numbers for regular math
  3. comments in the right margin
I'd also like to have some control over the numbering, especially for the in-line math (i. e. I don't want all in-line math numbered, only what I select).

Is there any way I can do all three of these things together and make the document look professional? Let me know, thanks!

Recommended reading 2024:

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

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Numbering in-line Equations

Post by frabjous »

Do you want (a) and (b) to use the same number sequence, or different number sequence?

I'm going to assume not, and just to keep them straight, I'll you want the inline ones to use roman numbers. Probably you just need to define a counter and some commands for them.

(b) is already built in; (c) is no problem; just use \marginpar or similar.

Here's such a document.

Code: Select all

\documentclass{article}
\usepackage{amsmath}

\newcounter{inlineequation}
\setcounter{inlineequation}{0}
\renewcommand{\theinlineequation}{(\Roman{inlineequation})}

\newcommand{\inlineeq}[1]{\refstepcounter{inlineequation}\theinlineequation\ \(#1\)}

\begin{document}
Two of the most useful results are \inlineeq{x + y = y + z}\label{comm}, and \inlineeq{x+(y+z)=(x+y)+z}\label{assoc}. The equation \ref{comm} expresses the law of commutativity, and \ref{assoc} expresses the law of associativity. From them you can infer that $x+(y+z)=z+(x+y)$. Now let us consider:\marginpar{A Comment}
\begin{equation}
x \cdot (y \cdot z) = (x \cdot y) \cdot z
\label{assocm}
\end{equation}
The result \eqref{assocm} is a lot like \ref{assoc}, except for multiplication. 
\end{document}

Post Reply