5

Total neophyte to TeX, trying to type up a term paper due tonight and I keep getting really weird errors during compile. I'm not sure if this question has been asked before, but I don't really know any of the lingo to be able to word the question properly. I've just been going about learning TeX from the internet, and so I apologize if this is an absolute shambles.

Here's a copy of the code snippet that is causing the problem, please let me know if there's anything else I need to include.

\documentclass[paper=a4, fontsize=12pt]{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage[margin=1in]{geometry}
\usepackage[english]{babel}
\usepackage{mathtools,amsfonts,amsthm}
\usepackage{sectsty}
\allsectionsfont{\centering \normalfont\scshape}
\usepackage{fancyhdr}
\pagestyle{fancyplain}
\fancyhead{} 
\fancyfoot[L]{}
\fancyfoot[C]{}  

\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\setlength{\headheight}{11pt}


\setlength{\parindent}{2em}
\setlength{\parskip}{16pt}

\begin{document}

if we start our octave at C, or N_{0}=C, then we get \{C,C,D,C,F,E,C,C,D,C,G,F\}, which we can relabel as \{0,0,2,0,5,4,0,0,2,0,7,5\} if we just use the indices of the group elements.

\end{document}

2 Answers2

7

If you examine the .log, you'll see the following:

! Missing $ inserted.
<inserted text>
               $
l.25 if we start our octave at C, or N_
                                       0=C,
I've inserted a begin-math/end-math symbol since I think
you left one out. Proceed, with fingers crossed.

What that tells you is that TeX thinks (rightly in this case) that there is a problem with the underscore (i.e., the _), which it normally expects only to see in math mode.

Ideally, if you are writing a(n inline) mathematical expression, you should write:

$N_{0}=C$   

If you want a regular underscore in regular text, you need to escape it with a backslash:

N\_0=C

Note that any good introduction should cover which relatively common symbols need escaping. It is also discussed in the Comprehensive LaTeX Symbol List, which is a really indispensible document no matter what kind of document you end up writing.

jon
  • 22,325
2

Here is a working example with fixes, and I have made one suggestion: create a \newcommand by which you may define the style of tone values (C, D, etc)...I chose sans serif, but you can make it anything you like. That way, you may put them in text or math mode and they will appear as desired...as well as distinguishable from text and math variables.

\documentclass[paper=a4, fontsize=12pt]{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage[margin=1in]{geometry}
\usepackage[english]{babel}
\usepackage{mathtools,amsfonts,amsthm}
\usepackage{sectsty}
\allsectionsfont{\centering\normalfont\scshape}
\usepackage{fancyhdr}
\pagestyle{fancyplain}
\fancyhead{} 
\fancyfoot[L]{}
\fancyfoot[C]{}  

\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\setlength{\headheight}{11pt}


\setlength{\parindent}{2em}
\setlength{\parskip}{16pt}

\newcommand{\tone}[1]{\textsf{#1}} % to change typeface of tone values, simply change this line...and that is why we use TeX!

\begin{document}

if we start our octave at \tone{C}, or $N_{0}=\tone{C}$, then we get $\{\tone{C},\tone{C},\tone{D},\tone{C},\tone{F},\tone{E},\tone{C},\tone{C},\tone{D},\tone{C},\tone{G},\tone{F}\}$, which we can relabel as $\{0,0,2,0,5,4,0,0,2,0,7,5\}$ if we just use the indices of the group elements.

\end{document}
commonhare
  • 2,630