0

When I try to compile my LaTeX file, where begin{align} environment is to be used, I get an error:

my command is :

\begin{align}
    \textbf{Y}_{it}  = \alpha + {\sum}_l{\beta}_l\{t-\text{E}_i=l\}*treatment_i + $X$_{it}\Gamma + \phi_i + \gamma_t + \varepsilon_{it}
\end{align}

enter image description here

the output is kind of funny enter image description here

since it gives me"programepstopdf" in pdf view....

also try in begin{equation} and end{equation}, still throws error. Does someone know what did i do wrong here? also checked other questions and answers but not solve it.

2
  • Use \mathbf, not \textbf in the context of math formulas. And \mathrm, not \text for a letter you want upright. Also treatment should be \mathit{treatment}.
    – egreg
    Jan 16 at 22:05
  • There's also no reason for encasing \sum and \beta in curly braces. In fact, encasing \sum in curly braces is a rather bad idea.
    – Mico
    Jan 16 at 23:40

2 Answers 2

1

You wrongly used $ in align which is also math:

\documentclass{article}

\usepackage{amsmath}

\begin{document}
    \begin{align}
    \textbf{Y}_{it}  = \alpha + {\sum}_l{\beta}_l\{t-\text{E}_i=l\}*treatment_i + X_{it}\Gamma + \phi_i + \gamma_t + \varepsilon_{it}
\end{align}
\end{document}

preview

1
  • Please don't encase \sum in curly braces.
    – Mico
    Jan 16 at 23:41
1

The error is caused by $X$, because $ initiates or ends math mode, but the contents of align is already in math mode.

There's much room for improvements, though.

  1. Avoid align for a single equation, it's for aligning multiple ones (or parts thereof)

  2. \textbf{Y} should be \mathbf{Y}

  3. \text{E} should be \mathrm{E}, assuming you want the letter to be upright

  4. The letters treatment are considered a product of several variables; if you want to mean a single multiletter variable, use \mathit{treatment}

  5. * is never used in mathematics for denoting multiplication

  6. I guess you don't want \sum, but \Sigma

  7. Avoid redundant braces

Complete example

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{equation}
\mathbf{Y}_{it}  = 
\alpha + \Sigma_l\beta_l\{t-\mathrm{E}_i=l\}\cdot \mathit{treatment}_i 
+ X_{it}\Gamma + \phi_i + \gamma_t + \varepsilon_{it}
\end{equation}

\end{document}

enter image description here

Or, maybe, you want \sum, but with the subscript on the side. In this case

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{equation}
\mathbf{Y}_{it}  = 
\alpha + \sum\nolimits_l\beta_l\{t-\mathrm{E}_i=l\}\cdot \mathit{treatment}_i 
+ X_{it}\Gamma + \phi_i + \gamma_t + \varepsilon_{it}
\end{equation}

\end{document}

enter image description here

2
  • +1. "I guess you don't want \sum, but \Sigma". Actually, my guess is that what the OP wants is \sum\nolimits_l...
    – Mico
    Jan 16 at 23:42
  • @Mico Agreed and added.
    – egreg
    Jan 16 at 23:54

You must log in to answer this question.

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