2

This is a bit of a complex question because I want to align equations but also string text such that all the text is aligned to the left and all the equations' start is aligned. The two alignments must not be related to each other.

I'm using the amsmath package. I tried using align environment but had a better result with flalign.

What I get with the following code is very close but not good enough. The equations start after the text and get out of the page.

I'd like for the text alignment (in black) to ignore the equations alignment if possible such that the equations don't try to align so far right.

I'd state that I'm not an advanced Latex user so a simple solution will be better for me.

{\color{red}
\begin{flalign}
&{\color{black}\text{komplex konjugiert, Spiegelung auf der reellen Achse:}}& \nonumber \\
&&z = x + iy \Rightarrow \overline{z} = x - iy \\
&{\color{black}\text{Realteil:}} \nonumber \\
&&Re(z) = Re(\overline{z}) = x = \frac{z + \overline{z} }{2}  \\
&{\color{black}\text{Imaginärteil:}} \nonumber \\
&&Im(z) = -Im(\overline{z}) = y = \frac{z - \overline{z} }{2i} \\
&{\color{black}\text{Betrag:}}  \nonumber \\
&&r = |z| = |\overline{z}| = \sqrt{x^2+y^2} = \sqrt{z \cdot \overline{z}} \\
&{\color{black}\text{Argument:}}  \nonumber \\
&&\varphi = arg(z) = arg(\overline{z}) = 
                                                 \begin{cases}
                                                        \cos^{-1}(\frac{x}{r}), \quad y \geq 0\\
                                                        -\cos^{-1}(\frac{x}{r}), \quad y \leq 0\\
                                                \end{cases} \\
&{\color{black}\text{Eulersche Zahlen:}}  \nonumber \\
&&z = r \cdot e^{i \varphi} = r \cdot (\cos(\varphi) + i\sin(\varphi)),\\
&&\overline{z} = r \cdot e^{-i \varphi} = r \cdot (\cos(\varphi) - i\sin(\varphi)) \\
&{\color{black}\text{Skalar Produkt von 2 komplexe Zahlen:}}  \nonumber \\
&&Re(z \cdot \overline{w}) = <z,w>
\end{flalign}
}
3
  • 1
    it is much easier to answer if you provide a test file rather than a fragment that we have to constrict oruselves and guess atext width. Your usse of fleqn looks rather unusual you are not aligning on any p[ratpr at all and have & at the start of every line? Apr 15, 2021 at 19:29
  • 1
    your &{\color{black}\text{Eulersche Zahlen:}} \nonumber lines could more easily be set using \intertext Apr 15, 2021 at 19:30
  • Good point David, I already got an answer but if it doesn't work I'll add a test file
    – Toma
    Apr 15, 2021 at 19:32

2 Answers 2

2

A solution like this will not always work, but in this case since text and math are on separate rows of the flalign, it suffices. What I did was to replace all instances of \text with \laptext, where the latter is defined as an \rlap of its argument. In this way, the width of the text will have no effect on the align points.

EDIT: To appease the TeX gods, I replaced Re, Im, and arg, with macros that typeset in upright text.

\documentclass{article}
\usepackage{amsmath,xcolor}
\newcommand\laptext[1]{\rlap{#1}}
\newcommand\Real{\mathrm{Re}}
\newcommand\Imag{\mathrm{Im}}
\newcommand\Arg{\mathrm{arg}}
\begin{document}
{\color{red}
\begin{flalign}
&{\color{black}\laptext{komplex konjugiert, Spiegelung auf der reellen Achse:}}& \nonumber \\
&&z = x + iy \Rightarrow \overline{z} = x - iy \\
&{\color{black}\laptext{Realteil:}} \nonumber \\
&&\Real(z) = \Real(\overline{z}) = x = \frac{z + \overline{z} }{2}  \\
&{\color{black}\laptext{Imaginärteil:}} \nonumber \\
&&\Imag(z) = -\Imag(\overline{z}) = y = \frac{z - \overline{z} }{2i} \\
&{\color{black}\laptext{Betrag:}}  \nonumber \\
&&r = |z| = |\overline{z}| = \sqrt{x^2+y^2} = \sqrt{z \cdot \overline{z}} \\
&{\color{black}\laptext{Argument:}}  \nonumber \\
&&\varphi = \Arg(z) = \Arg(\overline{z}) = 
                                                 \begin{cases}
                                                        \cos^{-1}(\frac{x}{r}), \quad y \geq 0\\
                                                        -\cos^{-1}(\frac{x}{r}), \quad y \leq 0\\
                                                \end{cases} \\
&{\color{black}\laptext{Eulersche Zahlen:}}  \nonumber \\
&&z = r \cdot e^{i \varphi} = r \cdot (\cos(\varphi) + i\sin(\varphi)),\\
&&\overline{z} = r \cdot e^{-i \varphi} = r \cdot (\cos(\varphi) - i\sin(\varphi)) \\
&{\color{black}\laptext{Skalar Produkt von 2 komplexe Zahlen:}}  \nonumber \\
&&\Real(z \cdot \overline{w}) = <z,w>
\end{flalign}
}
\end{document}

enter image description here

4
  • can I complain about math italic Im, Re and arg ? :-) Apr 15, 2021 at 19:31
  • 1
    @DavidCarlisle You may, but you'll have to get at the end of the line. Apr 15, 2021 at 19:32
  • Excelent! Exactly what I needed. @StevenB.Segletes can you please explain what the command does: what does 1 mean in: \LAPTEXT[1] and what does #1 do
    – Toma
    Apr 15, 2021 at 19:38
  • 1
    @Toma Well, LAPTEXT is \laptext when you accidentally turn CAPS-LOCK on, LOL. But as to what it is, it is a definition of new macro. The [1] means it takes one argument, which refers to the {...} following each invocation. \rlap{...} is a TeX command that sets the text rightward from the current location, but pretending that it has zero width. The #1 is used in TeX definitions to refer to the first argument to a macro (#2 is the second argument, etc.) Apr 15, 2021 at 19:45
1

You do not appear to want any alignment so flalign is the wrong environment, use gather. Also don't use math italic for words such as arg. Also \langle\rangle not <>.

enter image description here

\documentclass[a4paper]{article}

\usepackage{amsmath,color}

\let\Re\relax\DeclareMathOperator\Re{Re}
\let\Im\relax\DeclareMathOperator\Im{Im}
\begin{document}

{\color{red}
\begin{gather}
\intertext{\color{black}komplex konjugiert, Spiegelung auf der reellen Achse:}
z = x + iy \Rightarrow \overline{z} = x - iy \\
\intertext{\color{black}Realteil:}
\Re(z) = \Re(\overline{z}) = x = \frac{z + \overline{z} }{2}  \\
\intertext{\color{black}Imaginärteil:}
\Im(z) = -\Im(\overline{z}) = y = \frac{z - \overline{z} }{2i} \\
\intertext{\color{black}Betrag:}
r = |z| = |\overline{z}| = \sqrt{x^2+y^2} = \sqrt{z \cdot \overline{z}} \\
\intertext{\color{black}Argument:}
\varphi = \arg(z) = \arg(\overline{z}) = 
                                                 \begin{cases}
                                                        \cos^{-1}(\frac{x}{r})&, y \geq 0\\
                                                        -\cos^{-1}(\frac{x}{r})&, y \leq 0\\
                                                \end{cases} \\
\intertext{\color{black}Eulersche Zahlen:}
z = r \cdot e^{i \varphi} = r \cdot (\cos(\varphi) + i\sin(\varphi)),\\
\overline{z} = r \cdot e^{-i \varphi} = r \cdot (\cos(\varphi) - i\sin(\varphi)) \\
\intertext{\color{black}Skalar Produkt von 2 komplexe Zahlen:}
\Re(z \cdot \overline{w}) = \langle z,w\rangle
\end{gather}
}
\end{document}

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.