2

I have looked at answers to this question extensively and tried copied them but the second line of my equation keeps indenting to far to the right. How do I make it look normal?

            \begin{documentclass}
        \usepackage{amsmath}
        \begin{equation}
        \begin{split}
              \textrm{Y}_{it} = \beta_{0}+\beta_{1}\textrm{Education Construction}_{it}+ \beta_2\textrm{economic slack}_{it} + \beta_3\textrm{economic slack}*\textrm{Education Construction}_{it}+ & \\ \beta_4 X_{it} + \sum fe_{i} + \sum fe_{t} + \mu_{it} 
              \end{split}
        \end{equation}

        \end{documentclass}
  • 1
    Please make your code compilable. Regarding the subscripts, you might want to have a look at: Double Subscript for Subsequences – leandriis May 20 '19 at 14:41
  • Is that better now? – Asaf Cohen May 20 '19 at 14:47
  • 2
    You haven't specified an alignment point (with &) in the first line. That's necessary. Also (off topic) it's more usual to put a + at the beginning of a continuation line rather than at the end of the first, broken, line. – barbara beeton May 20 '19 at 14:47
  • By the way, a "compilable" example should start with \documentclass. (And \usepackage belongs in the preamble.) – barbara beeton May 20 '19 at 14:49
  • @barbarabeeton First of all thank you for the convention help, I didn't know that. But I do have a & after the line break – Asaf Cohen May 20 '19 at 14:51
  • You need a matching & in both lines, to set the position where the second line should start. The & at the end of the first line isn't really doing anything. What I'd do is move that to just before the =, and start the second line with &\qquad + so that it doesn't line up exactly with the =. Take a look at the amsmath user guide for examples. – barbara beeton May 20 '19 at 15:19
  • 1
    Well, your equation is too long to be on a line. Please do not "textize" your equation too much - equation is math! –  May 20 '19 at 15:25
  • do you really have a documentclass environment??, please test the code you have posted and check that anyone can run it to see the issue that you are asking about. – David Carlisle May 20 '19 at 16:30

2 Answers2

2

I would use more lines, with at most one of those “verbose variable” per line:

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{equation}
\begin{split}
\mathrm{Y}_{it} = \beta_{0}
&+\beta_{1}(\textrm{Education Construction})_{it} \\
&+\beta_2(\textrm{Economic Slack})_{it} \\
&+\beta_3(\textrm{Economic Slack})\cdot(\textrm{Education Construction})_{it} \\
&+\beta_4 X_{it} + \sum fe_{i} + \sum fe_{t} + \mu_{it}
\end{split}
\end{equation}

\end{document}

enter image description here

egreg
  • 1,121,712
0

Welcome to TeX.SX! There are a few issues with your example code.

Basic Document Format

Since you do not appear to be defining a documentclass here, you should start with a simple preamble that defines which documentclass you are using. If you are unsure, article is a common choice. For example:

\documentclass{article}

\begin{document}
...
\end{document}

Be sure to include the beginning and ending of your document (in fact, you should \end{...} anything that you \begin{...}). Including packages with \usepackage{...} should go before \begin{document} but after \documentclass{...}.

Applying these principles, so far your code should look like this:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
    \begin{equation}
    \begin{split}
          \textrm{Y}_{it} = \beta_{0}+\beta_{1}\textrm{Education Construction}_{it}+ \beta_2\textrm{economic slack}_{it} + \beta_3\textrm{economic slack}*\textrm{Education Construction}_{it}+ & \\ \beta_4 X_{it} + \sum fe_{i} + \sum fe_{t} + \mu_{it} 
          \end{split}
    \end{equation}
\end{document}

How To Handle Long Equations

There are already questions that address this problem (for example here and here), but I suggest you use a simple align approach. You designate the location within the equation you would like to align your following lines to (left-align) with the & character. I tend to pick the =, so it's as simple as &=. You do not need split or equation in this case, you simply use the align environment. A simple replacement of your above method with the align method will yield:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align*}
    \textrm{Y}_{it} &= \beta_{0}+\beta_{1}\textrm{Education Construction}_{it}+ \beta_2\textrm{economic slack}_{it} + \beta_3\textrm{economic slack}*\textrm{Education Construction}_{it} \\
    &+ \beta_4 X_{it} + \sum fe_{i} + \sum fe_{t} + \mu_{it} 
\end{align*}
\end{document}

And to shorten or lengthen lines, simply change where you want to break them up at. For example, your equation would fit on the page if constructed as follows:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align*}
    \textrm{Y}_{it} &= \beta_{0}+\beta_{1}\textrm{Education Construction}_{it}+ \beta_2\textrm{economic slack}_{it} \\
    &+ \beta_3\textrm{economic slack}*\textrm{Education Construction}_{it} \\
    &+ \beta_4 X_{it} + \sum fe_{i} + \sum fe_{t} + \mu_{it} 
\end{align*}
\end{document}

Final Comments

@JouleV makes a good argument in the comments that your equation does contain a lot of text. I suggest removing or reducing the text, which would also help it to fit into more compact space.

Hope this helps!