我想自定义minted
语法突出显示,但minted
包装文档,也不是TeX.SX 上 minted 语法高亮的现有主题,也不谷歌提供如何做到这一点的解释。
我目前还不太相信这minted
比有那么好listings
,这一观点主要源于的即时可定制性listings
。
因此有两个问题:
minted
如果其他软件包的灵活性和定制可访问性有如此大的不足,我为什么要使用它呢?- 在哪里可以调整软件包的语法高亮颜色
minted
?我更希望能够制作自己的配色方案。
。
\documentclass{article}
\usepackage{xcolor}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{listings}
\lstset{ %
backgroundcolor=\color{white}, % choose the background color; you must add \usepackage{color} or \usepackage{xcolor}
basicstyle=\ttfamily, % the size of the fonts that are used for the code
breakatwhitespace=false, % sets if automatic breaks should only happen at whitespace
breaklines=true, % sets automatic line breaking
captionpos=b, % sets the caption-position to bottom
commentstyle=\color{red}, % comment style
deletekeywords={...}, % if you want to delete keywords from the given language
escapeinside={\%*}{*)}, % if you want to add LaTeX within your code
extendedchars=true, % lets you use non-ASCII characters; for 8-bits encodings only, does not work with UTF-8
frame=single, % adds a frame around the code
keepspaces=true, % keeps spaces in text, useful for keeping indentation of code (possibly needs columns=flexible)
keywordstyle=\color{orange}, % keyword style
language=R, % the language of the code
morekeywords={*,...}, % if you want to add more keywords to the set
numbers=left, % where to put the line-numbers; possible values are (none, left, right)
numbersep=5pt, % how far the line-numbers are from the code
numberstyle=\tiny\color{purple}, % the style that is used for the line-numbers
rulecolor=\color{black}, % if not set, the frame-color may be changed on line-breaks within not-black text (e.g. comments (green here))
showspaces=false, % show spaces everywhere adding particular underscores; it overrides 'showstringspaces'
showstringspaces=false, % underline spaces within strings only
showtabs=false, % show tabs within strings adding particular underscores
stepnumber=2, % the step between two line-numbers. If it's 1, each line will be numbered
stringstyle=\color{green}, % string literal style
tabsize=1, % sets default tabsize to 2 spaces
title=\lstname % show the filename of files included with \lstinputlisting; also try caption instead of title
}
\usepackage{minted}
\usemintedstyle{fruity}
\begin{document}
\begin{lstlisting}
#include <stdio.h>
#define N 10
/* Block
* comment */
int main()
{
int i;
// Line comment.
puts("Hello world!");
for (i = 0; i < N; i++)
{
puts("LaTeX is also great for programmers!");
}
return 0;
}
\end{lstlisting}
\begin{minted}{python}
import numpy as np
def incmatrix(genl1,genl2):
m = len(genl1)
n = len(genl2)
M = None #to become the incidence matrix
VT = np.zeros((n*m,1), int) #dummy variable
#compute the bitwise xor matrix
M1 = bitxormatrix(genl1)
M2 = np.triu(bitxormatrix(genl2),1)
...
\end{minted}
\end{document}