我想创建一个数学环境(最好是定制的 align/flalign 环境),其中具有左对齐/左对齐方程(因为使用 flalign 环境是可能的)和左对齐标签(而不是默认的右对齐),但使用与使用右对齐方程式和默认右对齐标签时 flalign 提供的相同的缩进处理。
我添加了一个屏幕截图和一个 MWE 以便澄清。
我将非常感激您的帮助 :-)
\documentclass[twoside]{scrbook}
\parindent0pt
\parskip6pt
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath, amssymb, enumitem, color}
\newcommand{\red}{\color{red}}
\newcommand{\set}[1]{\left\lbrace #1 \right\rbrace}
\newcommand{\script}[1]{\mathcal{#1}}
\renewcommand{\complement}{\mathcal{C}}
\makeatletter
\newenvironment{lalign}{\tagsleft@true\flalign}{\endflalign}
\makeatother
\begin{document}
\textbf{Definition} \quad ($\sigma$-field)
\begin{align}
& \Omega \in \script{A} \tag{SF1}\label{SF1} \\
& A \in \script{A} \Rightarrow \complement A \in \script{A} \tag{SF2}\label{SF2} \\
& A_1, A_2, \ldots \in \script{A} \Rightarrow \bigcup_{i=1}^\infty A_i \in \script{A} \tag{SF3}\label{SF3}
\end{align}
\textbf{Exercise} \quad Is $\script{A}$ a $\sigma$-field?
\begin{enumerate}[label=(\roman*)]
\item $\Omega$ arbitrary, $\script{A} = \set{\emptyset, \Omega}$.
\item $\ldots$
\end{enumerate}
\textbf{Solution} \quad
\begin{enumerate}[label=(\roman*)]
\item Let $\Omega$ be arbitrary and $\script{A} = \set{\emptyset, \Omega}$.
{\red It should be like this, but just the other way round:}
\begin{flalign}
&& \Omega \in \script{A} & \tag{\ref{SF1}} \\
&& \emptyset \in \script{A} \Rightarrow \complement \emptyset = \Omega \in \script{A} \tag{\ref{SF2}} \\
&& \Omega \in \script{A} \Rightarrow \complement \Omega = \emptyset \in \script{A} \notag \\
&& \emptyset, \Omega \in \script{A} \Rightarrow \emptyset \cup \Omega = \Omega \in \script{A} \tag{\ref{SF3}}
\end{flalign}
{\red This happens when I set \texttt{tagsleft@true} and use \texttt{flalign} for left-aligned equations:}
\begin{lalign}
& \Omega \in \script{A} & \tag{\ref{SF1}} \\
& \emptyset \in \script{A} \Rightarrow \complement \emptyset = \Omega \in \script{A} \tag{\ref{SF2}} \\
& \Omega \in \script{A} \Rightarrow \complement \Omega = \emptyset \in \script{A} \notag \\
& \emptyset, \Omega \in \script{A} \Rightarrow \emptyset \cup \Omega = \Omega \in \script{A} \tag{\ref{SF3}}
\end{lalign}
{\red I don't want centered equations because it should look like an enumeration:}
\begin{lalign}
& \Omega \in \script{A} \tag{\ref{SF1}} \\
& \emptyset \in \script{A} \Rightarrow \complement \emptyset = \Omega \in \script{A} \tag{\ref{SF2}} \\
& \Omega \in \script{A} \Rightarrow \complement \Omega = \emptyset \in \script{A} \notag \\
& \emptyset, \Omega \in \script{A} \Rightarrow \emptyset \cup \Omega = \Omega \in \script{A} \tag{\ref{SF3}}
\end{lalign}
{\red As it should look like (dirty coded, I want the code to be universally usable):}
\begin{lalign}
& \hspace*{1.2cm} \Omega \in \script{A} & \tag{\ref{SF1}} \\
& \hspace*{1.2cm} \emptyset \in \script{A} \Rightarrow \complement \emptyset = \Omega \in \script{A} \tag{\ref{SF2}} \\
& \hspace*{1.2cm} \Omega \in \script{A} \Rightarrow \complement \Omega = \emptyset \in \script{A} \notag \\
& \hspace*{1.2cm} \emptyset, \Omega \in \script{A} \Rightarrow \emptyset \cup \Omega = \Omega \in \script{A} \tag{\ref{SF3}}
\end{lalign}
\item $\ldots$
\end{enumerate}
\end{document}
恐怕我的问题不是 100% 清楚。因此,这里有一个新的 MWE 和屏幕截图,参考了建议使用枚举的答案。问题是:我不想制作一个独立于定义的方程标签的枚举。每个项目都应从 \ref{...} 中获取相关方程标签的名称。方程标签不能是数字。这是更新后的 MWE:
\documentclass[twoside]{scrbook}
\parindent0pt
\parskip6pt
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath, amssymb, enumitem, color}
\newcommand{\red}{\color{red}}
\newcommand{\set}[1]{\left\lbrace #1 \right\rbrace}
\newcommand{\script}[1]{\mathcal{#1}}
\renewcommand{\complement}{\mathcal{C}}
\makeatletter
\newenvironment{lalign}{\tagsleft@true\flalign}{\endflalign}
\makeatother
\begin{document}
\textbf{Definition} \quad ($\sigma$-field)
\begin{align}
& \Omega \in \script{A} \tag{SF1}\label{SF1} \\
& A \in \script{A} \Rightarrow \complement A \in \script{A} \tag{Complement}\label{SF2} \\
& A_1, A_2, \ldots \in \script{A} \Rightarrow \bigcup_{i=1}^\infty A_i \in \script{A} \tag{Union}\label{SF3}
\end{align}
\textbf{Exercise}
\begin{enumerate}[label=(\roman*)]
\item Let $\Omega$ be arbitrary and $\script{A} = \set{\emptyset, \Omega}$.
{\red It should be like this, but just the other way round:}
\begin{flalign}
&& \Omega \in \script{A} & \tag{\ref{SF1}} \\
&& \emptyset \in \script{A} \Rightarrow \complement \emptyset = \Omega \in \script{A} \tag{\ref{SF2}} \\
&& \Omega \in \script{A} \Rightarrow \complement \Omega = \emptyset \in \script{A} \notag \\
&& \emptyset, \Omega \in \script{A} \Rightarrow \emptyset \cup \Omega = \Omega \in \script{A} \tag{\ref{SF3}}
\end{flalign}
{\red This happens when I set \texttt{tagsleft@true} and use \texttt{flalign} for left-aligned equations:}
\begin{lalign}
& \Omega \in \script{A} & \tag{\ref{SF1}} \\
& \emptyset \in \script{A} \Rightarrow \complement \emptyset = \Omega \in \script{A} \tag{\ref{SF2}} \\
& \Omega \in \script{A} \Rightarrow \complement \Omega = \emptyset \in \script{A} \notag \\
& \emptyset, \Omega \in \script{A} \Rightarrow \emptyset \cup \Omega = \Omega \in \script{A} \tag{\ref{SF3}}
\end{lalign}
{\red Enumerations aren't an option, because of this false indent handling:}
\begin{enumerate}
\item[(\ref{SF1})] Enumeration with custom item label.
\end{enumerate}
\begin{enumerate}[leftmargin=*]
\item[(\ref{SF2})] Enumeration with custom item label and \texttt{leftmargin=*}
\end{enumerate}
{\red It should be more like this (but it's not the way I want to code it all the time and it isn't 100\% accurate either:}
\begin{flalign*}
&\begin{array}{ll}
(\text{\ref{SF1}}) & \Omega \in \script{A} \\
(\text{\ref{SF2}}) & \emptyset \in \script{A} \Rightarrow \complement \emptyset = \Omega \in \script{A} \\
& \Omega \in \script{A} \Rightarrow \complement \Omega = \emptyset \in \script{A} \\
(\text{\ref{SF3}}) & \emptyset, \Omega \in \script{A} \Rightarrow \emptyset \cup \Omega = \Omega \in \script{A}
\end{array}&
\end{flalign*}
\item $\ldots$
\end{enumerate}
\end{document}
答案1
当包amsmath
被加载时,会进行检查\iftagsleft@
并且更改相当多的设置。(此代码约占250行,而且相当复杂。)如果你将其应用\usepackage[leqno]{amsmath}
到你的例子,结果会大不相同,可能更像你想要的。
\iftagsleft@
通过绕过您自行调用的额外代码,在amsmath
完全消化之后,设置显示区域宽度的计算将永远不会得到正确执行。您需要考虑到这一点。
答案2
这是枚举:
\documentclass{scrbook}
\usepackage{amsmath,amssymb,amsthm,enumitem}
\theoremstyle{definition}
\newtheorem*{definition}{Definition}
\newcommand{\set}[1]{\left\lbrace #1 \right\rbrace}
\newcommand{\script}[1]{\mathcal{#1}}
\renewcommand{\complement}{\mathcal{C}}
\begin{document}
\begin{definition}[$\sigma$-field]\mbox{}
\begin{enumerate}[leftmargin=*,label=(SF\arabic*)]
\item\label{SF1} $\Omega \in \script{A}$
\item\label{SF2} $A \in \script{A} \Rightarrow \complement A \in \script{A}$
\item\label{SF3} $A_1, A_2, \dotsc \in \script{A} \Rightarrow
\bigcup_{i=1}^\infty A_i \in \script{A}$
\end{enumerate}
\end{definition}
\end{document}
我不会使用显示样式,以免破坏垂直对齐。还请注意\dotsc
(\ldots
参见https://tex.stackexchange.com/a/122497/4427)。要转到新行,只需使用\mbox{}
。
使用任意标签:
\documentclass{scrbook}
\usepackage{amsmath,amssymb,amsthm,enumitem}
\theoremstyle{definition}
\newtheorem*{definition}{Definition}
\newcommand{\script}[1]{\mathcal{#1}}
\renewcommand{\complement}{\mathcal{C}}
\ExplSyntaxOn
\NewDocumentEnvironment{axioms}{+b}
{
\par
\cs_set_eq:NN \axiom \__ternes_axioms_measure:nn
#1
\cs_set_eq:NN \axiom \__ternes_axioms_typeset:nn
\begin{enumerate}[
leftmargin=\dim_eval:n { \l__ternes_axioms_max_wd_dim + \labelsep},
labelwidth=\l__ternes_axioms_max_wd_dim,
itemindent=0pt,
]
#1
\end{enumerate}
}{}
\dim_new:N \l__ternes_axioms_max_wd_dim
\dim_new:N \l__ternes_axioms_wd_dim
\cs_new_protected:Nn \__ternes_axioms_measure:nn
{
\settowidth{\l__ternes_axioms_wd_dim}{(#1)}
\dim_set:Nn \l__ternes_axioms_max_wd_dim
{ \dim_max:nn { \l__ternes_axioms_max_wd_dim } { \l__ternes_axioms_wd_dim } }
}
\cs_new_protected:Nn \__ternes_axioms_typeset:nn
{
\renewcommand{\theenumi}{#1}
\item[(#1)]\refstepcounter{enumi} { \everymath{\displaystyle} #2 }
}
\ExplSyntaxOff
\begin{document}
\begin{definition}[$\sigma$-field]\mbox{}
\begin{axioms}
\axiom{SF1}{\label{SF1} $\Omega \in \script{A}$}
\axiom{Complement}{\label{SF2} $A \in \script{A} \Rightarrow \complement A \in \script{A}$}
\axiom{Union}{\label{SF3} $A_1, A_2, \dotsc \in \script{A} \Rightarrow
\bigcup_{i=1}^\infty A_i \in \script{A}$}
\end{axioms}
\end{definition}
The second axiom is called~\ref{SF2}.
\end{document}
答案3
如果您不介意缩进问题,而只是想使用 tag 来代替它的引用工作,那么您可以简单地重新定义\theenumi
和\labelenumi
。事实上,你说你确实介意缩进,但它可能会帮助其他人(这就是我最终来到这里的原因)。
\documentclass{article}
\usepackage{amsmath}
\newcommand\nameditem[1]{
\renewcommand{\theenumi}{#1}
\renewcommand{\labelenumi}{(\theenumi)}
\item
}
\begin{document}
\begin{enumerate}
\nameditem{SF1} $\Omega \in \mathcal{A}$\label{ax:SF1}
\nameditem{Complement} $A \in \mathcal{A} \Rightarrow \mathcal{C}(A) \in \mathcal{A}$
\nameditem{Union} $A_1, A_2, \dotsc \in \mathcal{A} \Rightarrow \bigcup_{i=1}^\infty A_i \in \mathcal{A}$
\end{enumerate}
Ref: \ref{ax:SF1}
\end{document}
打印内容:
可能有比我在这里所做的更好的替代方案,但我不确定它是什么。