为什么左花括号会影响 flalign 对齐?

为什么左花括号会影响 flalign 对齐?

我有一篇很长的文字评论了几组简短的方程式。这导致我遇到一些我想更好地处理的演示限制:

  • 将方程组向左对齐(页面中心的短文本不好看),
  • 将方程组与集合之间的“=”符号对齐。这迫使我基于 align、alignat 或 flalign 进行构建,因为我无法使用(短)intertext(据我所知)中断数组,
  • 我需要用左花括号开始方程组。我使用“dcases”,但从未让它在“alignat”中发挥作用(据我所知)

在我的 MWE 中,第三个示例给出了我预期的结果。但是,当我添加左花括号时,LaTeX 会在“=”符号前添加一个奇怪的空格。知道这是怎么回事吗?

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{luainputenc}    % WARNING: Source UTF8-encoded

\usepackage{amsmath}%,amssymb}
%\usepackage{eqparbox,xintexpr}
\usepackage{mathtools} % dcases

\begin{document}

{\bf'align' means centered on '='}
\begin{align*}
\cos\theta_1 \cos\theta_2-\sin\theta_1\sin\theta_2 &= \cos(\theta_1 +\theta_2) \\
\sin\theta_1 \cos\theta_2 + \cos\theta_1 \sin\theta_2 &= \sin(\theta_1+\theta_2)
\end{align*}
{\bf'flalign' means flushed to left and aligned on '='}
\begin{flalign*}
\cos\theta_1 \cos\theta_2-\sin\theta_1\sin\theta_2 &= \cos(\theta_1 +\theta_2) &\\
\sin\theta_1 \cos\theta_2 + \cos\theta_1 \sin\theta_2 &= \sin(\theta_1+\theta_2) &% Need tailing alignment char to get all the way left
\end{flalign*}
{\bf'flalign' with a compliant indentation}
\begin{flalign*}
\hspace{\parindent}\cos\theta_1 \cos\theta_2-\sin\theta_1\sin\theta_2 &= \cos(\theta_1 +\theta_2) &\\
\hspace{\parindent}\sin\theta_1 \cos\theta_2 + \cos\theta_1 \sin\theta_2 &= \sin(\theta_1+\theta_2) &% Need tailing alignment char to get all the way left
\end{flalign*}
{\bf'In 'flalign', curly brackets have an indentation impact on '='?}
\begin{flalign*}% 
\hspace{\parindent}&\begin{dcases}
\cos\theta_1 \cos\theta_2-\sin\theta_1\sin\theta_2&=\cos(\theta_1 +\theta_2)\\
\sin\theta_1 \cos\theta_2 + \cos\theta_1 \sin\theta_2&=\sin(\theta_1+\theta_2)
\end{dcases}&
\end{flalign*}

\end{document}

在此处输入图片描述

答案1

您可以使用fleqn选项来获得左对齐。dcases在设计上添加了一个四边形空间,但是该包提供了\newcases定义类似的命令,而不需要该命令:

在此处输入图片描述

\documentclass[fleqn]{article}% flush left equations
\usepackage[T1]{fontenc}
% it is best to avoid this unless you really need it \usepackage[utf8]{luainputenc}    % WARNING: Source UTF8-encoded

\usepackage{amsmath}%,amssymb}
%\usepackage{eqparbox,xintexpr}
\usepackage{mathtools} % dcases

\makeatletter
% a copy of dcases but without \quad in the second argument
% and with {} at the start of the second column so &= gets relation space like align
\newcases{dcasesnoquad}{}{%
  $\m@th\displaystyle{##}$\hfil}{$\m@th\displaystyle{{}##}$\hfil}{\lbrace}{.}
\makeatother

\begin{document}

Left aligned alignment
\begin{align*}
\cos\theta_1 \cos\theta_2-\sin\theta_1\sin\theta_2 &= \cos(\theta_1 +\theta_2) \\
\sin\theta_1 \cos\theta_2 + \cos\theta_1 \sin\theta_2 &= \sin(\theta_1+\theta_2)
\end{align*}

dcases
\[
\begin{dcasesnoquad}
\cos\theta_1 \cos\theta_2-\sin\theta_1\sin\theta_2&=\cos(\theta_1 +\theta_2)\\
\sin\theta_1 \cos\theta_2 + \cos\theta_1 \sin\theta_2&=\sin(\theta_1+\theta_2)
\end{dcasesnoquad}
\]

\end{document}

答案2

另外两个解决方案:一个使用empheqflalign*,另一个使用fleqn 来自nccmath& 的环境dcases

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[showframe]{geometry}
\usepackage{nccmath}
\usepackage{empheq} %

\begin{document}
\vspace*{1cm}

\begin{empheq}[left=\hspace{\parindent}\empheqlbrace]{flalign*}%
\cos\theta_1 \cos\theta_2-\sin\theta_1\sin\theta_2&=\cos(\theta_1 +\theta_2) & & \\
\sin\theta_1 \cos\theta_2 + \cos\theta_1 \sin\theta_2&=\sin(\theta_1+\theta_2)
\end{empheq}

\begin{fleqn}[\parindent]
\[ \begin{dcases}
\cos\theta_1 \cos\theta_2-\sin\theta_1\sin\theta_2=\cos(\theta_1 +\theta_2) \\
\sin\theta_1 \cos\theta_2 + \cos\theta_1 \sin\theta_2=\sin(\theta_1+\theta_2)
\end{dcases} \]
\end{fleqn}

\end{document}

在此处输入图片描述

答案3

您不需要使用dcases左花括号。您可以在之前使用 ˙\left{˙aligned或通过使用获得类似的结果empheq

\documentclass[fleqn]{article}
%--------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%
\usepackage{lipsum}                             % for dummy text
%---------------------------------------------------------------%

\usepackage[T1]{fontenc}
\usepackage{amsmath, empheq}
 
\begin{document}
\textbf{With 'align*'}
    \begin{align*}
        \cos\theta_1 \cos\theta_2 - \sin\theta_1 \sin\theta_2 &= \cos(\theta_1 + \theta_2) \\
        \sin\theta_1 \cos\theta_2 + \cos\theta_1 \sin\theta_2 &= \sin(\theta_1 + \theta_2)
    \end{align*}

\textbf{With 'aligned'}
\[
    \left\{\begin{aligned}
        \cos\theta_1 \cos\theta_2 - \sin\theta_1 \sin\theta_2   & = \cos(\theta_1 + \theta_2)\\
        \sin\theta_1 \cos\theta_2 + \cos\theta_1 \sin\theta_2   & = \sin(\theta_1 + \theta_2)
    \end{aligned}\right.  
\]

\textbf{With 'empheq'}
    \begin{empheq}[left=\empheqlbrace]{align*}
        \cos\theta_1 \cos\theta_2-\sin\theta_1\sin\theta_2      & = \cos(\theta_1 + \theta_2)\\
        \sin\theta_1 \cos\theta_2 + \cos\theta_1 \sin\theta_2   & = \sin(\theta_1 + \theta_2)
    \end{empheq}
\end{document}

在此处输入图片描述

(红线表示测试边界)

编辑:第一次尝试时,我误解了方程式应该在哪里。现在这个问题已经得到纠正(这样我的答案就变得与其他答案更相似了……)

相关内容