如何对齐线条并在线条太长时自动断线?

如何对齐线条并在线条太长时自动断线?

我尝试在 LaTeX 中对齐所有等号,但遇到了一个问题。如果行太长,它不会自动断开。

我目前的代码:

\begin{align*}
n &= \text{number of days in the support and resistance range;} \\
e &= \text{used for an alternative definition of extrema where a low (high) can be defined as the most recent closing price that is less (greater) than the n previous closing prices;} \\
b &= \text{fixed band multiplicative value;}
\end{align*}

目前结果: 结果

我想要得到什么:

最终结果

所以我希望如果行太长则自动换行,并将新行放在第一行下方(等号后面)。

我该怎么做?Ps 附加:有人知道“align”命令将文本垂直向下移动多少(cm/mm)吗?我真的不希望该命令将文本向下移动,而是想用“\vspace{-Xmm}”来纠正这个问题。

答案1

面向方程的环境(例如)align*不太适合当前任务。相反,请考虑使用类似表格的环境(例如)tabularx

以下代码使用构造在环境的第一列和第二列之间@{${}={}$}插入一个间距适当的符号;用于第二列的列类型会根据需要自动“换行”其内容。表格的整体宽度设置为——您可以根据需要调整此设置。=tabularxX0.75\textwidth

在此处输入图片描述

\documentclass{article}
\usepackage{tabularx}
\begin{document}

\begin{center}
\begin{tabularx}{0.75\textwidth}{>{$}r<{$} @{${}={}$} X}
  n &number of days in the support and resistance range; \\
  e &used for an alternative definition of extrema where 
     a low (high) can be defined as the most recent closing     
     price that is less (greater) than the n previous closing 
     prices; \\
  b &fixed band multiplicative value.\\
\end{tabularx}
\end{center}
\end{document}

答案2

您可以使用\parbox

\documentclass{article}
\usepackage{amsmath}
\usepackage{linegoal}
\begin{document}
  \begin{align*}
n &= \text{number of days in the support and resistance range;} \\
e &= \parbox[t]{\linegoal}{used for an alternative definition of extrema where a low (high) can be defined as the most recent closing price that is less (greater) than the n previous closing prices;} \\
b &= \text{fixed band multiplicative value;}
\end{align*}
\end{document}

在此处输入图片描述

相关内容