4

Can anyone help me to properly align my formula in my equation-environment. I do not manage to make a space between them, to align them that the colons are over each other, and that the smaller equation is in the middle of the longer one in terms of horizontal alignment. Is there a relatively easy way without dozens of lines of fancy preamble coding?

\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}
  • Could you please provide a hand-drawn image showing the intended result? It would be clearer (at least for me) to see the desired result. – Gonzalo Medina Mar 2 '15 at 0:34
3

Your question is a bit unclear in stating what you actually want aligned, but here you go:

If you only want your 'small' and 'long' formulae centered horizontally in 1 equation, I presume it's easiest to use an array environment instead of an aligned environment.

Maybe aligned could be possible as well but (though this comes close: https://tex.stackexchange.com/a/38442/46716), I have no idea how to get a horizontal centered alignment in the right hand side of your formulae (second column in aligned).

So array it is:

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

If you want both your equations to be aligned as well, use the blkarray package:

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

Take a look at this MWE to see the difference:

enter image description here

\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}
  • How can these blockarray-environments be spaced? \\ and \vspace{} don't work. – Lucas Mar 2 '15 at 22:34
  • No, correction: it does work, but only with an additional "Enter" pressing. – Lucas Mar 2 '15 at 22:51
5

Not sure quite what you want but this runs without error

enter image description here

\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}
  • @ David Carlisle I used the first answer which was exactly what I was looking for. But I experience some problems when adding a new blockarray with a bunch of error messages appearing for other lines in the text where none appeared before. I will open a new question for this. – Lucas Mar 3 '15 at 11:00
  • @Lucas I really wouldn't use blkarray in a production enviornment. – David Carlisle Mar 3 '15 at 11:54
  • @ David Carlisle Ok. I try your suggested syntax as well. I will figure out how to place all : in all 4 lines above each other. But how can I center formula1 with respect to formula2 and formula3 with respect to formula4 without using \hspace{} ? – Lucas Mar 3 '15 at 12:35
4

The following solution uses two drcases environments (provided by the mathtools package) inside an align* environment.

enter image description here

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.