方程间距和对齐

方程间距和对齐

有人能帮我在方程环境中正确对齐公式吗?我无法在它们之间留出空格,无法对齐冒号,也无法在水平对齐方面让较小的方程位于较长方程的中间。有没有一种相对简单的方法,不需要几十行花哨的序言代码?

\documentclass[a4paper,oneside,abstracton]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}                     %Schriftsatz Dokument
\usepackage{lmodern}                         %use this package in combination with [T1]{fontenc} wo have vector-graphics letters instead of pixelated letters
\usepackage[english]{babel}  
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{amsfonts}
\usepackage{amsbsy}
\usepackage{latexsym}

\begin{document}
\begin{equation}
%Master Dark[Bias]
\left.\begin{aligned}
\text{odd pixel values \textit{n}:& \textbf{Dark}[Bias]$_{\frac{n+1}{2}}$} \\
\text{even pixel values \textit{n}:& $\dfrac{1}{2}$\Big(\textbf{Dark}[Bias]$_{\frac{n}{2}} +$ \textbf{Dark}[Bias]$_{\frac{n}{2}+1}$\Big)} 
\end{aligned}
\right\}
= \text{Master-\textbf{Dark}[Bias]} \nonumber \\
%Master Dark-Flat[Bias]
\left.\begin{aligned}
\text{odd pixel values \textit{n}:& $\mathrm{\mathbf{{Dark}_{Flat}}}$[Bias]$_{\frac{n+1}{2}}$} \\
\text{even pixel values \textit{n}:& $\dfrac{1}{2}$\Big($\mathrm{\mathbf{{Dark}_{Flat}}}$[Bias]$_{\frac{n}{2}} + \mathrm{\mathbf{{Dark}_{Flat}}}$[Bias]$_{\frac{n}{2}+1}$\Big)} 
\end{aligned}
\right\}
= \text{Master-$\mathrm{\mathbf{{Dark}_{Flat}}}$[Bias]} \nonumber
\end{equation}
\end{document}

答案1

您的问题在说明您真正想要对齐的内容时有点不清楚,但您可以这样做:

如果您只希望“小”和“长”公式在 1 个方程中水平居中,我认为最简单的方法是使用环境array而不是aligned环境。

也许aligned也有可能,但是(尽管这很接近:https://tex.stackexchange.com/a/38442/46716),我不知道如何在公式的右侧(中的第二列aligned)获得水平居中对齐。

事实就是如此array

\begin{align*}
    \left.
    \begin{array}{rc}
        \text{odd pixel values } n: & \mathbf{Dark}\mathrm{[Bias]}_\frac{n+1}{2} \\
        \text{even pixel values } n: & \dfrac{1}{2}\left(\mathbf{Dark}\mathrm{[Bias]}_\frac{n}{2} + \mathbf{Dark}\mathrm{[Bias]}_{\frac{n}{2}+1}\right) \\
    \end{array}
    \right\} &= \mathrm{Master-}\mathbf{Dark}\mathrm{[Bias]} \\
    \\
    \left.
    \begin{array}{rc}
        \text{odd pixel values } n: & \mathbf{Dark}_\mathbf{flat}\mathrm{[Bias]}_\frac{n+1}{2} \\
        \text{even pixel values } n: & \dfrac{1}{2}\left(\mathbf{Dark}_\mathbf{flat}\mathrm{[Bias]}_\frac{n}{2} + \mathbf{Dark}_\mathbf{flat}\mathrm{[Bias]}_{\frac{n}{2}+1}\right) \\
    \end{array}
    \right\} &= \mathrm{Master-}\mathbf{Dark}_\mathbf{flat}\mathrm{[Bias]} \\
\end{align*}

如果您希望两个方程式也对齐,请使用以下blkarray包:

\begin{blockarray}{rc}
    \begin{block}{rc\Right{\}}{= Master-\textbf{Dark}[Bias]}}
        odd pixel values $n$ : & \textbf{Dark}[Bias]$_\frac{n+1}{2}$ \\
        even pixel values $n$ : & $\dfrac{1}{2}\left(\mathbf{Dark}\mathrm{[Bias]}_\frac{n}{2} + \mathbf{Dark}\mathrm{[Bias]}_{\frac{n}{2}+1}\right)$ \\
    \end{block}
    & \\
    \begin{block}{rc\Right{\}}{= Master-\textbf{Dark}$_\mathbf{flat}$[Bias]}}
        odd pixel values $n$ : & \textbf{Dark}$_\mathbf{flat}$[Bias]$_\frac{n+1}{2}$ \\
        even pixel values $n$ : & $\dfrac{1}{2}\left(\mathbf{Dark}_\mathbf{flat}\mathrm{[Bias]}_\frac{n}{2} + \mathbf{Dark}_\mathbf{flat}\mathrm{[Bias]}_{\frac{n}{2}+1}\right)$ \\
    \end{block}
\end{blockarray}

看一下这个 MWE 来发现区别:

在此处输入图片描述

\documentclass{article} 
\usepackage{amsmath}
\usepackage{blkarray}

\begin{document}

