如何在 LaTeX 的校样/对齐环境中对对齐进行换行?例如,我有一个方程式的对齐,但对齐偏离了页面,没有换行。我希望将对齐拆分并继续到下一行,当然,下一个方程式对齐对应该相应地向下移动。作为额外奖励,我还希望方程式具有与边距的固定缩进(即与问题编号的对齐方式不同)。
\documentclass[11pt, letterpaper]{article}
\usepackage{fullpage,amsmath,amsthm, amssymb}
\usepackage[margin=1in]{geometry}
\usepackage{enumitem}
\title{Example}
\author{Author}
\date{\today}
\renewcommand\qedsymbol{$\blacksquare$}
\newcommand{\justif}[2]{&{#1}&\text{#2}}
\begin{document}
\maketitle
\begin{enumerate}
\item
\begin{proof}
\begin{align*}
dog_{k+1} &= dog_{k} \justif{\quad}{The robot ate a chicken which was undercooked; ergo, the count of phones in the world remains the same and fixed as prior.}\\
cat_{k+1} &= cat_{k} \justif{\quad}{Cat likes running more than sleeping.}\\
\end{align*}
The inductive step is complete.
\end{proof}
\end{enumerate}
\end{document}
畸形线图片:
答案1
这是一种简单的可能性;对齐使用放置方程式后的剩余空间。它依赖于测量linegoal
线当前点的水平剩余空间的包。
\documentclass[11pt, letterpaper]{article}
\usepackage{fullpage,amsmath,amsthm, amssymb}
\usepackage[margin=1in]{geometry}
\usepackage{enumitem}
\usepackage{linegoal}
\title{Example}
\author{Author}
\date{\today}
\renewcommand\qedsymbol{$\blacksquare$}
\newcommand{\justif}[2]{&{#1}&\rlap{\parbox[t]{\linegoal}{\footnotesize#2}}}
\begin{document}
\maketitle
\begin{enumerate}
\item
\begin{proof}
\begin{alignat*}{2}
dog_{k+1} &= dog_{k} \justif{\quad}{The robot ate a chicken which was undercooked; ergo, the count of phones in the world remains the same and fixed as prior.}\\
cat_{k+1} &= cat_{k} \justif{\quad}{Cat likes running more than sleeping.}\\
\end{alignat*}
The inductive step is complete.
\end{proof}
\end{enumerate}
\end{document}
编辑:
另一个解决方案是使用\flalign
,然后通过可选参数 (默认值: ) 选择对齐的宽度0.3\linewidth
。使用以下代码,公式将在对齐左侧的空间中对齐并居中:
\newcommand{\fljustif}[2][0.3\linewidth]{\parbox[t]}
...................
\begin{flalign*}
& & dog_{k+1} &= dog_{k} & \fljustif{The robot ate a chicken which was undercooked; ergo, the count of phones in the world remains the same and fixed as prior.}\\
& & cat_{k+1} &= cat_{k} & \fljustif{Cat likes running more than sleeping.}\\
\end{flalign*}