Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • cloustile/njuthesis
  • GGbond/njuthesis
  • caomeng/njuthesis
  • yilye/njuthesis
  • kopanswer/njuthesis
  • Dansen/njuthesis
  • junjimy/njuthesis
  • wuqizuo123/njuthesis
  • zxlll-/njuthesis
  • Michael/njuthesis
  • bcbhfz/njuthesis
  • LingDu/njuthesis
  • jiejiangwu/njuthesis
  • Tilnel/njuthesisundergraduate
  • nju-lug/nju-latex-templates/njuthesis
15 results
Show changes
Showing
with 9555 additions and 2923 deletions
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% NJU Thesis
% 南京大学毕业论文LaTeX模板
% Version 0.12.0 (2021-11-30)
%
% 请关注项目地址以获取最新变化
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% njuthesis 示例模板 v1.4.2 2024-11-08
% https://github.com/nju-lug/NJUThesis
% https://git.nju.edu.cn/nju-lug/nju-latex-templates/njuthesis
% https://ctan.org/pkg/njuthesis
%
% 贡献者
% Yu XIONG @atxy-blip Yichen ZHAO @FengChendian
% Song GAO @myandeg Chang MA @glatavento
% Yu XIONG @atxy-blip Yichen ZHAO @FengChendian
% Song GAO @myandeg Chang MA @glatavento
% Yilun SUN @HermitSun Yinfeng LIN @linyinfeng
%
% Yukai Chou @Muzimuzhi
%
% 许可证
% LaTeX Project Public License(版本 1.3c 或更高)
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%-------------------------------------------------
% 一些提使用体验的小技巧:
%---------------------------------------------------------------------
% 一些提使用体验的小技巧:
% 1. 请务必使用 UTF-8 编码编写和保存本文档
% 2. 请务必使用 XeLaTeX 或 LuaLaTeX 引擎进行编译
% 3. 不保证接口稳定,写作前一定要读一读说明文档
% 3. 不保证接口稳定,写作前一定要留意版本号
% 4. 以百分号(%)开头的内容为注释,可以随意删除
%-------------------------------------------------
%---------------------------------------------------------------------
%---------------------------------------------------------------------
% 请先阅读使用手册:
% http://mirrors.ctan.org/macros/unicodetex/latex/njuthesis/njuthesis.pdf
%---------------------------------------------------------------------
\documentclass[
% 模板选项:
% degree = ug|mg|mf|phd, % 学位类型,默认为本科
% type = thesis|design, % 文档类型,默认为毕业论文
% nlcover = true|false, % 是否需要国家图书馆封面,默认关闭
% 以下两项为字体设置,不改动则自动调用系统预装字体
% customlatinfont=windows|macos|linux|gyre|none,
% customchinesefont=windows|macos|linux|fandol|founder|noto|none,
]{njuthesis}
\njusetup {
% 设置参数
% 模板选项(注意右端逗号):
%
% 一些提醒:
% 1. 千万不要有空行
% 2. 使用英文半角逗号(,)分隔选项
% 3. 等于号(=)两侧的空格会被忽略
% 3.1. 为避免歧义,请用花括号({})包裹内容
% 4. 本科生无需填写的项目已被特别标注
% type = bachelor|master|doctor|postdoc, % 文档类型,默认为本科生
% degree = academic|professional, % 学位类型,默认为学术型
%
% info 类用于录入个人信息
% 带*号的为对应英文字段
info = {
titlea = {第一行标题},
titleb = {第二行标题},
titlec = {第三行标题},
% 中文题目
% 这里采取手动换行方式,三个选项依次对应三行
% 如果只有第一行,其余两个选项就留空,以此类推
%
title* = {My Title in English},
% 英文题目
%
author = {姓名},
% 作者姓名
%
author* = {Ming Xing},
% 作者英文姓名
% 一般使用拼音
%
keywords = {我,就是,充数的,关键词},
% 中文关键词列表
% 使用英文半角逗号(,)分隔
%
keywords* = {Dummy,Keywords,Here,{It Is}},
% 英文关键词
% 使用英文半角逗号(,)分隔
%
grade = {2018},
% 年级
%
student-id = {189114514},
% 学号
% 本模板会自动更正研究生学号的大小写
%
department = {化学化工学院},
department* = {School of Chemistry and Chemical Engineering},
% 院系
%
major = {化学},
major* = {Chemistry},
% 专业
%
supervisora = {导师},
supervisora*= {My Supervisor},
% 导师姓名
%
supervisora-title = {教授},
supervisora-title* = {Professor},
% 导师职称
%
supervisorb = {第二导师},
supervisorb* = {My Second Supervisor},
supervisorb-title = {副教授},
supervisorb-title* = {Associate professor},
% 第二导师
% 如果确实没有第二导师,留空即可
%
submit-date = {2021年8月10日},
% 提交日期
%
%
% 以下均为研究生项
field = {理论与计算化学},
field* = {Theoretical and Computational Chemistry},
% 研究领域
%
submit-date* = {Aug 10, 2021},
% 提交日期(英文)
%
defend-date = {2021年9月19日},
% 答辩日期
%
chairman = {某某某~教授},
% 答辩委员会主席
% 推荐使用波浪号(~)分隔姓名和职称
%
reviewer = {
某某某~教授,
某某某~教授
},
% 答辩委员会成员
% 一共四名,使用英文半角逗号(,)分隔
%
clc = {0175.2},
% 中图分类号
%
secret-level = {限制},
% 密级
%
udc = {004.72},
% UDC分类号
%
supervisor-contact = {
博士~
南京大学~
江苏省南京市栖霞区仙林大道163号
}
% 导师联系方式
}
}
% 自行使用所需宏包
\usepackage{siunitx} % 用于书写单位符号
\usepackage[version=4]{mhchem} % 用于绘制分子式
% 设置图片存储位置
\graphicspath{{figure/}}
% 导入参考文献数据
\addbibresource{njuthesis-sample.bib}
% nl-cover, % 是否需要国家图书馆封面,默认关闭
% decl-page, % 是否需要诚信承诺书或原创性声明,默认关闭
%
% 页面模式,详见手册说明
% draft, % 开启草稿模式
% anonymous, % 开启盲审模式
% minimal, % 开启最小化模式
%
% 单双面模式,默认为适合印刷的双面模式
% oneside, % 单面模式,无空白页
% twoside, % 双面模式,每一章从奇数页开始
%
% 字体设置,不填写则自动调用系统预装字体,详见手册
% fontset = win|mac|macoffice|fandol|none,
]{njuthesis}
% 模板选项设置,包括个人信息、外观样式等
% 较为冗长且一般不需要反复修改,我们把它放在单独的文件里
\input{njuthesis-setup.def}
% 自行载入所需宏包
% \usepackage{subcaption} % 嵌套小幅图像,比 subfig 和 subfigure 更新更好
% \usepackage{siunitx} % 标准单位符号
% \usepackage{physics} % 物理百宝箱
% \usepackage[version=4]{mhchem} % 绘制分子式
% \usepackage{listings} % 展示代码
% \usepackage{algorithm,algorithmic} % 展示算法伪代码
% 在导言区随意定制所需命令
% \DeclareMathOperator{\spn}{span}
% \NewDocumentCommand\mathbi{m}{\textbf{\em #1}}
% 开始编写论文
\begin{document}
%-------------------------------------------------
%---------------------------------------------------------------------
% 封面、摘要、前言和目录
%-------------------------------------------------
%---------------------------------------------------------------------
% 生成封面页
\maketitle
\maketitle
% 模板默认使用 \flushbottom,即底部平齐
% 效果更好,但可能出现 underfull \vbox 信息
% 以下命令用于抑制这些信息
\raggedbottom
\begin{abstract}
中文摘要
中文摘要
\end{abstract}
\begin{abstract*}
English abstract
English abstract
\end{abstract*}
\begin{preface}
前言
\end{preface}
% 生成目录
\tableofcontents
% 生成图片清单
\listoffigures
% \listoffigures
% 生成表格清单
\listoftables
% \listoftables
%-------------------------------------------------
%---------------------------------------------------------------------
% 正文部分
%-------------------------------------------------
%---------------------------------------------------------------------
\mainmatter
% 符号表
% 语法与 description 环境一致
% 两个可选参数依次为说明区域宽度、符号区域宽度
% 带星号的符号表(notation*)不会插入目录
% \begin{notation}[10cm]
% \item[DFT] 密度泛函理论 (Density functional theory)
% \item[DMRG] 密度矩阵重正化群 (Density-Matrix Reformation-Group)
% \end{notation}
% 建议将论文内容拆分为多个文件
% 即新建一个 chapters 文件夹
% 把每一章的内容单独放入一个 tex 文件
% 然后在这里用 \input{} 导入,例如
% \input{chapters/introduction}
% \input{chapters/environments}
% 把每一章的内容单独放入一个 .tex 文件
% 然后在这里用 \include 导入,例如
% \include{chapters/introduction}
% \include{chapters/environments}
\chapter{引言}
%-------------------------------------------------
\section{量子计算}
John Preskill 认为我们现在处于“含噪声的中型量子时代”。\cite{preskill2018}
量子位的不稳定性和有限的量子比特数量限制了量子计算机的复杂度和纠错能力。
%---------------------------------------------------------------------
% 参考文献
%-------------------------------------------------
%---------------------------------------------------------------------
\printbibliography[
heading=bibintoc,% 插入目录条目
title=参考文献]
% 生成参考文献页
\printbibliography
%-------------------------------------------------
%---------------------------------------------------------------------
% 致谢
%-------------------------------------------------
%---------------------------------------------------------------------
\begin{acknowledgement}
感谢\href{https://git.nju.edu.cn/nju-lug/lug-introduction}{NJU Linux User Group}
感谢 \href{https://git.nju.edu.cn/nju-lug/lug-introduction}{LUG@NJU}
\end{acknowledgement}
%-------------------------------------------------
%---------------------------------------------------------------------
% 学术简历
%---------------------------------------------------------------------
% 详见手册中“成果列表”一节
% \njuchapter{学术成果}
% \njupaperlist[攻读博士学位期间发表的学术论文]{preskill2018}
%---------------------------------------------------------------------
% 附录部分
%-------------------------------------------------
%---------------------------------------------------------------------
% 附录部分使用单独的字母序号
\appendix
% 可以在这里插入补充材料
\chapter{正文中涉及的数据及源代码}
\dots
% 完工
\end{document}
% njuthesis 参数设置文件 v1.4.2 2024-11-08
% 一些提醒:
% 1. \njusetup 内部千万不要有空行
% 2. 使用英文半角逗号(,)分隔选项
% 3. 等于号(=)两侧的空格会被忽略
% 3.1. 为避免歧义,请用花括号({})包裹内容
% 4. 本科生无需填写的项目已被特别标注
% 5. 可以尽情删除本注释
% info 类用于录入个人信息
% 带*号的为对应英文字段
\njusetup[info]{
title = {第一行标题\\第二行标题\\第三行标题},
% 中文题目
% 直接填写标题就是自动换行
% 可以使用换行控制符(\\)手动指定换行位置
%
title* = {My Title in English},
% 英文题目
%
author = {姓名},
% 作者姓名
%
author* = {Ming Xing},
% 作者英文姓名
% 一般使用拼音
%
keywords = {我,就是,充数的,关键词},
% 中文关键词列表
% 使用英文半角逗号(,)分隔
%
keywords* = {Dummy,Keywords,Here,{It Is}},
% 英文关键词
% 使用英文半角逗号(,)分隔
%
grade = {2018},
% 年级
%
student-id = {181850195},
% 学号或工号
% 研究生请斟酌大小写字母格式
% 本模板并不会自动更正大小写
%
department = {化学化工学院},
department* = {School of Chemistry and Chemical Engineering},
% 院系
%
major = {化学},
major* = {Chemistry},
% 专业
%
% major = {封面专业,摘要专业},
% 研究生专业型学位可能遇到两处内容不一致的情况
%
supervisor = {导师姓名,教授},
supervisor*= {Professor My Supervisor},
% 导师全称
% 使用英文半角逗号(,)分隔中文姓名和职称
%
% supervisor-ii = {第二导师姓名,副教授},
% supervisor-ii* = {Associate professor My Second Supervisor},
% 第二导师全称
% 如果确实没有第二导师,不填写即可
%
submit-date = {2022-05-20},
% 提交日期
% 格式为 yyyy-mm-dd
% 不填就是编译当天日期
%
%
% 以下均为研究生项
%
% degree = {工程硕士},
% degree* = {Master of Engineering},
% 覆盖默认学位名称
%
field = {物理化学},
field* = {Physical Chemistry},
% 研究领域
%
chairman = {某某某~教授},
% 答辩委员会主席
% 推荐使用波浪号(~)分隔姓名和职称
%
reviewer = {
某某某~教授,
某某某~教授
},
%
% 答辩委员会成员
% 一般为四名,使用英文半角逗号(,)分隔
%
clc = {O643.12},
% 中国图书分类号
%
udc = {544.4},
% 国际图书分类号
%
secret-level = {公开},
% 密级
%
defend-date = {2022-05-21},
% 答辩日期
% 格式为 yyyy-mm-dd
% 不填就是编译当天日期
%
email = {xyz@smail.nju.edu.cn},
% 电子邮箱地址
% 只用于出版授权书
%
%
% 以下用于国家图书馆封面
confer-date = {2022-05-22},
% 学位授予日期
%
bottom-date = {2022-05-23},
% 封面底部日期
%
supervisor-contact = {
南京大学~
江苏省南京市栖霞区仙林大道163号
}
% 导师联系方式
}
% bib 类用于参考文献设置
\njusetup[bib]{
% style = numeric|author-year,
% 参考文献样式
% 默认为顺序编码制(numeric)
% 可选著者-出版年制(author-year)
%
resource = {njuthesis-sample.bib},
% 参考文献数据源
% 需要带扩展名的完整文件名
% 可使用逗号分隔多个文件
% 此条等效于 \addbibresource 命令
%
% option = {
% doi = false,
% isbn = false,
% url = false,
% eprint = false,
% 关闭部分无用文献信息
%
% refsection = chapter,
% 将参考文献表置于每章后
%
% gbnamefmt = lowercase
% 使用仅首字母大写的姓名
% }
% 额外的 biblatex 宏包选项
}
% image 类用于载入外置的图片
\njusetup[image]{
% path = {{./figure/}{./image/}},
% 图片搜索路径
%
nju-emblem = {nju-emblem},
nju-name = {nju-name},
% 校徽和校名图片路径
% 建议使用 PDF 格式的矢量图
% 使用外置图片有助于减少编译时间
% 空置时会自动使用 njuvisual 宏包绘制
%
% nju-emblem = {nju-emblem-purple},
% nju-name = {nju-name-purple},
% 替换为紫色版本
% 这个选项只能填写一次
% 切换时要注释掉上方的黑色版本
}
% abstract 类用于设置摘要样式
\njusetup[abstract]{
toc-entry = false,
% 摘要是否显示在目录条目中
%
% underline = false,
% 研究生英文摘要页条目内容是否添加下划线
%
% title-style = strict|centered|natural
% 研究生摘要标题样式,详见手册
}
% 目录自身是否显示在目录条目中
\njusetup{
% tableofcontents/toc-entry = false,
% listoffigures/toc-entry = false,
% listoftables/toc-entry = false
}
% 为目录中的章标题添加引导线
\njusetup[tableofcontents/dotline]{chapter}
% math 类用于设置数学符号样式,功能详见手册
\njusetup[math]{
% style = TeX|ISO|GB,
% 整体风格,缺省值为国标(GB)
% 相当于自动设置以下若干项
%
% integral = upright|slanted,
% integral-limits = true|false,
% less-than-or-equal = slanted|horizontal,
% math-ellipsis = centered|lower,
% partial = upright|italic,
% real-part = roman|fraktur,
% vector = boldfont|arrow,
% uppercase-greek = upright|italic
}
% theorem 类用于设置定理类环境样式,功能详见手册
\njusetup[theorem]{
% define,
% 默认创建内置的七种定理环境
%
% style = remark,
% header-font = \sffamily \bfseries,
% body-font = \normalfont,
% qed-symbol = \ensuremath { \male },
% counter = section,
% share-counter = true,
% type = {...}
% 以上设置项在重新调用 theorem/define 后生效
}
% footnote 类用于设置脚注样式,功能详见手册
\njusetup[footnote]{
% style = pifont|circled,
% 使用圈码编号
%
% hang = false,
% 不使用悬挂缩进
}
% 页眉页脚内容设置
\njusetup{
% header/content = {
% {OR}{\thepage},{OL}{\rightmark},
% {EL}{\thepage},{ER}{\leftmark}
% },
% 页眉设置,详见手册
% 奇数页页眉:左侧章名,右侧页码
% 偶数页页眉:左侧页码,右侧节名
%
% footer/content = {}
}
% 页眉页脚的字体样式
% \njusetformat{header}{\small\kaishu}
% \njusetformat{footer}{}
% 在盲审模式下隐藏学校信息
% \njusetup{anonymous-mode/no-nju}
% 一些灵活调整
% \njusetname{type}{本科毕业设计} % 我做的是毕业设计
% \njusetname{notation}{术语表} % 更改符号表名称
% \njusetlength{crulewd}{240pt} % 加长封面页下划线
% \njusetformat{tabular}{\zihao{-4}\bfseries} % 修改表格环境的字号
% \EditInstance{nju}{u/cover/emblem-img}{align=l} % 左对齐的本科生封面校徽
#!/usr/bin/env sh
mkdir -p "mythesis"
cd "mythesis"
mkdir -p mythesis
cd mythesis
cp -f "../docs/njuthesis-sample.tex" .
cp -f "../docs/njuthesis-sample.bib" .
cp -f "../source/njuthesis.dtx" .
cp -f ../docs/njuthesis-sample.tex .
cp -f ../docs/njuthesis-sample.bib .
cp -f ../docs/njuthesis-setup.def .
cp -f ../docs/nju-emblem*.pdf .
cp -f ../docs/nju-name*.pdf .
cp -f ../source/njuthesis.dtx .
curl -s -o "njuvisual.dtx" "https://mirror.nju.edu.cn/CTAN/macros/latex/contrib/njuvisual/njuvisual.dtx"
curl -s -o "njuvisual-curves.dtx" "https://mirror.nju.edu.cn/CTAN/macros/latex/contrib/njuvisual/njuvisual-curves.dtx"
xetex "njuthesis.dtx" > /dev/null
xetex "njuvisual.dtx" > /dev/null
xetex njuthesis.dtx > /dev/null
rm *.dtx
rm *.ins
rm *.log
# rm *.md
rm njuthesis-doc.cls
cd ..
@ECHO OFF
MKDIR "mythesis"
CD "mythesis"
COPY /Y "..\docs\njuthesis-sample.tex" .
COPY /Y "..\docs\njuthesis-sample.bib" .
COPY /Y "..\source\njuthesis.dtx" .
curl -s -o "njuvisual.dtx" "https://mirror.nju.edu.cn/CTAN/macros/latex/contrib/njuvisual/njuvisual.dtx"
curl -s -o "njuvisual-curves.dtx" "https://mirror.nju.edu.cn/CTAN/macros/latex/contrib/njuvisual/njuvisual-curves.dtx"
xetex "njuthesis.dtx" > NUL
xetex "njuvisual.dtx" > NUL
DEL "*.dtx"
DEL "*.ins"
DEL "*.log"
DEL "*.md"
CD ..
@ECHO OFF
MKDIR "mythesis"
CD "mythesis"
COPY /Y "..\docs\njuthesis-sample.tex" .
COPY /Y "..\docs\njuthesis-sample.bib" .
COPY /Y "..\docs\njuthesis-setup.def" .
COPY /Y "..\docs\nju-emblem*.pdf" .
COPY /Y "..\docs\nju-name*.pdf" .
COPY /Y "..\source\njuthesis.dtx" .
xetex "njuthesis.dtx" > NUL
DEL "*.dtx"
DEL "*.ins"
DEL "*.log"
DEL "njuthesis-doc.cls"
CD ..
# https://github.com/stone-zeng/tl-depend-analysis/
if [ -z "$1" ]; then
MIRROR=https://mirror.ctan.org
else
MIRROR=$1
fi
curl -o texlive.tlpdb $MIRROR/systems/texlive/tlnet/tlpkg/texlive.tlpdb
curl -o texlive.tlpdb.sha512 $MIRROR/systems/texlive/tlnet/tlpkg/texlive.tlpdb.sha512
sha512sum -c texlive.tlpdb.sha512
rm texlive.tlpdb.sha512
if [ ! -d data ]; then
mkdir data
fi
mv texlive.tlpdb data/
# https://github.com/stone-zeng/tl-depend-analysis/
import os
import re
import sys
from typing import TextIO
LUA_MODULE_PATTERN = re.compile(r'''
\brequire\s*
\(?\s*["'](.+?)["']
''', re.VERBOSE)
LUALIBS_MODULE_PATTERN = re.compile(r'''
loadmodule\s*
\(*\s*["'](.+\.lua)["']
''', re.VERBOSE)
CLASS_PATTERN = re.compile(r'''
\\(?:LoadClass|LoadClassWithOptions|documentclass)\s*
(?:\[.*\]\s*)?
\{\s*(.+?)\s*\}
''', re.VERBOSE)
PACKAGE_PATTERN = re.compile(r'''
\\(?:RequirePackage|RequirePackageWithOptions|usepackage)\s*
(?:\[.*\]\s*)?
\{\s*(.+?)\s*\}
''', re.VERBOSE)
USEFONT_PATTERN = re.compile(r'''
\\usefont\s*
\{\s*(.+?)\s*\}\s*
\{\s*(.+?)\s*\}
''', re.VERBOSE)
class Parser:
def __init__(self, path: str):
self.path = path
self.state = State()
self.depend: set[str] = set()
def parse(self):
try:
with open(self.path, 'r', encoding='utf-8', errors='replace') as fp:
match os.path.splitext(self.path)[1]:
case '.tex' | '.ltx' | '.cls' | '.sty' | '.def' | '.clo':
self._parse_tex(fp)
case '.lua':
self._parse_lua(fp)
case _:
print('Unknown file type:', self.path, file=sys.stderr)
except FileNotFoundError:
print('File not found:', self.path, file=sys.stderr)
def _parse_lua(self, fp: TextIO):
comment_flag = False
for line in fp:
line = line.strip()
if line.startswith('--[['):
comment_flag = True
continue
if line.endswith(']]') or line.endswith(']]--'):
comment_flag = False
continue
if not comment_flag and not line.startswith('--'):
self.depend.update(self._parse_lua_line(line))
def _parse_lua_line(self, line: str) -> list[str]:
if match := LUA_MODULE_PATTERN.findall(line):
return [match[0] + '.lua']
if match := LUALIBS_MODULE_PATTERN.findall(line):
return [match[0]]
return []
def _parse_tex(self, fp: TextIO):
for line in fp:
if line.rstrip() == '\\endinput':
return
if not line.strip().startswith('%'):
self.depend.update(self._parse_tex_line(line))
def _parse_tex_line(self, line: str) -> list[str]:
if self.state.stack == '':
# Classes (single line)
# - \LoadClass[...]{class}
# - \documentclass[...]{class}
if match := CLASS_PATTERN.findall(line):
return self._parse_cls_sty_match(match, suffix='.cls')
# Packages (single line)
# - \RequirePackage[...]{package}
# - \usepackage[...]{package}
if match := PACKAGE_PATTERN.findall(line):
return self._parse_cls_sty_match(match, suffix='.sty')
# Packages (multiple line)
if '\\RequirePackage' in line or '\\usepackage' in line:
self.state.update(line.split('%')[0].strip())
if match := USEFONT_PATTERN.findall(line):
return self._parse_font_match(match)
return []
self.state.update(line.split('%')[0].strip())
if self.state.is_braces_closed():
match = PACKAGE_PATTERN.findall(self.state.stack)
self.state.reset()
return self._parse_cls_sty_match(match, suffix='.sty')
return []
@staticmethod
def _parse_cls_sty_match(match: list[str], suffix: str) -> list[str]:
res = []
for m in match:
for s in map(str.strip, m.split(',')):
if Parser._is_valid_name(s):
res.append(s + suffix)
return res
@staticmethod
def _parse_font_match(match: list[str]) -> list[str]:
res = []
for m in match:
encoding, family = m
if Parser._is_valid_name(encoding) and Parser._is_valid_name(family):
res.append(f'{encoding.strip()}{family.strip()}.fd'.lower())
return res
@staticmethod
def _is_valid_name(name: str) -> bool:
return (
name != ''
and '\\' not in name and '#' not in name
and not name.startswith('.')
)
class State:
def __init__(self):
self.stack = ''
self.braces_count = 0
self.braces_open = False
self.brackets_count = 0
self.brackets_open = False
def __repr__(self) -> str:
return ', '.join([
f'stack = "{self.stack}"',
f'braces_count = {self.braces_count}',
f'braces_open = {self.braces_open}',
f'brackets_count = {self.brackets_count}',
f'brackets_open = {self.brackets_open}',
])
def update(self, line: str):
self.stack += line
for c in line:
match c:
case '{':
self.braces_count += 1
self.braces_open = True
case '}':
self.braces_count -= 1
case '[':
self.brackets_count += 1
self.brackets_open = True
case ']':
self.brackets_count -= 1
self.brackets_open = False
def is_braces_closed(self):
return self.braces_count == 0 and self.braces_open and not self.brackets_open
def reset(self):
self.stack = ''
self.braces_count = 0
self.braces_open = False
self.brackets_count = 0
self.brackets_open = False
def _main():
if len(sys.argv) < 2:
print('Usage: python file_parser.py <file>', file=sys.stderr)
sys.exit(1)
parser = Parser(sys.argv[1])
parser.parse()
for d in sorted(parser.depend):
print(d)
if __name__ == '__main__':
_main()
@ECHO OFF
pdflatex --shell-escape generate-img
DEL "generate-img.pdf"
DEL "*.aux"
DEL "*.auxlock"
DEL "*.dpth"
DEL "*.log"
DEL "*.md5"
#!/usr/bin/env sh
pdflatex --shell-escape generate-img
rm generate-img.pdf
rm *.aux
rm *.auxlock
rm *.dpth
rm *.log
rm *.md5
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 本文件用于生成校徽和校名图片
% 编译命令为 pdflatex --shell-escape generate-img
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass{article}
\usepackage{njuvisual}
\usetikzlibrary{external}
\tikzexternalize[prefix=nju-]
\begin{document}
% 黑色
\tikzsetnextfilename{emblem} \njuemblem[black]{!}{!}
\tikzsetnextfilename{name} \njuname [black]{!}{!}
% 紫色
\tikzsetnextfilename{emblem-purple} \njuemblem[njupurple]{!}{!}
\tikzsetnextfilename{name-purple} \njuname [njupurple]{!}{!}
\end{document}
# adapted from https://github.com/stone-zeng/tl-depend-analysis/
# under MIT license
# require python>=3.10
import dataclasses
import json
import os
import subprocess
import sys
from typing import Any
from argparse import ArgumentParser
from file_parser import Parser
arg_parser = ArgumentParser(
description='Find and install dependencies of a given LaTeX module')
arg_parser.add_argument('-m', '--module', type=str, default='njuthesis',
help='Name of your module')
arg_parser.add_argument('-p', '--pkg', type=str, default='',
help='Additional package name to be installed')
arg_parser.add_argument('-e', '--exclude', type=str, default='',
help='Module file to be excluded from searching')
args = arg_parser.parse_args()
MODULE_NAME = args.module
EXCLUDE_FILE = set(args.exclude.split())
INIT_PACKAGES = set(args.pkg.split())
TLPDB_PATH = 'data/texlive.tlpdb'
TL_DEPEND_PATH = 'data/tl-depend.json'
L3BUILD_UNPACKED_PATH = "../build/unpacked"
TEST_PATH = "../test"
TEXMFDIST_PATH = subprocess.run(
['kpsewhich', '-var-value', 'TEXMFDIST'],
capture_output=True, check=True).stdout.decode().strip()
# TEXMFDIST_PATH = '/usr/local/texlive/2023/texmf-dist'
@dataclasses.dataclass
class Package:
name: str
category: str
revision: int
tl_depend: list[str]
depend: list[str]
runfiles: list[str]
class PackageEncoder(json.JSONEncoder):
def default(self, o):
if isinstance(o, Package):
return {
'name': o.name,
'depend': o.depend,
'tl_depend': o.tl_depend,
}
# return dataclasses.asdict(o)
return json.JSONEncoder.default(self, o)
class TLDepend:
def __init__(self):
self.packages: list[Package] = []
self.file_mappings: dict[str, str] = {}
self.njuthesis_depend: set[str] = []
def parse_tlpdb(self):
with open(TLPDB_PATH, 'r', encoding='utf-8') as fp:
items = fp.read().strip().split('\n\n')
for item in items:
lines = item.split('\n')
_, name = lines[0].split()
if not name.startswith('00') and '.' not in name:
self.packages.append(
Package(name=name, depend=[], **self._parse_tlpdb_item(lines)))
@staticmethod
def _parse_tlpdb_item(lines: list[str]):
package: dict[str, Any] = {
'tl_depend': [],
'runfiles': [],
}
runfiles_flag = False
for line in lines:
key, *value = line.strip().split(maxsplit=1)
value = value[0] if value else None
match key:
case 'category':
package['category'] = value
case 'revision':
package['revision'] = int(value) if value else -1
case 'depend':
package['tl_depend'].append(value)
case 'runfiles':
runfiles_flag = True
case _ if runfiles_flag:
if line.startswith(' '):
package['runfiles'].append(line.strip())
else:
runfiles_flag = False
return package
def get_file_mappings(self, verbose: bool = False):
for package in self.packages:
if package.name.endswith('-dev'):
if verbose:
print('Skip dev package:', package.name, file=sys.stderr)
continue
for file in package.runfiles:
if file.startswith('RELOC') or file.startswith('texmf-dist'):
_, path = file.split('/', maxsplit=1)
# if path.startswith('fonts'):
# continue
if (name := os.path.basename(path)) in self.file_mappings:
if verbose:
print('Duplicate file:', file, file=sys.stderr)
else:
self.file_mappings[name] = package.name
def get_module_depend(self, file_paths: list, verbose: bool = False):
depend: set[str] = INIT_PACKAGES
for fp in file_paths:
for f in os.listdir(fp):
full_path = os.path.join(fp, f)
if not f in EXCLUDE_FILE and not os.path.isdir(full_path):
if verbose:
print('Process file', full_path)
depend.update(self._get_depend_from_file(full_path, verbose))
depend.discard(MODULE_NAME)
self.njuthesis_depend = depend
def update_module_depend(self, verbose: bool = False):
init_depend = self.njuthesis_depend.copy()
full_depend: set[str] = set()
with open(TL_DEPEND_PATH, mode="r", encoding='utf-8') as f:
data = json.load(f)
while len(init_depend) > 0:
# recursive method
pkg = init_depend.pop()
full_depend.update([pkg])
for entry in data:
if entry["name"] == pkg:
temp = set(entry["depend"])
common = full_depend.intersection(temp)
init_depend.update(temp.difference(common))
if verbose:
print(len(full_depend), len(init_depend), pkg)
self.njuthesis_depend = sorted(full_depend)
def install(self):
os.system('tlmgr install ' + ' '.join(self.njuthesis_depend))
def _get_depend_from_file(self, file: str, verbose: bool = False):
depend: set[str] = set()
parser = Parser(file)
parser.parse()
for d in parser.depend:
try:
depend.add(self.file_mappings[d])
except KeyError:
print('Dependency not found:', d, file=sys.stderr)
if verbose:
if depend == set():
print('Find no package')
else:
print('Add packages', ' '.join(sorted(depend)))
print('-----')
return depend
def main():
analyzer = TLDepend()
analyzer.parse_tlpdb()
analyzer.get_file_mappings()
analyzer.get_module_depend([L3BUILD_UNPACKED_PATH, TEST_PATH], True)
analyzer.update_module_depend()
# print(analyzer.njuthesis_depend)
analyzer.install()
if __name__ == '__main__':
main()
This diff is collapsed.
\begin{abstract}
\zhlipsum[76][name=zhufu]
\end{abstract}
\begin{abstract*}
\blindtext
\end{abstract*}
\chapter*{攻读博士学位期间研究成果及参与项目情况}
\addcontentsline{toc}{chapter}{攻读博士学位期间研究成果及参与项目情况}
\njuchapter{攻读博士学位期间研究成果及参与项目情况}
\njupaperlist{goossens93,segl03}
\njupaperlist*{goossens93,njuthesis}
\njupaperlist[攻读博士学位期间发表的学术论文]{Nemec1997-209-214,Chiani1998-2998-3008,Chiani1998a}
\section*{攻读博士学位期间参与的科研课题}
......
\begin{acknowledgement}
感谢\href{https://git.nju.edu.cn/nju-lug/lug-introduction}{NJU Linux User Group}
\end{acknowledgement}
\chapter{管理参考文献}
\chapter{引用参考文献}
\label{chap:bibliography}
\section{引用命令}
使用\hologo{biber}作为\hologo{BibTeX}后端。相关定义位于\lstinline|profile/reference.sty|。
顺序编码制的 \cite{qiujinhengetal2010,njuthesis,riedl2009quasi}(上标可设置页码)、\parencite{qiujinhengetal2010}(非上标可设置页码)、\pagescite{qiujinhengetal2010}(上
标加自动页码)、\textcite{qiujinhengetal2010}(提供作者为主语加非上标编号)、\authornumcite{qiujinhengetal2010}(提供作
者为主语加上标编号)、\footfullcite{qiujinhengetal2010}(脚注方式)
\section{添加和管理}
默认参考文献存储于主目录下的\lstinline|njuthesis.bib|。如果有其他来源,也可以在\lstinline|njuthesis.tex|中修改以下命令:
\begin{lstlisting}[language=TeX]
\addbibresource{njuthesis.bib}
\end{lstlisting}
\subsection{使用EndNote}
南京大学信息化建设管理服务中心已购买\href{https://itsc.nju.edu.cn/EndNote/list.htm}{EndNote}供全校师生免费试用,最新版为EndNote 20.。
\subsection{使用Zotero}
\href{https://www.zotero.org/}{Zotero}是一款免费的文献管理软件,支持所有桌面平台。
在保持Zotero程序运行的情况下,点击浏览器工具栏的Zotero Connector插件即可自动从网页抓取参考文件信息。
Zotero也有知网插件
\section{文段内引用}
\lstinline|\cite{myref}|
\lstinline|\citesuthor{myref}|
\section{引用格式}
符合GB7714-2015规范
著者-年份制的\cite{qiujinhengetal2010,njuthesis,riedl2009quasi}(作者加年份用
括号包围可设置页码)、\pagescite{qiujinhengetal2010}(作者加年份用括号包围自动页码)、\yearcite{qiujinhengetal2010}(提供
年份用括号包围)、\yearpagescite{qiujinhengetal2010}(提供年份用括号包围自动页码)、\textcite{qiujinhengetal2010}(提供主
语作者加括号包围年份)、\footfullcite{qiujinhengetal2010}(脚注方式)。
\chapter{配置环境}
\textbf{特别提醒:本章文字仅供格式示例,内容已停止维护,请参考宏包手册进行设置}
\section{本地编译}
\subsection{安装\hologo{TeX}发行版}
首先需要下载\hologo{TeX}软件发行版,校园网环境中使用\href{https://mirror.nju.edu.cn/download/app/TeX%20%E6%8E%92%E7%89%88%E7%B3%BB%E7%BB%9F}{南大镜像站}可以获得最好的体验。\textbf{推荐使用最新的\hologo{TeX}\,Live 2021或者\hologo{MiKTeX} 21以避免潜在的兼容性问题。}
\begin{itemize}
\item 为了避免不必要的麻烦,请尽可能下载 full 版本,如 texlive-full。简而言之,下载大的那个。
\item 并且,尽可能使用最新版(截至目前是 2021)。2020 及之前版本使用 PDF 格式的图片可能会出现加粗问题。
\end{itemize}
下表是目前经过测试的环境。如果有其他可用不可用的环境,欢迎补充。
\begin{table}[ht]
\caption{经过测试的环境}
% \label{tab:1}
\begin{tabular}{ccc}
\toprule
OS & TeX & 测试情况 \\
\midrule
Windows 10 & \hologo{TeX}\,Live 2021 & 通过 \\
Windows 10 & \hologo{MiKTeX} & 通过 \\
Windows 10 & \hologo{TeX}\,Live 2020 & cref存在格式问题 \\
macOS 10.15 & \hologo{TeX}\,Live 2021 & 通过 \\
Ubuntu 20.04 & \hologo{TeX}\,Live 2021 & 通过 \\
\bottomrule
\end{tabular}
\end{table}
\subsection{选择编辑器}
配置完编译器后,还需要一个\textbf{文本编辑器}作为前端来完成\texttt{.tex}文件内容的写作。
至今仍有相当一部分人认为Windows自带的\textit{记事本}是最好的文本编辑器,但对于本项目而言,在此诚心诚意地推荐你使用\textbf{更现代更美观更多功能}的编辑器,譬如\emph{安装了 LaTeX Workshop 插件 的 \href{https://code.visualstudio.com/}{Visual Studio Code}},来完成论文编写。你也可以根据个人的喜好随便使用其他编辑器,如 TeXworks、TeX Studio 等,顺手就行。
若使用 LaTeX Workshop 插件,本项目在\lstinline|.vscode/|中提供一份简易配置,可以省略初始配置步骤直接使用。
\subsection{编译顺序}
应采用以下命令顺序进行编译,以生成正确的目录、编号和参考文献条目。
\begin{enumerate}
\item \lstinline|xelatex| / \lstinline|lualatex|
\item \lstinline|biber|
\item \lstinline|xelatex| / \lstinline|lualatex|
\item \lstinline|xelatex| / \lstinline|lualatex|
\end{enumerate}
编译产物\footnote{作为化学学生,俺认为用“产物”代替“编译生成的文件”是一个通俗易懂的说法}\lstinline|njuthesis.pdf|,位于主目录下。此外还会生成一系列中间文件,可以选择使用\lstinline|latexmk -c|进行清理。
\section{在线编译}
相信你在接触了本地编译以后,很快就会意识到一些十分显然的事实,譬如\hologo{TeX}编译器安装过程较为漫长,占用空间过大,而且在一部分处理器性能不佳的电脑上需要较长编译时间\footnote{其实这三点都是对广大的Windows用户说的,同一个模板在Linux编译可以节省一半耗时}。拒绝接受这些麻烦的同学不妨尝试本节介绍的在线编译方法。
\subsection{南大\hologo{TeX}平台简介}
\href{https://tex.nju.edu.cn}{南大\hologo{TeX}}基于开源的ShareLaTeX平台\footnote{理论上在\href{https://doc.nju.edu.cn/books/latex}{这个网站}能找到一段平台简介,实际上大家都有意无意地鸽了,下次一定补上。},于2021年3月4日正式上线,面向南京大学全体师生开放,首次使用需凭学校邮箱自助注册账号。
\subsection{操作步骤}
\begin{enumerate}
\item 下载\href{https://github.com/nju-lug/NJUThesisUndergraduate/archive/refs/heads/master.zip}{模板全部文件}
\item 访问\href{https://tex.nju.edu.cn}{南大\hologo{TeX}},点击界面右上方Register,使用\emph{南京大学邮箱}注册账号并登录
\item 点击New Project -> Upload Project上传刚刚得到的zip文件,上传后njuthesis.tex、njuthesis.cls等文件应在根目录,目录结构如\cref{{sec:directory}}所示
\item 在项目页面左上角的Menu中,将编译器更改为支持中文的\hologo{XeLaTeX}或者\hologo{LuaLaTeX}
\item 编写论文
\item 点击Compile按钮进行编译和预览
\item 点击编译按钮右侧第三个按钮下载产物
\end{enumerate}
\subsection{关于Overleaf平台}
由于\href{https://www.overleaf.com/}{Overleaf平台}\hologo{TeX}\,Live版本停留在2020,\texttt{cleveref}包在引用章节时会生成错误的标签,引发格式错误;而南大\hologo{TeX}通过及时更新规避了这一问题。因此\emph{请务必不要使用Overleaf官网进行编译}
\section{字体}
学校论文格式要求使用的字体一般已经预装在各个操作系统,本模板针对不同平台进行了自动检测适配,可以开箱即用。
各个系统的默认字体请参考\cref{tab:defaultfontset}。可以看到,不同系统上使用的字体有所差别,实际输出结果可能存在细微不同, 使用时请注意。例如,在Linux平台或者使用了Ubuntu后端的南大\hologo{TeX}上,宋体加粗效果更明显;另一方面,在Windows平台进行编译的效果更接近Word加粗\footnote{因为SimSun没有原生粗体,通过AutoFakeBold=2.17进行模仿}
% \begin{enumerate}
% \item Ubuntu 下遇到缺失字体 WenQuanYi Zen Hei Mono 或 Times New Roman的问题:
% 安装对应字体即可。使用以下指令下载:
% \begin{lstlisting}
% sudo apt install fonts-wqy-zenhei ttf-mscorefonts-installer
% \end{lstlisting}
% \item macOS 下提示 Package fontspec Warning: Font "STSong" does not contain requested Script "CJK"
% 忽略即可,不影响使用。该警告已被抑制。
% \end{enumerate}
指定字体的相关命令写于\texttt{profile/font.sty}
该文件中也预留有使用方正字体或者思源字体的命令,涉及的字体见\cref{tab:userfontset},可根据个人喜好进行修改选择。
\begin{table}[htbp]
\caption{操作系统预装字体清单}
\label{tab:defaultfontset}
\begin{tabular}{cccc}
\toprule
类型 & Windows & macOS & Linux \\
\midrule
西文衬线 & Times~New~Roman & Times~New~Roman & TeX~Gyre~Termes \\
西文无衬线 & Arial & Arial & TeX~Gyre~Heros \\
西文等宽 & Courier~New & Menlo & TeX~Gyre~Cursor \\
宋体 & SimSun & Songti~SC~Light &FandolSong-Regular \\
黑体 & SimHei & Heiti~SC~Light & FandolHei-Regular \\
仿宋 & FangSong & STFangsong & FandolFang-Regular \\
楷体 & KaiTi & Kaiti~SC & FandolKai-Regular \\
\bottomrule
\end{tabular}
\end{table}
如果 Ubuntu 下遇到缺失字体 Times New Roman 的问题,安装对应字体即可。使用以下指令下载:
\begin{lstlisting}
sudo apt install ttf-mscorefonts-installer
\end{lstlisting}
\begin{table}[htbp]
\caption{预留的自定义中文字体清单}
\label{tab:userfontset}
\begin{tabular}{ccc}
\toprule
类型 & 方正 & 思源 \\
\midrule
宋体 & FZSSK & Noto~Serif~CJK~SC \\
黑体 & FZHTK & Noto~Sans~CJK~SC \\
仿宋 & FZFSK & 方正仿宋简体 \\
楷体 & FZKTK & 方正楷体简体 \\
\bottomrule
\end{tabular}
\end{table}
\subsection{修改字体配置}
本模板提供了若干个字体相关的控制选项,已于\cref{sec:classoptions}初步进行介绍。如果希望覆盖检测系统字体的命令(譬如在Linux编译时使用Windows字体样式),请将
systemfont设置为false,并通过customlatinfont和customchinesefont进行选择。
全部字符集命令如下所示。
\begin{description}
\item[\texttt{\textbackslash set\textunderscore latin\textunderscore fontset\textunderscore windows}] Windows英文字符集
\item[\texttt{\textbackslash set\textunderscore chinese\textunderscore fontset\textunderscore windows}] Windows中文字符集
\item[\texttt{\textbackslash set\textunderscore latin\textunderscore fontset\textunderscore macos}] macOS英文字符集
\item[\texttt{\textbackslash set\textunderscore chinese\textunderscore fontset\textunderscore macos}] macOS中文字符集
\item[\texttt{\textbackslash set\textunderscore latin\textunderscore fontset\textunderscore gyre}] Linux英文字符集
\item[\texttt{\textbackslash set\textunderscore chinese\textunderscore fontset\textunderscore fandol}] Linux中文字符集
\item[\texttt{\textbackslash set\textunderscore chinese\textunderscore fontset\textunderscore founder}] 方正中文字符集
\item[\texttt{\textbackslash set\textunderscore chinese\textunderscore fontset\textunderscore noto}] 思源中文字符集
\end{description}
对于需要进一步自定义的同学,可以将CustomEnFont和CustomZhFont设置为null,自行在导言区设置字体。
\chapter{图片、表格与代码}
\section{图片}
插入一张图片,就像\cref{fig:arcaea}这样。
\begin{figure}[htbp]
\centering
\includegraphics[width=0.5\textwidth]{test.png}
\caption{火热劲爆 Arcaea}
\label{fig:arcaea}
\end{figure}
\zhlipsum[3][name=aspirin]
% \subsection{文字环绕图像}
% % wrapfigure后面不能有空行
% \begin{wrapfigure}{r}{0cm}
% \label{fig:arcaeaedge}
% \includegraphics[width=.15\textwidth]{test.png}
% \caption{闊靛緥婧愮偣}
% \end{wrapfigure}
% \zhlipsum[2][name=simp]
% \subsection{多个图像}
% \begin{figure}[htbp]
% \centering
% \begin{subfigure}{.32\textwidth}
% \centering
% \includegraphics[width=\textwidth]{test.png}
% \caption{闊靛緥婧愮偣}
% \end{subfigure}
% \begin{subfigure}{.32\textwidth}
% \centering
% \includegraphics[width=\textwidth]{test.png}
% \caption{Arcaea}
% \end{subfigure}
% \begin{subfigure}{.32\textwidth}
% \centering
% \includegraphics[width=\textwidth]{test.png}
% \caption{闊虫父}
% \end{subfigure}
% \caption{新概念空间立体节奏游戏}
% \end{figure}
\section{表格}
你可以使用 |table| 环境插入标准三线表,如\cref{tab:testtab}所示。
\begin{table}[htbp]
% \centering
\caption{经过测试的环境}
\label{tab:testtab}
\begin{tabular}{ccc}
\toprule
OS & TeX & 测试情况 \\
\midrule
Windows 10 & TeX Live 2021 &\\
Windows 10 & MiKTeX &\\
Windows 10 & TeX Live 2020 & × \\
Ubuntu 20.04 & TeX Live 2021 &\\
南大 TeX & Overleaf &\\
\bottomrule
\end{tabular}
\end{table}
全部预定义的数学环境如\cref{tab:mathenv}所示。
\begin{table}[htbp]
% \centering
\caption{数学环境}
\label{tab:mathenv}
\begin{tabular}{cc|cc}
\toprule
标签 & 名称 & 标签 & 名称 \\
\midrule
axiom & 公理 & lemma & 引理 \\
corollary & 推论 & proof & 证明 \\
definition & 定义 & theorem & 定理 \\
example && & \\
\bottomrule
\end{tabular}
\end{table}
\chapter{图片、表格与代码}
\section{图片示例}
所有图片默认存放在主目录下的\texttt{figure/}文件夹内
% \begin{figure}[htbp]
% % \includegraphics[width=0.5\textwidth]{njuname}
% \resizebox{0.5\textwidth}{!}{\input{njuname.tikz}}
% \caption{南京大学名称}
% \label{fig:njuname}
% \end{figure}
% 你可以使用\lstinline|figure|环境插入图片,如\cref{fig:njuname},代码如下:
% \begin{lstlisting}[style=LaTeX]
% \begin{figure}
% % \includegraphics[width=0.5\textwidth]{njuname}
% \resizebox{0.5\textwidth}{!}{\input{njuname.tikz}}
% \caption{南京大学名称}
% \end{figure}
% \end{lstlisting}
% \subsection{文字环绕图像}
% % wrapfigure后面不能有空行
% \begin{wrapfigure}{r}{0cm}
% % \label{fig:njuemblem}
% % \includegraphics[width=.15\textwidth]{njuemblem}
% \resizebox{.15\textwidth}{!}{\input{njuemblem.tikz}}
% \caption{校徽}
% \end{wrapfigure}
% \zhlipsum[3][name=xiangyu]
% \begin{figure}[htbp]
% \begin{subfigure}{.32\textwidth}
% \centering
% % \includegraphics[width=\textwidth]{njuemblem}
% \resizebox{\textwidth}{!}{\input{njuemblem.tikz}}
% \caption{logo1}
% \end{subfigure}
% \begin{subfigure}{.32\textwidth}
% \centering
% % \includegraphics[width=\textwidth]{njuemblem}
% \resizebox{\textwidth}{!}{\input{njuemblem.tikz}}
% \caption{logo2}
% \end{subfigure}
% \begin{subfigure}{.32\textwidth}
% \centering
% % \includegraphics[width=\textwidth]{njuemblem}
% \resizebox{\textwidth}{!}{\input{njuemblem.tikz}}
% \caption{logo3}
% \end{subfigure}
% \caption{njuemblems}
% \end{figure}
\section{表格示例}
\begin{table}[htbp]
\caption{经过测试的环境}
\label{tab:testtab}
\begin{tabular}{ccc}
\toprule
OS & TeX & 测试情况 \\
\midrule
Windows 10 & TeXLive 2021 &\\
Windows 10 & MiKTeX &\\
Windows 10 & TeXLive 2020 & ×\footnote{cleveref在引用章节时不能正常工作} \\
Ubuntu 20.04 & TeXLive 2021 &\\
南大TeX & Overleaf &\\
\bottomrule
\end{tabular}
\end{table}
你可以使用\lstinline|table|环境插入标准三线表,如\cref{tab:testtab}所示,代码如下:
\begin{lstlisting}[style=LaTeX]
\begin{table}[htbp]
\caption{经过测试的环境}
\begin{tabular}{ccc}
\toprule
OS & TeX & 测试情况 \\
\midrule
Windows 10 & TeXLive 2021 &\\
Windows 10 & MiKTeX &\\
Windows 10 & TeXLive 2020 & × \\
Ubuntu 20.04 & TeXLive 2021 &\\
南大TeX & Overleaf &\\
\bottomrule
\end{tabular}
\end{table}}
\end{lstlisting}
\section{代码示例}
\subsection{行内代码}
The new command pretty-prints the code. The exclamation marks delimit
the code and can be replaced by any character not in the code;
\lstinline$var i:integer;$ gives the same result.
使用\lstinline!\lstinline|\textit{<Your code>}|!,只要使用在代码中未出现的符号将代码包括在内即可。
\chapter{绪论}
\textbf{特别提醒:本章文字仅供格式示例,内容已停止维护,请参考宏包手册进行设置}
\section{简介}
南京大学学位论文\hologo{LaTeX}模板\cite{njuthesis}基于本科生院的论文撰写规范制作,同时参考研究生院提供的硕士、博士学位材料包,用于生成符合南京大学学位论文排版要求和相应的国家规范、行业标准的学位论文,旨在为同学提供毕业论文书写的方便。
此模板通过LPPL协议开源,目前已\href{https://ctan.org/pkg/njuthesis}{发布在CTAN}
如有模板问题或者版权问题,请于Github项目主页上\href{https://github.com/nju-lug/NJUThesis/issues}{提出issue}
\begin{quotation}
请注意,本示例文档内容\textbf{存在较多过时之处},请参考.dtx文件生成的使用手册以获得准确的参考。
\end{quotation}
\section{开发环境}
本模板的开发维护主要在\hologo{MiKTeX}\hologo{TeX}\,Live\,2021下进行,内部代码主要由\lstinline|expl3|宏包提供的\hologo{LaTeX3}语法实现。
\section{目录结构}
\label{sec:directory}
\begin{lstlisting}[language=bash]
│ njuthesis.bib
│ njuthesis.cls
│ njuthesis.tex
├─figure
│ njulogo.pdf
│ njuname.pdf
└─profile
abstract.sty
components.sty
cover.sty
font.sty
packages.sty
page.sty
reference.sty
\end{lstlisting}
\subsection{文件说明}
\begin{description}
\item [\texttt{abstract.sty}] 定义中英文摘要环境及相关格式
\item [\texttt{components.sty}] 定义图片、表格、代码、数学环境样式
\item [\texttt{cover.sty}] 定义论文封面内容
\item [\texttt{font.sty}] 重定义CTeX宏集的默认字体,因为CTeX字体加粗要求不满足论文规定
\item [\texttt{package.sty}] 存放所有被引用的包
\item [\texttt{page.sty}] 定义正文页面、标题以及目录条目格式
\item [\texttt{reference.sty}] 定义引文格式
\end{description}
\section{自定义选项}
\label{sec:classoptions}
njuthesis类提供了若干个可以自定义的选项,如下所示。
\begin{description}
\item[\texttt{titlelength}] 标题长度,用于控制封面标题的行数。可选值为1、2、3,缺省值为1。
\item[\texttt{secondmentor}] 是否有第二导师,用于在封面和摘要添加第二导师,缺省值为false。
\item[\texttt{nlcover}] 是否需要国家图书馆封面,缺省值为false。
\item[\texttt{degree}] 学位类型,本科学位为ug,即undergraduate的缩写;学术型硕士学位为mg;硕士专业学位为mf;博士学位为phd。
\item[\texttt{type}] 用于选择文档类型并将相关字段输出在封面和摘要页。可选值包括thesis(表示毕业论文)和design(表示毕业设计),缺省值为thesis。
\item[\texttt{systemfont}] 是否用系统字体,用于自动检测运行系统并使用预装字体,缺省值为true。
\item[\texttt{customlatinfont}] 用于选择自定义英文字符集。可选值包括windows, macos, gyre, null,缺省值为windows。
\item[\texttt{customchinesefont}] 用于选择自定义中文字符集。可选值包括windows, macos, fandol, founder, noto, null,缺省值为windows。
\end{description}
\chapter{页面布局}
\textbf{特别提醒:本章文字仅供格式示例,内容已停止维护,请参考宏包手册进行设置}
本模板格式依照《11-南京大学毕业论文(设计)的撰写规范和装订要求》进行调整,文件内容详见\cref{chap:standard}
\section{封面页}
\texttt{cover.sty}中定义了生成封面的相关命令
\subsection{第二导师}
secondmentor 用于指定是否在封面打印第二导师
\subsection{国家图书馆封面}
对于研究生,本模板提供了nlcover 用于生成国家图书馆封面
\subsection{文档类型}
如果编写的是毕业设计,请参考\cref{sec:classoptions},将Type选项改为design。
\subsection{多行标题}
为了使较长的论文题目也能美观地呈现在封面页上,njuthesis类提供了\texttt{TitleLength}这一选项,用于控制封面标题的行数。该命令已于\cref{sec:classoptions}进行介绍,可以在\texttt{njuthesis.tex}文件开头的类定义中找到,可选值为1、2、3,缺省值为单行标题。
\subsection{输入个人信息}
\texttt{njusetup}定义了用于文档封面的诸多属性参数,
写作时修改相应字符串即可。注意不要有空行,否则可能报错
\begin{lstlisting}
\njusetup {
info = {
<type> = <myinfo>;
}
}
\end{lstlisting}
\subsubsection{论文标题}
\begin{description}
\item[\texttt{TitleA}] 单行标题,或多行标题的第一行。关于是否应该折行,单行能容纳的最长标题为\emph{15个中文字符},请自行选择合适的截断处。
\item[\texttt{TitleB}] 多行标题的第二行
\item[\texttt{TitleC}] 多行标题的第三行
\item[\texttt{TitleEN}] 英文标题,注意空格要用波浪线(\textasciitilde)替代
\end{description}
\subsubsection{个人年级、学号、姓名}
\begin{description}
\item[\texttt{Grade}] 年级
\item[\texttt{StudentID}] 本科生为9位数字学号,研究生为两位英文字母标识加8位数字学号,两位字母自动大写
\item[\texttt{StudentName}] 姓名
\item[\texttt{StudentNameEN}] 姓名拼音
\end{description}
\subsubsection{就读院系专业}
本科生无需填写研究方向。
\begin{description}
\item[\texttt{Department}] 学院名称
\item[\texttt{DepartmentEN}] 学院英文名称
\item[\texttt{Major}] 专业名称
\item[\texttt{MajorEN}] 专业英文名称
\item[\texttt{Field}] 研究方向
\item[\texttt{FieldEN}] 研究方向英文名称
\end{description}
\subsubsection{导师信息}
注意标注A的为第一导师
\begin{description}
\item[\texttt{Mentor<A/B>}] 导师姓名
\item[\texttt{Mentor<A/B>EN}] 导师姓名的英文拼音
\item[\texttt{Mentor<A/B>Title}] 导师职称
\item[\texttt{Mentor<A/B>TitleEN}] 导师职称英文
\end{description}
\subsubsection{提交日期}
\begin{description}
\item[\texttt{SubmitDate}] 论文提交日期
\end{description}
\subsubsection{答辩信息}
除答辩日期以外,本部分内容仅用于国家图书馆封面。本科生忽略即可。
答辩委员会姓名与职称之间需使用波浪线连接。
\begin{description}
\item[\texttt{DefendDate}] 答辩日期
\item[\texttt{ReviewerChairman}] 答辩委员会主席的姓名及职称
\item[\texttt{Reviewer<A/B/C/D>}] 四位评阅人的姓名及职称
\end{description}
\subsubsection{国家图书馆封面相关信息}
本部分内容仅用于国家图书馆封面。本科生忽略即可。
\begin{description}
\item[\texttt{Classification}] 分类号
\item[\texttt{SecurityLevel}] 限制
\item[\texttt{UDC}] UDC
\item[\texttt{MentorInfo}] 指导教师职务、职称、学位、单位名称及地址
\end{description}
\section{摘要页}
\texttt{profile/abstract.sty}提供了摘要页格式的定义。
\begin{lstlisting}
\begin{abstract}
<text>
\keywords{<keywords>}
\end{abstract}
\begin{englishabstract}
<text>
\englishkeywords{<keywords>}
\end{englishabstract}
\end{lstlisting}
摘要页一般不插入目录,默认只添加pdf书签。如确实有插入目录的需求,请在\texttt{abstract.sty}文件中定位到如下语句
\begin{lstlisting}[language=TeX]
% \phantomsection\addcontentsline{toc}{chapter}{中文摘要}
\pdfbookmark[0]{中文摘要}{中文摘要}
\end{lstlisting}
将其修改为
\begin{lstlisting}[language=TeX]
\phantomsection\addcontentsline{toc}{chapter}{中文摘要}
% \pdfbookmark[0]{中文摘要}{中文摘要}
\end{lstlisting}
在使用\hologo{LuaLaTeX}编译时,研究生中文摘要页的标题会出现空格无下划线的问题,目前正在积极寻求解决方法。
\section{前言页}
使用preface环境定义
\begin{lstlisting}
\begin{preface}
<text>
\end{preface}
\end{lstlisting}
\section{目录页}
目录页格式定制于\texttt{profile/page.sty}
\section{正文}
正文格式定制于\texttt{profile/page.sty}
页边距在\texttt{profile/packages.sty}
本科生无页眉,页面编号居中位于页脚;研究生无页脚,页眉包括章节名和页面编号。
% 对中文加下划线请使用xeCJKfntef包的CJKunderline命令代替uline,以解决中文的换行问题
\section{参考文献页}
需要使用biber手动编译才会显示,具体内容参考\cref{chap:reference}
\section{致谢页}
同前言,使用acknowledgement环境
\begin{lstlisting}
\begin{acknowledgement}
<text>
\end{acknowledgement}
\end{lstlisting}
\section{附录页}
附录放在\lstinline|\appendix|命令后,以英文字母进行编号