如何将 amsmath 方程标签移至 LHS 边缘?

如何将 amsmath 方程标签移至 LHS 边缘?

我正在使用 amsmath,我想将方程标签移动到与方程顶部对齐的左侧边缘。我查看了文档,但没有找到有关标签位置的任何信息。请告诉我如何执行此操作,或者更好地告诉我在哪里可以找到这些信息。此外,如果 LaTeX 默认这样做是有原因的,请告诉我原因。

一个小问题,你如何让标签写成 Eq(1.1) 而不是 (1.1)

编辑(1):

当前方程如下所示: 在此处输入图片描述

编辑(2):根据egregs的建议:

\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}

为了获得以下内容:

在此处输入图片描述

这看起来好多了,所以最后一个问题是否有任何方法可以让等式中的标签读取 Eq.2.2,或者有什么充分的理由说明为什么我不应该这样做

答案1

如需添加,Eq.请使用cleveref。如需在边距中添加方程式编号:

\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}

但请不要这么做。

在此处输入图片描述

但是,我认为您的问题属于“XY 问题”。您给出的示例方程应该用 来处理split,而不是通过增加边距中的数字来处理。

\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}

在此处输入图片描述

这是另一个版本,其中Eq.在方程式编号中也添加了 。我永远不会在文档中使用它;图形和表格是不同的东西:“图形”和“表格”在标题中用作相对于它们引用的对象的标识符;对于方程式来说,数字的含义是完全清楚的。

\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}

在此处输入图片描述

相关内容