Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am trying to center my equation on the line using this code:

\[

\ l_{12} =  \frac {m_{c} c_{c} \frac {dT_{c}}{dt} + m_{s} c_{s} \frac {dT_{s}}{dt}}{m_{s}} Delta t 

\]

but I keep getting this error: Missing $ inserted. I tried adding $ but it's still not working.

share|improve this question
2  
Welcome to TeX.sx! Are there empty lines in your source, too? (Comment those lines out (%) or remove them. This applies to every math mode (plain, LaTeX or amsmaths environment).) –  Qrrbrbirlbel Nov 11 '12 at 1:44
1  
I can confirm that it works when removing empty lines. –  Ketan Nov 11 '12 at 1:46
    
I removed the empty lines but I am getting the same error. Is there a specific package I need to use? I have now {amsmath} and {amssymb} –  Lynn Nov 11 '12 at 1:49
1  
@Lynn Can you post a minimal working example (MWE) starting with \documentclass and ending with \end{document}? A tip: If you indent lines by 4 spaces, they'll be marked as a code sample. You can also highlight the code and click the "code" button (with "{}" on it). –  Qrrbrbirlbel Nov 11 '12 at 1:50
1  
Yep, as the others said you have a blank line issue. Also, there is a leading backslash that I think was meant for \Delta instead which is missing the backslash. The four space indenting is only for posting here so that the code gets displayed as code rather than text. –  Peter Grill Nov 11 '12 at 2:08
show 2 more comments

1 Answer

As already said in my comment. Empty lines in math mode are not allowed.

Comment them out with % or remove them entirely.

If you load amsmath you have the benefit of using its very helpful math environments. In this case you probably want the equation or (unnumbered) the equation* environment.

(I also removed the preceding backslash \ and moved it in front of Delta.)

Code

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\[
%
l_{12} =  \frac {m_{c} c_{c} \frac {dT_{c}}{dt} + m_{s} c_{s} \frac {dT_{s}}{dt}}{m_{s}} \Delta t 
%
\]

\[
l_{12} =  \frac {m_{c} c_{c} \frac {dT_{c}}{dt} + m_{s} c_{s} \frac {dT_{s}}{dt}}{m_{s}} \Delta t 
\]

\begin{equation}
l_{12} =  \frac {m_{c} c_{c} \frac {dT_{c}}{dt} + m_{s} c_{s} \frac {dT_{s}}{dt}}{m_{s}} \Delta t 
\end{equation}

\begin{equation*}
l_{12} =  \frac {m_{c} c_{c} \frac {dT_{c}}{dt} + m_{s} c_{s} \frac {dT_{s}}{dt}}{m_{s}} \Delta t 
\end{equation*}
\end{document}

Output

Output

share|improve this answer
add comment

Your Answer

 
discard

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.