我认为唯一的问题是\setmonofont{Consolas}
。令我困惑的是,我已经成功编译了代码,但是,当我重建我的操作系统(Windows 10)时,它不起作用。我尝试了很多方法但都是徒劳的。
\documentclass{article}
\usepackage{xcolor}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{geometry}
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{listings}
\usepackage{fontspec}
\setmonofont{Consolas}
\usepackage[UTF8]{ctex} % Chinese
\geometry{left = 2.0cm, right = 2.0cm, top = 2.5cm, bottom = 2.5cm} % 控制使用页面尺寸
\begin{document}
\title{Templates for ACM-ICPC}
\date{July 5, 2017}
\author{Phoebus}
\maketitle % Creates the titlepage
\pagenumbering{gobble} % Turns off page numbering
\newpage % Starts a new page
\tableofcontents % Auto-generate a table of content after compile again.
\newpage
\pagenumbering{arabic} % Turns on page numbering
\section{Mathmatics}
\subsection{快速乘法,防止爆long long}
\begin{lstlisting}[language = C++, numbers=left, numberstyle=\tiny,keywordstyle=\color{blue!70},
commentstyle=\color{red!50!green!50!blue!50},frame=shadowbox, rulesepcolor=\color{red!20!green!20!blue!20},basicstyle=\ttfamily]
// a*k equals Add k-a
typedef long long ll;
ll quickMul(ll a, ll k, ll m) {
ll ret = 0;
while(k){
if(k & 1) ret = (ret + a) % m;
k >>= 1;
a = (a << 1) % m;
}
return ret;
}
\end{lstlisting}
\end{document}