[Tex/LaTex] No line-break after align environment

alignamsmathline-breaking

Whenever one uses the align environment, a line-break is automatically inserted after it:

\documentclass[]{article}
\usepackage{amsmath}

\begin{document}
\begin{align*}
    1 + 2
\end{align*}
Text
\end{document}

The same happens when using two align environments after each other (line-break in inserted between them:

\documentclass[]{article}
\usepackage{amsmath}

\begin{document}
\begin{align*}
    1 + 2
\end{align*}
\begin{align*}
    3 + 4
\end{align*}
\end{document}

Is there a way to prevent that from happening, i.e. from having a line-break after an align environment?

EDIT: To clarify, I am certainly not looking for a simple inline equation. I don't want the results to be in the same line, obviously. I just want to get rid of the extra blank line that separates results.

For instance, with the first code snippet above I get:

enter image description here

While I would want:

enter image description here

Similarly, with the second code snippet above I get:

enter image description here

While I want to have something like:

enter image description here

Notice, the challenge is doing that not using one single align.

Best Answer

You could use \centerline to get what you are hoping:

\documentclass[]{article}
\newcommand\myalign[1]{\centerline{$\displaystyle#1$}}
\usepackage{amsmath}
\begin{document}
\myalign{1 + 2}
\myalign{3 + 4}
\noindent text
\end{document}

enter image description here

And while the OP's question doesn't express the need, if you really needed the actual ability to use alignment tabs in the argument, then a TABstack is for you!

\documentclass{article}
\usepackage{tabstackengine}
\TABstackMath
\TABstackMathstyle{\displaystyle}
\newcommand\myalign[1]{\centerline{\alignShortstack{\strut#1\strut}}}
\usepackage{amsmath}
\begin{document}
\myalign{1 + 2}
\myalign{y =&3 + 4\\y_1=&4x + 15\\y+y_1 =& 0}
\noindent text
\end{document}

enter image description here

Related Question