1

i keep getting a lot of errors when compiling this equation:

\begin{center}{
$\textit{C} \in \{2^0, 2^1,..., 2^9\}; \textit{\gamma} \in \{\frac{2^0}{100},\frac{2^1}{100},..., \frac{2^6}{100}\}$
}\end{center}

Mainly the 'Missing $ inserted' and 'Extra }, or forgotten $' appear. I tried all possible combinations of placing $, e.g. for every single \frac, using $$ or placing more {}. I'm quite new to LaTex so maybe I just don't see the obvious ;) thanks!

  • Welcome. Please show us the packages you have included. Though unrelated, \cdots may be used instead of the three dots .. – Frenzy Li Jul 29 '16 at 10:40
  • 1
    Welcome to TeX.SX! The correct input is \[C\in\{2^0, 2^1,\dots, 2^9\}; \gamma\in \{\frac{2^0}{100},\frac{2^1}{100},\dots, \frac{2^6}{100}\}\] – egreg Jul 29 '16 at 10:40
  • 1
    (1) welcome, (2) sorry to say this, but you really need to have a look at some introductionary note about LaTeX. This is not how you write math – daleif Jul 29 '16 at 10:41
  • 1
    welcome to tex.sx. $, all by itself, makes single letters, both greek and latin, italic, so no special treatment is needed. also, \textit puts you into text mode, and \gamma requires math mode. just get rid of \textit and you should be (mostly) okay. – barbara beeton Jul 29 '16 at 10:41
  • Thanks guys for the quick reply! just removing the \textit commands did the job. Have a nice weekend :) – Johan Jul 29 '16 at 11:10
3

Beginner's mistakes.

If you want to have a displayed equation, use

\begin{equation*}
<the equation>
\end{equation*}

So in your case you would have to type

\begin{equation*}
C\in\{2^0, 2^1,\dots, 2^9\}; 
\gamma\in \left\{\frac{2^0}{100},\frac{2^1}{100},\dots, \frac{2^6}{100}\right\}
\end{equation*}

(line breaks are irrelevant so long as there is no blank line in the equation* environment).

Note that the environment already puts you in math mode and you don't need \mathit or \textit around letters, because math mode italicizes automatically.

Minimal full example.

\documentclass{article}
\usepackage{amsmath}

\usepackage{lipsum} % just to add some mock text

\begin{document}

\lipsum*[1]
\begin{equation*}
C\in\{2^0, 2^1,\dots, 2^9\}; 
\gamma\in \left\{\frac{2^0}{100},\frac{2^1}{100},\dots, \frac{2^6}{100}\right\}
\end{equation*}
\lipsum[2]

\end{document}

Never leave a blank line before a math display.

enter image description here

Please, do yourself a favor and consult a beginner's guide such as LaTeX for Complete Novices

  • 3
    As a suggestion, may be add a space after ;\ , or ;\quad or ;\qquad. – Manuel Jul 29 '16 at 11:34
  • Out of curiosity: why is LaTeX not robust to blank lines in math displays? – JPi Jul 29 '16 at 12:44
  • 1
    @JPi Error confinement; it was Knuth's precise choice. – egreg Jul 29 '16 at 12:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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