3

I have the following formulas in an align environment:

\begin{align}
l_t&=\sigma_t * \epsilon_t\\ 
\hat{VaR}_{0.99,T+1|T}&=\hat{\sigma}_{T+1|T} * z_{0.99}\\
\hat{\sigma}_{T+1|T}^{ewma}&=\sqrt{(1-\lambda)\sum_{i=0}^{(262-1)} \lambda^i l_{T-i}^2} 
\end{align}

How can I set this formulas with a different envrironment?

ShreevatsaR
  • 45,428
  • 10
  • 117
  • 149
align
  • 41
  • 1
  • 2
  • May I ask why you want to do that? What is wrong with align? – Torbjørn T. Aug 21 '13 at 11:31
  • 1
    Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. – karlkoeller Aug 21 '13 at 11:31
  • How do you want your equations (their alignment, I mean)? – karlkoeller Aug 21 '13 at 11:33
  • @TorbjørnT. I sometimes get an odd error message that says I have somehow a wrong alignment inside the \halign in the $$. I don't know what that means. I changed another single equation from align into equation and that worke. Here I have not only one equation, therefore it does not work. – align Aug 21 '13 at 11:36
  • @karlkoeller So that the equal signs are aligned. – align Aug 21 '13 at 11:37
  • 1
    Your code works fine for me. Are you sure you are not putting your code inside $$....$$ since it is prohibited... – karlkoeller Aug 21 '13 at 11:39
  • No I have a very long document and LaTex somehow is not able to make a pagebreak. So it always occurs if I try to add some text to my lines. I don't know why this happens and I cannto strip it down to a MWE. – align Aug 21 '13 at 11:41
  • Posting a complete document MWE demonstrating the problem would help – Andrew Swann Aug 21 '13 at 11:41
  • @AndrewSwann As I already stated it is not possible to strip it down to a MWE. If I delete the other text the error disappears, but I need the other text in my thesis. – align Aug 21 '13 at 11:42
  • That's why I just asked for a different possibility to set this equations. Something like a efficient work-around. – align Aug 21 '13 at 11:42
  • Without an MWE we have no chance of saying what is wrong. align is a well-established environment. Something else in your particular coding must be causing the problem. – Andrew Swann Aug 21 '13 at 11:45
  • For single equations you should use equation anyway. If you want a pagebreak within an align, the easiest way is to add \allowdisplaybreaks in the preamble (for more info read the amsmath manual). If you want to understand why an error occurs, please post the code that produces the error, and the exact error message. – Torbjørn T. Aug 21 '13 at 11:53
  • @TorbjørnT. The error message is: ! Improper \halign inside $$'s. \halign – align Aug 21 '13 at 12:07
  • Ok, but the code you posted doesn't produce that error. There may be someone who can guess what you've done wrong from the error alone, but I cannot, so you should create an example that actually reproduces the error. – Torbjørn T. Aug 21 '13 at 12:11

1 Answers1

2

This aligns without the align environment, within the constraints given in the comments below, using the method developed in align separate equations. The alignment point will carry across the document, unless/until \leftalgn and/or \rightalgn are reset. The use of the \snug macro is described in the cited page, and is used to eliminate vertical space before an equation, where the prior text line is short, and the equation's left horizontal extent does not commence until the prior text is complete.

\documentclass{article}

\def\leftalgn{0.45}\def\rightalgn{0.45}
\def\algnrow{\rule{\leftalgn\textwidth}{0ex}&\rule{\rightalgn\textwidth}{0ex}}
% CONSTRAINTS:
% equation label must fit in {1 -\leftalgn -\rightalgn}\textwidth
% \leftalgn must be larger than any text to left of align character
% \rightalgn must be larger than any text to right of align character
\newenvironment{algneqn}{%
  \arraycolsep=0ex\renewcommand\arraystretch{0}%
  \begin{equation}%
  \begin{array}{rl}%
  \algnrow\\}%
 {\\\algnrow%
  \end{array}%
  \end{equation}\ignorespacesafterend%
}
\def\snug#1{\vspace*{-#1\baselineskip}}
\begin{document}
\begin{algneqn}
l_t&{}=\sigma_t * \epsilon_t\\ 
\end{algneqn}
\begin{algneqn}
\hat{VaR}_{0.99,T+1|T}&{}=\hat{\sigma}_{T+1|T} * z_{0.99}\\
\end{algneqn}
\begin{algneqn}
\hat{\sigma}_{T+1|T}^{ewma}&{}=\sqrt{(1-\lambda)\sum_{i=0}^{(262-1)}
\lambda^i l_{T-i}^2} 
\end{algneqn}
\end{document}

enter image description here

I EDITED the result to get the proper spacing around the = sign, as pointed out by barbara beeton. Because this approach is done using the array environment, I either had to use \arraycolsep (which I did not) or else inset a null placeholder {} before the = (which I did), in order to get the space added before the = sign.

David Carlisle
  • 757,742