I am trying to export org-mode source blocks to pdf via Latex and I use minted to get syntax highlighting. My org file looks like this:
#+latex_header: \usepackage[utf8]{inputenc} %% For unicode chars
#+latex_header: \usepackage{minted}
#+latex_header: \usepackage{xcolor}
#+latex_header: \usemintedstyle{monokai} %% sets default for all source-code blocks
#+latex_header: \definecolor{dark}{HTML}{272822} %% custom colour for background
#+attr_latex: :options bgcolor=dark
#+BEGIN_SRC bash -i
rosrun rosbag topic_renamer.py <in topic> <in bag> <out topic> <out bag>
#+END_SRC
I read on this latex thread, that I have to manually specify the background colour, which is why I use that additional #+attr_latex:
specifying bgcolor
. That definitely does seem to help, but I cannot get the bash language to be correctly coloured. I get black text on the manually applied dark
background:
So it seems the colour of the text is somehow affected by the bgcolor
I manually apply to the source-block.
If I change the language, e.g. to c
, I get something more like what I expect (which also happens to look pretty cool!):
#+attr_latex: :options bgcolor=dark
#+BEGIN_SRC c -i
rosrun rosbag topic_renamer.py <in topic> <in bag> <out topic> <out bag>
#+END_SRC
trying to set the style manually for the source-block also doesn't seem to help. Using this:
#+attr_latex: :options style=monokai, bgcolor=dark
#+BEGIN_SRC bash -i
rosrun rosbag topic_renamer.py <in topic> <in bag> <out topic> <out bag>
#+END_SRC
makes no difference, and I get the same as above, without the style option:
I can see in the generated tex
files that options are being passed correctly to the minted block:
\begin{minted}[breaklines=true,breakanywhere=true,bgcolor=dark]{shell}
rosrun rosbag topic_renamer.py <in topic> <in bag> <out topic> <out bag>
\end{minted}
I have the following setup in my init file:
(setq org-latex-listings 'minted
org-latex-packages-alist '(("newfloat" "minted"))
org-latex-pdf-process
'("pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"
"pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"))
which was taken from here.
I have tried looking in the list of language names to language modes (a mapping) that org-mode maintains, and see that bash was there, I also added (shell shell)
so the name "shell" is mapped the shell-mode
.
Otherwise I don't really know where to start
EDIT:
Output when editing the .tex
file and compiling in terminal:
\begin{minted}[style=monokai,bgcolor=dark]{bash}
#!/usr/bin/bash
for (( i=0; i != 10; i=i+1)); do
echo $i
done
\end{minted}
some text remains dark and un-readable