2

I have the following code:

\[
  \begin{cases*}
    1& if 
  \end{cases*}
...

after the if, I want to type a dollar sign but get the error message "Math mode started with '\[' cannot be closed with dollar". I am unsure how to fix this.

EDIT: Clarifications

  • I want to type a dollar sign to enter into math mode. Note that the cases* environment expects text after the ampersand.
  • The error message mentioned is an AUCTeX error (shows up in the *Messages* buffer)---it doesn't allow me to type the dollar sign character into the Emacs buffer.
7
  • 2
    Please be more specific. What do you mean by a dollar? What exactly is the full if phrase here? – daleif Jan 14 at 22:50
  • When you say “you want to type a dollar sign”, do you mean you want to go into math mode to write a formula, or do you mean you want to actually produce a dollar sign in the pdf output? – Peter LeFanu Lumsdaine Jan 14 at 23:02
  • if asking about an error please post some code that reproduces the error so people can debug. Currently all we know is that some code you have not shown generates an error. (the tex error will be unrelated to auctex which is just the editor support for writing the file) – David Carlisle Jan 14 at 23:10
  • 1
    you do know that $ starts or ends math mode and \$ is needed to typeset a $ ? – David Carlisle Jan 14 at 23:19
  • 4
    @DavidCarlisle The cases* environment wants text in the second column; thus it's a real AUCTeX error not to allow for $ in that position. Apparently, AUCTeX hasn't got support for the mathtools extensions to amsmath. – egreg Jan 15 at 6:53
2

This behaviour comes from the TeX-insert-dollar function which is described as

(defun TeX-insert-dollar (&optional arg)
  "Insert dollar sign.

If current math mode was not entered with a dollar, refuse to
insert one.  Show matching dollar sign if this dollar sign ends
the TeX math mode and `blink-matching-paren' is non-nil.

When outside math mode, the behavior is controlled by the variable
`TeX-electric-math'.

With raw \\[universal-argument] prefix, insert exactly one dollar
sign.  With optional ARG, insert that many dollar signs."

Looking at the implementation there does not seem to be a possibility to only disable this specific behaviour of refusing to insert $. You basically have two options:

  1. Follow the documentation shown above and use the universal argument, i.e. press C-u $ to insert a dollar sign.

  2. Remove the $ key from the mode-dependent mapping, i.e.

    (define-key TeX-mode-map "$" nil)
    

    This will map $ back to self-insert-command (or whatever is in your global map) but this way you will also lose the other functionality brought by TeX-insert-dollar such as TeX-electric-math.

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.