我正在使用 XeLaTeX,并使用 listings 包来显示一些源代码。\lstset
我将 tabsize 设置为 4:
\documentclass[a4paper, 11pt]{article}
\usepackage{filecontents}
\begin{filecontents*}{Text.txt}
public static int[] mergeSort(int[] array) {
if (array.length == 1) {
return array;
}
int[] left = new int[array.length / 2], right = new int[array.length - left.length];
System.arraycopy(array, 0, left, 0, array.length / 2);
System.arraycopy(array, left.length, right, 0, right.length);
left = mergeSort(left);
right = mergeSort(right);
return merge(left, right);
}
\end{filecontents*}
\usepackage{listings}
\lstset{
backgroundcolor=\color{lightgray},
basicstyle=\ttfamily\color{darkgray},
keywordstyle=\ttfamily\color{darkgray},
caption=a,
commentstyle=\color{gray}\ttfamily,
showstringspaces=false,
flexiblecolumns=true,
tabsize=4,
showtabs=false,
xleftmargin=0pt,
xrightmargin = 0pt,
label=DescriptiveLabel,
breaklines=true,
breakatwhitespace=true,
language=JAVA
}}
\begin{document}
\lstinputlisting{Text.txt}
\end{document}
但是显示代码时的 tabsize 是 3。可能是什么问题?感谢您的帮助。