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
minted
norpygments
. Nevertheless from pygments.org/demo I would have expectedbash
as language specifier for theminted
LaTeX environment but you getshell
which is not present in theSelect a lexer
box at pygments.org/demo. Maybe the mapping ofbash
source blocks toshell
source blocks is the actual problem. Try to replaceshell
bybash
in the LaTeX source file and to runpdflatex
for that file. – Tobias Jul 19 '18 at 16:48org-latex-listings-langs
, but this also didn't help anything. As thetex
file itself (when altered manually) isn't producing the expected output, I am starting to think the problem lies with tex/minted/pygments - not org-mode. – n1k31t4 Jul 19 '18 at 17:42tex
file from terminal, and the style is not taken... I have\usemintedstyle{monokai}
i.e. a dark theme in the pre-amble, however teh background is light and the text is dark. If I then force a dark background, the font colours remain the same as before, but it doesn't match the example from the pygments demo (see the added picture in my edit above). It is better than what org-mode manages, but still not right. I tried bothbash
andshell
as languages, both giving that same result. – n1k31t4 Jul 20 '18 at 8:45