emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Org not preserving Python indent levels on LaTex export due to tabs
@ 2014-02-01 23:56 James Ryland Miller
  2014-02-02  7:49 ` Nicolas Goaziou
  0 siblings, 1 reply; 9+ messages in thread
From: James Ryland Miller @ 2014-02-01 23:56 UTC (permalink / raw)
  To: emacs-orgmode

I'm having trouble with getting python source=code blocks to export to
LaTeX properly. I've figured out what's going wrong: the exporter is
inserting tab characters on lines with 2 or more indentation levels in
python. If I use org to export to .tex first, and then untabify the
.tex files, the indent levels are preserved (assuming the tabs
correctly lined up with the corresponding python in the first place,
which many times they don't).

Here's a test.org file:

* Heading 1

LaTeX export does not work on python src blocks with more than 2
levels of indentation.

For example (4 spaces per indent level, not tabs):

#+BEGIN_SRC python -n
      def foo(x):
          print("Hi: %s" % x)
          if x == "James":
              print("James is the best!")
          else:
              return x
#+END_SRC

The above should be indented properly. But it isn't. The resulting
.tex file has tabs on the second indent level lines and the tab
doesn't even line up with the 4 spaces per tab either. Any ideas how
to get rid of this? If I run a =C-x h M-x untabify= on the .tex file,
then it exports just fine. But I don't /want/ to do that each and
every time I export my org files.

Here's the verbatim portion of the generated LaTeX source:

#+BEGIN_SRC latex -n

\begin{verbatim}
1  def foo(x):
2      print("Hi: %s" % x)
3      if x == "James":
4   print("James is the best!")
5      else:
6   return x
\end{verbatim}
#+END_SRC

Note: lines 4 and 6 in the =\begin{verbatim}= blocks.

Line 4 is "4[space][space][tab]print("James...")"  How do I get org to export
with all spaces and no tabs for verbatims in LaTeX?

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2014-03-15  6:43 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-01 23:56 Org not preserving Python indent levels on LaTex export due to tabs James Ryland Miller
2014-02-02  7:49 ` Nicolas Goaziou
2014-02-02 17:32   ` James Ryland Miller
2014-02-02 18:05     ` John Hendy
2014-02-03 13:08   ` Sebastien Vauban
2014-02-03 14:56     ` Bastien
2014-02-14  0:32   ` Samuel Wales
2014-02-16 10:11     ` Nicolas Goaziou
2014-03-15  6:43       ` Bastien

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).