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.

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}
share|improve this question
1  
Welcome to TeX.SX! –  Christian Hupfer Mar 14 at 3:30
    
If you're using large CSV-lists (in math-mode), you may have problems breaking them across lines. To get around this, consider reading How to achieve line break in simple $formula$-mode. –  Werner Mar 14 at 3:44
    
Freaky—a friend of mine is doing the same thing tonight, and her thesis is also on music (coupled with CS). Welcome to TeX.SX! Note that when you want to type math, you need to wrap it in $ signs (or \(…\), but that's much less common.) –  Sean Allred Mar 14 at 4:00

2 Answers 2

up vote 7 down vote accepted

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.

share|improve this answer

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}
share|improve this answer

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.