4

I am using amsmath and I would like to move the equation label into the left hand side margin aligned with the top of the equation. I have looked through the documentation but I can't find anything on label position. Please could let me know how to do this, or even better where to find the information. Also if there is a reason that LaTeX does this as default then could let me know why.

As a small side question how do you get the label to say Eq(1.1) rather than (1.1)

EDIT(1):

Currently equation looks as following: enter image description here

EDIT(2): Based on egregs advice used:

\begin{equation}
\begin{split}
\text{P(consequence)} & =  \text{P(hazard occuring)}
                     \\& \times \text{P(exposure of agent|hazard occuring)} 
                    \\& \times \text{E(Damage|hazard and exposure)} 
\end{split}
\end{equation}

To gain the following:

enter image description here

This looks much nicer, so last question is there any way to get the label in the equation to read Eq.2.2 or is there a good reason for why I shouldnt do this

10
  • 1
    \usepackage[leqno]{amsmath}?
    – egreg
    Commented Apr 24, 2015 at 8:56
  • @egreg so its on the LHS now, but do you know how to get it into the margin rather than in the text body?
    – PaulBarr
    Commented Apr 24, 2015 at 8:58
  • \renewcommand{\theequation}{Eq(\thesection.\arabic{equation})} to get Eq(1.1) Commented Apr 24, 2015 at 9:11
  • 1
    \eqref is for references, not for the direct equation number output at the equation. I thought you want to change the reference too.
    – user31729
    Commented Apr 24, 2015 at 9:27
  • 1
    Oh ok, I use cref so I think that does it automatically. Thanks!
    – PaulBarr
    Commented Apr 24, 2015 at 9:29

1 Answer 1

5

For adding Eq. use cleveref. For the equation numbers in the margin:

\documentclass[leqno]{article}
\usepackage{amsmath}
\usepackage{etoolbox}
\usepackage{lipsum}

\makeatletter
% detach \eqref processing from \tag processing
\let\tagform@ref\tagform@
\let\maketag@@@ref\maketag@@@
\patchcmd{\eqref}{\tagform@}{\tagform@ref}{}{}
\patchcmd{\tagform@ref}{\maketag@@@}{\maketag@@@ref}{}{}
% redefine \maketag@@@
\def\maketag@@@#1{\llap{\m@th\normalfont#1\quad}\kern1sp}
\makeatother

\begin{document}

\lipsum*[2]
\begin{align}
X&=Y\\
Z+Z'&=W
\end{align}
\lipsum*[3]
\begin{equation}\label{x}
a+b=c
\end{equation}
Now we cite equation \eqref{x} to see all's right.

\end{document}

But don't do it, please.

enter image description here

However, I believe yours is an “XY question”. The example equation you show should be treated with split, not by pushing the number in the margin.

\documentclass[leqno]{article}
\usepackage[tbtags]{amsmath}
\usepackage{etoolbox}
\usepackage{cleveref}

\usepackage{lipsum} % this is just for mock text

\DeclareMathOperator{\prob}{P}
\DeclareMathOperator{\expec}{E}
\newcommand{\tevent}[1]{\textup{#1}}
\crefname{equation}{Eq.}{Eqs.}

\begin{document}

\lipsum*[2]
\begin{equation}\label{x}
\begin{split}
\prob(\tevent{consequence})={}
  & \prob(\tevent{hazard occurring}) \\
  & \times \prob(\tevent{exposure of agent}\mid\tevent{hazard occurring}) \\
  & \times \expec(\tevent{damage}\mid\tevent{hazard and exposure})
\end{split}
\end{equation}
Here we cite the equation: \cref{x}.
\end{document}

enter image description here

Here's a further version where Eq. is added also in the equation number. I'd never use this in a document; figures and tables are a different thing: “Figure” and “Table” are used in the caption as identifiers with respect to the object they refer to; for equations it's completely clear what the number is about.

\documentclass[leqno]{article}
\usepackage[tbtags]{amsmath}
\usepackage{etoolbox}
\usepackage{cleveref}

\usepackage{lipsum} % this is just for mock text

\makeatletter
% detach \eqref processing from \tag processing
\let\tagform@ref\tagform@
\let\maketag@@@ref\maketag@@@
\patchcmd{\eqref}{\tagform@}{\tagform@ref}{}{}
\patchcmd{\tagform@ref}{\maketag@@@}{\maketag@@@ref}{}{}
% redefine \tagform@
\def\tagform@#1{\maketag@@@{(Eq.\ \ignorespaces#1\unskip\@@italiccorr)}}
\makeatother

\DeclareMathOperator{\prob}{P}
\DeclareMathOperator{\expec}{E}
\newcommand{\tevent}[1]{\textup{#1}}
\crefname{equation}{Eq.}{Eqs.}

\begin{document}

\lipsum*[2]
\begin{equation}\label{x}
\begin{split}
\prob(\tevent{consequence})={}
  & \prob(\tevent{hazard occurring}) \\
  & \times \prob(\tevent{exposure of agent}\mid\tevent{hazard occurring}) \\
  & \times \expec(\tevent{damage}\mid\tevent{hazard and exposure})
\end{split}
\end{equation}
Here we cite the equation: \cref{x}.
\end{document}

enter image description here

1
  • Thank you for your answer and explaining your reasoning for why things shouldn't be done. I am in the process of learning Latex hence I want to try out different things and learn from your code what you did. Its also much easier to learn what to do if you know why some things shouldnt be done. Cheers
    – PaulBarr
    Commented Apr 24, 2015 at 13:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .