# AUCTex: Math mode started with ‘\[’ cannot be closed with dollar in cases*

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.
• Please be more specific. What do you mean by a dollar? What exactly is the full if phrase here? Jan 14, 2021 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? Jan 14, 2021 at 23:02
• you do know that $ starts or ends math mode and \$ is needed to typeset a $ ? Jan 14, 2021 at 23:19 • @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. Jan 15, 2021 at 6:53
• @ArashEsbati I understand the problem. My aim was to avoid the misunderstanding: the OP does want a $ there, not \$ like it was suggested. Jan 16, 2021 at 11:45

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.