![不同语言有不同铸造风格](https://linux22.com/image/476817/%E4%B8%8D%E5%90%8C%E8%AF%AD%E8%A8%80%E6%9C%89%E4%B8%8D%E5%90%8C%E9%93%B8%E9%80%A0%E9%A3%8E%E6%A0%BC.png)
我正在尝试向文档添加两个不同的代码片段,一个是 Java 代码,另一个是 ObjC 代码。我已经能够按照自己喜欢的方式设置语言,但我想根据我使用的语言设置不同的样式。根据 minted 文档,\usemintedstyle[<language>]{<style>}
可以使用该命令,但我一直收到错误。这是我目前所拥有的:
\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}
知道它为什么会失败吗?