\begin{align*}
    \left.
    \begin{array}{rc}
        \text{odd pixel values } n: & \mathbf{Dark}\mathrm{[Bias]}_\frac{n+1}{2} \\
        \text{even pixel values } n: & \dfrac{1}{2}\left(\mathbf{Dark}\mathrm{[Bias]}_\frac{n}{2} + \mathbf{Dark}\mathrm{[Bias]}_{\frac{n}{2}+1}\right) \\
    \end{array}
    \right\} &= \mathrm{Master-}\mathbf{Dark}\mathrm{[Bias]} \\
    \\
    \left.
    \begin{array}{rc}
        \text{odd pixel values } n: & \mathbf{Dark}_\mathbf{flat}\mathrm{[Bias]}_\frac{n+1}{2} \\
        \text{even pixel values } n: & \dfrac{1}{2}\left(\mathbf{Dark}_\mathbf{flat}\mathrm{[Bias]}_\frac{n}{2} + \mathbf{Dark}_\mathbf{flat}\mathrm{[Bias]}_{\frac{n}{2}+1}\right) \\
    \end{array}
    \right\} &= \mathrm{Master-}\mathbf{Dark}_\mathbf{flat}\mathrm{[Bias]} \\
\end{align*}

\vspace*{2cm}

\begin{blockarray}{rc}
    \begin{block}{rc\Right{\}}{= Master-\textbf{Dark}[Bias]}}
        odd pixel values $n$ : & \textbf{Dark}[Bias]$_\frac{n+1}{2}$ \\
        even pixel values $n$ : & $\dfrac{1}{2}\left(\mathbf{Dark}\mathrm{[Bias]}_\frac{n}{2} + \mathbf{Dark}\mathrm{[Bias]}_{\frac{n}{2}+1}\right)$ \\
    \end{block}
    & \\
    \begin{block}{rc\Right{\}}{= Master-\textbf{Dark}$_\mathbf{flat}$[Bias]}}
        odd pixel values $n$ : & \textbf{Dark}$_\mathbf{flat}$[Bias]$_\frac{n+1}{2}$ \\
        even pixel values $n$ : & $\dfrac{1}{2}\left(\mathbf{Dark}_\mathbf{flat}\mathrm{[Bias]}_\frac{n}{2} + \mathbf{Dark}_\mathbf{flat}\mathrm{[Bias]}_{\frac{n}{2}+1}\right)$ \\
    \end{block}
\end{blockarray}

\end{document}

答案2

不太确定你想要什么,但运行起来没有错误

在此处输入图片描述

\documentclass[a4paper,oneside,abstracton]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}                     %Schriftsatz Dokument
\usepackage{lmodern}                         %use this package in combination with [T1]{fontenc} wo have vector-graphics letters instead of pixelated letters
\usepackage[english]{babel}  
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{amsfonts}
\usepackage{amsbsy}
\usepackage{latexsym}

\newcommand\B{[\mathrm{bias}]}
\newcommand\D{\mathbf{Dark}}
\newcommand\F{_\mathrm{flat}}

\begin{document}
\begin{align*}
%Master Dark[Bias]
\left.\begin{aligned}
\text{odd pixel values $n$}&: 
\D\B_{\frac{n+1}{2}} \\
\text{even pixel values $n$}&:
 \dfrac{1}{2}\Bigl(\D\B_{\frac{n}{2}} + \D\B_{\frac{n}{2}+1}\Bigr)
\end{aligned}
\right\}
&= \text{Master-}\D\B\\[\jot]
%Master Dark-Flat\B
\left.\begin{aligned}
\text{odd pixel values $n$}&:
 \D\F\B_{\frac{n+1}{2}} \\
\text{even pixel values $n$}&:
 \dfrac{1}{2}\Bigl(\D\F\B_{\frac{n}{2}} + \D\F\B_{\frac{n}{2}+1}\Bigr)
\end{aligned}
\right\}
&= \text{Master-}\D\F\B
\end{align*}
\end{document}

答案3

以下解决方案在一个环境中使用两个drcases环境(由包提供mathtoolsalign*

在此处输入图片描述

\documentclass[a4paper,oneside,abstracton]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}  
\usepackage{lmodern}   
\usepackage[english]{babel}  
\usepackage{mathtools}
\newcommand\DB{\text{\textbf{Dark}[Bias]}}
\newcommand\DFB{\text{\textbf{Dark$_{\textbf{Flat}}$}[Bias]}}
\begin{document}
\begin{align*}
&\begin{drcases}
 \text{odd pixel values $n$:}&  \DB_{\frac{n+1}{2}} \\
 \text{even pixel values $n$:}& \frac{1}{2} \Bigl(\DB_{\frac{n}{2}} + \DB_{\frac{n}{2}+1}\Bigr)
\end{drcases}
= \text{Master-}\DB \\[3ex]
&\begin{drcases}
 \text{odd pixel values $n$:}&  \DFB_{\frac{n+1}{2}} \\
 \text{even pixel values $n$:}& \frac{1}{2}\Bigl(\DFB_{\frac{n}{2}} + \DFB_{\frac{n}{2}+1}\Bigr) 
\end{drcases}
= \text{Master-}\DFB 
\end{align*}
\end{document}

相关内容