1

I'm trying to insert a python code in my latex document so, I used a couple of colors to highlight the keywords and string words ...

\documentclass[a4paper,12pt,blue,rgb,]{tubsbook}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{lipsum}
\usepackage{listings}
\usepackage{xcolor}
\usepackage{hyperref}
\usepackage{array,multirow}
\usepackage{graphicx}
\usepackage[activate]{pdfcprot}

\definecolor{codegreen}{rgb}{0,0.6,0}
\definecolor{codegray}{rgb}{0.5,0.5,0.5}
\definecolor{backcolour}{rgb}{0.95,0.95,0.92}
\lstdefinestyle{mystyle}{
  backgroundcolor=\color{backcolour},   
  commentstyle=\color{codegreen},
  keywordstyle=\color{Maroon},
  numberstyle=\tiny\color{codegray},
  stringstyle=\color{magenta},
  basicstyle=\footnotesize,
  breakatwhitespace=false,         
  breaklines=true,                 
  captionpos=b,                    
  keepspaces=true,                 
  numbers=left,                    
  numbersep=5pt,                  
  showspaces=false,                
  showstringspaces=false,
  showtabs=false,                  
  tabsize=2
}

But I'm getting this error with the maroon color : ! Package xcolor Error: Undefined color `Maroon' What could be the reason?

  • 1
    Load xcolor with option [dvipsnames] or [svgnames] (more colours). – Bernard Aug 25 '16 at 10:45
  • i tried with options but i get this : ! LaTeX Error: Option clash for package xcolor. – A.nechi Aug 25 '16 at 10:49
  • 3
    This means xcolor is already loaded by some other package (hyperref?) with other options or no option. In this case, either use \PassOptionsToPackage{svgnames or dvipsnames or both}{xcolor}, or write the option in the document class options. – Bernard Aug 25 '16 at 11:03
  • 1
    @Christian Hupfer/ Yes, I'v just checked: hyperref only loads color, hycolor and xcolor-patch, none of which seem to load xcolor. That said, I think the advice is valid for any (normal?) class. – Bernard Aug 25 '16 at 11:11
  • 1
    @ChristianHupfer LaTeX-Vorlagen im Corporate Design der TU Braunschweig (external link). – campa Aug 25 '16 at 11:49

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.