source.tex 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. % =============================================================================
  2. % Compact template for integration with an empty agent: Nanjing University of Science and Technology bachelor's thesis format
  3. % Cover all structural components with minimal body text, focusing on format reuse
  4. % Compile: tectonic main.tex or xelatex && bibtex && xelatex && xelatex
  5. % =============================================================================
  6. \documentclass[a4paper, 12pt, twoside]{ctexart}
  7. % --- Page setup (A4; top 30mm, bottom 24mm, left/right 25mm; header footskip=20mm) ---
  8. \usepackage[
  9. a4paper,
  10. top=30mm, bottom=24mm, left=25mm, right=25mm,
  11. headheight=15pt, headsep=10mm, footskip=20mm
  12. ]{geometry}
  13. % --- Body: SimSun, Chinese small size 4, approximately 20pt fixed line spacing ---
  14. \usepackage{setspace}
  15. \AtBeginDocument{\zihao{-4}\songti\setlength{\baselineskip}{20pt}\setlength{\parindent}{2em}}
  16. % --- Prevent Overfull \hbox by allowing paragraph word spacing to stretch ---
  17. \emergencystretch=0.5em
  18. % --- Font settings ---
  19. % Chinese: SimSun for body text; synthetic bold SimSun for headings to meet the school's bold-SimSun requirement
  20. % English and numbers: Times New Roman
  21. \usepackage{fontspec}
  22. \setmainfont{Times New Roman}
  23. \setCJKmainfont[AutoFakeBold=2.5]{Songti SC}
  24. \setCJKfamilyfont{song}[AutoFakeBold=2.5]{Songti SC}
  25. \setCJKfamilyfont{hei}{Heiti SC}
  26. % --- Mathematical formulas ---
  27. \usepackage{amsmath, amssymb}
  28. % --- Figures and tables ---
  29. \usepackage{graphicx}
  30. \graphicspath{{../图表/}}
  31. \usepackage{float}
  32. \usepackage{subcaption}
  33. \DeclareCaptionFont{songwu}{\songti\zihao{5}}
  34. \captionsetup{font=songwu, labelfont=songwu, labelsep=space}
  35. \captionsetup[lstlisting]{font=songwu, labelfont=songwu, labelsep=space}
  36. \usepackage{booktabs}
  37. \usepackage{multirow}
  38. \usepackage{longtable}
  39. \usepackage{tabularx}
  40. \usepackage{adjustbox}
  41. \usepackage{afterpage}
  42. % --- Number figures, tables, and equations by chapter (Figure X-X, Table X-X, Equation X-X) ---
  43. \IfFileExists{chngcntr.sty}{\usepackage{chngcntr}}{}
  44. \counterwithin{figure}{section}
  45. \counterwithin{table}{section}
  46. \counterwithin{equation}{section}
  47. \def\thefigure{\thesection.\arabic{figure}}
  48. \def\thetable{\thesection.\arabic{table}}
  49. \def\theequation{\thesection.\arabic{equation}}
  50. % --- Code blocks ---
  51. \usepackage{listings}
  52. \usepackage{listingsutf8}
  53. \usepackage{xcolor}
  54. \lstset{
  55. basicstyle=\zihao{5}\ttfamily,
  56. columns=fullflexible,
  57. keepspaces=true,
  58. literate={,}{{,}}1 {。}{{。}}1 {:}{{:}}1 {;}{{;}}1
  59. {(}{{(}}1 {)}{{)}}1 {、}{{、}}1,
  60. keywordstyle=\color{blue},
  61. commentstyle=\color{gray},
  62. stringstyle=\color{red!70!black},
  63. numbers=left,
  64. numberstyle=\tiny\color{gray},
  65. frame=single,
  66. breaklines=true,
  67. tabsize=4,
  68. }
  69. % --- Cross-references and hyperlinks (load hyperref as late as possible) ---
  70. \usepackage{hyperref}
  71. \hypersetup{
  72. colorlinks=true,
  73. linkcolor=black,
  74. citecolor=black,
  75. urlcolor=black,
  76. }
  77. % --- References (GB/T 7714-2015 numeric style; sort&compress compacts citation numbers) ---
  78. % Use natbib + gbt7714-numerical; for BibTeX, run xelatex twice, bibtex, then xelatex twice
  79. \usepackage[numbers,sort&compress]{natbib}
  80. \bibliographystyle{gbt7714-numerical}
  81. % --- Headers and footers (different odd/even pages, page numbers on the outside) ---
  82. % Even pages (CE): chapter title on the left, "Bachelor's Thesis" on the right
  83. % Odd pages (CO): "Bachelor's Thesis" on the left, chapter title on the right
  84. % Page numbers at LE (left even) and RO (right odd), i.e. the outer edges
  85. \usepackage{fancyhdr}
  86. \pagestyle{fancy}
  87. \fancyhf{}
  88. % Correct sectionmark definition; must precede its use
  89. \makeatletter
  90. \def\sectionmark#1{\markboth{\thesection\quad #1}{}}
  91. \makeatother
  92. \fancyhead[CO]{\songti\zihao{5} 学士学位论文\hfill <论文题目(简)>}
  93. \fancyhead[CE]{\songti\zihao{5} \leftmark\hfill 学士学位论文}
  94. \fancyfoot[LE,RO]{\songti\zihao{5}\thepage}
  95. \fancypagestyle{plain}{%
  96. \fancyhf{}%
  97. \fancyhead[CO]{\songti\zihao{5} 学士学位论文\hfill <论文题目(简)>}%
  98. \fancyhead[CE]{\songti\zihao{5} \leftmark\hfill 学士学位论文}%
  99. \fancyfoot[LE,RO]{\songti\zihao{5}\thepage}%
  100. }
  101. % --- TOC depth: include three heading levels ---
  102. % tocloft: \cftsecnumdepth=3 includes section/sub/subsub levels
  103. \IfFileExists{tocloft.sty}{\usepackage[titles]{tocloft}}{}
  104. \def\contentsname{目\quad 录}
  105. \def\refname{参考文献}
  106. % --- Chapter heading format (school requirements) ---
  107. \ctexset{
  108. section = {
  109. format = \raggedright\songti\bfseries\zihao{-3},
  110. beforeskip = 18pt,
  111. afterskip = 18pt,
  112. break = \clearpage,
  113. },
  114. subsection = {
  115. format = \raggedright\songti\bfseries\zihao{4},
  116. beforeskip = 12pt,
  117. afterskip = 12pt,
  118. },
  119. subsubsection = {
  120. format = \raggedright\songti\bfseries\zihao{-4},
  121. beforeskip = 6pt,
  122. afterskip = 6pt,
  123. },
  124. paragraph = {
  125. format = \raggedright\songti\zihao{-4},
  126. beforeskip = 6pt,
  127. afterskip = 0pt,
  128. },
  129. }
  130. % --- Custom commands ---
  131. \newcommand{\frontmattertitle}[1]{%
  132. \vspace*{18pt}\begin{center}{\songti\bfseries\zihao{3}#1}\end{center}\vspace{18pt}}
  133. \newcommand{\centeredsectionstar}[1]{%
  134. \clearpage\phantomsection\vspace*{18pt}\begin{center}{\songti\bfseries\zihao{3}#1}\end{center}\vspace{18pt}}
  135. % =============================================================================
  136. \begin{document}
  137. % ========================== Abstract ==========================
  138. \newpage
  139. \pagestyle{plain}
  140. \pagenumbering{roman}
  141. \frontmattertitle{摘\quad 要}
  142. \phantomsection
  143. \addcontentsline{toc}{section}{摘要}
  144. 本文针对XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX。
  145. XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX。
  146. XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX。
  147. \vspace{1cm}
  148. \noindent{\songti\bfseries\zihao{4} 关键词:}{\songti\zihao{-4} 关键词1;关键词2;关键词3}
  149. % ========================== Abstract ==========================
  150. \newpage
  151. \markboth{Abstract}{}
  152. \begin{center}{\bfseries\zihao{3} Abstract}\end{center}\vspace{18pt}
  153. \phantomsection
  154. \addcontentsline{toc}{section}{Abstract}
  155. This thesis presents a systematic study of XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.
  156. XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.
  157. XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.
  158. \vspace{1cm}
  159. \noindent{\bfseries\zihao{4} Keywords:}{\zihao{-4} keyword1; keyword2; keyword3}
  160. % ========================== Table of contents ==========================
  161. \newpage
  162. \markboth{目\quad 录}{}
  163. \begingroup
  164. \def\contentsname{目\quad 录}
  165. \tableofcontents
  166. \endgroup
  167. % For duplex printing, add a blank page if the front matter has an odd page count
  168. \ifodd\value{page}\newpage\thispagestyle{empty}\mbox{}\fi
  169. % ========================== Main text ==========================
  170. \newpage
  171. \pagestyle{fancy}
  172. \pagenumbering{arabic}
  173. % ========================================================================
  174. % Chapter 1: Introduction
  175. % ========================================================================
  176. \section{绪论}
  177. \subsection{研究背景与意义}
  178. XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX。
  179. 如图\ref{fig:architecture}所示,XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX。
  180. \begin{figure}[H]
  181. \centering
  182. \includegraphics[width=0.65\textwidth]{architecture.jpg}
  183. \caption{系统架构图}
  184. \label{fig:architecture}
  185. \end{figure}
  186. \subsection{国内外研究现状}
  187. XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX。
  188. 文献\cite{author2024example}提出了XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX。
  189. \subsubsection{Linux调度器研究}
  190. XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX。
  191. % Use paragraph for level-four headings; school requirements generally omit subsubsubsection
  192. \paragraph{相关技术基础}
  193. XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX。
  194. \subsection{本文创新点}
  195. 本文主要创新点如下:
  196. \begin{enumerate}
  197. \item 创新点一:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX。
  198. \item 创新点二:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX。
  199. \end{enumerate}
  200. % ========================================================================
  201. % Chapter 2: Technical Background
  202. % ========================================================================
  203. \section{相关技术基础}
  204. 本章介绍XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX。
  205. \subsection{Linux调度器原理}
  206. CFS的核心思想是XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX。
  207. 虚拟运行时间的计算如式\eqref{eq:vruntime}所示。
  208. \begin{equation}
  209. \Delta vruntime = \Delta t_{wall} \times \frac{NICE\_0\_LOAD}{weight(task)}
  210. \label{eq:vruntime}
  211. \end{equation}
  212. 表\ref{tab:cfs-params}列出了CFS的核心可调参数及其语义。
  213. \begin{table}[H]
  214. \centering
  215. \caption{CFS核心可调参数}
  216. \label{tab:cfs-params}
  217. \begin{tabular}{lll}
  218. \toprule
  219. \textbf{参数名称} & \textbf{基准值} & \textbf{语义} \\
  220. \midrule
  221. \texttt{sched\_latency\_ns} & 6\,ms & 调度周期目标 \\
  222. \texttt{sched\_min\_granularity\_ns} & 0.75\,ms & 最小抢占粒度 \\
  223. \bottomrule
  224. \end{tabular}
  225. \end{table}
  226. % ========================================================================
  227. % Chapter 3: System Design
  228. % ========================================================================
  229. \section{系统设计}
  230. XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX。
  231. \subsection{总体架构}
  232. XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX。
  233. \section{实验与分析}
  234. XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX。
  235. % ========================================================================
  236. % References
  237. % ========================================================================
  238. % Reference page numbers continue in Arabic numerals from the main text; do not switch back to Roman numerals
  239. % For BibTeX, replace \begin{thebibliography}... with
  240. % \bibliography{refs}, then run xelatex && bibtex && xelatex && xelatex
  241. \newpage
  242. \begin{thebibliography}{99}
  243. \bibitem{author2024example} Author A, Author B. Title of the reference[J].
  244. Journal Name, 2024, 1(1): 1-10. DOI: 10.0000/example.
  245. \bibitem{linuxkernel} Linux Kernel Documentation[EB/OL].
  246. \url{https://www.kernel.org/doc/html/latest/}.
  247. \end{thebibliography}
  248. % ========================== Appendix ==========================
  249. \appendix
  250. \centeredsectionstar{附\quad 录}
  251. \markboth{附\quad 录}{}
  252. \addcontentsline{toc}{section}{附录}
  253. \subsection*{附录A:实验配置}
  254. 表~\ref{tab:appendix-configs}列出了实验配置。
  255. \begin{table}[H]
  256. \centering
  257. \caption{实验配置表}
  258. \label{tab:appendix-configs}
  259. \begin{tabular}{llr}
  260. \toprule
  261. \textbf{参数} & \textbf{符号} & \textbf{值} \\
  262. \midrule
  263. CPU核心数 & $N$ & 4 \\
  264. 调度周期 & $T$ & 10\,ms \\
  265. \bottomrule
  266. \end{tabular}
  267. \end{table}
  268. \subsection*{附录B:核心代码}
  269. \begin{lstlisting}[language=C, caption={示例代码}, label={lst:sample}]
  270. #include <stdio.h>
  271. int main() {
  272. printf("Hello, World!\n");
  273. return 0;
  274. }
  275. \end{lstlisting}
  276. \end{document}