Math & ScienceEnumerated, aligned Equations with flushed right Annotations

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
xeror
Posts: 3
Joined: Wed May 02, 2012 5:52 pm

Enumerated, aligned Equations with flushed right Annotations

Post by xeror »

Greeting everyone. This is my first time to post a question in this forum. Hopefully I meet all the rules here.

I want to write a solution to some math questions. There are several subquestions, and for each subquestion there are multiple steps. For some steps, I would like to annotate it by something like (By using bababa). I have tried align* with tag but it does not stay the same line with enumerate. I have also tried aligned but the annotation isn't flush right. Here is a piece of code. Thanks.

Code: Select all

\documentclass[a4paper,fleqn]{article}
\usepackage[a4paper]{geometry}
\usepackage{fullpage}
\usepackage{enumitem}
\usepackage{amsmath}

\setlength{\mathindent}{0pt}

\begin{document}
\begin{enumerate}
\item \begin{align*}
	n^2-n&=\sum_{k=2}^n{(k^2-k)a_k}\\
		&=\sum_{k=2}^n{k^2 a_k}-\sum_{k=1}^n{k a_k}+a_1\\
		&=\sum_{k=1}^n{k^2 a_k}+n\tag{By equation 1}\\
	n^2-2n&=\sum_{k=1}^n{k^2 a_k}
\end{align*}
\end{enumerate}
\end{document}

Recommended reading 2024:

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

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

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

Enumerated, aligned Equations with flushed right Annotations

Post by Stefan Kottwitz »

Hi,

welcome to the board!

The plan seems to be challenging, because that's like mixing three different environments: an enumerated list, a multi-line math environment and a flushed right environment, keeping base lines within those environments also vertically aligned.

This can be a reason to design the layout in another way. However, perhaps you could use this simple way: use a two-column top aligned alignedat environment within enumerate, with the right column for right aligned text. The alignment would work, however here I need to manually specify the width.

Code: Select all

\begin{enumerate}
\item $\begin{alignedat}[t]{2}
        n^2-n&=\sum_{k=2}^n{(k^2-k)a_k}&\hspace{.5\textwidth}\\
                &=\sum_{k=2}^n{k^2 a_k}-\sum_{k=1}^n{k a_k}+a_1&\\
                &=\sum_{k=1}^n{k^2 a_k}+n&\text{(By equation 1)}\\
        n^2-2n&=\sum_{k=1}^n{k^2 a_k}&\text{(you know)}
\end{alignedat}$\hfill
\end{enumerate}
equations.png
equations.png (3.59 KiB) Viewed 7109 times
Stefan
LaTeX.org admin
xeror
Posts: 3
Joined: Wed May 02, 2012 5:52 pm

Enumerated, aligned Equations with flushed right Annotations

Post by xeror »

Stefan_K wrote:Hi,

welcome to the board!

The plan seems to be challenging, because that's like mixing three different environments: an enumerated list, a multi-line math environment and a flushed right environment, keeping base lines within those environments also vertically aligned.

This can be a reason to design the layout in another way. However, perhaps you could use this simple way: use a two-column top aligned alignedat environment within enumerate, with the right column for right aligned text. The alignment would work, however here I need to manually specify the width.

Code: Select all

\begin{enumerate}
\item $\begin{alignedat}[t]{2}
        n^2-n&=\sum_{k=2}^n{(k^2-k)a_k}&\hspace{.5\textwidth}\\
                &=\sum_{k=2}^n{k^2 a_k}-\sum_{k=1}^n{k a_k}+a_1&\\
                &=\sum_{k=1}^n{k^2 a_k}+n&\text{(By equation 1)}\\
        n^2-2n&=\sum_{k=1}^n{k^2 a_k}&\text{(you know)}
\end{alignedat}$\hfill
\end{enumerate}
equations.png
Stefan
Thanks a lot. But the flushed right annotation is not aligned when I have multiple such block. I would rather use 0pt width \rule and negative \vspace with {align}, although I have to adjust the vertical displacement every time.

Code: Select all

\begin{enumerate}
\item \rule{0pt}{14pt} \vspace*{-28pt}
\begin{align*}
n^2-n&=\sum_{k=2}^n{(k^2-k)a_k}\\
                &=\sum_{k=2}^n{k^2 a_k}-\sum_{k=1}^n{k a_k}+a_1&\\
                &=\sum_{k=1}^n{k^2 a_k}+n&\text{(By equation 1)}\\
        n^2-2n&=\sum_{k=1}^n{k^2 a_k}&\text{(you know)}
\end{align*}
\end{enumerate}
Post Reply