我的代码:
\begin{itemize}
\item Case $1$ :
\begin{align*}
& 2^x-1 =0\\
\implies & 2^x = 1 \\
\implies & \ln(2^x) = \ln(1) & \text{ [taking natural logarithm on both sides]} \\
\implies & x \ln2 = 0 \\
\therefore & \quad x = 0
\end{align*}
\item Case $2$ :
\begin{align*}
& x+3 =0\\
\therefore & \quad x = -3
\end{align*}
\item Case $3$ :
\begin{align*}
& x-1 =0\\
\therefore & \quad x = 1
\end{align*}
\end{itemize}
现在的问题是我不想将情况 2 和 3 中的方程式置于中心。我想让它们沿着我在其输出上标记的红线保持。
我怎样才能证明我的代码能够达到所需的输出?
答案1
像这样?
\documentclass{article}
\usepackage{mathtools, amssymb}
\begin{document}
\begin{itemize}
\item Case $1$ :
$ \begin{aligned}[t] \\
& 2^x-1 =0\\
\implies & 2^x = 1 \\
\implies & \ln(2^x) = \ln(1) & \text{ [taking natural logarithm on both sides]} \\
\implies & x \ln2 = 0 \\
\therefore & \quad x = 0
\end{aligned} $
\item Case $2$ :
$ \begin{aligned}[t] \\
\phantom{\implies} & x+3 =0\\
\therefore & \quad x = -3
\end{aligned} $
\item Case $3$ :
$ \begin{aligned}[t] \\
\phantom{\implies} & x-1 =0\\
\therefore & \quad x = 1
\end{aligned} $
\end{itemize}
\end{document}
答案2
可以使用flalign
来不将方程式居中,但至少需要一行额外的 && 来占据页面的右侧。使用 可以实现缩进minipage
,从而有效地减少\textwidth
剩余空间。
\documentclass{article}
\usepackage{mathtools, amssymb}
\usepackage{showframe}% alignment tool
\newlength \tempwidth
\settowidth{\tempwidth}{Case $2$ :}
\begin{document}
\begin{itemize}
\item Case $1$ :\begin{minipage}[t]{\dimexpr \linewidth-\tempwidth}
\abovedisplayskip=0pt% or even -\baselineskip
\begin{flalign*}
& 2^x-1 =0 &&\\
\implies & 2^x = 1 \\
\implies & \ln(2^x) = \ln(1) & \text{ [taking natural logarithm on both sides]} \\
\implies & x \ln2 = 0 \\
\therefore & \quad x = 0
\end{flalign*}\end{minipage}
\item Case $2$ :\begin{minipage}[t]{\dimexpr \linewidth-\tempwidth}
\abovedisplayskip=0pt
\begin{flalign*}
\phantom{\implies} & x+3 =0 &&\\
\therefore & \quad x = -3
\end{flalign*}\end{minipage}
\item Case $3$ :\begin{minipage}[t]{\dimexpr \linewidth-\tempwidth}
\abovedisplayskip=0pt
\begin{flalign*}
\phantom{\implies} & x-1 =0 &&\\
\therefore & \quad x = 1
\end{flalign*}\end{minipage}
\end{itemize}
\end{document}