4

Like this post, when I indent within a SRC code block in org-mode, 8 consecutive spaces are converted to a tab. Moreover, when I export to LaTeX 8 consecutive spaces are converted to tabs in the resultant .tex output. This is a problem as my LaTeX (pdflatex / xelatex) convert tabs in verbatim mode to a single space. This means my source code's indentation is off. A http://tex.stackexchange.com poster was told to use fancyvrb, but that doesn't immediately solve my problem.

I want to use org-mode to write these documents, C-c ' to edit source blocks, and C-c C-e l p to turn my org-mode files into pdfs.

What options do I have to, for instance:

  • make org-mode SRC blocks export as fancyvrb's Verbatim mode OR

  • prevent my org-mode's indentation mechanism and my export to LaTeX from turning 8 spaces into a tab OR

  • post-process the exported LaTeX and transform the tabs into 8 spaces?

And how can I make this setting the default for my org-mode? I would like not to have to include this same boilerplate in all of my org-mode files that I intend to use with it, and I would like to avoid having a special latex compilation command to have to use for the tex files I generate.

2 Answers 2

2
(setq TeX-auto-untabify 't)

Adding that to the .emacs file solves the problem wonderfully.

1
  • 1
    Mark your own question as the solution if it solved the problem you had.
    – user12563
    Apr 5, 2018 at 7:05
1

With respect to "prevent my org-mode's indentation mechanism and my export to LaTeX from turning 8 spaces into a tab", consider setting org-src-preserve-indentation to a non-NIL value. If org-src-preserve-indentation is set to NIL, org will remove leading whitespace and reindent the code block.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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