4

I want to align 2 similar equations such that the first is directly over the other.

$ a + b = c $ \\
text $ d + e = f $ \\

How do I do that?

It should look like:

     $ a + b = c $ \\
text $ d + e = f $ \\

My original code:

Die Wronskimatrix entspricht dann die linear Kombination der Funktionen: \\
$ {\color{orange} \alpha x + \beta x^2 = 0}$ \\
und $ {\color{orange} \alpha 1 + \beta 2x = 0   }$ für die Ableitungen\\

I want it to look like:

Die Wronskimatrix entspricht dann die linear Kombination der Funktionen: \\
    $ {\color{orange} \alpha x + \beta x^2 = 0}$ \\
und $ {\color{orange} \alpha 1 + \beta 2x = 0   }$ für die Ableitungen\\

I tried using \begin{alinged}[b] as shown below but it didn't compile with error of missing } in a wierd place.

  • Can you provide some broader context of the information surrounding your code snippet? Specifically, this information seems to be presented in regular text/paragraph mode with line-breaks via \\. Instead, it is far better to use a display like \begin{align*}...\end{align*}. – Werner Mar 7 at 18:54
  • Where should I place \begin{align*}...\end{align*} to avoid collisions with my code? – Toma Mar 8 at 11:35
  • 1
    With the context of your code, align* is not a viable option. – Werner Mar 8 at 16:45
7

enter image description here

\documentclass{article}

\usepackage{amsmath}

\begin{document}


zzzzzzzzzzzz

text $\begin{aligned}[b]
   a + b &= c  \\
  d + e &= f 
\end{aligned}$

zzzzzzzzzzzzzzzzzzzzzzzzz

\end{document}
  • It would be nice if you showed a line of text above and another below, just to show that it works in context. (Of course, just cheating and using \phantom{text }$... would avoid all possible baseline problems.) – barbara beeton Mar 7 at 19:07
  • 1
    @barbarabeeton ^^ – David Carlisle Mar 7 at 19:28
  • The gap between the two lines with the math expressions is larger than the gap between a math line and the adjacent text line. (Not surprising, actually, since the aligned and align vertical separation is more than the default baselineskip.) – barbara beeton Mar 7 at 20:15
  • @barbarabeeton yes, quite probably you would set the whole thing off in a display construct such as center so the \lineskip difference wouldn't be obtrusive, or you could correct fro it of course. – David Carlisle Mar 7 at 20:53
  • Got it, I should have placed the color enviroment to encapsulate the aligned. Tnx! – Toma Mar 8 at 11:46
5
\documentclass{article}
\usepackage{tabstackengine}
\TABstackMath
\begin{document}
text \alignLongstack{a + b =& c\\ d + e =& f} more text
\end{document}

enter image description here

The default baselineskip for a long stack can be set in the preamble with \setstackgap{L}{<length>}.

If it is to be literally used within typeset text, one may wish to add \strutlongstacks{T} to get proper line spacing:

\documentclass{article}
\usepackage{tabstackengine}
\usepackage[nopar]{lipsum}
\strutlongstacks{T}
\TABstackMath
\begin{document}
\lipsum[1]
text \alignLongstack{a + b =& c\\ d + e =& f}
\lipsum[2]
\end{document}

enter image description here

1

Display your formulas:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}

\usepackage{amsmath,mathtools}
\usepackage[dvipsnames]{xcolor}

\begin{document}

\section{A}

Die Wronskimatrix entspricht dann die linear Kombination der Funktionen:
\begin{alignat*}{2}
&&& \color{orange} \alpha x + \beta x^2 = 0 \\
\text{und}&\qquad&& \color{orange} \alpha 1 + \beta 2x = 0
\end{alignat*}
für die Ableitungen.

\section{B}

Die Wronskimatrix entspricht dann die linear Kombination der Funktionen:
\begin{align*}
& \color{orange} \alpha x + \beta x^2 = 0 \\
\shortintertext{und}
& \color{orange} \alpha 1 + \beta 2x = 0
\end{align*}
für die Ableitungen.

\end{document}

enter image description here

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.