Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I would like to have the same result that the figure below (with others variables of course):

enter image description here

I tried this code and it worked well, but for me it is not the right way to do because I need the numbering for each equation as it is possible to have with an align environment. The code I used is as follows and as you can see, the code is too huge. I was wondering if it is possible to reduce it to an align environment or another simple way to work with \underbrace {}? ..

\documentclass{article}
\usepackage{amsmath}
\usepackage{mathtools}

\begin{document}
\[
\underbrace{
\begin{array}{c}
z_1 \\[0.2cm]
z_2 \\[0.2cm]
z_3 \\[0.2cm] 
z_4
\end{array}}_\text{Measurements}
\begin{array}{c}
= \\[0.2cm] 
= \\[0.2cm] 
= \\[0.2cm]
=
\end{array}
\underbrace{
\begin{array}{c}
h_1\left(x_1, x_2, x_3, x_4\right) \\[0.2cm] 
h_2\left(x_1, x_2, x_3, x_4\right) \\[0.2cm] 
h_3\left(x_1, x_2, x_3, x_4\right) \\[0.2cm] 
h_4\left(x_1, x_2, x_3, x_4\right) 
\end{array}}_\text{True values from system model}
\begin{array}{c}
+ \\[0.2cm] 
+ \\[0.2cm] 
+ \\[0.2cm] 
+
\end{array}
\underbrace{
\begin{array}{c}
e_1 \\[0.2cm] 
e_2 \\[0.2cm] 
e_3 \\[0.2cm] 
e_4
\end{array}}_\text{Errors}
\]
\end{document}

Thank you, in advance for your helps.

share|improve this question

2 Answers 2

up vote 4 down vote accepted

I'm not really sure either of the solutions are really satisfying; I'd probably write outside the alignment the meaning of the symbols. Anyway, here's it:

\documentclass{article}
\usepackage{amsmath}
\usepackage{mathtools,calc}

% for the align solution
\newcommand{\fakeunderbrace}[3]{%
  \mathmakebox[\widthof{$\underbrace{#3}_{#1}$}]{\;#2}%
}
\newcommand{\fuba}[1]{%
  \fakeunderbrace{\text{Measurements}}{#1}{\qquad\qquad}%
}
\newcommand{\fubb}[1]{%
  \fakeunderbrace{\substack{\text{True values from}\\\text{system model}}}
  {#1}{\,h_4(x_1, x_2, x_3, x_4)\,}%
}
\newcommand{\fubc}[1]{%
  \fakeunderbrace{\text{Errors}}{#1}{\qquad\qquad}%
}

% for the alignat solution
\newcommand{\fw}[2]{\mathmakebox[\widthof{$#1$}]{#2}}
\newcommand{\fwa}[1]{\fw{\substack{\text{Measurements}}}{#1}}
\newcommand{\fwb}[1]{\fw{\quad h_1(x_1,x_2,x_3,x_4)\quad}{#1}}
\newcommand{\fwc}[1]{\fw{\substack{\text{Errors}}}{#1}}

\begin{document}
\begin{align}
\fuba{z_1} &= \fubb{h_1(x_1, x_2, x_3, x_4)} + \fubc{e_1} \\
\fuba{z_2} &= \fubb{h_2(x_1, x_2, x_3, x_4)} + \fubc{e_2} \\
\fuba{z_3} &= \fubb{h_3(x_1, x_2, x_3, x_4)} + \fubc{e_3} \\
\fuba{z_4} &= \fubb{h_4(x_1, x_2, x_3, x_4)} + \fubc{e_4} \\[-.8\baselineskip]
\underbrace{\qquad\qquad}_{\text{Measurements}} &\hphantom{{}={}}
\underbrace{\mathmakebox[\widthof{$h_1(x_1, x_2, x_3, x_4)$}]{}}%
  _{\substack{\text{True values from}\\\text{system model}}}
\hphantom{\;+\;} \underbrace{\qquad\qquad}_{\text{Errors}}\nonumber
\end{align}

\begin{alignat}{2}
\substack{\text{Measurements}} 
& \hphantom{{}={}}
\fwb{\substack{\text{True values from}\\\text{system model}}}
&& \hphantom{{}+{}}
\fwc{\substack{\text{Errors}}} \nonumber \\
\fwa{z_1} &= \fwb{h_1(x_1, x_2, x_3, x_4)} &&+ \fwc{e_1} \\
\fwa{z_2} &= \fwb{h_2(x_1, x_2, x_3, x_4)} &&+ \fwc{e_2} \\
\fwa{z_3} &= \fwb{h_3(x_1, x_2, x_3, x_4)} &&+ \fwc{e_3} \\
\fwa{z_4} &= \fwb{h_4(x_1, x_2, x_3, x_4)} &&+ \fwc{e_4} 
\end{alignat}

\end{document}

enter image description here

share|improve this answer
    
Thank you so much. –  yond4im Jul 26 at 11:21
    
Could you explain the different \newcommand for align solution. I don't know how is it worked exactly ? –  yond4im Jul 26 at 11:49
1  
@yond4im I first define a “generic” command to make a box that's as wide as the underbrace for #3, with subscript #1, containing #2, centered. Then I define shorthands for each column, in order not to clobber the code. –  egreg Jul 26 at 12:33

Here is a slightly less-calculated way, but it works:

enter image description here

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{alignat}{3}
  z_1\qquad &= h_1\bigl(x_1, x_2, x_3, x_4\bigr) && + \enspace e_1 \\
  z_2\qquad &= h_2\bigl(x_1, x_2, x_3, x_4\bigr) && + \enspace e_2 \\
  z_3\qquad &= h_3\bigl(x_1, x_2, x_3, x_4\bigr) && + \enspace e_3 \\
  z_4\qquad &= h_4\bigl(x_1, x_2, x_3, x_4\bigr) && + \enspace e_4 \\[-.5\normalbaselineskip]
  \underbrace{\hphantom{zzzzzzz}}_{\text{Measurements}} &
  \phantom{{}=}\underbrace{\hphantom{h_4\bigl(x_1, x_2, x_3, x_4\bigr)}}_{\text{\shortstack{True values from \\ system model}}} &&
  \phantom{+}\underbrace{\hphantom{eeeeee}}_{\text{Errors}} \nonumber
\end{alignat}

\end{document}
share|improve this answer
    
thank you so much as well :) –  yond4im Jul 26 at 11:22

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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