3

Consider this MWE:

\documentclass[preview]{standalone}

\usepackage{amsmath}

\begin{document}
    \begin{align*}
        &\phantom{\rightarrow} & \text{2nd-order mechanics} \\
        &\rightarrow & \text{non-negligible inertia} \\
        &\rightarrow & \text{directional migration} 
    \end{align*}

    \begin{align*}
        &\phantom{\rightarrow} & \text{rule: decaying persistence memory} & \\
        &+ & \text{rule: increase persistence after collision} & \\
        &\rightarrow & \text{directional migration} &
    \end{align*}
\end{document}

Output:

enter image description here

I would like the end result to look like:

    2nd-order mechanics 
--> non-negligible inertia 
--> directional migration 

    rule: decaying persistence memory  
 +  rule: increase persistence after collision  
--> directional migration 

The two examples are slightly different, because in the second environment, I would like to make sure that the \rightarrows and the + are visually centered in their environment (set justification to centered for that column)?

In both examples, I want the text itself to be left justified within its column.

How can I force this behaviour? Or am I using the wrong tool? I could use a table (for instance, see):

\documentclass[preview]{standalone}

\usepackage{amsmath}

\begin{document}
    \begin{tabular}{cl}
        $\phantom{\rightarrow}$ & 2nd-order mechanics \\ 
        $\rightarrow$ & non-negligible inertia \\
        $\rightarrow$ & directional migration  
    \end{tabular} 

    \begin{tabular}{cl}
        $\phantom{\rightarrow}$ & rule: decaying persistence memory \\ 
        $+$ & rule: decaying persistence memory \\
        $\rightarrow$ & directional migration  
    \end{tabular} 
\end{document}

enter image description here

  • First comment: The \phantom s doesn't offer something in the place it used in your code... but could offer on the centering part... Second: The symbol & is used to LEFT-align "columns" that following... You using it with a really strange way (with nothing before or after)... And because of this, it is not supposed to center any columns. So... Answer: yes! a table is a better option (since you not even have any math in there... But even if you had, this environment has really different usage)... What is your problem with the table – koleygr Jan 15 '18 at 4:54
  • Yes, you should use a tabular. – egreg Jan 15 '18 at 7:50
5

Like this?

enter image description here

\documentclass{article}
\usepackage{amsmath}
\begin{document}
    \begin{align*}
         & \text{2nd-order mechanics} \\
    \to{}& \text{non-negligible inertia} \\
    \to{}& \text{directional migration} \\[2ex]
         & \text{rule: decaying persistence memory}\\
    {}+{}& \text{rule: increase persistence after collision} \\
    \to{}& \text{directional migration}
    \end{align*}
\end{document}

Observe that the code in this answer employs only one &-based alignment point in both the upper and lower group. (In contrast, your setup features two or even three & alignment points.) Note the presence of {} -- known as an "empty math group" -- in both \to{} and {}+{}. The empty math groups are crucial for obtaining horizontal spacing that's appropriate for relational operators, such as \to (aka \rightarrow), and binary operators such as +. (To verify this, run the answer without the empty math groups and see what happens.) Finally, why is it necessary to provide two empty math groups for + but only one for \to in order to get the correct spacing? The reason is buried deep down in the way the amsmath package chose to implement its alignment operations whenever it encounters an instance of &. (If you really want to know how LaTeX handles these alignment operations, in all gory detail, please ask a new question.)


Alternatively, consider employing an array environment.

enter image description here

\documentclass{article}
\usepackage{array}
\newcolumntype{L}{>{$}l<{$}}
\newcolumntype{C}{>{{}}c<{{}}}

\begin{document}
\[
\setlength\arraycolsep{0pt}
\renewcommand\arraystretch{1.33}
\begin{array}{CL}
         & 2nd-order mechanics \\
    \to  & non-negligible inertia \\
    \to  & directional migration \\[2ex]
         & rule: decaying persistence memory\\
    +    & rule: increase persistence after collision \\
    \to  & directional migration
\end{array}
\]
\end{document}
  • Can you explain why your first version using align works, but mine doesn't? – user89 Jan 15 '18 at 6:49
  • In the align*-based solution I provided, there's only one &-based alignment point, in both the upper and lower group. (In contrast, your setup features two or even three & alignment points.) Note the presence of {} in \to{}; that's crucial for obtaining spacing that's appropriate for relational operators (such as \to, aka \rightarrow). – Mico Jan 15 '18 at 7:19
  • Mico, could you update your answer with that explanation, and can you also write a bit more about what{} is? e.g. can you explain why you do {}+{} but only \to{}? – user89 Jan 15 '18 at 19:36
  • @user89 - Done. :-) – Mico Jan 16 '18 at 1:16
3

Here is a solution showing what was saying in my comment (in the first two align's) and creating an environment for this strange approach of align usage:

\documentclass{article}
\usepackage{environ}
\usepackage{amsmath}


\NewEnviron{strangealign}{\def\ra{\rightarrow\,\hspace{60pt}}\def\pl{+\,\,\hspace{60pt}}\begin{align*}\BODY\end{align*}}



\begin{document}
    \begin{align*}
        & \text{2nd-order mechanics} \\
        \rightarrow\hspace{10pt} & \text{non-negligible inertia} \\
        \rightarrow\hspace{10pt} & \text{directional migration} 
    \end{align*}

    \begin{align*}
        & \text{rule: decaying persistence memory}  \\
        +\,\,\hspace{40pt}& \text{rule: increase persistence after collision}  \\
        \rightarrow\,\hspace{40pt}& \text{directional migration} 
    \end{align*}

    \begin{strangealign}
      &\text{Initial text}\\
      \pl&\text{Some text here}\\
      \ra&\text{Some other text left aligned}
    \end{strangealign}
\end{document}

Output:

enter image description here

3

This is a job for tabular:

\documentclass{standalone}
\usepackage{amsmath}

\newcommand{\tra}{\ensuremath{\rightarrow}}% text right arrow

\begin{document}

\begin{tabular}{@{}r@{ }l@{}}
     & 2nd-order mechanics \\
\tra & non-negligible inertia \\
\tra & directional migration
\end{tabular}

\qquad\vrule\qquad

\begin{tabular}{@{}r@{ }l@{}}
     & rule: decaying persistence memory \\
+    & rule: increase persistence after collision \\
\tra & directional migration
\end{tabular}

\end{document}

The vertical rule is just for separating the two tables.

enter image description here

This is what happens if I use \begin{tabular}{@{}c@{ }l@{}} in order to center the symbols in the first column.

enter image description here

  • @koleygr That's a stylistic decision. – egreg Jan 15 '18 at 9:39
  • 1
    @koleygr OK, added the output and the suggestion on how to get it. – egreg Jan 15 '18 at 10:04

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.