How to align equations under section name, not numbering?
The "twist" in your setup is that you use roman rather than arabic numerals for the section numbers. This requires setting a separate indentation amount each time \section
is run. The following code achieves this by creating a macro called \setmylength
, which sets the value of a length variable called \mylength
.
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\renewcommand{\thesection}{\Roman{section}}
\setlength\parindent{0pt}
\newlength\mylength
\newcommand\setmylength{\settowidth\mylength{\Large\bfseries\thesection\quad}}
\begin{document}
\section{Euler's Number \textit{e}}
\setmylength
\hspace{\mylength}%
$\begin{aligned}
e &= \lim_{x \to \infty} \Bigl( 1 + \frac{1}{x} \Bigr) ^{x} \\
&= \sum_{x=0}^{\infty} \frac{1}{x!} \\
e^{x} &= \lim_{n \to \infty} \Bigl( 1 + \frac{x}{n} \Bigr) ^{n} \\
&= \sum_{x=0}^{\infty} \frac{x^n}{n!}
\end{aligned}$
\setcounter{section}{27} % just for this example
\section{Euler's Number \textit{e}}
\setmylength
\hspace{\mylength}%
$\begin{aligned}
e &= \lim_{x \to \infty} \Bigl( 1 + \frac{1}{x} \Bigr) ^{x} \\
&= \sum_{x=0}^{\infty} \frac{1}{x!} \\
e^{x} &= \lim_{n \to \infty} \Bigl( 1 + \frac{x}{n} \Bigr) ^{n} \\
&= \sum_{x=0}^{\infty} \frac{x^n}{n!}
\end{aligned}$
\end{document}
Addendum to address the OP's follow-up query: If more than one alignment point is needed, replaced the aligned
environment with an alginedat
environment. E.g.,
$\begin{alignedat}{2}
&e &&= \lim_{x \to \infty} \Bigl( 1 + \frac{1}{x} \Bigr) ^{x} \\
& &&= \sum_{x=0}^{\infty} \frac{1}{x!} \\
&e^{x} &&= \lim_{n \to \infty} \Bigl( 1 + \frac{x}{n} \Bigr) ^{n} \\
& &&= \sum_{x=0}^{\infty} \frac{x^n}{n!}
\end{alignedat}$
Here I have given an answer using nccmath
, and scrextend
packages with the enviroment
\begin{addmargin}.... \end{addmargin}
I had worked before without your MWE and I think that there are many solutions. With
\begin{addmargin}[.5em]{1em}&<------
you can change the parameters of the left margin of the only equations.
\documentclass[a4paper,12pt]{article}
\usepackage{amsmath,amssymb}
\usepackage{scrextend}
\usepackage{nccmath}
\begin{document}
\section{The Euler's Number $e$.}
\begin{addmargin}[.5em]{1em}
\begin{fleqn}[\parindent]
\begin{align*}
e &= \lim_{x \to \infty} \left( 1 + \frac{1}{x} \right) ^{x} \\
&= \sum_{x=0}^{\infty} \frac{1}{x!} \\
e^{x} &= \lim_{n \to \infty} \left( 1 + \frac{x}{n} \right) ^{n} \\
&= \sum_{x=0}^{\infty} \frac{x^n}{n!}
\end{align*}
\end{fleqn}
\end{addmargin}
\end{document}
I put another example, with \begin{addmargin}[1em]{1em}
.
\documentclass[a4paper,12pt]{article}
\usepackage{amsmath,amssymb}
\usepackage{scrextend}
\usepackage{nccmath}
\begin{document}
\section{The Euler's Number $e$.}
\begin{addmargin}[1em]{1em}
\begin{fleqn}[\parindent]
\begin{align*}
e &= \lim_{x \to \infty} \left( 1 + \frac{1}{x} \right) ^{x} \\
&= \sum_{x=0}^{\infty} \frac{1}{x!} \\
e^{x} &= \lim_{n \to \infty} \left( 1 + \frac{x}{n} \right) ^{n} \\
&= \sum_{x=0}^{\infty} \frac{x^n}{n!}
\end{align*}
\end{fleqn}
\end{addmargin}
\end{document}