[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] Org not preserving Python indent levels on LaTex export due to tabs

From: James Ryland Miller
Subject: [O] Org not preserving Python indent levels on LaTex export due to tabs
Date: Sat, 1 Feb 2014 17:56:59 -0600

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!")
              return x

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

1  def foo(x):
2      print("Hi: %s" % x)
3      if x == "James":
4   print("James is the best!")
5      else:
6   return x

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?

reply via email to

[Prev in Thread] Current Thread [Next in Thread]