0

In my TeXworks (MikTeX 2.9) editor, the following file compiles correctly. But when I change sin-1(x) to sin^-1(x) the following error occurs. I thought TeXworks would treat sin^-1(x) just as a plain text if not inside amsmath delimiters $..$, \(...\) etc.:

! Missing $ inserted.
<inserted text> 
                $
l.8 Ignore sin^
               -1(x) for typesetting
? 

.text File:

\documentclass[11pt]{article}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\begin{document}

This \(a^{4}\) is a test.
Ignore sin-1(x) for typesetting
Another \(a_3\) test.

\end{document}
nam
  • 1,105
  • 1
    Try \^{}, also see http://tex.stackexchange.com/questions/77646/how-to-typset-the-symbol-caret-circumflex-hat โ€“ Francis Dec 25 '15 at 19:42

1 Answers1

2

This doesn't have anything to do with TeXworks, MikTeX, or Ams-TeX; the LaTeX compiler itself is throwing this error at you.

The issue is that LaTeX restricts the usage of some symbols that have a special meaning to the interpreter. For example, because % signals the beginning of a comment, if you want a percent sign in your document, you have to write it as \%. Similarly, you will also need to escape \, #, $, ^, &, ~, _, {, and } in text mode, because these all have special meanings.

Specifically, ^ means a superscript in math mode, so $a^2 + b^2 = c^2$ is OK, but the 5^{th} symphony will generate the same error you have, since ^ isn't allowed in textmode without being escaped.

To solve this problem, you have a couple options, depending on context and what you want it to look like.

  1. You can write sin\^{-1}(x) and keep everything in text mode.
  2. You can use \textsuperscript to get a superscript in text mode: sin\textsuperscript{-1}(x).
  3. You can put everything in math mode, where it works without issue: $\sin^{-1}(x)$. (Writing \sin instead of sin typesets it upright, which looks better.)
  4. If you want it written in monospace, use \verb+sin^-1(x)+.

Here's how each of these options looks in the final document. I personally prefer option 3.

enter image description here

Arun Debray
  • 7,126
  • 2
  • 30
  • 54