Text FormattingAligning with several fixed points

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
theo96
Posts: 2
Joined: Tue Jul 13, 2021 1:52 pm

Aligning with several fixed points

Post by theo96 »

Hello,

I am new to this forum, so I apologize in advance for maybe not asking in the right way.

I would like to have more than one fixpoint in a line, I can align future lines to. I am using the aligned environment plugged into the equation environment, this should not change. Maybe this question gets clearer in my MWE:

Code: Select all

\documentclass {article}
\usepackage[left=1 cm]{geometry}
\usepackage{amsmath}


\begin{document}


\begin{equation*}\begin{aligned}
\text{This line uses has two different points }&= \text{ but also }+ \text{are good points to start further lines}\\
&=\text{ this line starts with }=\\
&\hspace{1.9 cm} + \text{this line should start at }+ \text{ without using hspace}
\end{aligned}\end{equation*}

\end{document}
Thank you for your support :-D

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Aligning with several fixed points

Post by Stefan Kottwitz »

Hi Theo,

welcome to the forum!

You could use the alignedat environment that supports several alignment places:

Code: Select all

\documentclass {article}
\usepackage[left=1 cm]{geometry}
\usepackage{mathtools}

\begin{document}

\begin{equation*}\begin{alignedat}{2}
\text{This line uses has two different points }&= \text{ but also }&&+ \text{are good points to start further lines}\\
&=\mathrlap{\text{ this line starts with }=}\\
&&&+ \text{this line should start at }+ \text{ without using hspace}
\end{alignedat}\end{equation*}

\end{document}
I used \mathrlap of the mathtools package so the second line would not force the column to be too wide. mathtools loads amsmath implicitly.

Btw. if it's for text, you could use the tabbing environment.

Stefan
LaTeX.org admin
theo96
Posts: 2
Joined: Tue Jul 13, 2021 1:52 pm

Aligning with several fixed points

Post by theo96 »

Hi Stefan,

thanks for this solution. It works exactly in the way I wanted. :D
Post Reply