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
Select Git revision
  • master
  • dev
  • type-debug
  • create-theorem
  • bib
  • xtemplate
  • legacy
  • v0.10.0
  • v0.10.1
  • v0.11.0
  • v0.11.1
  • v0.11.2
  • v0.11.3
  • v0.12.0
  • v0.12.1
  • v0.12.2
  • v0.12.3
  • v0.13.0
  • v0.13.1
  • v0.14.0
  • v0.15.0
  • v0.16.0
  • v0.16.1
  • v0.17.0
  • v0.18.0
  • v0.19.0
  • v0.20.0
  • v0.3.0
  • v0.3.3
  • v0.4.0
  • v0.5.0
  • v0.6.0
  • v0.6.1
  • v0.7.0
  • v0.7.1
  • v0.7.2
  • v0.7.4
  • v0.8.0
  • v0.8.1
  • v0.8.2
  • v0.8.3
  • v0.8.4
  • v0.9.0
  • v0.9.1
  • v0.9.2
  • v0.9.3
  • v0.9.4
  • v1.0.0
  • v1.1.0
  • v1.1.1
  • v1.1.2
  • v1.2.0
  • v1.2.1
  • v1.3.0
  • v1.3.1
  • v1.3.2
  • v1.3.3
  • v1.4.0
  • v1.4.1
  • v1.4.2
  • v1.4.3
61 results

Target

Select target project
No results found
Select Git revision
  • master
  • bib
  • xtemplate
  • legacy
  • v0.10.0
  • v0.10.1
  • v0.11.0
  • v0.11.1
  • v0.11.2
  • v0.11.3
  • v0.12.0
  • v0.12.1
  • v0.12.2
  • v0.12.3
  • v0.13.0
  • v0.13.1
  • v0.14.0
  • v0.3.0
  • v0.3.3
  • v0.4.0
  • v0.5.0
  • v0.6.0
  • v0.6.1
  • v0.7.0
  • v0.7.1
  • v0.7.2
  • v0.7.4
  • v0.8.0
  • v0.8.1
  • v0.8.2
  • v0.8.3
  • v0.8.4
  • v0.9.0
  • v0.9.1
  • v0.9.2
  • v0.9.3
  • v0.9.4
37 results
Show changes

Commits on Source 543

443 additional commits have been omitted to prevent performance issues.
60 files
+ 13938
889
Compare changes
  • Side-by-side
  • Inline

Files

.editorconfig

0 → 100644
+11 −0
Original line number Original line Diff line number Diff line
root = true

[*]
trim_trailing_whitespace = true
insert_final_newline = true
charset = utf-8
end_of_line = lf
indent_style = space

[*.{dtx,tex,bib,def}]
indent_size = 2
+89 −0
Original line number Original line Diff line number Diff line

# 贡献者公约

## 我们的承诺

身为项目成员、贡献者、负责人,我们保证参与此社区的每个人都不受骚扰,不论其年龄、体型、身体条件、民族、性征、性别认同与表现、经验水平、教育程度、社会地位、国籍、相貌、种族、宗教信仰及性取向如何。

我们承诺致力于建设开放、友善、多元、包容、健康的社区环境。

## 我们的准则

有助于促进本社区积极环境的行为包括但不限于:

* 与人为善、推己及人
* 尊重不同的主张、观点和经历
* 积极提出、耐心接受有益批评
* 面对过失,承担责任、认真道歉、从中学习
* 关注社区共同诉求,而非一己私利

不当行为包括但不限于:

* 发布与性有关的言论或图像,以及任何形式的献殷勤或勾引
* 挑衅行为、侮辱或贬损的言论、人身及政治攻击
* 公开或私下骚扰
* 未获明确授权擅自发布他人的资料,如地址、电子邮箱等
* 其他有理由认定为违反职业操守的不当行为

## 落实之义务

社区负责人有责任诠释何谓“妥当行为”,并据此准则,妥善公正地认定与处置不当、威胁、冒犯及有害的行为。

社区负责人有权利和义务删除、编辑、拒绝违背本公约的评论(comment)、提交(commit)、代码、维基(wiki)编辑、问题(issue)等贡献。如有必要,需告知采取措施之理由。

## 适用范围

此行为标准适用于本社区全部场合,以及在其他场合代表本社区的个人。

代表本社区的情形包括但不限于:使用官方电子邮件与社交平台、作为指定代表参与在线或线下活动。

## 贯彻落实

如遇滥用、骚扰等不当行为,请通过 [git+nju-lug-email-3104-issue-@yaoge123.cn](mailto:git+nju-lug-email-3104-issue-@yaoge123.cn) 向纪律检查委员举报。
纪委将迅速审议并调查全部投诉。

社区全体负责人有义务保密举报者信息。

## 指导方针

社区负责人将依据下列方案判断并处置违纪行为:

### 一、督促

**社区影响**:用语不当、举止不符合职业道德或不受社区欢迎。

**处理意见**:由社区负责人予以非公开的书面警告,阐明违纪事由、解释举止如何不妥。或将要求公开道歉。

### 二、警告

**社区影响**:一起或多起事件中的违纪行为。

**处理意见**:警告继续违纪之后果、违纪者在特定时间内禁止与当事人往来、不得擅自与社区执法者往来,禁令涵盖社区内外、社交网络在内的一切联络。如有违反,可致封禁乃至开除。

### 三、封禁

**社区影响**:严重违纪行为,包括屡教不改。

**处理意见**:违纪者在特定时间内禁止与社区的任何往来或公开联络,禁止任何与当事人公开或私下往来,不得擅自与社区执法者往来。如有违反,可致开除。

### 四、开除

**社区影响**:典型违纪行为,例如屡教不改、骚扰某个人、敌对或贬低某个群体。

**处理意见**:无限期禁止违纪者与项目社区的一切公开往来。

## 来源

