我希望方程式在此特定场景(即嵌套枚举)中左对齐,并且不想更改整个文章的环境设置。我该怎么做?以下是我的代码和序言
\documentclass{article}
\usepackage[a4paper,portrait, margin=1in]{geometry}
\usepackage{graphicx}
\graphicspath{ {./images/} }
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{float} %% keep tables and figures in float position
\usepackage[utf8]{inputenc}
...
\item Find the unique cubic polynomial P that satisfies
\begin{equation*}
P(-2) = 1, P(-1) = 4 P(0) = 2, P(2) = 4.
\end{equation*}
Write P in both the Lagrange and Newton forms
\begin{itemize}
\item Lagrange: $construct l_j for j \in [1,4]$ \par
\begin{equation*}
\begin{aligned}
l_1(x) = \frac{1}{-8}(x+1)x(x-2) \\
l_2(x) = \frac{1}{3}(x+2)x(x-2) \\
l_3(x) = \frac{1}{-4}(x+2)(x+1)(x-2) \\
l_4(x) = \frac{1}{24}(x+2)(x+1)x \\
P(x) = l_1(x)+4l_2(x)+2l_3(x)+4l_4(x)
\end{aligned}
\end{equation*}
\item Newton
答案1
我假设您希望将aligned
环境中的 5 个方程式对齐到它们各自的=
(“等于”)符号上。&
应使用(“与号”)符号来指示所需的对齐点。(正如您所发现的,如果没有指定对齐点,方程式最终将右对齐。)
\documentclass{article}
\usepackage[a4paper,portrait,margin=1in]{geometry}
\usepackage{graphicx}
\graphicspath{ {./images/} }
\usepackage{amsmath,amssymb}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\begin{document}
\begin{itemize}
\item Find the unique cubic polynomial $P$ that satisfies
\begin{equation*}
P(-2)=1,\quad P(-1)=4,\quad P(0)=2,\quad P(2)=4\,.
\end{equation*}
\item Write $P$ in both the Lagrange and Newton forms.
\begin{itemize}
\item Lagrange: Construct $l_j$ for $j \in \{1,2,3,4\}$
\begin{equation*}
\begin{aligned}
l_1(x) &= -\frac{1}{8}(x+1)x(x-2) \\
l_2(x) &= \frac{1}{3}(x+2)x(x-2) \\
l_3(x) &= -\frac{1}{4}(x+2)(x+1)(x-2) \\
l_4(x) &= \frac{1}{24}(x+2)(x+1)x \\
P(x) &= l_1(x) +4l_2(x) +2l_3(x) +4l_4(x)
\end{aligned}
\end{equation*}
\item Newton: \dots
\end{itemize}
\end{itemize}
\end{document}