6

I'm trying to align in LaTeX all equal signs, but I'm encountering a problem. If the line is too long it won't automatically break.

My code at the moment:

\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*}

Result at the moment: Result

What I want to get:

End Result

So I want the line to automatically break if it's too long and put the new line right under the first line (after the equal sign).

How can I do this? P.s. Additional: Does somebody also know how much (cm/mm) the "align" command shifts the text vertical down? I don't really want the command to shift the text downwards, and want to correct this with "\vspace{-Xmm}".

3
  • Can you clarify about the text being pushed down? Which text? It is the \belowdisplayskip which is the vertical space between the text below and the last line of the equation.
    – user11232
    Sep 26, 2015 at 13:32
  • I think the \align* function in combination with my template made the text (box) shifts down (in relation to my header), however such thing won't happen with \tabularx.
    – Wildman
    Sep 26, 2015 at 14:09
  • Welcome to TeX.SX! Usually, we don't put a greeting or a “thank you” in our posts. While this might seem strange at first, it is not a sign of lack of politeness, but rather part of our trying to keep everything very concise. Accepting and upvoting answers is the preferred way here to say “thank you” to users who helped you. Sep 26, 2015 at 14:25

2 Answers 2

7

An equation-oriented environment such as align* isn't well suited for the task at hand. Instead, consider using a table-like environment such as tabularx.

The following code uses the construct @{${}={}$} to insert a properly-spaced = symbol between the first and second column of the tabularx environment; the X column type, used for the second column, "wraps" its contents automatically as needed. The overall width of the table is set to 0.75\textwidth -- adjust this setting as you see fit.

enter image description here

\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}
3
  • Thanks, this is maybe even smarter/faster as the \align* command!
    – Wildman
    Sep 26, 2015 at 14:10
  • 1
    What is the meaning of >{$}r<{$}?
    – fairytale
    Jan 30, 2021 at 15:31
  • 1
    @fairytale - I will assume that you know that $ has a special meaning in TeX and LaTeX documents, viz, to initiate and terminate (inline) math mode. The r part in >{$}r<{$} stands for right-alignment of the cell contents. The >{$} and <{$} particles serve to inform LaTeX that the cell contents should be processed in (inline) math mode automatically. With this setup, the creator of the table needn't remember to encase the n, e, and b letters in start-math and end-math $ dollar tokens. I would argue that this makes the table code easier to parse.
    – Mico
    Jan 30, 2021 at 15:37
6

You can use a \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}

enter image description here

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .