Skip to content

Commit ef44e11

Browse files
committed
update: documentation
1 parent 253d4b8 commit ef44e11

File tree

7 files changed

+152
-96
lines changed

7 files changed

+152
-96
lines changed

.github/workflows/ctan-package.yml

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ jobs:
125125
cat > ctan/tongjithesis/tongjithesis.dtx << EOF
126126
% \iffalse meta-comment
127127
%
128-
% Copyright (C) 2023-$CURRENT_YEAR TJ-CSCCG
128+
% Copyright (C) 2022-$CURRENT_YEAR TJ-CSCCG
129129
%
130130
% This file may be distributed and/or modified under the
131131
% conditions of the LaTeX Project Public License, either version 1.3
@@ -270,7 +270,12 @@ jobs:
270270
% \begin{description}
271271
% \item[oneside] Formats the document for one-sided printing (default).
272272
% \item[twoside] Formats the document for two-sided printing.
273-
% \item[draft] Enables draft mode.
273+
% \item[fullwidthstop=true|false] Controls whether Chinese full-width period (。) is replaced with
274+
% Western-style period (.). Default is \texttt{false}.
275+
% \item[times=true|false] Controls whether to use Times New Roman font. Default is \texttt{false}.
276+
% \item[minted=true|false] Controls whether to use the minted package for code highlighting.
277+
% Default is \texttt{true}.
278+
% \item[fontset=name] Sets the font set to use. Default is \texttt{fandol}.
274279
% \end{description}
275280
%
276281
% \subsection{Thesis Information Commands}
@@ -464,7 +469,13 @@ jobs:
464469
%!TEX program = xelatex
465470
%!TEX encoding = UTF-8
466471
467-
\documentclass[oneside]{tongjithesis}
472+
\documentclass[
473+
oneside,
474+
fullwidthstop=false,
475+
fontset=fandol,
476+
times=false,
477+
minted=true,
478+
]{tongjithesis}
468479
469480
% Set thesis information
470481
\school{计算机科学与技术学院}
@@ -519,6 +530,34 @@ jobs:
519530
交通标志识别是自动驾驶系统的重要组成部分,它能够帮助车辆理解道路环境,遵守交通规则。
520531
准确、实时的交通标志识别对于提高自动驾驶安全性具有重要意义。
521532
533+
% 代码示例(使用 minted 或 listings,取决于 minted 选项)
534+
\begin{listing}
535+
\begin{minted}{python}
536+
import torch
537+
import torch.nn as nn
538+
539+
class CNN(nn.Module):
540+
def __init__(self, num_classes=43):
541+
super(CNN, self).__init__()
542+
self.conv1 = nn.Conv2d(3, 32, kernel_size=3, padding=1)
543+
self.relu = nn.ReLU()
544+
self.pool = nn.MaxPool2d(kernel_size=2, stride=2)
545+
self.fc = nn.Linear(32 * 16 * 16, num_classes)
546+
547+
def forward(self, x):
548+
x = self.pool(self.relu(self.conv1(x)))
549+
x = x.view(x.size(0), -1)
550+
x = self.fc(x)
551+
return x
552+
553+
# 创建模型实例
554+
model = CNN()
555+
print(model)
556+
\end{minted}
557+
\caption{用于交通标志识别的简化卷积神经网络模型}
558+
\label{listing:cnn}
559+
\end{listing}
560+
522561
% ... More sections would go here ...
523562
524563
\section{结论}

README-EN.md

Lines changed: 57 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -50,22 +50,64 @@ The project is configured with GitHub Actions in `.github/workflows/*.yaml`. Pus
5050

5151
We recommend installing TeX Live (Windows, Linux) or MacTeX (macOS) following the [official quick install guide](https://tug.org/texlive/quickinstall.html).
5252

53-
#### Supporting Code Highlighting
53+
#### Document Class Options
5454

55-
This template supports code highlighting by incorporating the `minted` package. The `minted` package requires Python support, so you need to install Python and use `pip` to install `Pygments`. Afterwards, add the Python path with `Pygments` installed to the environment variable `PATH`, or configure as follows to ensure $\LaTeX$ can correctly invoke the `minted` package.
55+
This template provides the following document class options, which can be configured in `main.tex`:
5656

57-
<details><summary>Don't want to add this Python path to the environment variable `PATH`?</summary>
57+
```latex
58+
\documentclass[
59+
oneside, % One-sided printing (default), use twoside for double-sided printing
60+
fullwidthstop=false, % Whether to replace Chinese period "。" with Western-style period ".", default is false
61+
fontset=fandol, % Font set to use, default is fandol
62+
times=false, % Whether to use Times New Roman font, default is false
63+
minted=true, % Whether to use the minted package for code highlighting, default is true
64+
]{tongjithesis}
65+
```
66+
67+
##### Single/Double-Sided Printing Options
68+
69+
- `oneside`: Single-sided printing (default)
70+
- `twoside`: Double-sided printing, adjusts page margins and binding line
71+
72+
##### Font Options
73+
74+
- `fontset=fandol`: Use Fandol font set (default)
75+
- `fontset=adobe`: Use Adobe font set (requires Adobe fonts installation)
76+
- `times=false`: Use default math font (default)
77+
- `times=true`: Use Times New Roman font
78+
79+
##### Chinese Punctuation Options
80+
81+
- `fullwidthstop=false`: Keep Chinese period "。" unchanged (default)
82+
- `fullwidthstop=true`: Replace Chinese period "。" with Western-style period "."
5883

59-
You can add a redirect to the Python path of the `minted` package in the `main.tex` file:
84+
##### Code Highlighting Options
85+
86+
This template provides two code highlighting solutions:
87+
88+
1. **`minted` package** (Python-based): Provides advanced syntax highlighting features, requires Python environment.
89+
- Enable by setting `minted=true` (default) in `main.tex`
90+
- Requires installation of Python and Pygments library (`pip install pygments`)
91+
- You need to add Python to the system `PATH` environment variable,
92+
- or specify the Python path in `main.tex` (see below)
93+
- Requires `-shell-escape` parameter during compilation (this template has added)
94+
95+
2. **`listings` package** (pure LaTeX): Does not depend on external programs, can be used in any environment.
96+
- Enable by setting `minted=false` in `main.tex`
97+
- No additional program installation required
98+
99+
If you do not want to install Python or encounter `minted`-related errors, you can change `minted=true` to `minted=false` in `main.tex`. When using `minted=false`, the template will automatically use the `listings` package to process all code, without requiring additional configuration.
100+
101+
<details><summary>Using `minted` but don't want to add Python to the `PATH` environment variable?</summary>
102+
103+
You can add a redirection to the Python path of the `minted` package in the `main.tex` file:
60104

61105
```latex
62106
\renewcommand{\MintedPython}{/path/to/your/python}
63107
```
64108

65109
</details>
66110

67-
If you do not need code highlighting, please comment out the related content in the `minted` package.
68-
69111
#### Building the Project
70112

71113
Due to the complex file structure of this template, we do not recommend using commands like `latexmk` that come with TeX Live for compilation.
@@ -118,34 +160,16 @@ For detailed usage, see [tongji-undergrad-thesis-env](https://github.com/TJ-CSCC
118160

119161
### Other Features
120162

121-
#### Double-Sided Printing
122-
123-
If you need to use double-sided printing, simply change the first line in `main.tex` from
124-
125-
```latex
126-
\documentclass[oneside]{tongjithesis}
127-
```
128-
129-
to
130-
131-
```latex
132-
\documentclass[twoside]{tongjithesis}
133-
```
134-
135-
to enable it.
136-
137163
#### Rendering Rare Characters
138164

139-
Due to the default use of the Fandol font in this template, support for rare characters such as names and specific terms might not be adequate. We provide the Adobe font set in the [`fonts`](https://github.com/TJ-CSCCG/tongji-undergrad-thesis/tree/fonts) branch of our GitHub repository. You can download and install these fonts, and then change the line in `style/tongjithesis.cls` from
140-
141-
```latex
142-
\LoadClass[UTF8,a4paper,fontset=fandol]{ctexart}
143-
```
144-
145-
to
165+
Due to the default use of the Fandol font in this template, support for rare characters such as names and specific terms might not be adequate. We provide the Adobe font set in the [`fonts`](https://github.com/TJ-CSCCG/tongji-undergrad-thesis/tree/fonts) branch of our GitHub repository. You can download and install these fonts, and then use the `fontset=adobe` option in `main.tex` to use the Adobe font set:
146166

147167
```latex
148-
\LoadClass[UTF8,a4paper,fontset=adobe]{ctexart}
168+
\documentclass[
169+
oneside,
170+
fontset=adobe,
171+
% other options...
172+
]{tongjithesis}
149173
```
150174

151175
This modification will switch the rendering in the document to use the Adobe font set, enhancing support for rare characters.
@@ -165,7 +189,7 @@ This project uses the [LPPL-1.3c license](https://www.latex-project.org/lppl/lpp
165189

166190
```text
167191
%% tongji-undergrad-thesis
168-
%% Copyright 2023 TJ-CSCCG
192+
%% Copyright 2022-2025 TJ-CSCCG
169193
%
170194
% This work may be distributed and/or modified under the
171195
% conditions of the LaTeX Project Public License, either version 1.3
@@ -189,6 +213,7 @@ This project uses the [LPPL-1.3c license](https://www.latex-project.org/lppl/lpp
189213
- Starting May 9, 2021, [ganler](https://github.com/ganler) enhanced the functionalities (project structure and platform compatibility) based on the original project and began maintaining it.
190214
- As of May 12, 2022, [skyleaworlder](https://github.com/skyleaworlder) started contributing to the project, integrated it into [TJ-CSCCG](http://github.com/TJ-CSCCG), and has continued to update and improve it. It has now become a comprehensive undergraduate thesis template.
191215
- From April 2023, [RizhongLin](https://github.com/RizhongLin) began contributing to and managing the project.
216+
- April 2025 update, implemented key-value based class options, supporting more flexible configuration.
192217

193218
We deeply appreciate the efforts of these contributors, whose work has facilitated and assisted many students.
194219

@@ -209,5 +234,5 @@ We have learned a lot from excellent open-source projects from top universities:
209234
f'jiawei#@$.edu'.replace('#', '6').replace('$', 'illinois'),
210235
f'jgli22@$.edu.cn'.replace('$', 'm.fudan'),
211236
f'rizhong.lin@$.%'.replace('$', 'epfl').replace('%', 'ch'),
212-
]
237+
][-1]
213238
```

README.md

Lines changed: 47 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
> [!NOTE]
88
> 完整样例可见 [模板输出样例展示(完整版)](https://github.com/TJ-CSCCG/tongji-undergrad-thesis/discussions/21)[Release 页](https://github.com/TJ-CSCCG/tongji-undergrad-thesis/releases) 中 "Assets" 下的 pdf 下载链接或 [Overleaf 模版 PDF](https://www.overleaf.com/latex/templates/tongji-university-undergraduate-thesis-template/tfvdvyggqybn.pdf)
99
10-
以下依次展示 “封面”、“中文摘要”、“目录”、“主要内容”、“参考文献“谢辞”
10+
以下依次展示 "封面"、"中文摘要"、"目录"、"主要内容"、"参考文献""谢辞"
1111

1212
<p align="center">
1313
<img src="https://media.githubusercontent.com/media/TJ-CSCCG/TJCS-Images/tongji-undergrad-thesis/preview/main_page-0001.jpg" width="30%">
@@ -50,44 +50,53 @@
5050

5151
我们建议参照[官方快速安装指南](https://tug.org/texlive/quickinstall.html)安装 TeX Live(Windows、Linux)或 MacTeX(macOS)。
5252

53-
#### 代码高亮选项
53+
#### 文档类选项
54+
55+
本模板提供以下文档类选项,可以在 `main.tex` 中进行配置:
56+
57+
```latex
58+
\documentclass[
59+
oneside, % 单面打印(默认),使用 twoside 可启用双面打印
60+
fullwidthstop=false, % 是否将中文句号"。"替换为西文句号".",默认为false
61+
fontset=fandol, % 使用的字体集,默认为 fandol
62+
times=false, % 是否使用 Times New Roman 字体,默认为 false
63+
minted=true, % 是否使用 minted 包进行代码高亮,默认为 true
64+
]{tongjithesis}
65+
```
66+
67+
##### 单双面打印选项
68+
69+
- `oneside`:单面打印(默认)
70+
- `twoside`:双面打印,会调整页边距和装订线
71+
72+
##### 字体选项
73+
74+
- `fontset=fandol`:使用 Fandol 字体集(默认)
75+
- `fontset=adobe`:使用 Adobe 字体集(需要安装 Adobe 字体)
76+
- `times=false`:使用 `newtx` 包提供的字体(默认)
77+
- `times=true`:使用 Times New Roman 字体
78+
79+
##### 中文标点选项
80+
81+
- `fullwidthstop=false`:保持中文句号"。"不变(默认)
82+
- `fullwidthstop=true`:将中文句号"。"替换为西文句号"."
83+
84+
##### 代码高亮选项
5485

5586
本模板提供两种代码高亮解决方案:
5687

5788
1. **`minted`**(基于 Python):提供高级的语法高亮功能,需要 Python 环境。
5889
- 通过在 `main.tex` 中设置 `minted=true`(默认)启用
5990
- 需要安装 Python 及 Pygments 库(`pip install pygments`
60-
- 编译时需添加 `-shell-escape` 参数
91+
- 需要将 Python 添加到系统环境变量 `PATH` 中,
92+
- 或者在 `main.tex` 中指定 Python 路径(见下文)
93+
- 编译时需添加 `-shell-escape` 参数(本模板已添加)
6194

6295
2. **`listings`**(纯 LaTeX):不依赖外部程序,在任何环境都能使用。
6396
- 通过在 `main.tex` 中设置 `minted=false` 启用
6497
- 无需额外安装任何程序
6598

66-
如果您不希望安装 Python 或遇到 `minted` 相关错误,可以在 `main.tex` 中将:
67-
68-
```latex
69-
\documentclass[
70-
oneside,
71-
% fullwidthstop=true,
72-
fontset=fandol,
73-
% times=true,
74-
minted=true,
75-
]{tongjithesis}
76-
```
77-
78-
修改为:
79-
80-
```latex
81-
\documentclass[
82-
oneside,
83-
% fullwidthstop=true,
84-
fontset=fandol,
85-
% times=true,
86-
minted=false,
87-
]{tongjithesis}
88-
```
89-
90-
使用 `minted=false` 时,模板将自动使用 `listings` 包处理所有代码,无需其他配置。
99+
如果您不希望安装 Python 或遇到 `minted` 相关错误,可以在 `main.tex` 中将 `minted=true` 修改为 `minted=false`。使用 `minted=false` 时,模板将自动使用 `listings` 包处理所有代码,无需其他配置。
91100

92101
<details><summary>使用 `minted` 但不想将 Python 添加到环境变量 `PATH` 中?</summary>
93102

@@ -151,37 +160,19 @@ make wordcount # wordcount
151160

152161
### 其他功能
153162

154-
#### 双面打印版
155-
156-
如果您需要使用双面打印版,请在 `main.tex` 中将第 1 行的
157-
158-
```latex
159-
\documentclass[oneside]{tongjithesis}
160-
```
161-
162-
修改为
163-
164-
```latex
165-
\documentclass[twoside]{tongjithesis}
166-
```
167-
168-
即可。
169-
170163
#### 渲染生僻字
171164

172-
由于本模版默认使用 Fandol 字体,对于姓名、专有名词等生僻字的支持可能不够完善。我们在本模版 GitHub 仓库的 [`fonts`](https://github.com/TJ-CSCCG/tongji-undergrad-thesis/tree/fonts) 分支中提供了 Adobe 字体集,您可以下载、安装这些字体,然后在 `style/tongjithesis.cls` 中将
165+
由于本模版默认使用 Fandol 字体,对于姓名、专有名词等生僻字的支持可能不够完善。我们在本模版 GitHub 仓库的 [`fonts`](https://github.com/TJ-CSCCG/tongji-undergrad-thesis/tree/fonts) 分支中提供了 Adobe 字体集,您可以下载、安装这些字体,然后在 `main.tex` 中通过 `fontset=adobe` 选项来使用 Adobe 字体集:
173166

174167
```latex
175-
\LoadClass[UTF8,a4paper,fontset=fandol]{ctexart}
176-
```
177-
178-
修改为
179-
180-
```latex
181-
\LoadClass[UTF8,a4paper,fontset=adobe]{ctexart}
168+
\documentclass[
169+
oneside,
170+
fontset=adobe,
171+
% 其他选项...
172+
]{tongjithesis}
182173
```
183174

184-
这样修改后,LaTeX 将使用 Adobe 字体集来渲染文档。您可以在模板文档的 1.2.1 小节 测试生僻字 中查看具体效果。
175+
这样修改后,LaTeX 将使用 Adobe 字体集来渲染文档。您可以在模板文档的 1.2.1 小节 "测试生僻字" 中查看具体效果。
185176

186177
> [!WARNING]
187178
> 将 Adobe 字体文件放置在项目根目录下并在 `main.tex` 中指定字体路径的方式并不总是有效。因此,我们建议您将 Adobe 字体文件安装到系统字体目录中。
@@ -198,7 +189,7 @@ make wordcount # wordcount
198189

199190
```text
200191
%% tongji-undergrad-thesis
201-
%% Copyright 2023 TJ-CSCCG
192+
%% Copyright 2022-2025 TJ-CSCCG
202193
%
203194
% This work may be distributed and/or modified under the
204195
% conditions of the LaTeX Project Public License, either version 1.3
@@ -222,6 +213,7 @@ make wordcount # wordcount
222213
- 2021.05.09 起,[ganler](https://github.com/ganler) 以上述项目为基础,增强其功能(项目结构与平台适配)并开始维护新项目。
223214
- 2022.05.12 起,[skyleaworlder](https://github.com/skyleaworlder) 开始贡献本项目,并将其整合进 [TJ-CSCCG](http://github.com/TJ-CSCCG),并持续对该项目进行更新和改进,目前已经成为一个完善的本科毕业论文模板。
224215
- 2023.04 起,[RizhongLin](https://github.com/RizhongLin) 开始贡献本项目,并负责项目的维护和更新。
216+
- 2025.04 更新,实现基于键值对的类选项,支持更灵活的配置。
225217

226218
我们非常感谢以上贡献者的付出,他们的工作为更多同学提供了方便和帮助。
227219

@@ -242,5 +234,5 @@ make wordcount # wordcount
242234
f'jiawei#@$.edu'.replace('#', '6').replace('$', 'illinois'),
243235
f'jgli22@$.edu.cn'.replace('$', 'm.fudan'),
244236
f'rizhong.lin@$.%'.replace('$', 'epfl').replace('%', 'ch'),
245-
]
237+
][-1]
246238
```

main.tex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@
6565

6666
% B. 如果使用bibtex,取消下面的注释
6767
% B. If using bibtex, uncomment the lines below
68-
% \addcontentsline{toc}{section}{参考文献} % 将参考文献项加入目录
69-
% \bibliography{bib/note}
68+
% \addcontentsline{toc}{section}{参考文献} % 将参考文献项加入目录
69+
% \bibliography{bib/note.bib} % 指定参考文献数据库文件
7070

7171
\clearpage
7272
\input{sections/ack}
7373

74-
\end{document}
74+
\end{document}

sections/01_intro.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
\section{介绍}\label{sec:introduction}
22

3-
在本节(\cref{sec:introduction})中,我们将讨论文档中常用的各种标题级别和字体样式。在文章中,标题是非常重要的组成部分之一,它可以帮助读者更好地理解文章的结构和内容。
3+
在本节中,我们将讨论文档中常用的各种标题级别和字体样式。在文章中,标题是非常重要的组成部分之一,它可以帮助读者更好地理解文章的结构和内容。
44

55
\subsection{二级标题}
66

sections/02_math.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
\section{数学}\label{sec:math}
22

3-
在本节(\cref{sec:math})中,我们展示各种数学符号和环境的使用。
3+
在本节中,我们展示各种数学符号和环境的使用。
44

55
\subsection{数字和单位}
66

0 commit comments

Comments
 (0)