|
| 1 | +\documentclass{article} |
| 2 | +\usepackage[fontset=none]{ctex} |
| 3 | +\usepackage{amsmath, amsthm, amssymb} |
| 4 | +\usepackage{lmodern} |
| 5 | +\usepackage{listings,xcolor} |
| 6 | +\usepackage{geometry} |
| 7 | +\usepackage{fontspec} |
| 8 | +\usepackage{graphicx} |
| 9 | +\usepackage[colorlinks, linkcolor=blue, anchorcolor=blue, citecolor=green]{hyperref} |
| 10 | +\usepackage{setspace} |
| 11 | +\usepackage{fancyhdr} |
| 12 | +\usepackage{titletoc} |
| 13 | + |
| 14 | +% 页面布局紧凑设置 |
| 15 | +\geometry{a4paper, left=1.5cm, right=1.5cm, top=2cm, bottom=2cm} % 减小边距 |
| 16 | +\setlength{\footskip}{20pt} % 减小页脚间距 |
| 17 | + |
| 18 | +% 字体设置 |
| 19 | +\setCJKmainfont{Source Han Sans HW SC}[ |
| 20 | + ItalicFont={Source Han Sans HW SC}, |
| 21 | + ItalicFeatures={FakeSlant=0.2} |
| 22 | +] |
| 23 | +\setCJKsansfont{Source Han Sans HW SC}[ |
| 24 | + ItalicFont={Source Han Sans HW SC}, |
| 25 | + ItalicFeatures={FakeSlant=0.2} |
| 26 | +] |
| 27 | +\setCJKmonofont{Source Han Sans HW SC}[ |
| 28 | + ItalicFont={Source Han Sans HW SC}, |
| 29 | + ItalicFeatures={FakeSlant=0.2} |
| 30 | +] |
| 31 | + |
| 32 | +\setmainfont{Inconsolata LGC Nerd Font Mono} |
| 33 | +\setsansfont{Inconsolata LGC Nerd Font Mono} |
| 34 | +\setmonofont{Inconsolata LGC Nerd Font Mono} |
| 35 | + |
| 36 | +% 取消首行缩进和减小行间距 |
| 37 | +\setlength{\parindent}{0pt} % 无首行缩进 |
| 38 | +\setstretch{1.0} % 行距调整为 1.0 |
| 39 | + |
| 40 | +% 页眉页脚紧凑设置 |
| 41 | +\setlength{\headheight}{13pt} |
| 42 | +\pagestyle{fancy} |
| 43 | +\fancyhf{} |
| 44 | +\fancyhead[L]{\leftmark} % 页眉左侧显示章节名 |
| 45 | +\fancyfoot[C]{\thepage} % 页脚中间显示页码 |
| 46 | + |
| 47 | +% 代码样式设置 |
| 48 | +\lstdefinestyle{cppstyle}{ |
| 49 | + language=C++, % 语言设置为 C++ |
| 50 | + basicstyle=\ttfamily\small\linespread{1.0}\selectfont, |
| 51 | + keywordstyle=\color{blue}\bfseries, % 关键字颜色 |
| 52 | + commentstyle=\color{gray}\itshape, % 注释颜色,斜体 |
| 53 | + stringstyle=\color{red}, % 字符串颜色 |
| 54 | + numbers=left, % 行号显示在左侧 |
| 55 | + numberstyle=\small\color{gray}, % 行号样式 |
| 56 | + stepnumber=1, % 行号递增 |
| 57 | + numbersep=10pt, % 行号和代码的间隔 |
| 58 | + backgroundcolor=\color{gray!5}, |
| 59 | + showspaces=false, % 不显示空格 |
| 60 | + showstringspaces=false, % 字符串中不显示空格 |
| 61 | + breaklines=true, % 自动换行 |
| 62 | + frame=single, % 给代码添加边框 |
| 63 | + rulecolor=\color{black!30}, % 边框颜色 |
| 64 | + tabsize=4, % 设置 Tab 宽度 |
| 65 | + captionpos=b % 标题位置 |
| 66 | +} |
| 67 | + |
| 68 | +\lstdefinestyle{pythonstyle}{ |
| 69 | + language=Python, % 语言设置为 Python |
| 70 | + basicstyle=\ttfamily\small\linespread{1.0}\selectfont, |
| 71 | + keywordstyle=\color{blue}\bfseries, % 关键字颜色 |
| 72 | + commentstyle=\color{gray}\itshape, % 注释颜色,斜体 |
| 73 | + stringstyle=\color{red}, % 字符串颜色 |
| 74 | + numbers=left, % 行号显示在左侧 |
| 75 | + numberstyle=\small\color{gray}, % 行号样式 |
| 76 | + stepnumber=1, % 行号递增 |
| 77 | + numbersep=10pt, % 行号和代码的间隔 |
| 78 | + backgroundcolor=\color{gray!5}, |
| 79 | + showspaces=false, % 不显示空格 |
| 80 | + showstringspaces=false, % 字符串中不显示空格 |
| 81 | + breaklines=true, % 自动换行 |
| 82 | + frame=single, % 给代码添加边框 |
| 83 | + rulecolor=\color{black!30}, % 边框颜色 |
| 84 | + tabsize=4, % 设置 Tab 宽度 |
| 85 | + captionpos=b % 标题位置 |
| 86 | +} |
| 87 | + |
| 88 | +\lstdefinestyle{javastyle}{ |
| 89 | + language=Java, % 语言设置为 Java |
| 90 | + basicstyle=\ttfamily\small\linespread{1.0}\selectfont, |
| 91 | + keywordstyle=\color{blue}\bfseries, % 关键字颜色 |
| 92 | + commentstyle=\color{gray}\itshape, % 注释颜色,斜体 |
| 93 | + stringstyle=\color{red}, % 字符串颜色 |
| 94 | + numbers=left, % 行号显示在左侧 |
| 95 | + numberstyle=\small\color{gray}, % 行号样式 |
| 96 | + stepnumber=1, % 行号递增 |
| 97 | + numbersep=10pt, % 行号和代码的间隔 |
| 98 | + backgroundcolor=\color{gray!5}, |
| 99 | + showspaces=false, % 不显示空格 |
| 100 | + showstringspaces=false, % 字符串中不显示空格 |
| 101 | + breaklines=true, % 自动换行 |
| 102 | + frame=single, % 给代码添加边框 |
| 103 | + rulecolor=\color{black!30}, % 边框颜色 |
| 104 | + tabsize=4, % 设置 Tab 宽度 |
| 105 | + captionpos=b % 标题位置 |
| 106 | +} |
| 107 | + |
| 108 | + |
| 109 | +% 标题样式设置 |
| 110 | +\usepackage{titlesec} |
| 111 | +\titleformat{\section}{\large\bfseries}{\thesection}{1em}{} |
| 112 | +\titleformat{\subsection}{\normalsize\bfseries}{\thesubsection}{1em}{} |
| 113 | +\titleformat{\subsubsection}{\small\bfseries}{\thesubsubsection}{1em}{} |
| 114 | + |
| 115 | +% 目录样式设置 |
| 116 | +\usepackage{tocloft} |
| 117 | +\cftsetindents{subsection}{1.2em}{2.5em} |
| 118 | +\cftsetindents{subsubsection}{2.5em}{3.5em} |
| 119 | + |
| 120 | +% 封面设置 |
| 121 | +\title{{PLACEHOLDER:TITLE}} |
| 122 | +\author{{PLACEHOLDER:AUTHOR}} |
| 123 | +\date{\today} |
| 124 | + |
| 125 | +\begin{document} |
| 126 | + |
| 127 | +% 封面内容 |
| 128 | +\maketitle |
| 129 | +{ |
| 130 | + \hypersetup{linkcolor=black} |
| 131 | + \tableofcontents |
| 132 | +} |
| 133 | + |
| 134 | +\newpage |
0 commit comments