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.

Typing, for example,

a^3

emacs would automatically change the source (!) to

This causes all sorts of problems with spacing, double superscripts, etc.

How can I turn off any such WYSIWYG behaviour?

Here is a LaTeX example (copy-paste from emacs)

\begin{equation}
  E(M) =  \pm 2\sqrt{\epsilon_0² + 16 t²-8t\epsilon_0}
\end{equation}

If I look at the file with more, I have for the same equation

\begin{equation}
  E(M) =  \pm 2\sqrt{\epsilon_0<B2> + 16 t<B2>-8t\epsilon_0}
\end{equation}
share|improve this question
    
This might not be Emacs' fault but your GUI's input manager's. Which operating system are you using? –  Christian Clason Sep 27 '12 at 14:07
    
Ubuntu 12 with Gnome. –  Martin Sep 27 '12 at 14:14
    
I get something similar in my emacs/AucTeX environment under Windows, but it shows $a^³$ . Tastes differ, but I find that quite helpful. And certainly no problems with the output. –  Brent.Longborough Sep 27 '12 at 14:45
    
Just to make sure: When you write "change the source", you mean the file as it is saved to disk (you can check by opening the file in gedit or using less in the terminal)? Or does it only happen in Emacs? –  Christian Clason Sep 27 '12 at 14:49
2  
Then it's definitely Gnome's keyboard driver. As such, it's not really specific to TeX, and will probably get better answers at the main SE site. (The fix involves switching to a keyboard layout with dead acute. Short workaround: hit ^ twice before typing the 2.) –  Christian Clason Sep 27 '12 at 15:53
show 3 more comments

4 Answers 4

Emacs will never automatically change the source. Your issue is either fontification, in which case you should be seeing a superscript caret '^' as well as the superscript '3', or you have enabled preview mode, which displays the LaTeX output of math environments in your buffer.

In the first case, assuming you are using Auctex (the recommended LaTeX editing environment), you can turn off fontification for scripts in the customization system:

M-x customize-variable font-latex-fontify-script <RET>

Then set the value to off or nil, and fontification will no longer apply to superscripts.

If you don't see the little caret, then you must have preview mode on. You should be able to remove all previews from the buffer using the preview menu on the menu bar, or by calling M-x preview-clearout-document. If you do have preview mode on, take a look at your .emacs and remove the line that is loading it.

share|improve this answer
add comment

Since the actual file is changed, and not just the displayed buffer, this is most likely due to the way the X server handles the input from the keyboard. Even with a localized layout, there is often not enough room on the keyboard for all the special, especially accented, characters many languages require. The solution people came up with is to use composition: First you hit one key to insert the accent ^ followed by the letter e, and you get ê. (Note that in the age of utf8 encoding and pdflatex, this is actually useful since you can input accented characters in your source directly.)

The drawback is that it leads to dead keys which do not yield the character they stand for; this is the case for the standard German keyboard layout, for example. If you enter more maths than French, of course, this is annoying. You have two options:

  1. Change the keyboard layout for a variant without dead keys (often called no dead keys or eliminate dead keys). Since you're on Ubuntu, here's a question that might help.

  2. Keep the layout, and hit ^ twice (or ^ followed by the spacebar) to enter a caret. (This works for any dead key.)

share|improve this answer
add comment

I'll bet you accidentally turned on the TeX input method. I have done similar things accidentally. You can do this for testing purposes by typing M-x set-input-method RET TeX RET. You will see exactly the behavior you describe. You can turn it off with M-x toggle-input-method.

If you ever wonder what you did you can type C-h l to see "lossage" which is a very funny name for the last 300 keystrokes (and mouse/menu events). You can hunt through that looking for something suspicious. Of course it only helps if you notice relatively soon.

share|improve this answer
add comment

I do not know much elisp, so I can not explain the code, but it might help you. Place the following in your .emacs file(or other loaded preference file):

;; Only change sectioning colour
(setq font-latex-fontify-sectioning 'color)
;; super-/sub-script on baseline
(setq font-latex-script-display (quote (nil)))
;; Do not change super-/sub-script font
(custom-set-faces
 '(font-latex-subscript-face ((t nil)))
 '(font-latex-superscript-face ((t nil)))
 )
;; Exclude bold/italic from keywords
(setq font-latex-deactivated-keyword-classes
      '("italic-command" "bold-command" "italic-declaration" "bold-declaration"))

Update: I just remembered, from where I got the code: http://stackoverflow.com/questions/9534239/emacs-auctex-latex-syntax-prevents-monospaced-font

share|improve this answer
add comment

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.