1

First time posting here, let me know if I can make the question clearer/better. Below is a simple example of what I'm trying to accomplish.

\documentclass{article}
\usepackage{amsmath} 

\begin{document}

\begin{alignat*}{2}
y_{ijk} \sim N(&\theta_{ijk}, se_{ijk}) \\ 
&\downarrow && \\
&\theta_{ijk} = &&\beta_{1ij} t_{ijk}^{p_1}  \\
& &&\downarrow \\
& &&\beta_{1ij}
\end{alignat*}

\end{document}

Hierarchical model

I'm hoping to move the \beta_{1ij} t_{ijk}^{p_1} term to its normal positioning next to the equals sign. This is tantamount to aligning it with the subscripts on se_{ijk}. I understand that I could align it with se, however this would alter its natural spacing, causing essentially the same problem. Even if it is possible to align with the subscript using &&, one would have to spend a great deal of time searching for the exact letter with which to align each time one wanted to start a new alignment at a letter that has text above it.

Is there a natural way to accomplish such a thing? Specifically,

  1. Is it possible to end old alignments and start new ones within an alignat environment? (I suspect the answer here is no.)

or

  1. Is it possible to align in a "ragged array" of sorts, so that new alignments don't necessarily have to follow the old ones? That is, is there a way to start new alignments where the text below aligns but the text above does not necessarily have to align?

I've spent a good deal of fooling around with tikz, but I would prefer to align objects vertically, and ultimately it seems to lead back to the same issue presented here. Thanks for any help here!

2 Answers 2

1

I think you're best served with old chap array:

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{equation*}
\setlength{\arraycolsep}{0pt}
\renewcommand{\arraystretch}{1.2}
\begin{array}{rclcl}
y_{ijk} \sim N( & \theta_{ijk} & \multicolumn{2}{l}{, se_{ijk})} \\
&\downarrow \\
&\theta_{ijk} & {}={} & \beta_{1ij} & t_{ijk}^{p_1}  \\
&&&\downarrow \\
&&&\beta_{1ij}
\end{array}
\end{equation*}

\end{document}

enter image description here

Some more work is needed in order to get vertically aligned subscripts:

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{equation*}
\setlength{\arraycolsep}{0pt}
\renewcommand{\arraystretch}{1.2}
\newcommand{\fs}{^{\vphantom{p_1}}}
\begin{array}{rclcl}
y\fs_{ijk} \sim N( & \theta\fs_{ijk} & \multicolumn{2}{l}{, se\fs_{ijk})} \\
&\downarrow \\
&\theta\fs_{ijk} & {}={} & \beta\fs_{1ij\vphantom{k}} & t_{ijk}^{p_1}  \\
&&&\downarrow \\
&&&\beta\fs_{1ij}
\end{array}
\end{equation*}

\end{document}

enter image description here

0

Here are two solutions, with a better alignment of the \downarrow thanks to the eqparbox package. One solution uses the alignat*environment combined with the \mathlap command from mathtools, the other one uses an aligned environment nest in a simple align*:

\documentclass{article}
\usepackage{mathtools}
\usepackage{eqparbox}
 \newcommand\eqmathbox[2][M]{\eqmakebox[M#1]{$\displaystyle#2$}}

\begin{document}

\begin{align*}
  y_{ijk} ∼ N(&\eqmathbox[1]{\theta_{ijk}}, se_{ijk}) \\
  &\eqmathbox[1]{\downarrow} \\
    & \theta_{ijk} =\! \begin{aligned}[t] & \eqmathbox[2]{\beta_{1ij}} t_{ijk}^{p₁} \\
  &\eqmathbox[2]{\downarrow} \\
  &\beta_{1ij}
  \end{aligned}
\end{align*}

\begin{alignat*}{2}
  y_{ijk} ∼ N(&\mathrlap{\eqmathbox[1]{\theta_{ijk}}, se_{ijk})} \\
    & \eqmathbox[1]{\downarrow} & & \\
    & \theta_{ijk} ={} & & \eqmathbox[2]{\beta_{1ij}} t_{ijk}^{p₁} \\
    & & & \eqmathbox[2]{\downarrow} \\
    & & & \beta_{1ij}
\end{alignat*}

\end{document} 

enter image description here

You must log in to answer this question.

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