本行为标准改编自[参与者公约][homepage]2.0版,可在此查阅:[https://www.contributor-covenant.org/zh-cn/version/2/0/code_of_conduct.html][v2.0]

指导方针借鉴自[Mozilla纪检分级][Mozilla CoC]

此行为标准常见问题请洽:[https://www.contributor-covenant.org/faq][FAQ]
另有诸译本:[https://www.contributor-covenant.org/translations][translations]

[homepage]:https://www.contributor-covenant.org
[v2.0]: https://www.contributor-covenant.org/version/2/0/code_of_conduct.html
[Mozilla CoC]: https://github.com/mozilla/diversity
[FAQ]: https://www.contributor-covenant.org/faq
[translations]: https://www.contributor-covenant.org/translations
+102 −0
Original line number Original line Diff line number Diff line
name: 报告问题
description: 描述需要修复的问题
title: "[Bug]: "
labels: ["bug"]
body:
  - type: markdown
    attributes:
      value: |
        请使用此模板来报告*模板运行问题*,并尽可能多地提供信息。
  - type: checkboxes
    id: prerequisites
    attributes:
      label: 先决条件
      options:
        - label: |-
            我已尝试更新[模板版本](https://github.com/nju-lug/NJUThesis/blob/master/CHANGELOG.md)
          required: true
        - label: |-
            我已检索[模板手册](http://mirrors.ctan.org/macros/unicodetex/latex/njuthesis/njuthesis.pdf)
          required: true
        - label: |-
            我已检索[项目 wiki](https://github.com/nju-lug/NJUThesis/wiki)
          required: true
        - label: |-
            我已确认这个问题没有在[其他 issues](https://github.com/nju-lug/NJUThesis/issues) 中提出过。
          required: true
  - type: textarea
    id: expected_behavior
    attributes:
      label: 期望的现象
      placeholder: 本来应该是什么效果
    validations:
      required: true
  - type: textarea
    id: what_happened
    attributes:
      label: 发生了什么
      placeholder: 实际发生了什么偏差,此处不妨拖拽上传截图
    validations:
      required: true
  - type: textarea
    id: minimal_working_example
    attributes:
      label: 最小工作示例
      description: |
        一段*完整的可供编译*的 LaTeX 代码,用来复现上述问题。这段代码应当从 `\documentclass` 开始,到 `\end{document}` 结束。请删除*所有不会引起该问题的内容*。譬如,对于正文格式出现的问题,不必添加 `\njusetup` `\tableofcontents` 等命令。删除无关内容是一个 debug 的过程,能帮助你我更准确地问题的根源 : D
      placeholder: |
        \documentclass[]{njuthesis}
        ...
        \end{document}
      render: TeX
    validations:
      required: true
  - type: input
    id: njuthesis_version
    attributes:
      label: njuthesis 模板版本
      placeholder: v1.0.0
      description: 模板版本可以在 `.log` 文件中搜索 `njuthesis` 得到。
    validations:
      required: true
  - type: dropdown
    id: source
    attributes:
      label: 模板获取途径
      options:
        - <https://tex.nju.edu.cn>
        - 使用包管理器从 CTAN 安装
        - 通过 GitHub Releases 或镜像站下载
        - 从 Git 仓库下载
  - type: dropdown
    id: operating_system
    attributes:
      label: 操作系统
      options:
        - Windows
        - macOS
        - Linux
  - type: input
    id: tex_distribution
    attributes:
      label: TeX 发行版
      placeholder: TeX Live 2022 / MiKTeX 22.1
  - type: dropdown
    id: compiler
    attributes:
      label: 编译程序
      options:
        - XeLaTeX
        - LuaLaTeX
  - type: textarea
    id: more_info
    attributes:
      label: 额外信息
      placeholder: 任何你认为有帮助的信息
  - type: markdown
    attributes:
      value: |

        -----

        在提交这篇 issue 时,您将默认服从我们的[行为准则](https://github.com/nju-lug/NJUThesis/blob/master/.github/CODE_OF_CONDUCT.md)。
Original line number Original line Diff line number Diff line
name: 请求新功能
description: 提出可以改进的要点
title: "[Feature]: "
labels: ["enhancement"]
body:
  - type: checkboxes
    id: prerequisites
    attributes:
      label: 先决条件
      options:
        - label: |-
            我已尝试更新模板版本
          required: true
        - label: |-
            我已检索[模板手册](http://mirrors.ctan.org/macros/unicodetex/latex/njuthesis/njuthesis.pdf)
          required: true
        - label: |-
            我已检索[项目 wiki](https://github.com/nju-lug/NJUThesis/wiki)
          required: true
        - label: |-
            我已确认这个请求没有在[其他 issues](https://github.com/tuna/issues/issues)中提出过。
          required: true
  - type: textarea
    id: inconvenience
    attributes:
      label: 现有模板的不便之处
      placeholder: 你的请求是否来自于使用上有不好的体验?请简要进行描述。
  - type: textarea
    id: possible_solution
    attributes:
      label: 提出可能的解决方案
      placeholder: 你认为需要采取什么措施,或者你希望改进后将呈现出什么效果。
    validations:
      required: true
  - type: textarea
    id: considerations
    attributes:
      label: 提出考虑过的方案
      placeholder: 请描述你进行过的相关尝试。
  - type: textarea
    id: more_info
    attributes:
      label: 额外信息
      placeholder: 任何你认为有帮助的信息
  - type: markdown
    attributes:
      value: |
        在提交这篇 issue 时,我们默认您服从我们的[行为准则](https://github.com/nju-lug/NJUThesis/blob/master/.github/CODE_OF_CONDUCT.md)。
+5 −0
Original line number Original line Diff line number Diff line
blank_issues_enabled: true
contact_links:
  - name: 讨论
    url: https://github.com/nju-lug/NJUThesis/discussions/new
    about: 使用上的疑惑可以发在论坛哦
Original line number Original line Diff line number Diff line
name: Build LaTeX document
name: Build
on: [push]

on:
  push:
    branches:
      - master

  pull_request:
    branches:
      - master

env:
  CTAN_URL: https://mirrors.rit.edu/CTAN
  PACKAGES: latexmk cleveref enumitem footmisc tex-gyre xits biblatex-gb7714-2015 biber

jobs:
jobs:
  build_latex:
  build-on-ubuntu:
    runs-on: ubuntu-latest
    runs-on: ubuntu-latest
    if: "!startsWith(github.ref, 'refs/tags/v')"
    env:
      SET_PATH: |
        export PATH=/tmp/texlive/bin/x86_64-linux:$PATH
    steps:
    steps:
      - name: Set up Git repository
      - name: Set up Git repository
        uses: actions/checkout@v2
        uses: actions/checkout@v4


      - name: Compile to PDF
      - name: Install TeX Live
        uses: HermitSun/latex-action@v3
        run: |
        with:
          ${{ env.SET_PATH }}
          root_file: njuthesis.tex
          wget ${{ env.CTAN_URL }}/systems/texlive/tlnet/install-tl-unx.tar.gz
          latexmk_use_xelatex: true
          tar -xzf install-tl-unx.tar.gz
          args: '-bibtex'
          cd install-tl-20* && ./install-tl --profile ../.github/workflows/texlive.profile

      - name: Install latest njuthesis
        run: |
          ${{ env.SET_PATH }}
          tlmgr option repository ${{ env.CTAN_URL }}/systems/texlive/tlnet/
          tlmgr install xetex l3build
          l3build install
          cd scripts
          bash download.sh ${{ env.CTAN_URL }}
          cd data
          wget https://raw.githubusercontent.com/stone-zeng/tl-depend-analysis/data/data/tl-depend.json
          cd ..
          python3 main.py --pkg "${{ env.PACKAGES }}" --exclude "njuthesis-doc.cls"
          tlmgr update --self --all --no-auto-install

      - name: Compile test file
        run: |
          ${{ env.SET_PATH }}
          cd test
          latexmk -xelatex  -halt-on-error test-xetex-undergraduate
          xelatex           -halt-on-error test-xetex-graduate
          xelatex           -halt-on-error test-xetex-graduate-nlcover
          # latexmk -lualatex -halt-on-error test-luatex


      - name: Upload PDF
      - name: Upload CLS Files
        uses: actions/upload-artifact@v2
        uses: actions/upload-artifact@v4
        with:
        with:
          name: PDF
          name: "njuthesis-cls-${{ github.sha }}"
          path: njuthesis.pdf
          path: |
            build/unpacked/njuthesis.cls
            build/unpacked/*.def
+94 −0
Original line number Original line Diff line number Diff line
name: Release

on:
  push:
    branches:
      - master

    tags:
      - v*

env:
  CTAN_URL: https://mirrors.rit.edu/CTAN
  PACKAGES: cm-unicode tex-gyre tex-gyre-math lexend xits natbib makeindex

jobs:
  release:
    runs-on: ubuntu-latest
    if: startsWith(github.ref, 'refs/tags/v')
    env:
      SET_PATH: |
        export PATH=/tmp/texlive/bin/x86_64-linux:$PATH
    steps:
      - name: Set up Git repository
        uses: actions/checkout@v4

      - name: Set Version
        run: echo "VERSION=${GITHUB_REF##*/}" >> $GITHUB_ENV

      - name: Install TeX Live
        run: |
          ${{ env.SET_PATH }}
          wget ${{ env.CTAN_URL }}/systems/texlive/tlnet/install-tl-unx.tar.gz
          tar -xzf install-tl-unx.tar.gz
          cd install-tl-20* && ./install-tl --profile ../.github/workflows/texlive.profile

      - name: Install latest njuthesis
        run: |
          ${{ env.SET_PATH }}
          tlmgr option repository ${{ env.CTAN_URL }}/systems/texlive/tlnet/
          tlmgr install xetex l3build
          l3build install
          cd scripts
          bash download.sh ${{ env.CTAN_URL }}
          cd data
          wget https://raw.githubusercontent.com/stone-zeng/tl-depend-analysis/data/data/tl-depend.json
          cd ..
          python3 main.py --pkg "${{ env.PACKAGES }}" --exclude "njuthesis.cls"
          tlmgr update --self --all --no-auto-install

      - name: Install latest ctex
        run: |
          ${{ env.SET_PATH }}
          git clone https://github.com/CTeX-org/ctex-kit.git
          cd ctex-kit/ctex
          l3build install

      - name: Install fonts
        run: |
          mkdir fonts
          wget https://github.com/adobe-fonts/source-han-serif/raw/release/OTF/SimplifiedChinese/SourceHanSerifSC-SemiBold.otf
          wget https://github.com/adobe-fonts/source-han-serif/raw/release/OTF/SimplifiedChinese/SourceHanSerifSC-Bold.otf
          wget https://github.com/adobe-fonts/source-han-serif/raw/release/OTF/SimplifiedChinese/SourceHanSerifSC-Heavy.otf
          wget https://github.com/be5invis/Iosevka/releases/download/v15.6.3/ttf-iosevka-15.6.3.zip
          unzip ttf-iosevka-15.6.3.zip
          cp *.otf                   /usr/share/fonts/
          cp iosevka-lightitalic.ttf /usr/share/fonts/
          cp iosevka-light.ttf       /usr/share/fonts/
          cp iosevka-semibold.ttf    /usr/share/fonts/
          chmod -x /usr/share/fonts/*.otf
          chmod -x /usr/share/fonts/*.ttf
          fc-cache -fv

      - name: Zip CTAN package
        run: |
          ${{ env.SET_PATH }}
          l3build ctan
          mv njuthesis-ctan.zip njuthesis-ctan-$VERSION.zip
          mv njuthesis.pdf njuthesis-$VERSION.pdf

      - name: Zip USER package
        run: |
          ${{ env.SET_PATH }}
          mv docs/* .
          mv build/unpacked/* .
          zip -r njuthesis-user-$VERSION.zip *.def njuthesis-sample* njuthesis.cls nju-*.pdf LICENSE CHANGELOG.md README.md

      - uses: "marvinpinto/action-automatic-releases@latest"
        with:
          repo_token: "${{ secrets.GITHUB_TOKEN }}"
          prerelease: true
          files: |
            njuthesis-v*.pdf
            njuthesis-user-v*.zip
            njuthesis-ctan-v*.zip
+14 −0
Original line number Original line Diff line number Diff line
# From latex3
# https://github.com/latex3/latex3/blob/main/support/texlive.profile

selected_scheme     scheme-infraonly
TEXDIR              /tmp/texlive
TEXMFSYSCONFIG      /tmp/texlive/texmf-config
TEXMFSYSVAR         /tmp/texlive/texmf-var
TEXMFLOCAL          /tmp/texlive/texmf-local
TEXMFHOME           ~/texmf
TEXMFCONFIG         ~/.texlive/texmf-config
TEXMFVAR            ~/.texlive/texmf-var
option_doc          0
option_src          0
tlpdbopt_autobackup 0
+28 −4
Original line number Original line Diff line number Diff line
@@ -12,17 +12,41 @@
*.cb2
*.cb2
.*.lb
.*.lb


## DocStrip generated file
*.cls
*.def
*.ins
*.sty
!docs/njuthesis-setup.def

## Zip file
*.zip

## Fonts
*.ttf
*.otf

## Intermediate documents:
## Intermediate documents:
*.hd
*.dvi
*.dvi
*.xdv
*.xdv
*-converted-to.*
*-converted-to.*

# these rules might exclude image files for figures etc.
# these rules might exclude image files for figures etc.
# *.ps
# *.ps
# *.eps
# *.eps
# *.pdf
njuthesis*.pdf

test*.pdf
## Generated if empty string is given at "Please type another file name for output:"

njuthesis.pdf
# Folders
build/
release/
support/
scripts/data
TDS/
temp/
mythesis/
__pycache__/


## Bibliography auxiliary files (bibtex/biblatex/biber):
## Bibliography auxiliary files (bibtex/biblatex/biber):
*.bbl
*.bbl
Original line number Original line Diff line number Diff line
{
{
    "latex-workshop.latex.autoBuild.run": "never", // 禁止自动编译
    "latex-workshop.latex.recipe.default": "lastUsed", // 使用前一次的编译方法
    "latex-workshop.latex.tools": [
    "latex-workshop.latex.tools": [
        {
        {
            "name": "xelatex",
            "name": "xelatex",
            "command": "xelatex",
            "command": "xelatex",
            "args": [
            "args": [
                "-synctex=1",
                "-synctex=1",
                "-shell-escape",
                "-interaction=nonstopmode",
                "-interaction=nonstopmode",
                "-file-line-error",
                "-file-line-error",
                "%DOCFILE%"
                "%DOCFILE%"
            ]
            ]
        },
        },
        {
        {
            "name": "latexmk",
            "name": "latexmk-xe",
            "command": "latexmk",
            "command": "latexmk",
            "args": [
            "args": [
                "-xelatex"
                "-xelatex",
                "-time",
                "-interaction=nonstopmode",
                "%DOCFILE%"
            ]
        },
        {
            "name": "latexmk-lua",
            "command": "latexmk",
            "args": [
                "-lualatex",
                "-time",
                "-interaction=nonstopmode",
                "%DOCFILE%"
            ]
            ]
        },
        },
        {
        {
@@ -28,15 +44,17 @@
            "name": "lualatex",
            "name": "lualatex",
            "command": "lualatex",
            "command": "lualatex",
            "args": [
            "args": [
                "-interaction=nonstopmode",
                "-file-line-error",
                "%DOCFILE%"
                "%DOCFILE%"
            ]
            ]
        }
        },
    ],
    ],
    "latex-workshop.latex.recipes": [
    "latex-workshop.latex.recipes": [
        {
        {
            "name": "latexmk 🔃",
            "name": "latexmk(xe)",
            "tools": [
            "tools": [
                "latexmk"
                "latexmk-xe"
            ]
            ]
        },
        },
        {
        {
@@ -45,6 +63,21 @@
                "xelatex"
                "xelatex"
            ]
            ]
        },
        },
        {
            "name": "xe->bib->xe->xe",
            "tools": [
                "xelatex",
                "biber",
                "xelatex",
                "xelatex"
            ]
        },
        {
            "name": "latexmk(lua)",
            "tools": [
                "latexmk-lua"
            ]
        },
        {
        {
            "name": "lualatex",
            "name": "lualatex",
            "tools": [
            "tools": [
@@ -52,13 +85,13 @@
            ]
            ]
        },
        },
        {
        {
            "name": "xe->bib->xe->xe",
            "name": "lua->bib->lua->lua",
            "tools": [
            "tools": [
                "xelatex",
                "lualatex",
                "biber",
                "biber",
                "xelatex",
                "lualatex",
                "xelatex"
                "lualatex"
            ]
            ]
        }
        },
    ]
    ]
}
}

CHANGELOG.md

0 → 100644
+736 −0

File added.

Preview size limit exceeded, changes collapsed.

README-CTAN.md

0 → 100644
+49 −0
Original line number Original line Diff line number Diff line
The `njuthesis` class
=====================

The `njuthesis` class is intended for typesetting Nanjing University
dissertations with LaTeX, providing support for bachelor, master,
doctoral thesis and postdoctoral report. Compilation of this class
requires either `xelatex` or `lualatex` engine.

Usage
-----

A minimal example of this document class should look like

```LaTeX
\documentclass{njuthesis}
\njusetup{}
\begin{document}
\maketitle
\tableofcontents
\mainmatter
\chapter{Welcome}
Hello \LaTeX{}
\printbibliography
\end{document}
```

Contributing
------------

[Issues](https://github.com/nju-lug/NJUThesis/issues) and
[pull requests](https://github.com/nju-lug/NJUThesis/pulls)
are always welcome.

Wiki
----

Please see [Chinese wiki](https://github.com/nju-lug/NJUThesis/wiki).

License
-------

This work may be distributed and/or modified under the conditions of
the [LaTeX Project Public License](http://www.latex-project.org/lppl.txt),
either version 1.3c of this license or (at your option) any later
version.

-----

Copyright (C) 2021 - 2025 by NJU LUG.
+48 −56
Original line number Original line Diff line number Diff line
# NJU Thesis Undergraduate
# NJU Thesis: 南京大学学位论文 LaTeX 模板


[![njuthesis](https://img.shields.io/badge/njuthesis-latex-blue)](https://git.nju.edu.cn/nju-lug/nju-latex-templates)
![build status](https://github.com/nju-lug/NJUThesis/actions/workflows/build.yml/badge.svg)
[![overleaf](https://img.shields.io/badge/overleaf-supported-brightgreen)](https://tex.nju.edu.cn)
[![CTAN](https://img.shields.io/ctan/v/njuthesis.svg)](https://www.ctan.org/pkg/njuthesis)
![build status](https://github.com/nju-lug/NJUThesisUndergraduate/actions/workflows/build.yml/badge.svg)
[![GitHub release](https://img.shields.io/github/release/nju-lug/NJUThesis/all.svg)](https://github.com/nju-lug/NJUThesis/releases/latest)
[![overleaf](https://img.shields.io/badge/online_editor-supported-brightgreen)](https://tex.nju.edu.cn/template)
[![nju-git](https://img.shields.io/gitlab/stars/nju-lug/nju-latex-templates/njuthesis?gitlab_url=https%3A%2F%2Fgit.nju.edu.cn&style=social)](https://git.nju.edu.cn/nju-lug/nju-latex-templates/njuthesis)


> 此项目是基于[NJU thesis 2021](https://github.com/FengChendian/NJUThesis2021)的重构版本,目前本科生版本**已经基本重构完成**
`njuthesis` 是制作南京大学本科生毕业论文、研究生学位论文、博士后出站报告的 LaTeX 文档类。本模板基于本科生院的论文撰写规范制作,同时参考研究生院提供的硕士、博士学位材料包,用于生成符合南京大学排版要求和相应的国家标准的学位论文,力求通过 LaTeX3 语法实现清晰的实现逻辑、较高的可定制性以及友好的用户接口


原来的[NJU thesis 2021](https://github.com/FengChendian/NJUThesis2021)模板太过古老并且不支持硕士、博士论文,目前难以维护,因此为了模板的可持续发展,现在将对该项目进行重构,项目将被挂载于[NJU-LUG](https://github.com/nju-lug)组织仓库下。
## 快速开始


相关文档请参见[本项目wiki](https://github.com/nju-lug/NJUThesisUndergraduate/wiki)
请首先阅读[用户手册](http://mirrors.ctan.org/macros/unicodetex/latex/njuthesis/njuthesis.pdf),其中详尽阐述了模板的特性和使用方法


## 快速开始
对于普通用户,首要推荐使用下述的**南大 TeX 编译方法**

### 南大 TeX 编译

[南大 TeX](https://tex.nju.edu.cn)[eScience 中心](https://sci.nju.edu.cn)为南大在校师生提供的在线 LaTeX 写作平台,已*安装有本模板的最新版*。注册登录后,只需在**创建新项目**菜单中选择**论文模板**即可开始写作。

**使用本平台时,请积极备份自己的文稿。**


### 本地编译
### 本地编译


1. 安装TexLive或者MikTex最新版
推荐使用包管理器安装 `njuthesis``njuvisual` 的最新版。
2. 下载[模板全部文件](https://github.com/nju-lug/NJUThesisUndergraduate/archive/refs/heads/master.zip)
4. 根据需要更改`njuthesis.tex`文件中的内容
5. 在模板根目录下运行`latexmk -xelatex`编译文件,得到对应的PDF

#### **关于本地编译**

- 模板支持`latexmk``XeLaTex``LuaLaTex`三种编译方式
- 如果使用`latexmk`,请务必使用完整的命令`latexmk -xelatex`以免产生不必要的问题
- 如果使用`XeLaTex``LuaLaTex`,需要按照`XeLaTex/LuaLaTex` -> `biber` -> `XeLaTex/LuaLaTex` -> `XeLaTex/LuaLaTex`的顺序编译四次
- 仓库中.vscode附带一份VScode的Latex WorkShop的配置文件,可根据需要使用

### [南大Tex](https://tex.nju.edu.cn)编译

1. 下载[模板全部文件](https://github.com/nju-lug/NJUThesisUndergraduate/archive/refs/heads/master.zip)
2. 登录[南大Tex](https://tex.nju.edu.cn),点击New Project -> Upload Project上传刚刚得到的zip文件,上传后`njuthesis.tex``njuthesis.cls`等文件应在根目录,目录结构如下所示:

    ```bash
    │  coverinfo.sty
    │  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
    ```


3. 在南大Tex项目内页面左上角的`Menu`中,将编译器改为`LuaLatex`
新手同学不妨直接使用以下流程:
4. 编写tex文件


### 其他
1. [从南大镜像站下载](https://mirror.nju.edu.cn/download/app/TeX%20%E6%8E%92%E7%89%88%E7%B3%BB%E7%BB%9F)并安装最新的 TeX 发行版,并更新所有宏包
2. 下载包含[模板全部文件](https://github.com/nju-lug/NJUThesis/releases/latest)的压缩包 `njuthesis-user-v*.zip`
3. 根据需要更改 `njuthesis-sample.tex` 文件中的内容
4. 在模板根目录下运行 `latexmk -xelatex` 运行编译,得到对应的 PDF 文件


更多内容请参见项目Wiki中的[使用说明](https://github.com/nju-lug/NJUThesisUndergraduate/wiki/%E4%BD%BF%E7%94%A8%E8%AF%B4%E6%98%8E)
### 典型结构


## 常见问题
```LaTeX
\documentclass{njuthesis}
\njusetup{}
\begin{document}
\maketitle
\tableofcontents
\mainmatter
\chapter{欢迎}
使用 \LaTeX{}
\printbibliography
\end{document}
```


请参见[常见问题](https://github.com/nju-lug/NJUThesisUndergraduate/wiki/%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98)
## 反馈


## 贡献
在你遇到模板问题时,请遵守以下步骤:


如果你发现了模板的问题,欢迎在Github中提交issue或者PR。
1. 在《[修订记录](https://github.com/nju-lug/NJUThesis/blob/master/CHANGELOG.md)》查看该问题是否已经修复但未发布;
    - 若是,则可以使用仓库中的开发版本解决问题
1.[GitHub Issues](https://github.com/nju-lug/NJUThesis/issues)[Discussions](https://github.com/nju-lug/NJUThesis/discussions) 中搜索该问题的关键词;
1. 浏览[本项目 Wiki](https://github.com/nju-lug/NJUThesis/wiki)[用户手册](http://mirrors.ctan.org/macros/unicodetex/latex/njuthesis/njuthesis.pdf)
1. 在你确定这是一个新问题时
    - 对于模板 bug、请求新功能、文档笔误等提出[新 issue](https://github.com/nju-lug/NJUThesis/issues/new/choose)
    - 对于用法的疑惑、格式上的斟酌等提出[新 discussion](https://github.com/nju-lug/NJUThesis/discussions/new)
    - 两个划分不绝对,区别在于 issue 是解决即关闭的
    - 如果确实重复了,会打上 duplicate 标签并将你引导至本问题首条提问


## 许可
如果导师或院系有额外要求,请一同附上要求原文或格式截图。


本模板的发布遵守 LaTeX Project Public License(版本 1.3c 或更高)。
## 贡献

欢迎提交 [PR](https://github.com/nju-lug/NJUThesis/pulls)


## TODO
## 许可


- [x] 主要代码转为Latex3,使用expl3宏包
本模板的发布遵守 [LaTeX Project Public License(版本 1.3c 或更高)](https://www.latex-project.org/lppl/lppl-1-3c/)
- [x] 基于CTex宏集重构所有页面以符合学校论文要求
- [x] Github Action自动化构建预览PDF
- [x] 完善文档
- [ ] CTAN发布宏包

build.lua

0 → 100644
+22 −0
Original line number Original line Diff line number Diff line
#!/usr/bin/env texlua

-- Build script for njuthesis.
-- run with `l3build`

module        = "njuthesis"

checkengines  = {"xetex", "luatex"}
checkopts     = "-interaction=batchmode"

textfiles     = {"LICENSE", "README*.md", "*.ins"}
ctanreadme    = "README-CTAN.md"

sourcefiledir = "source"
sourcefiles   = {"*.dtx"}
installfiles  = {"*.cls", "*.def"}

typesetexe    = "xelatex"
typesetfiles  = {"njuthesis.dtx"}

unpackexe     = "xetex"
unpackfiles   = {"njuthesis.dtx"}

conf.txsprofile

0 → 100644
+1408 −0

File added.

Preview size limit exceeded, changes collapsed.

coverinfo.sty

deleted100644 → 0
+0 −19
Original line number Original line Diff line number Diff line
\ProvidesExplPackage{coverinfo}{2021-09-04}{0.1}{NJU Thesis Undergraduate cover information}

\tl_const:Nn \TitleA {曲率引擎的研究}% 第一行标题
\tl_const:Nn \TitleB {}% 第二行标题
\tl_const:Nn \TitleC {}% 第三行标题
\tl_const:Nn \Title_EN {Curvature~engine~research} % 注意英文名中空格必须替换为波浪线
\tl_const:Nn \Grade {2017}
\tl_const:Nn \StudentID {17184xxx}
\tl_const:Nn \StudentName {张三}
\tl_const:Nn \StudentName_EN {Zhang~San}
\tl_const:Nn \Department {未来学院}
\tl_const:Nn \Department_EN {School~of~Future}
\tl_const:Nn \Major {未来学}
\tl_const:Nn \Major_EN {Future}
\tl_const:Nn \Mentor {李四}
\tl_const:Nn \Mentor_EN {Li~Si}
\tl_const:Nn \MentorTitle {教授}
\tl_const:Nn \MentorTitle_EN {Professor}
\tl_const:Nn \SubmitDate {2077年12月31日}
+14 −0
Original line number Original line Diff line number Diff line
@article{preskill2018,
  title = {Quantum {{Computing}} in the {{NISQ}} Era and Beyond},
  author = {Preskill, John},
  author+an = {1=thesisauthor},
  date = {2018-08-06},
  journaltitle = {Quantum},
  volume = {2},
  pages = {79},
  publisher = {{Verein zur Förderung des Open Access Publizierens in den Quantenwissenschaften}},
  doi = {10.22331/q-2018-08-06-79},
  url = {https://quantum-journal.org/papers/q-2018-08-06-79/},
  urldate = {2022-10-27},
  langid = {british}
}
+159 −0
Original line number Original line Diff line number Diff line
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% njuthesis 示例模板 v1.4.3 2025-05-21
% https://github.com/nju-lug/NJUThesis
%
% 贡献者
% 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. 不保证接口稳定,写作前一定要留意版本号
%   4. 以百分号(%)开头的内容为注释,可以随意删除
%---------------------------------------------------------------------

%---------------------------------------------------------------------
% 请先阅读使用手册:
% http://mirrors.ctan.org/macros/unicodetex/latex/njuthesis/njuthesis.pdf
%---------------------------------------------------------------------

\documentclass[
    % 模板选项(注意右端逗号):
    %
    % type = bachelor|master|doctor|postdoc, % 文档类型,默认为本科生
    % degree = academic|professional,        % 学位类型,默认为学术型
    %
    % 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

% 模板默认使用 \flushbottom,即底部平齐
% 效果更好,但可能出现 underfull \vbox 信息
% 以下命令用于抑制这些信息
\raggedbottom

\begin{abstract}
  中文摘要
\end{abstract}

\begin{abstract*}
  English abstract
\end{abstract*}

% 生成目录
\tableofcontents
% 生成图片清单
% \listoffigures
% 生成表格清单
% \listoftables

%---------------------------------------------------------------------
%	正文部分
%---------------------------------------------------------------------
\mainmatter

% 符号表
% 语法与 description 环境一致
% 两个可选参数依次为说明区域宽度、符号区域宽度
% 带星号的符号表(notation*)不会插入目录
% \begin{notation}[10cm]
%   \item[DFT] 密度泛函理论 (Density functional theory)
%   \item[DMRG] 密度矩阵重正化群 (Density-Matrix Reformation-Group)
% \end{notation}

% 建议将论文内容拆分为多个文件
% 即新建一个 chapters 文件夹
% 把每一章的内容单独放入一个 .tex 文件
% 然后在这里用 \include 导入,例如
%   \include{chapters/introduction}
%   \include{chapters/environments}

\chapter{引言}

\section{量子计算}

John Preskill 认为我们现在处于“含噪声的中型量子时代”。\cite{preskill2018}
量子位的不稳定性和有限的量子比特数量限制了量子计算机的复杂度和纠错能力。

%---------------------------------------------------------------------
%	参考文献
%---------------------------------------------------------------------

% 生成参考文献页
\printbibliography

%---------------------------------------------------------------------
%	致谢
%---------------------------------------------------------------------

\begin{acknowledgement}
  感谢 \href{https://git.nju.edu.cn/nju-lug/lug-introduction}{LUG@NJU}
\end{acknowledgement}

%---------------------------------------------------------------------
%	学术简历
%---------------------------------------------------------------------

% 详见手册中“成果列表”一节
% \njuchapter{学术成果}
% \njupaperlist[攻读博士学位期间发表的学术论文]{preskill2018}

%---------------------------------------------------------------------
%	附录部分
%---------------------------------------------------------------------

% 附录部分使用单独的字母序号
\appendix

% 可以在这里插入补充材料
\chapter{正文中涉及的数据及源代码}
\dots

% 完工
\end{document}
+264 −0
Original line number Original line Diff line number Diff line
% njuthesis 参数设置文件 v1.4.3 2025-05-21

% 一些提醒:
%   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          = {...},
    % define,
    % 以上设置项在重新调用 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{subsection}{\normalfont\bfseries} % 修改 subsection 为小四号粗体宋体
% \njusetformat{tabular}{\zihao{-4}\bfseries}     % 修改表格环境的字号
% \EditInstance{nju}{u/cover/emblem-img}{align=l} % 左对齐的本科生封面校徽

install-unix.sh

0 → 100755
+20 −0
Original line number Original line Diff line number Diff line
#!/usr/bin/env sh

mkdir -p mythesis
cd mythesis

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                 .

xetex njuthesis.dtx > /dev/null

rm *.dtx
rm *.ins
rm *.log
rm njuthesis-doc.cls

cd ..

install-win.bat

0 → 100644
+20 −0
Original line number Original line Diff line number Diff line
@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 ..

njuthesis.bib

deleted100644 → 0
+0 −6
Original line number Original line Diff line number Diff line
@ARTICLE{njuthesis,
 title={南京大学学士学位论文LaTex模板},
 AUTHOR = {NJU-LUG},
 JOURNALTITLE = {Github},
 YEAR   = {2021}
}
 No newline at end of file

njuthesis.cls

deleted100644 → 0
+0 −36
Original line number Original line Diff line number Diff line
\NeedsTeXFormat{LaTeX2e}

\ProvidesClass{njuthesis}

\RequirePackage{kvoptions}

\SetupKeyvalOptions{
    family=njuthesis,
    prefix=
}

\LoadClass[
  a4paper,
  twoside,
  UTF8,
  scheme=chinese,
  linespread=1.625,% laTex默认1.2行距,word默认行距是1.3,要求1.5倍word行距,故1.5/1.2*1.3 = 1.625
  fontset=none,
  zihao=-4
  ]{ctexbook}[2018/04/01]

\DeclareStringOption[1]{TitleLength}
\DeclareStringOption[UG]{Degree}
\DeclareStringOption[thesis]{Type}

\ProcessKeyvalOptions*\relax

% 输入配置文件
\RequirePackage{profile/packages}
\RequirePackage{coverinfo} 
\RequirePackage{profile/font}
\RequirePackage{profile/page}
\RequirePackage{profile/reference}
\RequirePackage{profile/components}
\RequirePackage{profile/cover}
\RequirePackage{profile/abstract}

njuthesis.tex

deleted100644 → 0
+0 −177
Original line number Original line Diff line number Diff line
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% NJU Thesis Undergraduate
% 南京大学本科生毕业论文LaTeX模板
% Version 0.1 (2021/09/07)
%
% 请关注项目地址以获取最新变化
% https://github.com/nju-lug/NJUThesisUndergraduate
% https://git.nju.edu.cn/nju-lug/nju-latex-templates/njuthesisundergraduate
%
% 贡献者
% @atxy
% @FengChendian
% @HermitSun
% @glatavento
% 
% 许可证
% LaTeX Project Public License(版本 1.3c 或更高)
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass[
    TitleLength=1,% 选择标题行数,范围是1~3
    Degree=UG,% 学位 本科:UG
    Type=thesis% thesis:毕业论文,design:毕业设计
]{njuthesis}

% 导入参考文献源
\addbibresource{njuthesis.bib}

\begin{document}

%----------------------------------------------------------------------------------------
%	封面、摘要和目录
%----------------------------------------------------------------------------------------

\maketitle % 请在coverpage.sty输入封面信息

\begin{abstract}
    \zhlipsum[76][name=zhufu]
    \keywords{驾驶;星际穿越}
\end{abstract}

\begin{englishabstract}
    \blindtext
    % 英文关键词。关键词之间用英文半角逗号隔开,末尾无符号。
    \englishkeywords{Drive, Interstellar travel}
\end{englishabstract}

\tableofcontents

%----------------------------------------------------------------------------------------
%	正文部分
%----------------------------------------------------------------------------------------
\mainmatter

\chapter{绪论}
\section{简介}
南京大学学士学位论文\LaTeX 模板\cite{njuthesis}基于本科生院的论文撰写规范修改,用于生成符合南京大学学位论文排版要求和相应的国家规范、行业标准的学位论文。

此模板旨在为同学提供毕业论文书写的方便,如有模板问题或者版权问题,请于Github上提出issue。

\section{表格示例}
\begin{table}[htbp]
    \caption{经过测试的环境}
    \label{tab:mytab}
    \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}
你可以使用\lstinline|table|环境插入标准三线表,如\cref{tab:mytab}所示,代码如下:
\begin{lstlisting}[language=TeX]
\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{图片示例}
\label{sec:figures}
\begin{figure}[htbp]
    \includegraphics[width=0.5\textwidth]{njuname}
    \caption{南京大学名称}
    \label{fig:njuname}
\end{figure}
你可以使用\lstinline|figure|环境插入图片,如\cref{fig:njuname},代码如下:
\begin{lstlisting}[language=TeX]
\begin{figure}
    \includegraphics[width=0.5\textwidth]{njuname}
    \caption{南京大学名称}
\end{figure}
\end{lstlisting}

\subsection{文字环绕图像}
% wrapfigure后面不能有空行
\begin{wrapfigure}{r}{0cm}
    \includegraphics[width=.3\textwidth]{njulogo}
    \caption{环绕图像测试}
    \label{fig:njulogo}
\end{wrapfigure}
\zhlipsum[4][name=xiangyu]

你可以使用\lstinline|wrapfigure|环境插入图片,类似于\cref{sec:figures}的普通图片插入方法,代码如下:
\begin{lstlisting}[language=TeX]
\begin{wrapfigure}{r}{0cm}
    \includegraphics[width=.3\textwidth]{njulogo}
    \caption{环绕图像测试}
    \label{fig:njulogo}
\end{wrapfigure}
\end{lstlisting}

\section{公式示例}
\begin{equation}\label{eq:dewitt}
    \int  e^{ax} \tanh bx\ dx = 
    \begin{cases}
    \displaystyle{ \frac{ e^{(a+2b)x}}{(a+2b)} 
    {_2F_1}\left[ 1+\frac{a}{2b},1,2+\frac{a}{2b}, -e^{2bx}\right] }& \\
    \displaystyle{
    \hspace{1cm}-\frac{1}{a}e^{ax}{_2F_1}\left[ 1, \frac{a}{2b},1+\frac{a}{2b}, -e^{2bx}\right]
    }
     & a\ne b \\
    \displaystyle{\frac{e^{ax}-2\tan^{-1}[e^{ax}]}{a} } & a = b
    \end{cases}
\end{equation}
    
你可以使用\lstinline|equation|环境插入公式,如\cref{eq:dewitt},代码如下:
\begin{lstlisting}[language=TeX]
\begin{equation}\label{eq:dewitt}
    \int  e^{ax} \tanh bx\ dx = 
    \begin{cases}
    \displaystyle{ \frac{ e^{(a+2b)x}}{(a+2b)} 
    {_2F_1}\left[ 1+\frac{a}{2b},1,2+\frac{a}{2b}, -e^{2bx}\right] }& \\
    \displaystyle{
    \hspace{1cm}-\frac{1}{a}e^{ax}{_2F_1}\left[ 1, \frac{a}{2b},1+\frac{a}{2b}, -e^{2bx}\right]
    }
        & a\ne b \\
    \displaystyle{\frac{e^{ax}-2\tan^{-1}[e^{ax}]}{a} } & a = b
    \end{cases}
\end{equation}
\end{lstlisting}

%----------------------------------------------------------------------------------------
%	参考文献
%----------------------------------------------------------------------------------------

\printbibliography[heading=bibintoc, title=参考文献] % 输出参考文献列表并将本页插入目录条目

%----------------------------------------------------------------------------------------
%	致谢
%----------------------------------------------------------------------------------------

% \chapter*{致谢}
% \addcontentsline{toc}{chapter}{致谢}
% 感谢\href{https://git.nju.edu.cn/nju-lug/lug-introduction}{NJU LUG}。

%----------------------------------------------------------------------------------------
%	附录部分
%----------------------------------------------------------------------------------------
\appendix 

\end{document}
 No newline at end of file

profile/abstract.sty

deleted100644 → 0
+0 −65
Original line number Original line Diff line number Diff line
\ProvidesExplPackage{profile/abstract}{2021-09-04}{0.1}{NJU Thesis Undergraduate abstract design}

% 拼合标题
\tl_const:Nn \Title {\TitleA\TitleB\TitleC}

% 摘要环境
\NewDocumentEnvironment{abstract} {}
{%
  \pagestyle{plain}
  \pagenumbering{Roman}
  \begin{center}
    \kaishu\zihao{-2}{\textbf{\uuline{南京大学本科生毕业论文(设计、作品)中文摘要}}}
  \end{center}
  {\bgroup
    \kaishu\zihao{-4}
    \tl_set:Nn \tabcolsep {0pt}
    \tl_set:Nn \arraystretch {0.8}
    \noindent
    题目: \Title \\
    院系: \Department \\
    专业: \Major \\
    本科生姓名: \StudentName \\
    指导教师(姓名、职称): \Mentor\ \MentorTitle \\
    摘要:
    \egroup
  }
  \kaishu\zihao{-4}\par%
}{%
\newpage
}

% 中文关键词
\NewDocumentCommand \keywords {m} {%
  \par\vspace{2ex}\noindent%
  {\kaishu\zihao{-4}\makebox[4em][s]{关键词{}}}~{#1}%
}

% 英文摘要
\NewDocumentEnvironment{englishabstract} {}
{%
  \pagestyle{plain}
  \begin{center}
      \kaishu\zihao{-2}{\textbf{\uuline{南京大学本科生毕业论文(设计、作品)英文摘要}}}
  \end{center}
  {
    \bgroup
    THESIS: ~~\Title_EN \\
    DEPARTMENT: ~~\Department_EN \\
    SPECIALIZATION: ~~\Major_EN \\
    UNDERGRADUATE:~~\StudentName_EN \\
    MENTOR:~~\Mentor_EN \ \MentorTitle_EN\\
    ABSTRACT:
    \egroup
  }
  \zihao{-4}\par%
}{%
\cleardoublepage
\newpage
}

% 英文关键词
\NewDocumentCommand \englishkeywords {m} {%
  \par\vspace{2ex}\noindent%
  {KEYWORDS{:}}~~{#1}%
}
 No newline at end of file

profile/components.sty

deleted100644 → 0
+0 −58
Original line number Original line Diff line number Diff line
\ProvidesExplPackage{profile/components}{2021-09-04}{0.1}{NJU Thesis Undergraduate components configuration} 

% 图表位置调整
\floatsetup[lstlisting]{ % Captions for lstlistings
	capposition=above,%
	margins=centering,%
	floatwidth=\textwidth%
}
\floatsetup[figure]{ % Captions for figures
	capposition=bottom,%
	margins=centering,%
	floatwidth=\textwidth%
}
\floatsetup[table]{ % Captions for tables
	capposition=above,%
	margins=centering,%
	floatwidth=\textwidth%
}

% 代码样式
\lstset{
	basicstyle=\ttfamily\linespread{1}\selectfont,
    keywordstyle=\bfseries,% use bold style for keywords
    commentstyle=\rmfamily\itshape,% use italic style for comments
    stringstyle=\ttfamily,% 字符串风格
    flexiblecolumns,% ?
    numbers=left,% left-aligned numbering
    showspaces=false,% hide markers for spaces
    showstringspaces=false,
    captionpos=t,% place the caption at the top
	% frame=lrtb,% show all four sides of the frame
	%linewidth=.8\textwidth,
	% breakatwhitespace=true,
	breaklines=true,
	xleftmargin=2em,xrightmargin=2em,% set the width of the code environment
}

% 图表标题样式
\DeclareCaptionFont{songticap}{\zihao{5}\bf\songti}
\captionsetup{
    font=small,%
    labelfont=songticap,
	textfont=songticap,
	strut=no,%
	hypcap=true, % Links point to the top of the figure
	% indention=0pt, % Suppress indentation
	% % parindent=0pt, % Suppress space between paragraphs
	aboveskip=6pt, % Increase the space between the figure and the caption
	belowskip=6pt, % Increase the space between the caption and the table
}

% list configuration
\renewcommand{\labelitemi}{\small$\blacktriangleright$}
\renewcommand{\labelitemii}{\textbullet}

\setlist[itemize]{noitemsep}
\setlist[enumerate]{noitemsep}
\setlist[description]{noitemsep}

profile/cover.sty

deleted100644 → 0
+0 −106
Original line number Original line Diff line number Diff line
\ProvidesExplPackage{profile/cover}{2021-09-04}{0.1}{NJU Thesis Undergraduate cover design} 

% 封面下划线
\cs_new:Npn \cover_underline:nn #1 #2 {
  \uline{\makebox[#1]{#2}}
}

% 封面表格边框
\cs_new:Npn \coverbox:n #1 {
  \makebox[4.2em][s]{#1}
}

% 封面信息栏
\tl_new:N \cover_personalinfo
\tl_set:Nn \cover_personalinfo {
  \begin{tabular}{p{4.2em}c}
    \coverbox:n {\hfill}
    & \cover_underline:nn {250pt}{\songti\Department}\\
    \coverbox:n {\hfill}
    & \cover_underline:nn {250pt}{\songti\Major}\\

    \int_case:nn {\TitleLength}
      {
        { 1 } { 
          \coverbox:n {\hfill}
          & \cover_underline:nn {250pt}{\textbf{\songti\TitleA}} \\ }
        { 2 } {
          \coverbox:n {\hfill}
          & \cover_underline:nn {250pt}{\textbf{\songti\TitleA}} \\
          & \cover_underline:nn {250pt}{\textbf{\songti\TitleB}} \\ }
        { 3 } { 
          \coverbox:n {\hfill}
          & \cover_underline:nn {250pt}{\textbf{\songti\TitleA}} \\
          & \cover_underline:nn {250pt}{\textbf{\songti\TitleB}} \\
          & \cover_underline:nn {250pt}{\textbf{\songti\TitleC}} \\}
      }
  \end{tabular}\\

  \begin{tabular}{p{4.2em}cp{4.2em}c}
    \coverbox:n {\hfill}
    & \cover_underline:nn {90pt}{\Grade}
    & \coverbox:n {\hfill}
    & \cover_underline:nn {90pt}{\songti\StudentID}\\
  \end{tabular}\\
  
  \begin{tabular}{p{4.2em}c}
    \coverbox:n {\hfill\hfill\hfill}
    & \cover_underline:nn {250pt}{\StudentName}
  \end{tabular}\\
  \begin{tabular}{p{4.2em}cp{4.2em}c}
    \coverbox:n {\hfill}
    & \cover_underline:nn {90pt}{\Mentor}
    & \coverbox:n {\hfill}
    & \cover_underline:nn {90pt}{\MentorTitle}\\
  \end{tabular}\\
%   % 第二导师
%   \ifnjut@title@twosupervisors
%     \begin{tabular}{p{4.2em}cp{4.2em}c}
%       \coverbox:n {\njut@cap@cover@secondsupervisor}
%       & \njutunderline[90pt]{\songti\njut@value@secondsupervisor}
%       & \coverbox:n {\njut@cap@cover@secondsupervisortitle}
%       & \njutunderline[90pt]{\songti\njut@value@secondsupervisortitle}\\
%     \end{tabular}
%   \fi
  \begin{tabular}{p{4.2em}c}
    \coverbox:n {\hfill\hfill\hfill}
    & \cover_underline:nn {250pt}{\SubmitDate}\\
  \end{tabular}
}

% 判断类型
\str_if_eq:eeTF {\Degree} {UG}
{\tl_const:Nn \Degreename {\hfill\hfill }}{}

\str_if_eq:eeTF {\Type} {thesis} 
{\tl_const:Nn \typename {\Degreename\hfill\hfill\hfill}}
{\tl_const:Nn \typename {\Degreename\hfill\hfill\hfill}}

% 重定义maketitle生成封面
\RenewDocumentCommand \maketitle {} {%
  \thispagestyle{empty}
  \pagenumbering{Roman}
  % Start 
  \begin{spacing}{1.25}
  \vskip 0mm
  \hspace{-10mm}
  \includegraphics[height=3cm]{njulogo}\smallskip 
  \begin{center}
    \includegraphics[height=3.35cm]{njuname}
    \vskip 10mm 
    {\zihao{1}\makebox[9em][s]{\textbf{\songti\typename}}}
    \vfill
    \vskip\stretch{0}
    {\bgroup
    \kaishu\zihao{3}
    \def\tabcolsep{1pt}
    \def\arraystretch{1.5}
    \cover_personalinfo % 绘制信息框
    \egroup}
    \vfill
  \end{center}
  \end{spacing}
  \cleardoublepage
  \vfill
  % \newpage
}

profile/font.sty

deleted100644 → 0
+0 −184
Original line number Original line Diff line number Diff line
\ProvidesExplPackage{profile/font}{2021-09-04}{0.1}{NJU Thesis Undergraduate font configuration}

% \RequireXeTeX
% \RequireLuaTeX

% 设置西文字体
\NewDocumentCommand\set_latin_fontset_windows{}{
  \setmainfont{Times~New~Roman}
  \setsansfont{Arial}
  \setmonofont{Courier~New}[Scale=MatchLowercase]
}

\NewDocumentCommand\set_latin_fontset_macos{}{
  \setmainfont{Times~New~Roman}
  \setsansfont{Arial}
  \setmonofont{Menlo}[Scale=MatchLowercase]
}

\NewDocumentCommand\set_latin_fontset_gyre{}{
  \setmainfont{texgyretermes}[
    Extension=.otf,
    UprightFont=*-regular,
    BoldFont=*-bold,
    ItalicFont=*-italic,
    BoldItalicFont=*-bolditalic]
  \setsansfont{texgyreheros}[
    Extension=.otf,
    UprightFont=*-regular,
    BoldFont=*-bold,
    ItalicFont=*-italic,
    BoldItalicFont=*-bolditalic]
  \setmonofont{texgyrecursor}[
    Extension=.otf,
    UprightFont=*-regular,
    BoldFont=*-bold,
    ItalicFont=*-italic,
    BoldItalicFont=*-bolditalic,
    Scale=MatchLowercase,
    Ligatures=CommonOff]
}

% 设置中文字体
\NewDocumentCommand\set_chinese_fontset_windows{}{
  \setCJKmainfont{SimSun}[
    AutoFakeBold=2.17, 
    ItalicFont=KaiTi]
  \setCJKsansfont{SimHei}
  \setCJKmonofont{FangSong}
  \setCJKfamilyfont{zhsong}{SimSun}[AutoFakeBold=2.17]
  \setCJKfamilyfont{zhhei}{SimHei}
  \setCJKfamilyfont{zhfs}{FangSong}
  \setCJKfamilyfont{zhkai}{KaiTi}[AutoFakeBold=2.17]
  \setCJKfamilyfont{zhnewhei}{Microsoft~YaHei}[BoldFont=Microsoft~YaHei~Bold]
}

\NewDocumentCommand\set_chinese_fontset_macos{}{
  \msg_redirect_name:nnn {fontspec} {no-script} {info} % 移除 does not contain script "CJK" 警告
  \setCJKmainfont{Songti~SC~Light}[
    BoldFont=Songti~SC~Bold,
    ItalicFont=Kaiti~SC,
    BoldItalicFont=Kaiti~SC~Bold]
  \setCJKsansfont{Heiti~SC~Light}[BoldFont=Heiti~SC~Medium]
  \setCJKmonofont{STFangsong}
  \setCJKfamilyfont{zhsong}{Songti~SC~Light}[BoldFont=Songti~SC~Bold]
  \setCJKfamilyfont{zhhei}{Heiti~SC~Light}[BoldFont=Heiti~SC~Medium]
  \setCJKfamilyfont{zhfs}{STFangsong}
  \setCJKfamilyfont{zhkai}{Kaiti~SC}[BoldFont=Kaiti~SC~Bold]
  \setCJKfamilyfont{zhnewhei}{PingFang~SC}
}

\NewDocumentCommand\set_chinese_fontset_fandol{}{
  \msg_redirect_name:nnn {fontspec} {no-script} {info} % 移除 does not contain script "CJK" 警告
  \setCJKmainfont{FandolSong-Regular}[
    Extension=.otf,
    BoldFont=FandolSong-Bold,
    ItalicFont=FandolKai-Regular]
  \setCJKsansfont{FandolHei-Regular}[
    Extension=.otf,
    BoldFont=FandolHei-Bold]
  \setCJKmonofont{FandolFang-Regular}[Extension=.otf]
  \setCJKfamilyfont{zhsong}{FandolSong-Regular}[
    Extension=.otf,
    BoldFont=FandolSong-Bold]
  \setCJKfamilyfont{zhhei}{FandolHei-Regular}[
    Extension=.otf,
    BoldFont=FandolHei-Bold]
  \setCJKfamilyfont{zhfs}{FandolFang-Regular}[Extension=.otf]
  \setCJKfamilyfont{zhkai}{FandolKai-Regular}[
    Extension=.otf,
    AutoFakeBold=2.17]
}

% 方正字符集
\NewDocumentCommand\set_chinese_fontset_founder{}{
  \setCJKmainfont{FZSSK}[
    Extension=.ttf,
    BoldFont=FZXBSK,
    ItalicFont=FZKTK]
  \setCJKsansfont{FZXH1K}[
    Extension=.ttf,
    BoldFont=FZHTK]
  \setCJKmonofont{FZFSK}[Extension=.ttf]
  \setCJKfamilyfont{zhsong}{FZSSK}[
    Extension=.ttf,
    BoldFont=FZXBSK]
  \setCJKfamilyfont{zhhei}{FZHTK}[
    Extension=.ttf,
    AutoFakeBold=2.17]
  \setCJKfamilyfont{zhfs}{FZFSK}[Extension=.ttf]
  \setCJKfamilyfont{zhkai}{FZKTK}[Extension=.ttf]
  \setCJKfamilyfont{zhnewhei}{FZYouHK_508R}[
    Extension=.ttf,
    BoldFont=FZYouHK_511M]
}

\NewDocumentCommand\set_chinese_fontset_noto{}{
  % 思源宋体 https://www.google.com/get/noto/#serif-hans
  \setCJKmainfont[
    UprightFont=NotoSerifCJKsc-Regular,
    BoldFont=NotoSerifCJKsc-Bold,
    ItalicFont=NotoSerifCJKsc-Regular,
    BoldItalicFont=NotoSerifCJKsc-Bold,
    ItalicFeatures=FakeSlant,
    BoldItalicFeatures=FakeSlant]{Noto~Serif~CJK~SC}

  % 思源黑体 https://www.google.com/get/noto/#sans-hans
  \setCJKsansfont[
    UprightFont=NotoSansCJKsc-Regular,
    BoldFont=NotoSansCJKsc-Bold,
    ItalicFont=NotoSansCJKsc-Regular,
    BoldItalicFont=NotoSansCJKsc-Bold,
    ItalicFeatures=FakeSlant,
    BoldItalicFeatures=FakeSlant]{Noto~Sans~CJK~SC}

  % 包含于上述思源黑体
  \setCJKmonofont[
    UprightFont=NotoSansMonoCJKsc-Regular,
    BoldFont=NotoSansMonoCJKsc-Bold,
    ItalicFont=NotoSansMonoCJKsc-Regular,
    BoldItalicFont=NotoSansMonoCJKsc-Bold,
    ItalicFeatures=FakeSlant,
    BoldItalicFeatures=FakeSlant]{Noto~Sans~Mono~SC}

  \setCJKfamilyfont{zhsong}{Noto~Serif~CJK~SC}
  \setCJKfamilyfont{zhhei}{Noto~Sans~CJK~SC}

  % 方正楷体、方正仿宋为免费商用字体,且支持CJK字符集
  % 方正仿宋 http://www.foundertype.com/index.php/FontInfo/index/id/128.html
  % 方正楷体 http://www.foundertype.com/index.php/FontInfo/index/id/137.html
  \setCJKfamilyfont{zhfs}{方正仿宋简体}[AutoFakeBold=2.17]
  \setCJKfamilyfont{zhkai}{方正楷体简体}[AutoFakeBold=2.17]
}

% 检测是否是 Windows
\sys_if_platform_windows:TF
{
  \set_latin_fontset_windows
  \set_chinese_fontset_windows
}
{
  % 检测是否是 MacOS
  \ctex_if_platform_macos:TF
  {
    \set_latin_fontset_macos
    \set_chinese_fontset_macos
  }
  % 其余系统一律使用自由字体
  {
    \set_latin_fontset_gyre
    \set_chinese_fontset_fandol
  }
}

% 使用方正字体
% \set_chinese_fontset_founder

% 使用思源宋体+思源黑体
% \set_chinese_fontset_noto

\NewDocumentCommand\songti{}{\CJKfamily{zhsong}}
\NewDocumentCommand\heiti{}{\CJKfamily{zhhei}}
\NewDocumentCommand\fangsong{}{\CJKfamily{zhfs}}
\NewDocumentCommand\kaishu{}{\CJKfamily{zhkai}}
% \NewDocumentCommand\lishu{}{\CJKfamily{zhli}}

profile/packages.sty

deleted100644 → 0
+0 −51
Original line number Original line Diff line number Diff line
\ProvidesExplPackage{profile/packages}{2021-09-04}{0.1}{NJU Thesis Undergraduate packages used} 

\RequirePackage{expl3}
\RequirePackage{ifxetex}
\RequirePackage{fontspec}
\RequirePackage[    
    top=2.5cm,
    bottom=2.5cm,
    left=3.2cm,
    right=3.2cm
]{geometry}
\RequirePackage{ifthen}
\RequirePackage{xparse}
% \RequirePackage{etoolbox}
\RequirePackage{titlesec} % 修改章节标题功能由CTeX提供
\RequirePackage{titletoc}
\RequirePackage{appendix} % 定义附录样式
\RequirePackage{fancyhdr} % 调整页眉页脚
\RequirePackage[hyphens]{url} % generate better linebreaks in the url
\RequirePackage{ulem} % 绘制下划线
\RequirePackage{setspace}
\RequirePackage{lastpage}
\RequirePackage{emptypage} % 清除空白页的页码
\RequirePackage{listings} % 代码环境
\RequirePackage{enumitem} % 用于修改列表环境
\RequirePackage{caption}
\RequirePackage{floatrow} % 用于图表等页面元素的定位
\RequirePackage{booktabs} % 用于绘制三线表
\RequirePackage{siunitx} % 用于书写单位符号
\RequirePackage[version=4]{mhchem} % 用于绘制分子式
\RequirePackage{hologo} % 用于生成可以被插入书签的LaTeX logo
\RequirePackage{needspace} % Required to prevent page break right after a sectioning command
\RequirePackage{xspace} % Better print trailing whitespace
\RequirePackage{microtype}

\RequirePackage{blindtext} % 生成用于测试的大段无意义英文文字
\RequirePackage{zhlipsum} % 生成用于测试的大段无意义中文文字
% \RequirePackage{showframe} % 加载以后展示内容边界

\RequirePackage{amssymb} % Must be loaded before unicode-math
\RequirePackage{unicode-math} % Math fonts in xetexorluatex

\RequirePackage{graphicx}
\DeclareGraphicsExtensions{.pdf,.eps,.jpg,.png}
\graphicspath{{figure/}}
\RequirePackage{wrapfig} % Wrap text around figures

% 必须以该顺序加载以下三个包
% \RequirePackage{varioref}
\RequirePackage[hidelinks,bookmarksnumbered=true]{hyperref}
\RequirePackage[capitalise,nameinlink,noabbrev]{cleveref}

profile/page.sty

deleted100644 → 0
+0 −48
Original line number Original line Diff line number Diff line
\ProvidesExplPackage{profile/page}{2021-09-04}{0.1}{NJU Thesis Undergraduate page layout} 

% 论文页码 页脚居中、五号阿拉伯数字(新罗马体)连续编码
\fancypagestyle{njuplain}{%
   \fancyhead{}               
   \fancyfoot[C]{\zihao{5}\thepage}        
}
% the header line
\tl_set:Nn \headrulewidth {0pt}
% the footer line
\tl_set:Nn \footrulewidth {0pt}

\AtBeginDocument{\pagestyle{njuplain}} % 无页眉页脚

% ctex格式设置
% 目录标题 三号宋体加粗
% 各部分标题 四号黑体
\ctexset{
    contentsname = \songti\bfseries\zihao{3}\hspace{2em} 录,
    chapter/format = \zihao{4}\heiti\centering,
    section/format = \zihao{4}\heiti\raggedright,
    subsection/format = \zihao{4}\heiti\raggedright,
    subsubsection/format = \zihao{4}\heiti\raggedright
}

% 重定义目录中章节标题样式
% 目录内容中章的标题 四号黑体
% 目录中其他内容 小四号宋体
\titlecontents{chapter}% 标题级别
                [5em]% 标题左间距
                {\heiti\zihao{4}\vspace{10pt}}% 标题格式
                {\contentslabel{4em}}% 标题标志
                {\hspace*{-4em}}% 无序号标题
                {~\titlerule*[0.6pc]{$.$}~\contentspage}% 指引线与页码

\titlecontents{section}
                [5em]
                {\zihao{-4}\vspace{0pt}}
                {\contentslabel{2.5em}}
                {\hspace*{-4em}}
                {~\titlerule*[0.6pc]{$.$}~\contentspage}

\titlecontents{subsection}
                [8em]
                {\zihao{-4}\vspace{0pt}}
                {\contentslabel{3em}}
                {\hspace*{-4em}}
                {~\titlerule*[0.6pc]{$.$}~\contentspage}

profile/reference.sty

deleted100644 → 0
+0 −55
Original line number Original line Diff line number Diff line
\ProvidesExplPackage{profile/reference}{2021-09-04}{0.1}{NJU Thesis Undergraduate bibliography and reference} 

% biblatex设置
\RequirePackage[
    style=gb7714-2015,
    %style=numeric-comp,
    %citestyle=authortitle-icomp,
    % citestyle=numeric-comp,
    %bibstyle=authoryear,
    % bibstyle=numeric,
    sorting=none,
    %sorting=nyt,
    %sortcites=true,
    %autocite=footnote,
    backend=biber, % Compile the bibliography with biber
    hyperref=true,
    backref=false,
    citecounter=true,
    pagetracker=true,
    citetracker=true,
    ibidtracker=context,
    autopunct=true,
    autocite=plain,
    % gbpub=false,         % Uncomment if you do NOT want '[S.l. : s.n.]' in reference entries, GitHub Issue (#47)
    % gbnamefmt=lowercase, % Uncomment if you do NOT want uppercase author names in reference entries, GitHub Issue (#23)
]{biblatex}

% Remove some unwanted entries from the bibliography
\AtEveryBibitem{
	\clearfield{abstract}
	\clearfield{issn}
	\clearfield{isbn}
	\clearfield{archivePrefix}
	\clearfield{arxivId}
	\clearfield{pmid}
	\clearfield{eprint}
	\ifentrytype{online}{}{\ifentrytype{misc}{}{\clearfield{url}}}
	% \ifentrytype{book}{\clearfield{doi}}{}
}

% 修改标签名称
\crefdefaultlabelformat{#2#1#3~} % 默认在名称后面添加空格
\creflabelformat{equation}{#2#1#3~} % 删除公式编号的空格

\crefname{theorem}{定理}{定理}
\crefname{lemma}{引理}{引理}
\crefname{definition}{定义}{定义}
\crefname{figure}{}{}
\crefname{table}{}{}
\crefname{equation}{公式}{公式}

\crefname{chapter}{§}{§}
\crefname{section}{§}{§}
\crefname{subsection}{§}{§}
\crefname{subsubsection}{§}{§}
 No newline at end of file

scripts/download.sh

0 → 100644
+18 −0
Original line number Original line Diff line number Diff line
# 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/

scripts/file_parser.py

0 → 100644
+196 −0
Original line number Original line Diff line number Diff line
# 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()
+9 −0
Original line number Original line Diff line number Diff line
@ECHO OFF

pdflatex --shell-escape generate-img
DEL "generate-img.pdf"
DEL "*.aux"
DEL "*.auxlock"
DEL "*.dpth"
DEL "*.log"
DEL "*.md5"
+9 −0
Original line number Original line Diff line number Diff line
#!/usr/bin/env sh

pdflatex --shell-escape generate-img
rm generate-img.pdf
rm *.aux
rm *.auxlock
rm *.dpth
rm *.log
rm *.md5
+16 −0
Original line number Original line Diff line number Diff line
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 本文件用于生成校徽和校名图片
% 编译命令为 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}

scripts/main.py

0 → 100644
+186 −0
Original line number Original line Diff line number Diff line
# 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()

source/latexmkrc

0 → 100644
+28 −0
Original line number Original line Diff line number Diff line
# Latexmk configuration file for njuthesis documentation.
# vim: set ft=perl:

# Use XeLaTeX to compile.
$pdf_mode = 5;
$xelatex = "xelatex -shell-escape -file-line-error -halt-on-error -interaction=nonstopmode -no-pdf -synctex=1 %O %S";
$xdvipdfmx = "xdvipdfmx -q -E -o %D %O %S";

$bibtex_use = 1.5;

# Clean auxiliary files .
$clean_ext = "hd loe ptc run.xml synctex.gz thm xdv";

# Process index.
$makeindex = "makeindex %O -s gind.ist -o %D %S";
add_cus_dep('glo','gls',0,'makeindex');
sub makeindex {
  if ( $silent ) {
    system( "makeindex -q -s gglo.ist -o \"$_[0].gls\" \"$_[0].glo\"" );
  }
  else {
    system( "makeindex -s gglo.ist -o \"$_[0].gls\" \"$_[0].glo\"" );
  };
}
$makeindex_silent_switch = "-q";

# Show CPU time used.
$show_time = 1;

source/njuthesis.dtx

0 → 100644
+9426 −0

File added.

Preview size limit exceeded, changes collapsed.

+11 −0
Original line number Original line Diff line number Diff line
\njuchapter{攻读博士学位期间研究成果及参与项目情况}

\njupaperlist[攻读博士学位期间发表的学术论文]{Nemec1997-209-214,Chiani1998-2998-3008,Chiani1998a}

\section*{攻读博士学位期间参与的科研课题}

\begin{enumerate}[label=\arabic*., labelindent=0em, leftmargin=*]
    \item 2020.1-2023.12, 国家自然科学基金, 12345678, 这是项目名称, 负责人: 老板1, 60 万.
    \item 2020.1-2022.12, 国家自然科学基金, 23456789, 这是项目名称, 负责人: 老板2, 25 万.
    \item 2020.1-2023.12, 国家自然科学基金, 34567890, 这是项目名称, 负责人: 老板3, 66 万.
\end{enumerate}
+13 −0
Original line number Original line Diff line number Diff line
\chapter{引用参考文献}
\label{chap:bibliography}

\section{引用命令}

顺序编码制的 \cite{qiujinhengetal2010,njuthesis,riedl2009quasi}(上标可设置页码)、\parencite{qiujinhengetal2010}(非上标可设置页码)、\pagescite{qiujinhengetal2010}(上
标加自动页码)、\textcite{qiujinhengetal2010}(提供作者为主语加非上标编号)、\authornumcite{qiujinhengetal2010}(提供作
者为主语加上标编号)、\footfullcite{qiujinhengetal2010}(脚注方式)

著者-年份制的\cite{qiujinhengetal2010,njuthesis,riedl2009quasi}(作者加年份用
括号包围可设置页码)、\pagescite{qiujinhengetal2010}(作者加年份用括号包围自动页码)、\yearcite{qiujinhengetal2010}(提供
年份用括号包围)、\yearpagescite{qiujinhengetal2010}(提供年份用括号包围自动页码)、\textcite{qiujinhengetal2010}(提供主
语作者加括号包围年份)、\footfullcite{qiujinhengetal2010}(脚注方式)。
+83 −0
Original line number Original line Diff line number Diff line
\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}
+63 −0
Original line number Original line Diff line number Diff line
\chapter{数学公式与定理}

\section{符号示例}

Caligraphic letters: $\mathcal{A}$

Mathbb letters: $\mathbb{A}$

Mathfrak letters: $\mathfrak{A}$

Math Sans serif letters: $\mathsf{A}$

Math bold letters: $\mathbf{A},\symbf{A}$

Math bold italic letters: $\mathbi{A}$

\section{公式示例}

% Thanks to github.com/YuanshengZhao/Garamond-Math
公式字体示例
\[
    \displaystyle \ointctrclockwise\mathcal{D}[x(t)]\sqrt{\frac{\displaystyle3\uppi^2-\sum_{q=0}^{\infty}(z+\hat L)^{q}\exp(\symrm{i}q^2 \hbar x)}{\displaystyle (\symsfup{Tr}\symbfcal{A})\left(\symbf\Lambda_{j_1j_2}^{i_1i_2}\Gamma_{i_1i_2}^{j_1j_2}\hookrightarrow\vec D\cdot \symbf P  \right)}}
    =\underbrace{\widetilde{\left\langle \frac{\notin \emptyset}{\varpi\alpha_{k\uparrow}}\middle\vert \frac{\partial_\mu T_{\mu\nu}}{2}\right\rangle}}_{\mathrm{K}_3\mathrm{Fe}(\mathrm{CN})_6} ,\forall z \in \mathbb{R}
\]

你可以使用\verb|equation|环境插入公式,如\cref{eq:dewitt}

\begin{equation}\label{eq:dewitt}
    \int \mathrm{e}^{ax} \tanh {bx} \, \mathrm{d}x =
    \begin{dcases}
        \begin{multlined}
            \frac{\mathrm{e}^{(a+2b)x}}{(a + 2b)} \,
            {{}_2F_1} \left( 1 + \frac{a}{2b}, 1, 2+\frac{a}{2b}, -\mathrm{e}^{2bx} \right) \\
            - \frac{1}{a} \mathrm{e}^{ax} \, {{}_2F_1} \left( 1, \frac{a}{2b}, 1 + \frac{a}{2b}, -\mathrm{e}^{2bx} \right)
        \end{multlined}
        & a \ne b \\
    \frac{e^{ax} - 2 \tan^{-1}(\mathrm{e}^{ax})}{a} & a = b
  \end{dcases}
\end{equation}

\section{定理环境}

\cref{pf:me1}\cref{pf:me1}\cref{def:others1}\cref{def:others1}\cref{thm:sleep}

\begin{proof}\label{pf:me1}
    证明我是我
\end{proof}

\begin{definition}[他人]\label{def:others1}
    定义他人即地狱
\end{definition}

\begin{proof}\label{pf:me2}
    证明我是我
\end{proof}

\begin{definition}[他人]\label{def:others2}
    定义他人即地狱
\end{definition}

\begin{theorem}[睡觉]\label{thm:sleep}
    管他呢先睡觉吧!
\end{theorem}
+104 −0
Original line number Original line Diff line number Diff line
\chapter[本科毕业论文格式规定]{南京大学本科毕业论文(设计)的撰写规范和装订要求(试行)}
\label{chap:standard}

本科毕业论文(设计)是本科教学中的重要环节,为规范本科毕业论文(设计)的工作,特制订毕业论文(设计)的撰写和装订要求,请同学们按照要求执行。如各院系已经制定了相应的规范,则按照院系的要求执行。

\section{毕业论文(设计)的撰写内容要求}
\subsection{论文题目}
论文题目应以简短、明确的词语恰当概括论文的核心内容,避免使用不常见的缩略词、缩写字。中文题目一般不宜超过40个字(含标点符号);外文题目一般不宜超过12个实词,最多不得超过180个字符(含标点符号)。
\subsection{摘要和关键词}
\subsubsection{中文摘要和中文关键词}
摘要内容应概括地反映出本论文的主要内容,主要说明本论文的研究目的、内容、方法、成果和结论。语言力求精练、准确,以300—600字为宜。

关键词是供检索用的主题词条。摘要与关键词应在同一页。关键词一般3—5个。

\subsubsection{英文摘要和英文关键词}
英文摘要和关键词内容与中文摘要和关键词相一致,其中英文摘要以约300个实词为宜。

\subsection{目录}
论文目录是论文的提纲,也是论文各章节组成部分的小标题。要求标题层次清晰,目录中的标题要与正文中的标题一致。

\subsection{主体}
主体部分一般从引言(绪论)开始,以结论或讨论结束,其中引言(绪论)应包括论文的研究目的、流程和方法等,论文研究领域的历史回顾,文献回溯,理论分析等内容,应独立成章,用足够的文字叙述;主体部分应从另页右页开始,每一章应另起页。

主体部分由于涉及的学科、选题、研究方法、结果表达方式等有很大的差异,不能作统一的规定。但是,必须实事求是,客观真切、准备完备、合乎逻辑、层次分明、简练可读。

\subsection{参考文献}
参考文献表是文中引用的有具体文字来源的文献集合,应置于正文后并另起页;所有被引用文献均要列入参考文献表中;引文采用著作-出版年制标注时,参考文献表应按著者字顺和出版年排序;

\subsection{相关的科研成果目录}
包括本科期间发表的与毕业论文(设计)相关的已发表论文或被鉴定的技术成果、发明专利等成果,应在成果目录中列出。此项非必需项。

\subsection{致谢}
谢辞应以简短的文字对课题研究与论文撰写过程中曾直接给予帮助的人员(例如指导教师、答疑教师及其他人员)表示自己的谢意,这不仅是一种礼貌,也是对他人劳动的尊重,是治学者应当遵循的学术规范。内容限一页。

\subsection{附录}
如果有不宜放在正文中的重要支撑材料,可编入毕业论文(设计)的附录中。包括某些重要的原始数据、详细数学推导、程序全文及其说明、复杂的图表、设计图纸等一系列需要补充提供的说明材料。附录的篇幅不宜太多,一般不超过正文。

\section{毕业论文(设计)的撰写规范要求}
\subsection{语言}
外语类专业的毕业论文(设计)应使用所学语种撰写,其他专业一般应使用中文撰写,具体按准出院系规定执行。非外语类专业如需用英文撰写,应于论文开题前由学生向准出院系提出申请,经院系批准后再进行撰写。以非中文完成的毕业论文(设计),应附上不少于2500字的中文详细摘要,作为该毕业论文(设计)的组成部分接受学术规范、答辩等所有审查评估。参加校级、省级本科生毕业论文(设计)评优的论文,如用英文撰写,必须同时提供中文版全文翻译(外语类专业除外)。

\subsection{字数}
除有特殊要求的专业外,毕业论文(设计)一般不少于15000字或相当信息量(包括图表)。如果院系有其他规定,按院系规定为准。

\subsection{字体和字号}
\begin{description}
    \item[论文题目] 三号宋体加粗
    \item[各部分标题] 四号黑体
    \item[中文摘要、关键词内容] 小四号楷体
    \item[英文摘要、关键词内容] 小四号新罗马体(Time New Roman)
    \item[目录标题] 三号宋体加粗
    \item[目录内容中章的标题] 四号黑体
    \item[目录中其他内容] 小四号宋体
    \item[正文] 小四号宋体(行距1.5倍)
    \item[参考文献标题] 四号黑体
    \item[参考文献内容] 小四号宋体
    \item[注释内容] 五号宋体
    \item[致谢、附录标题] 四号黑体
    \item[致谢、附录内容] 小四号宋体(行距1.5倍)
    \item[非正文部分的页码] 五号罗马数字(Ⅰ、Ⅱ……)
    \item[论文页码] 页脚居中、五号阿拉伯数字(新罗马体)连续编码
\end{description}

\subsection{关键词}
每个关键词之间用“;”分开,最后一个关键词不打标点符号。

\subsection{目录}
目录应另起一页,包括论文中的各级标题,按照“一……”、“(一)……”或“1……”、“1.1……”格式编写。

\subsection{各级标题}
正文各部分的标题应简明扼要,不使用标点符号。论文内文各大部分的标题用“一、二……(或1、2……)”,次级标题为“(一)、(二)……(或1.1、2.1……)”,三级标题用“1、2……(或1.1.1、2.1.1……)”,四级标题用“(1)、(2)……(或1.1.1.1、2.1.1.1……)”。不再使用五级以下标题。

\subsection{名词术语}
1、科学技术名词术语尽量采用全国自然科学名词审定委员会公布的规范词或国家标准中规定的名称,尚未统一规定或叫法有争议的名词术语,可采用惯用的名称。
2、特定含义的名词术语或新名词、以及使用外文缩写代替某一名词术语时,首次出现时应在括号内注明其含义。
3、外国人名一般采用英文原名,可不译成中文,英文人名按姓前名后的原则书写。一般很熟知的外国人名(如牛顿、爱因斯坦、达尔文、马克思等)可按通常标准译法写译名。

\subsection{图表的绘制}
表的题目在表的上方,图的题目在图的下方。图表的题目及内容的字体采用五号宋体。表中内容采用单倍行距。
图表的题目要简洁、加粗。图表的位置和题目皆要居中,与上下正文内容空一行。如果文中图表较多,建议采用章节+次序的办法编写,如第一章的第三个表为“表1-3”,第四章的第二个图为“图4-2”。通常表和图按各自顺序分开编号。

\subsection{注释}
毕业论文(设计)中有个别名词或情况需要解释时,可加注说明。注释采用脚注,每页独立编号,即每页都从1开始编码,编号用1,2,3……,文中编号用上标。

\subsection{参考文献}
参考文献的著录应符合国家标准,参考文献的序号左顶格,并用数字加方括号表示,如“[1]”。每一条参考文献著录均以“.”结束。

\section{毕业论文(设计)装订要求}
论文在打印和印刷时,要求本科毕业论文封面使用浅绿色皮纹纸;本科毕业设计封面使用天蓝色皮纹纸;纸张的四周应留足空白边缘,以便于装订、复印和读者批注。每一面的上方(天头)和左侧(订口)应分别留边25mm以上间隙,下方(地角)和右侧(切口)应分别留边20mm以上间隙。所有在南大毕设系统填报的毕业论文过程记录(含开题报告、中期检查等)均可从系统导出打印,除需装订的内容其余在系统内做电子存档。
毕业论文(设计)应线装或胶装,并应按以下顺序装订:
\begin{enumerate}
    \item 封面
    \item 南京大学本科毕业设计(论文)诚信承诺书
    \item 本科毕业论文(设计)指导教师和评阅教师意见(注意填写的日期应在答辩前)
    \item 本科毕业论文(设计)答辩记录、成绩评定
    \item 中文摘要纸
    \item 英文摘要纸
    \item 目录
    \item 正文
    \item 参考文献
    \item 相关的科研成果目录(非必需项)
    \item 致谢
    \item 附录(非必需项)
\end{enumerate}

test/test-luatex.tex

0 → 100644
+4 −0
Original line number Original line Diff line number Diff line
\def\TEST{}
\documentclass{njuthesis}
\njusetup{bib/style=author-year}
\input{test.tex}
+3 −0
Original line number Original line Diff line number Diff line
\def\TEST{}
\documentclass[type=doctor,nl-cover]{njuthesis}
\input{test.tex}
+3 −0
Original line number Original line Diff line number Diff line
\def\TEST{}
\documentclass[type=master,decl-page]{njuthesis}
\input{test.tex}
+3 −0
Original line number Original line Diff line number Diff line
\def\TEST{}
\documentclass[decl-page,oneside]{njuthesis}
\input{test.tex}

test/test.bib

0 → 100644
+67 −0

File added.

Preview size limit exceeded, changes collapsed.

test/test.tex

0 → 100644
+274 −0

File added.

Preview size limit exceeded, changes collapsed.