Emacs seems to be doing some WYSIWYG with _, as if it were in math mode (in the picture, _ is followed by subscript 'o', inside the include statement. It shouldn't. I'm using Emacs/Tex out of the box, no special configuration.

GNU Emacs 24.5.1

$ pdflatex --version
pdfTeX 3.14159265-2.6-1.40.19 (TeX Live 2018)
kpathsea version 6.3.0

the 'o' next to '_' is displayed as a subscript inside Emacs

Minimal text example for reconstruction:

\documentclass{article}
\usepackage{pdfpages}
\begin{document}
  Underscore-o should not be set as subscript in the next line:
  \includepdf[pages={1}]{home/er/Documents/records/law/fr/om-ren/20170117_o}

  But it should be set as subscript in math environments like $A_o$.
\end{document}
  • I can reproduce the effect with emacs -Q GNU Emacs 25.1.50.2. One possible solution would be to switch to AUCTeX. Therewith the argument of underscore is only set as subscript if it occurs in math environments. But I agree that AUCTeX is quite heavy. It brings a lot of features which you probably do not want. – Tobias Jul 17 at 12:55

This is an old problem, with an answer here - just use \textunderscore keyword. Works both in LaTeX and .org files. The underscore character is reserved in LaTeX.

In Emacs:

enter image description here

The resulting .pdf:

enter image description here

The better alternative to latex-mode from tex-mode.el is LaTeX-mode from AUCTeX. If AUCTeX is not provided by your Linux distribution you find it via package-list-packages after proper setup of package.el.

If you want to stick to latex-modefrom tex-mode.el and if you do not excessively use math in your documents you can toggle off tex-fontify-script via the customization interface. You get to the customization interface by M-x customize-option RET tex-fontify-script RET.

  • Thanks. AUCTeX displays underscored correctly. I'm posting a new question for setting up the viewer. – Erwann Jul 18 at 23:32
  • @Erwann If Xviewer is the name of the executable then Command should be Xviewer %o and Viewer Executable should be Xviewer. – Tobias Jul 18 at 23:59

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.