# Different minted styles for different languages

I am trying to add two different snippets of code to a document, one in Java and one in ObjC. I have been able to set up the languages the way I like them, but I would like to set a different style depending on what language I am using. According to the minted documentation, the command \usemintedstyle[<language>]{<style>} can be used, but I keep on getting errors. This is what I have for now:

\documentclass[]{article}
\usepackage{filecontents}   % for writing to the .m file from within this .tex file
\usepackage{minted}

%Get the nice font for the code
\usepackage[T1]{fontenc}
\usepackage[scaled=0.8]{beramono}

\newmintedfile[objectiveccode]{objectivec}{
numberblanklines=true,
numbersep=12pt,
numbersep=5pt,
gobble=0,
frame=lines,
framerule=0.4pt,
framesep=1mm,
tabsize=4,
obeytabs=true,
samepage=false, %with this setting you can force the list to appear on the same page
showspaces=false,
showtabs =false,
linenos,
stepnumber=2
}

\newmintedfile[javacode]{java}{
numberblanklines=true,
numbersep=12pt,
numbersep=5pt,
gobble=0,
frame=lines,
framerule=0.4pt,
framesep=1mm,
tabsize=4,
obeytabs=true,
samepage=false, %with this setting you can force the list to appear on the same page
showspaces=false,
showtabs =false,
linenos,
stepnumber=2
}

% ===== CAUSING PROBLEMS =====
\usemintedstyle[objectivec]{xcode}
\usemintedstyle[java]{emacs}

\begin{document}

Prova

\begin{filecontents*}{sampleObjCcode.m}
#import <stdio.h>

int main( int argc, const char *argv[] ) {
printf( "hello world\n" );
return 0;
}
\end{filecontents*}

\begin{filecontents*}{sampleJava.java}
public class HelloWorld {

public static void main(String[] args) {
System.out.println("Hello, World");
}

}\end{filecontents*}

\objectiveccode{sampleObjCcode.m}
\javacode{sampleJava.java}

\end{document}


Any ideas why it is failing?

• looking at minted doc \usemintedstyle does not take an optional argument. Removing those lines makes things work, I'm not sure what you intend it to do? you have already specified the two differemt styles in the \javacode and \objectiveccode commands. – David Carlisle Dec 16 '14 at 12:50
• Ok, my bad. I was looking at the documentation for the 2.0 version here and in section 3.4 there is the option. I guess I'll have to download the dev version. Thanks anyways! – ruben1691 Dec 16 '14 at 13:56

Meanwhile this feature is integrated into the distro package minted. So the \usemintedstyle by language will work and output the following for your example: