0

I want my Org Mode Latex Pdf Export to look like Code Styles and Colours


Colour definitions for the xcolor package have been added to

org-format-latex-header

It looks like that now:

 (setq org-format-latex-header 
       '("\\documentclass{article}
 \\usepackage[usenames]{color}
 [PACKAGES]
 [DEFAULT-PACKAGES]
 \\definecolor{codegreen}{rgb}{0,0.6,0}
 \\definecolor{codegray}{rgb}{0.5,0.5,0.5}
 \\definecolor{codepurple}{rgb}{0.58,0,0.82}
 \\definecolor{backcolour}{rgb}{0.95,0.95,0.92}

 \\pagestyle{empty}             % do not remove
 % The settings below are copied from fullpage.sty
 \\setlength{\\textwidth}{\\paperwidth}
 \\addtolength{\\textwidth}{-3cm}
 \\setlength{\\oddsidemargin}{1.5cm}
 \\addtolength{\\oddsidemargin}{-2.54cm}
 \\setlength{\\evensidemargin}{\\oddsidemargin}
 \\setlength{\\textheight}{\\paperheight}
 \\addtolength{\\textheight}{-\\headheight}
 \\addtolength{\\textheight}{-\\headsep}
 \\addtolength{\\textheight}{-\\footskip}
 \\addtolength{\\textheight}{-3cm}
 \\setlength{\\topmargin}{1.5cm}
 \\addtolength{\\topmargin}{-2.54cm}"
         )
       )

mystyle settings

\lstdefinestyle{mystyle}{...}

have been added to

org-latex-listings-options

It looks like that now:

     (setq org-latex-listings-options
       '(("backgroundcolor" "\\color{backcolour}")
         ("commentstyle" "\\color{codegreen}")
         ("keywordstyle" "\\color{magenta}")
         ("numberstyle" "\\tiny\\color{codegray}")
         ("stringstyle" "\\color{codepurple}")
         ("basicstyle" "\\ttfamily\\footnotesize")
         ("breakatwhitespace" "false")
         ("breaklines" "true")
         ("captionpos" "b")
         ("keepspaces" "true")
         ("numbers" "left")
         ("numbersep" "5pt")
         ("showspaces" "false")
         ("showstringspaces" "false")
         ("showtabs" "false")
         ("tabsize" "2")
         )
       )

If I now use the export dispatcher with C-c C-e l L, and analyze the buffer nothing has changed.


1. Am I adjusting the settings/variables incorrectly?

2. Is there a better org mode way to get an automatically generated .pdf with code style highlighting?


Edit 1:

the org-latex-listings-options is inserted above every

\begin{lstlisting}
...
\end{lstlisting}

and not once above the \begin{document}

3. How can I optimize that


Edit 2: Here some example Files (Naming should clarify the purpose) Don´t know how to attach files in StackExchange

File Link

  • Can you please provide a mininal org file on which one can see the problem? – JeanPierre Nov 6 at 15:56
  • I edited the post with a gdrive link to some example files. – 7ie7an Nov 7 at 6:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.