TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

So I am trying to insert an equation. The output seems to be correct, but I get some error messages.

  H(C) = - \sum\limits_{c=1}^{|C|} \left\frac{\sum\limits_{k=1}^{|K|} {a_c_k} }{n}\right log \left\frac{\sum\limits_{k=1}^{|K|} {a_c_k}}{n}\right
share|improve this question
up vote 2 down vote accepted


  • You can't write "double subscripts" like a_c_k. You have to choose either {a_c}_k or a_{c_k}. I went for the latter in my code below.

  • Your \left...\right syntax needs to specify what kind of bracket you want. For instance, \left(...\right).

  • You can't have align inside an equation, so I got rid of the align environment, since it wasn't doing anything. (Perhaps you intended aligned?)

  • I took the liberty of changing \frac{big formula}{n} to \frac{1}{n} big formula, which I think is better style.

  • \centering isn't doing anything here, so I got rid of it. Equations are centred by default.

Fixed code

  H(C) = - \sum\limits_{c=1}^{|C|} \left(\frac{1}{n}\sum\limits_{k=1}^{|K|} {a_{c_k}} \right) log \left(\frac{1}{n}\sum\limits_{k=1}^{|K|} {a_{c_k}}\right)


enter image description here

share|improve this answer
Wow, thanks so much! And to answer your question, I thought I had to have \align... I'm a latex-noob :) – Johan Sjons May 22 '13 at 14:35
Oh, one more thing I forgot in my answer: you should write \log rather than log. log is typeset as l multiplied by o multiplied by g. – John Wickerson May 22 '13 at 14:57
@JohanSjons -- align is not recommended for one-line equations. many people use it for convenience, but it's bad. some discussion appears in this question: Spacing between equation and text inconsistent due to large equations – barbara beeton May 22 '13 at 18:04
@JohnWickerson Thank you so much, noticed that in the original equation, but did not know the difference! I have another question (though feeling like an idiot). When trying almost the same thing, I get some error messages: \begin{equation} \label{eg:homogeneity1} H(C|K) = - \sum\limits_{k=1}^{|K|} \sum\limits_{c=1}^{|C|} \left(\frac{a_{c_k}}{n}\right) \log \left(\frac{a_{c_k}}{\sum\limits_{c=1}^{|C|} {a_{c_k}}\right)} \end{equation} – Johan Sjons May 23 '13 at 11:04
@barbarabeeton Thank you! – Johan Sjons May 23 '13 at 11:05

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.