0

I have defined a custom listings style in the header of my org mode file:

#+LATEX_HEADER: \usepackage{listings}
#+LATEX_HEADER: \usepackage{color}
#+LATEX_HEADER: \definecolor{codegreen}{rgb}{0,0.6,0}
#+LATEX_HEADER: \definecolor{codegray}{rgb}{0.5,0.5,0.5}
#+LATEX_HEADER: \definecolor{backcolour}{RGB}{247,248,250}
#+LATEX_HEADER: \definecolor{codebrown}{RGB}{171,88,106}
#+LATEX_HEADER: \definecolor{codeblue}{RGB}{122,99,192}
#+LATEX_HEADER: \definecolor{codeorange}{RGB}{255,165,121}
#+LATEX_HEADER: \lstdefinestyle{mystyle}{
#+LATEX_HEADER:     backgroundcolor=\color{backcolour},
#+LATEX_HEADER:     commentstyle=\color{codegreen},
#+LATEX_HEADER:     keywordstyle=\color{codebrown},
#+LATEX_HEADER:     morekeywords={Blocks, Block, Factor, Factors, dim_type,
#+LATEX_HEADER:                   Vars, Index_Set, Linear_Expr, Con, Cons, Gen,
#+LATEX_HEADER:                   Gens, Var, F_Poly},
#+LATEX_HEADER:     numberstyle=\tiny\color{codegray},
#+LATEX_HEADER:     stringstyle=\color{codeorange},
#+LATEX_HEADER:     basicstyle=\footnotesize\ttfamily,
#+LATEX_HEADER:     breakatwhitespace=false,
#+LATEX_HEADER:     breaklines=true,
#+LATEX_HEADER:     captionpos=b,
#+LATEX_HEADER:     keepspaces=true,
#+LATEX_HEADER:     numbers=none,
#+LATEX_HEADER:     showspaces=false,
#+LATEX_HEADER:     showstringspaces=false,
#+LATEX_HEADER:     showtabs=false,
#+LATEX_HEADER:     tabsize=2
#+LATEX_HEADER: }

Now, in my init file I tell emacs to use listings when using source blocks:

(add-to-list 'org-latex-packages-alist '("" "listings"))
(setq org-latex-listings 'listings)
(setq org-latex-listings-options
        '(("style" "mystyle")))

So, if in my org file I have something like this:

#+BEGIN_SRC C++
void remove_higher_space_dims(dim_type new_dim) {
  if (is_empty()) {
    dim = new_dim;
    return;
  }
}
#+END_SRC

it is exported like this:

\lstset{style=mystyle,language=C++,label= ,caption= ,captionpos=b,numbers=none}
\begin{lstlisting}
void remove_higher_space_dims(dim_type new_dim) {
  if (is_empty()) {
    dim = new_dim;
    return;
  }
\end{lstlisting}

But in the PDF the other keywords are not highlighted (e.g. dim_type) as you can see in this screen:

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.