TeX - LaTeX Asked by LongKit on May 28, 2021
I tried aligning equations under section names, but instead they got aligned under section numberings.
documentclass{article}
usepackage[utf8]{inputenc}
usepackage{amsmath}
title{Integration I}
author{LongKit}
date{December 5, 2020}
begin{document}
maketitle
renewcommand{thesection}{Roman{section}}
setlengthparindent{0pt}
section{The Euler's Number textit{e}}
vspace{baselineskip}
$begin{aligned}
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{aligned}$
end{document}
Upper: What I get; Lower: What I want
Much Appreciated!
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}}
setlengthparindent{0pt}
newlengthmylength
newcommandsetmylength{settowidthmylength{Largebfseriesthesectionquad}}
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}$
Correct answer by Mico on May 28, 2021
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}
Answered by Sebastiano on May 28, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP