3

I have the following array of equations produced by tabularx, in which I want the rows in the left and right panels to be aligned such that they look like they're written on the same line of binder paper, for example. But since the equations are apparently aligned at the very top, the tall summand symbols in the right panel lead to the following aesthetic horror:

enter image description here

How can I fix the alignment? A MWE appears below.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{tabularx}

\begin{document}

\begin{tabularx}{0.5\textwidth}{XX}
{\begin{align*}
X_{n1}^{(j)} &:= X_{n1}\\
&\vdots \\
X_{nC}^{(j)} &:= X_{nC}
\end{align*}} 
& 
{\begin{align*}
Y_{n1} &:= \widehat{\alpha}_{11} + \sum_{j=3}^C \widehat{\alpha}_{j1} X_{nj} + \epsilon_{n1}\\
&\vdots \\
Y_{nW} &:= \widehat{\alpha}_{1W} + \sum_{j=3}^C \widehat{\alpha}_{jW} X_{nj} + \epsilon_{nW}
\end{align*}} 
\end{tabularx}

\end{document}
1
  • 1
    Why do you need tabularx here?
    – Werner
    Commented Aug 29, 2018 at 21:02

3 Answers 3

4

As I don't understand why you use a tabularx environment for your equations, except perhaps to have the whole alignment near the left margin, I propose this very simple solution with alignat{2}, which displays two columns of alignment, with a controllable space between them. To have them near the leftmargin, I used the fleqn environment from nccmath (remove it if you want the equations be centred), and added some improvements from mathtools. In particular, \coloneqq which provides a :=, with the colon centred on the maths axis, and vertical dots centred w.r.t. :=:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{mathtools, nccmath}

\begin{document}

Some text. Some text. Some text. Some text. Some text. Some text. Some text. Some text. Some text. Some text. Some text. Some text.
\begin{fleqn}[2em]
\begin{alignat*}{2}
X_{n1}^{(j)} &\coloneqq X_{n1}
&\qquad Y_{n1} &\coloneqq \widehat{\alpha}_{11} + \sum_{j=3}^C \widehat{\alpha}_{j1} X_{nj} + \epsilon_{n1}\\[-1ex]
&\vdotswithin{\coloneqq} & & \vdotswithin{\coloneqq} \\[-1ex]
X_{nC}^{(j)} &\coloneqq X_{nC}
& Y_{nW} &\coloneqq \widehat{\alpha}_{1W} + \sum_{j=3}^C \widehat{\alpha}_{jW} X_{nj} + \epsilon_{nW}
\end{alignat*}
\end{fleqn}

\end{document} 

enter image description here

5

I'm not sure what's the need of tabularx in this case:

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

\begin{document}

\begin{align*}
X_{n1}^{(j)} &\coloneqq X_{n1}
&
Y_{n1} &\coloneqq \widehat{\alpha}_{11} +
  \sum_{j=3}^C \widehat{\alpha}_{j1} X_{nj} + \epsilon_{n1}
\\[-3ex]
&\vdotswithin{\coloneqq} & &\vdotswithin{\coloneqq}
\\[-2ex]
X_{nC}^{(j)} &\coloneqq X_{nC}
&
Y_{nW} &:= \widehat{\alpha}_{1W} +
  \sum_{j=3}^C \widehat{\alpha}_{jW} X_{nj} + \epsilon_{nW}
\end{align*}

\end{document}

enter image description here

1
  • You are absolutely right. In the presence of multiple correct answers, I'm accepting Bernard's since it was the first chronologically. Thanks.
    – half-pass
    Commented Aug 29, 2018 at 21:45
4

A quick fix using vphantom.

This creates a 'phantom' zero width box with a vertical height equal to the size of \sum_{j=3}^C.

enter image description here

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{tabularx}

\begin{document}

\begin{tabularx}{0.5\textwidth}{XX}
{\begin{align*}
X_{n1}^{(j)} &:= X_{n1} \vphantom{\sum_{j=3}^C}\\
&\vdots \\
X_{nC}^{(j)} &:= X_{nC} \vphantom{\sum_{j=3}^C}
\end{align*}} 
& 
{\begin{align*}
Y_{n1} &:= \widehat{\alpha}_{11} + \sum_{j=3}^C \widehat{\alpha}_{j1} X_{nj} + \epsilon_{n1}\\
&\vdots \\
Y_{nW} &:= \widehat{\alpha}_{1W} + \sum_{j=3}^C \widehat{\alpha}_{jW} X_{nj} + \epsilon_{nW}
\end{align*}} 
\end{tabularx}

\end{document}
1
  • You are absolutely right. In the presence of multiple correct answers, I'm accepting Bernard's since it was the first chronologically. Thanks.
    – half-pass
    Commented Aug 29, 2018 at 21:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .