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'm pretty new to LaTeX, completely new actually, and there is one thing I can't quite understand.

I get the error "Display math should end with $$" when writing an equation like this:

\begin{equation}

$R_{2}$=$\frac{U_{R_2}}{I_2}$=$\frac{2,95\, \mathrm{V}$}{$0,03*10^{-3}\, \mathrm{A}$} = 7,10\,\mathrm{k}\Omega \,.

\label{eq:Bsp_OhmsLaw}\end{equation}

I tried a lot of things, I also skimmed these forums. Nothing seemed to help :-(

Thanks in advance!

share|improve this question
10  
Welcome to the site! You shouldn't use all of those $ symbols within the equation environment; remove them, and the blank lines, and you should get closer to a working piece of code :) –  cmhughes Mar 29 at 15:57
2  
Please post complete compilable code as this makes it much easier to understand and answer your question. –  cfr Mar 29 at 16:00
    
Also, $$ is from plain TeX and has been replaced in LaTeX with a host of options, including \[ and \]. –  John Kormylo Mar 29 at 16:04

2 Answers 2

up vote 7 down vote accepted

In addition to removing the $ as cmhughes suggested, the blank lines in the equation environment confuse things. This may be why you added the dollar signs - with the blanks, LaTeX otherwise complains about missing $ symbols in the code.

Here's a working version:

\documentclass{article}

\begin{document}

\begin{equation}
  R_{2}=\frac{U_{R_2}}{I_2}=\frac{2,95\, \mathrm{V}}{0,03*10^{-3}\, \mathrm{A}} = 7,10\,\mathrm{k}\Omega \,.
  \label{eq:Bsp_OhmsLaw}
\end{equation}

\end{document}

equation

share|improve this answer
    
Thank's so much! It may sound odd, but my professor never really expained why and how to properly use the $ signs, so I just use them before and after every term that isn't just text.. worked fine so far, but I can see it leads to the first problems already. –  user48884 Mar 29 at 16:20
2  
Bascially, equation already tells TeX it is in maths mode. That's why you need e.g. \mathrm{} to get something text-like. If you are in a maths environment like that, don't use $ signs. Normally, you'd use $ signs if you wanted to typeset some maths inline i.e. in the middle of a paragraph or in the cell of a table or something like that. –  cfr Mar 29 at 16:43
1  
@cfr Or, even better than $...$, you can use \(...\). –  Jubobs Apr 11 at 12:25
    
You could also change * to \times to get a properly typeset multiplication symbol, and even though it is obvious from context in this case, * is used for other operations in mathematics. –  Ahlqvist Apr 11 at 12:59
    
I'd also like to mention that it's generally a good idea to not use several equals signs in the same line. –  1010011010 May 16 at 22:32

Use the siunitx package for typesetting physical quantities:

\documentclass{article}

\usepackage{amsmath}
\usepackage[
  locale = DE % comma as decimal mark
]{siunitx}

\begin{document}

\begin{equation}
\label{eq:Bsp_OhmsLaw}
  R_{2}
  = \frac{U_{2}}{I_{2}}
  = \frac{\SI{2.95}{\volt}}{\SI{0.03e-3}{\ampere}}
  = \SI{7.10}{\kilo\ohm}.
\end{equation}
Ohm's law is used in equation~\eqref{eq:Bsp_OhmsLaw}.

\end{document}

output

Note that cfr has given the answer to why the initial code isn't compiling.

Update

You can make the code a bit shorter by use abbreviations for the physical units:

\documentclass{article}

\usepackage{amsmath}
\usepackage[
  locale = DE % comma as decimal mark
]{siunitx}

\begin{document}

\begin{equation}
\label{eq:Bsp_OhmsLaw}
  R_{2}
  = \frac{U_{2}}{I_{2}}
  = \frac{\SI{2.95}{\V}}{\SI{0.03e-3}{\A}}
  = \SI{7.10}{\kohm}.
\end{equation}
Ohm's law is used in equation~\eqref{eq:Bsp_OhmsLaw}.

\end{document}

(See page 37 of the manual.)

share|improve this answer
    
Wouldn't it be more instructive to write out \V and \A as it was done with \kiko\ohm. Also unless really really required to, I'd recommend using . as the decimal point, not comma. Otherwise one will have to wrap all non unit numbers in \num{...} which is a big hassle if one have not done so from the beginning. –  daleif Apr 11 at 10:55
    
@daleif Regarding \V and \A: I guess. (The reverse case: Do you know if there is an abbreviation for \kiko\ohm?) The comma is because that is how it is in the question. –  Svend Tveskæg Apr 11 at 12:21
    
abreviations \kohm –  daleif Apr 11 at 12:24
    
@daleif You could also use the icomma package to get properly spacing if comma is used a decimal separator. –  Ahlqvist Apr 11 at 13:01
    
In that case I'd rather use the siunitx approach and not have globally active math comma –  daleif Apr 11 at 13:18

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.