refactor: 适配纳米材料专业课论文
这个提交包含在:
19
.gitignore
vendored
普通文件
19
.gitignore
vendored
普通文件
@ -0,0 +1,19 @@
|
||||
.git
|
||||
.svn
|
||||
.hg
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
*.aux
|
||||
*.bcf
|
||||
*.log
|
||||
*.out
|
||||
*.blg
|
||||
*.bbl
|
||||
*.run.xml
|
||||
*.synctex.gz
|
||||
*.pdf
|
||||
*.toc
|
||||
*.lof
|
||||
*.nav
|
||||
*.snm
|
||||
*.vrb
|
||||
83
.vscode/settings.json
vendored
普通文件
83
.vscode/settings.json
vendored
普通文件
@ -0,0 +1,83 @@
|
||||
{
|
||||
"latex-workshop.latex.recipes": [
|
||||
{
|
||||
"name": "pdflatex",
|
||||
"tools": [
|
||||
"pdflatex"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "pdflatex -> biber -> pdflatex (x2)",
|
||||
"tools": [
|
||||
"pdflatex",
|
||||
"biber",
|
||||
"pdflatex",
|
||||
"pdflatex"
|
||||
]
|
||||
}
|
||||
],
|
||||
"latex-workshop.latex.tools": [
|
||||
{
|
||||
"name": "texify",
|
||||
"command": "texify",
|
||||
"args": [
|
||||
"--synctex",
|
||||
"--pdf",
|
||||
"--tex-option=\"-interaction=nonstopmode\"",
|
||||
"--tex-option=\"-file-line-error\"",
|
||||
"%DOC%.tex"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "xelatex",
|
||||
"command": "xelatex",
|
||||
"args": [
|
||||
"-synctex=1",
|
||||
"-interaction=nonstopmode",
|
||||
"-file-line-error",
|
||||
"%DOC%"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "pdflatex",
|
||||
"command": "pdflatex",
|
||||
"args": [
|
||||
"-synctex=1",
|
||||
"-interaction=nonstopmode",
|
||||
"-file-line-error",
|
||||
"%DOC%"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "bibtex",
|
||||
"command": "bibtex",
|
||||
"args": [
|
||||
"%DOCFILE%"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "biber",
|
||||
"command": "biber",
|
||||
"args": ["%DOCFILE%"]
|
||||
}
|
||||
],
|
||||
"latex-workshop.latex.clean.fileTypes": [
|
||||
"*.aux", "*.bbl", "*.blg", "*.bcf", "*.run.xml"
|
||||
],
|
||||
"latex.linter.enabled": false,
|
||||
"files.exclude": {
|
||||
"**/.git": true,
|
||||
"**/.svn": true,
|
||||
"**/.hg": true,
|
||||
"**/.DS_Store": true,
|
||||
"**/Thumbs.db": true,
|
||||
"**.aux":true,
|
||||
"**.bcf":true,
|
||||
"**.log":true,
|
||||
"**.out":true,
|
||||
"**.blg":true,
|
||||
"**.bbl":true,
|
||||
"**.run.xml":true,
|
||||
"**.synctex.gz":true
|
||||
}
|
||||
}
|
||||
155
README.MD
普通文件
155
README.MD
普通文件
@ -0,0 +1,155 @@
|
||||
# 中央民族大学课程论文 LaTeX 模板
|
||||
|
||||
## 文件结构
|
||||
|
||||
```
|
||||
.
|
||||
├── main.tex # 主文件,导言区和文档结构
|
||||
├── config/
|
||||
│ └── configure.tex # 用户配置:标题、作者、学号、班级、关键词
|
||||
├── content/
|
||||
│ ├── abstract.tex # 摘要内容(MUCAbstract 环境)
|
||||
│ └── body.tex # 正文内容
|
||||
├── builtin/
|
||||
│ ├── config.tex # 内部配置命令(\doctitle、\makeauthorinfo 等)
|
||||
│ ├── header.tex # 页眉页脚、章节标题格式
|
||||
│ ├── abstract.tex # 摘要和关键词的内部命令(\makekeywords、MUCAbstract)
|
||||
│ └── cover.tex # 旧版封面(当前未使用)
|
||||
├── assets/
|
||||
│ └── MUC.jpg # 校徽图片
|
||||
├── ref.bib # BibTeX/Biber 参考文献数据库
|
||||
├── complie.sh # Linux 编译脚本
|
||||
└── complie.bat # Windows 编译脚本
|
||||
```
|
||||
|
||||
## 格式规范
|
||||
|
||||
| 元素 | 字体 | 字号 | 对齐 | 其他 |
|
||||
|---|---|---|---|---|
|
||||
| 正文 | 中文楷体 / 英文 Times New Roman | 小四 (12pt) | 两端对齐 | 首行缩进 2em |
|
||||
| 章节标题 | 楷体加粗 | 小三 (15.6pt) | 居中 | 格式 "第一章 章节名" |
|
||||
| 一级小节 | 楷体加粗 | 小四 (12pt) | — | 格式 "1.1 小节名" |
|
||||
| 二级小节 | 加粗 | 五号 (10.5pt) | — | 格式 "1.1.1 二级小节名" |
|
||||
| 目录 | 宋体 | 五号/小四 | — | 含章节、一二级小节 |
|
||||
| 页眉 | 宋体 | 五号 | 居中 | 正文页显示 |
|
||||
| 页码 | — | — | 居中 | 封面无页码 |
|
||||
| 结论 | 楷体加粗 | 小三 | 居中 | 无章节序号,独占一页 |
|
||||
| 参考文献标题 | 楷体加粗 | 小三 | 居中 | 无章节序号,独占一页 |
|
||||
| 参考文献条目 | 楷体 | 小四 (12pt) | — | GB/T 7714-2015 格式 |
|
||||
| 摘要标签 | 楷体加粗 | 10pt | — | 独占一行 |
|
||||
| 摘要内容 | 宋体 | 8pt | — | 标签下方换行 |
|
||||
| 关键词 | 楷体加粗 | 小五 (9pt) | — | 摘要之后 |
|
||||
| 作者信息 | 宋体 | 10pt | 右对齐 | 顺序:姓名、学号、班级 |
|
||||
|
||||
### 封面页布局
|
||||
|
||||
封面页包含以下元素,从上到下依次排列:
|
||||
1. 标题(左侧,灰蓝色底框)与校徽(右侧)同行
|
||||
2. 作者信息(姓名、学号、班级),右对齐
|
||||
3. 摘要标签 + 摘要内容
|
||||
4. 关键词
|
||||
|
||||
封面无页眉页码。
|
||||
|
||||
### 页面设置
|
||||
|
||||
- 纸张:A4
|
||||
- 上边距 1.56cm,下边距 3.1cm,左右边距 1.5cm
|
||||
|
||||
## 使用说明
|
||||
|
||||
### 1. 配置基本信息
|
||||
|
||||
编辑 `config/configure.tex`:
|
||||
|
||||
```latex
|
||||
\doctitle{中央民族大学课程论文——\textbf{《课程名称》}}
|
||||
\keywords{关键词1;关键词2;关键词3}
|
||||
\mucauthor{姓名}
|
||||
\mucstudentid{学号}
|
||||
\mucclass{班级}
|
||||
```
|
||||
|
||||
### 2. 撰写摘要
|
||||
|
||||
编辑 `content/abstract.tex`,在 `MUCAbstract` 环境内书写:
|
||||
|
||||
```latex
|
||||
\begin{MUCAbstract}
|
||||
这里是摘要内容。
|
||||
\end{MUCAbstract}
|
||||
```
|
||||
|
||||
### 3. 撰写正文
|
||||
|
||||
编辑 `content/body.tex`。编号 `\section` 会自动另起一页;`\subsection` 和 `\subsubsection` 可自由使用。
|
||||
|
||||
```latex
|
||||
\section{第一章标题}
|
||||
正文内容...
|
||||
|
||||
\subsection{1.1 小节}
|
||||
正文内容...
|
||||
|
||||
\subsubsection{1.1.1 二级小节}
|
||||
正文内容...
|
||||
```
|
||||
|
||||
结论使用 `\section*{}`(无序号),需手动换页:
|
||||
|
||||
```latex
|
||||
\clearpage
|
||||
\section*{结论}
|
||||
\phantomsection
|
||||
\addcontentsline{toc}{section}{结论}
|
||||
结论内容...
|
||||
```
|
||||
|
||||
### 4. 添加参考文献
|
||||
|
||||
编辑 `ref.bib`,使用 BibTeX 格式:
|
||||
|
||||
```bibtex
|
||||
@article{example,
|
||||
author = {作者},
|
||||
title = {文章标题},
|
||||
journal = {期刊名},
|
||||
year = {2024},
|
||||
}
|
||||
```
|
||||
|
||||
正文中用 `\cite{example}` 引用。
|
||||
|
||||
### 5. 编译
|
||||
|
||||
需要 XeLaTeX + Biber 编译链:
|
||||
|
||||
```bash
|
||||
xelatex main.tex
|
||||
biber main
|
||||
xelatex main.tex
|
||||
xelatex main.tex
|
||||
```
|
||||
|
||||
或直接运行编译脚本:
|
||||
|
||||
```bash
|
||||
# Linux / macOS
|
||||
bash complie.sh
|
||||
|
||||
# Windows
|
||||
complie.bat
|
||||
```
|
||||
|
||||
### 编译要求
|
||||
|
||||
- XeLaTeX(TeX Live 推荐)
|
||||
- Biber(参考文献处理)
|
||||
- 中文字体:楷体 (KaiTi)、宋体 (SimSun / Songti)、黑体 (SimHei / Heiti)
|
||||
- 英文字体:Times New Roman
|
||||
|
||||
## 自定义
|
||||
|
||||
- 页眉文本:编辑 `builtin/header.tex` 中 `\fancyhead[C]{}` 的内容
|
||||
- 标题底色:编辑 `main.tex` 中 `\definecolor{titleGary}` 的颜色值
|
||||
- 更多章节格式调整:参考 `titlesec` 和 `titletoc` 宏包文档
|
||||
二进制
assets/MUC.jpg
普通文件
二进制
assets/MUC.jpg
普通文件
二进制文件未显示。
|
之后 宽度: | 高度: | 大小: 30 KiB |
33
builtin/abstract.tex
普通文件
33
builtin/abstract.tex
普通文件
@ -0,0 +1,33 @@
|
||||
\makeatletter
|
||||
\def\muckeywords{} % @符号变量需包裹
|
||||
\def\mucenglishkeywords{} % @符号变量需包裹
|
||||
\makeatother
|
||||
|
||||
\newcommand{\keywords}[1]{%
|
||||
\makeatletter
|
||||
\def\muckeywords{#1}%
|
||||
\makeatother
|
||||
}
|
||||
|
||||
% 关键词生成
|
||||
\newcommand{\makekeywords}{%
|
||||
\makeatletter
|
||||
\par\noindent
|
||||
{\fontsize{9pt}{\baselineskip}\bfseries 关键字:}%
|
||||
{\fontsize{9pt}{\baselineskip}\bfseries\space \muckeywords}
|
||||
\makeatother
|
||||
}
|
||||
|
||||
\newenvironment{MUCAbstract}{%
|
||||
\phantomsection
|
||||
\addcontentsline{toc}{section}{摘要}%
|
||||
\par\noindent
|
||||
{\fontsize{10pt}{12pt}\selectfont\textbf{摘要:}}%
|
||||
\par{}
|
||||
\obeylines{}
|
||||
\ignorespaces{}
|
||||
\songti\fontsize{8pt}{10pt}\selectfont
|
||||
\ignorespaces
|
||||
}{%
|
||||
\par
|
||||
}
|
||||
99
builtin/config.tex
普通文件
99
builtin/config.tex
普通文件
@ -0,0 +1,99 @@
|
||||
\makeatletter
|
||||
\def\mucdoctitle{}
|
||||
\makeatother
|
||||
|
||||
\newcommand{\doctitle}[1]{%
|
||||
\def\mucdoctitle{#1}% 不需要 \makeatletter,因为没用到 @
|
||||
}
|
||||
|
||||
\newcommand{\makedoctitle}{%
|
||||
\color{white}\songti\zihao{3}%
|
||||
\mucdoctitle
|
||||
}
|
||||
|
||||
\makeatletter
|
||||
\def\mucdocsubtitle{}
|
||||
\makeatother
|
||||
|
||||
\newcommand{\docsubtitle}[1]{%
|
||||
\makeatletter
|
||||
\def\mucdocsubtitle
|
||||
{#1}%
|
||||
\makeatother
|
||||
}
|
||||
|
||||
\newcommand{\makedocsubtitle}{%
|
||||
\makeatletter
|
||||
{\fontsize{16pt}{18pt} \selectfont \heiti{}%
|
||||
\ifx\mucdocsubtitle\empty\else ——\mucdocsubtitle\fi}
|
||||
\makeatother
|
||||
}
|
||||
|
||||
\makeatletter
|
||||
\def\varmucprojectid{}
|
||||
\makeatother
|
||||
|
||||
\newcommand{\mucprojectid}[1]{%
|
||||
\makeatletter
|
||||
\def\varmucprojectid{#1}%
|
||||
\makeatother
|
||||
}
|
||||
|
||||
\makeatletter
|
||||
\def\varmucprojecttype{}
|
||||
\makeatother
|
||||
|
||||
\newcommand{\mucprojecttype}[1]{%
|
||||
\makeatletter
|
||||
\def\varmucprojecttype{#1}%
|
||||
\makeatother
|
||||
}
|
||||
|
||||
\makeatletter
|
||||
\def\varmucprojectteacher{}
|
||||
\makeatother
|
||||
|
||||
\newcommand{\mucprojectteacher}[1]{%
|
||||
\makeatletter
|
||||
\def\varmucprojectteacher{#1}%
|
||||
\makeatother
|
||||
}
|
||||
|
||||
\makeatletter
|
||||
\def\varmucauthor{}
|
||||
\makeatother
|
||||
|
||||
\newcommand{\mucauthor}[1]{%
|
||||
\makeatletter
|
||||
\def\varmucauthor{#1}%
|
||||
\makeatother
|
||||
}
|
||||
|
||||
\makeatletter
|
||||
\def\varmucstudentid{}
|
||||
\makeatother
|
||||
|
||||
\newcommand{\mucstudentid}[1]{%
|
||||
\makeatletter
|
||||
\def\varmucstudentid{#1}%
|
||||
\makeatother
|
||||
}
|
||||
|
||||
\makeatletter
|
||||
\def\varmucclass{}
|
||||
\makeatother
|
||||
|
||||
\newcommand{\mucclass}[1]{%
|
||||
\makeatletter
|
||||
\def\varmucclass{#1}%
|
||||
\makeatother
|
||||
}
|
||||
|
||||
\newcommand{\makeauthorinfo}{%
|
||||
{%
|
||||
\begin{flushright}
|
||||
\songti\fontsize{10pt}{12pt}\selectfont
|
||||
\varmucauthor{},\varmucstudentid{},\varmucclass{}%
|
||||
\end{flushright}
|
||||
}%
|
||||
}
|
||||
47
builtin/cover.tex
普通文件
47
builtin/cover.tex
普通文件
@ -0,0 +1,47 @@
|
||||
\newcommand{\fontstxs}{\fontsize{15pt}{17pt} \selectfont \songti{}}
|
||||
\newcommand{\fontstsh}{\fontsize{14pt}{16pt} \selectfont \songti{}}
|
||||
\newcommand{\fonthtxe}{\fontsize{18pt}{20pt} \selectfont \heiti{}}
|
||||
|
||||
\newcommand{\makecover}{
|
||||
\thispagestyle{empty}
|
||||
\begin{center}
|
||||
\vspace*{1cm}
|
||||
\noindent
|
||||
|
||||
%% 这里两个minipage的作用是让Logo与标题对齐
|
||||
|
||||
\begin{minipage}[c]{2.17cm}
|
||||
\includegraphics[width=\linewidth]{assets/MUC.jpg}
|
||||
\end{minipage}
|
||||
\hspace{0.5cm}
|
||||
\begin{minipage}[c]{0.8\textwidth}
|
||||
{\fontsize{18pt}{20pt}\selectfont \heiti{}
|
||||
中央民族大学大学生创新训练计划结题论文\\[0.3cm]}
|
||||
{\fontsize{12pt}{14pt}\fontfamily{phv} \selectfont \bfseries
|
||||
URTP Final Thesis of Minzu University of China}
|
||||
|
||||
% 中文黑体小二,英文Arial小四加粗
|
||||
\end{minipage}
|
||||
|
||||
%% 下方是正式的内容
|
||||
|
||||
\vspace{4cm}
|
||||
\makedoctitle{}
|
||||
\vspace{0.5cm}
|
||||
\makedocsubtitle{}
|
||||
\vspace{6cm}
|
||||
|
||||
\begin{tabular}{ll}
|
||||
{\fontstxs{} 计划编号:} & \underline{\fontstxs{} \makebox[6cm][c]{\varmucprojectid}}\\
|
||||
{\fontstxs{} 项目类型:} & \underline{\fontstxs{} \makebox[6cm][c]{\varmucprojecttype}}\\
|
||||
{\fontstxs{} 指导教师:} & \underline{\fontstxs{} \makebox[6cm][c]{\varmucprojectteacher}}\\
|
||||
{\fontstxs{} 项目成员:} & \underline{\fontstxs{} \makebox[6cm][c]{\varmucprojectmembers}}\\
|
||||
{\fontstxs{} 依托单位:} & \underline{\fontstxs{} \makebox[6cm][c]{\varmucprojectunit}}\\
|
||||
\end{tabular}
|
||||
|
||||
\vspace{3cm}
|
||||
|
||||
{\fontstsh{} \varmucprojectdate{}}
|
||||
\end{center}
|
||||
\clearpage
|
||||
}
|
||||
23
builtin/header.tex
普通文件
23
builtin/header.tex
普通文件
@ -0,0 +1,23 @@
|
||||
\newcommand{\setupHeader}{
|
||||
\renewcommand{\baselinestretch}{1.25}
|
||||
\setlength{\parindent}{2em}
|
||||
\titleformat{\section}
|
||||
{\clearpage\centering\bfseries\kaishu\sanhao}
|
||||
{第\chinese{section}章}
|
||||
{1em}
|
||||
{}
|
||||
\titleformat{name=\section,numberless}
|
||||
{\centering\bfseries\kaishu\sanhao}
|
||||
{}
|
||||
{0pt}
|
||||
{}
|
||||
\titlespacing*{\section}{0pt}{12pt}{6pt}
|
||||
|
||||
\pagestyle{fancy}
|
||||
\setlength{\headheight}{14.5pt} % 建议值=基础值+2pt缓冲
|
||||
\setlength{\headsep}{15pt} % 页眉与正文间距
|
||||
\fancyhf{}
|
||||
\fancyhead[C]{\songti\zihao{5}中央民族大学课程论文《纳米材料制备与表征方法》}
|
||||
\renewcommand{\headrulewidth}{1pt} % 页眉线粗细
|
||||
\fancyfoot[C]{\thepage}
|
||||
}
|
||||
94
complie.bat
普通文件
94
complie.bat
普通文件
@ -0,0 +1,94 @@
|
||||
@echo off
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
REM 增强版编译脚本 (Windows 批处理)
|
||||
REM 支持:自动检测编译器、错误重试、参考文献处理、PDF 预览
|
||||
|
||||
set TEX_FILE=%1
|
||||
if "%TEX_FILE%"=="" set TEX_FILE=main.tex
|
||||
set BASE_NAME=%~n1
|
||||
if "%BASE_NAME%"=="" set BASE_NAME=main
|
||||
|
||||
REM 检测编译器
|
||||
set COMPILER=pdflatex
|
||||
findstr /i /c:"documentclass.*{ctex" "%TEX_FILE%" >nul
|
||||
if not errorlevel 1 set COMPILER=xelatex
|
||||
findstr /i /c:"usepackage.*{xeCJK" "%TEX_FILE%" >nul
|
||||
if not errorlevel 1 set COMPILER=xelatex
|
||||
findstr /i /c:"usepackage.*{fontspec" "%TEX_FILE%" >nul
|
||||
if not errorlevel 1 set COMPILER=xelatex
|
||||
findstr /i /c:"usepackage.*{luatex" "%TEX_FILE%" >nul
|
||||
if not errorlevel 1 set COMPILER=lualatex
|
||||
|
||||
echo 检测到使用 %COMPILER% 编译器
|
||||
|
||||
REM 编译函数(通过标签实现)
|
||||
call :compile_tex
|
||||
if errorlevel 1 (
|
||||
echo 编译失败,请检查错误信息
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
REM 处理参考文献
|
||||
if exist "%BASE_NAME%.bcf" (
|
||||
where biber >nul 2>&1
|
||||
if not errorlevel 1 (
|
||||
echo 处理参考文献 (Biber)...
|
||||
biber "%BASE_NAME%"
|
||||
)
|
||||
) else if exist "%BASE_NAME%.aux" (
|
||||
where bibtex >nul 2>&1
|
||||
if not errorlevel 1 (
|
||||
echo 处理参考文献 (BibTeX)...
|
||||
bibtex "%BASE_NAME%"
|
||||
)
|
||||
)
|
||||
|
||||
REM 如果需要参考文献,则再次编译
|
||||
if exist "%BASE_NAME%.bcf" (
|
||||
echo 第二次编译...
|
||||
call :compile_tex
|
||||
echo 第三次编译...
|
||||
call :compile_tex
|
||||
) else if exist "%BASE_NAME%.aux" (
|
||||
echo 第二次编译...
|
||||
call :compile_tex
|
||||
echo 第三次编译...
|
||||
call :compile_tex
|
||||
)
|
||||
|
||||
REM 清理中间文件
|
||||
echo 清理中间文件...
|
||||
call :cleanup
|
||||
|
||||
echo 编译成功: %BASE_NAME%.pdf
|
||||
|
||||
REM 自动打开 PDF
|
||||
if "%2"=="--view" goto open_pdf
|
||||
if "%2"=="-v" goto open_pdf
|
||||
goto :eof
|
||||
|
||||
:open_pdf
|
||||
if exist "%BASE_NAME%.pdf" start "" "%BASE_NAME%.pdf"
|
||||
exit /b
|
||||
|
||||
REM 编译函数(带重试)
|
||||
:compile_tex
|
||||
set attempt=1
|
||||
set max_attempts=3
|
||||
:compile_loop
|
||||
if %attempt% gtr %max_attempts% (
|
||||
exit /b 1
|
||||
)
|
||||
echo 编译尝试 %attempt%/%max_attempts% ...
|
||||
%COMPILER% -synctex=1 -interaction=nonstopmode -file-line-error "%TEX_FILE%"
|
||||
if not errorlevel 1 exit /b 0
|
||||
set /a attempt+=1
|
||||
timeout /t 1 /nobreak >nul
|
||||
goto compile_loop
|
||||
|
||||
REM 清理函数
|
||||
:cleanup
|
||||
del /q "%BASE_NAME%.aux" "%BASE_NAME%.log" "%BASE_NAME%.bbl" "%BASE_NAME%.bcf" "%BASE_NAME%.blg" "%BASE_NAME%.run.xml" "%BASE_NAME%.toc" "%BASE_NAME%.out" "%BASE_NAME%.lof" "%BASE_NAME%.lot" "%BASE_NAME%.nav" "%BASE_NAME%.snm" "%BASE_NAME%.vrb" 2>nul
|
||||
for /d %%i in (_minted-*) do rd /s /q "%%i" 2>nul
|
||||
exit /b
|
||||
108
complie.sh
可执行文件
108
complie.sh
可执行文件
@ -0,0 +1,108 @@
|
||||
#!/bin/bash
|
||||
|
||||
# 增强版编译脚本
|
||||
# 支持:自动检测编译器、错误重试、PDF预览
|
||||
|
||||
set -e # 遇到错误立即退出
|
||||
|
||||
TEX_FILE=${1:-main.tex}
|
||||
BASE_NAME="${TEX_FILE%.*}"
|
||||
|
||||
# 检测编译器
|
||||
detect_compiler() {
|
||||
if grep -q "documentclass.*{ctex" "$TEX_FILE" || \
|
||||
grep -q "usepackage.*{xeCJK" "$TEX_FILE" || \
|
||||
grep -q "usepackage.*{fontspec" "$TEX_FILE"; then
|
||||
COMPILER="xelatex"
|
||||
elif grep -q "usepackage.*{luatex" "$TEX_FILE"; then
|
||||
COMPILER="lualatex"
|
||||
else
|
||||
COMPILER="pdflatex"
|
||||
fi
|
||||
echo "检测到使用 $COMPILER 编译器"
|
||||
}
|
||||
|
||||
# 编译函数
|
||||
compile_tex() {
|
||||
local attempt=1
|
||||
local max_attempts=3
|
||||
|
||||
while [ $attempt -le $max_attempts ]; do
|
||||
echo "编译尝试 $attempt/$max_attempts ..."
|
||||
$COMPILER -synctex=1 -interaction=nonstopmode -file-line-error "$TEX_FILE"
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
attempt=$((attempt + 1))
|
||||
sleep 1
|
||||
done
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
# 主流程
|
||||
main() {
|
||||
echo "📄 编译文档: $TEX_FILE"
|
||||
|
||||
detect_compiler
|
||||
|
||||
# 第一次编译
|
||||
echo "🔄 第一次编译..."
|
||||
if ! compile_tex; then
|
||||
echo "❌ 编译失败,请检查错误信息"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 处理参考文献
|
||||
if [ -f "$BASE_NAME.bcf" ] || [ -f "$BASE_NAME.aux" ]; then
|
||||
if command -v biber &> /dev/null; then
|
||||
echo "📚 处理参考文献 (Biber)..."
|
||||
biber "$BASE_NAME" || true
|
||||
elif command -v bibtex &> /dev/null; then
|
||||
echo "📚 处理参考文献 (BibTeX)..."
|
||||
bibtex "$BASE_NAME" || true
|
||||
fi
|
||||
|
||||
# 后续编译
|
||||
echo "🔄 第二次编译..."
|
||||
compile_tex
|
||||
|
||||
echo "🔄 第三次编译..."
|
||||
compile_tex
|
||||
fi
|
||||
|
||||
# 清理文件
|
||||
echo "🧹 清理中间文件..."
|
||||
cleanup
|
||||
|
||||
echo "✅ 编译成功: $BASE_NAME.pdf"
|
||||
|
||||
# 自动打开PDF
|
||||
if [ "$2" == "--view" ] || [ "$2" == "-v" ]; then
|
||||
open_pdf
|
||||
fi
|
||||
}
|
||||
|
||||
# 清理函数
|
||||
cleanup() {
|
||||
rm -f "$BASE_NAME".{aux,log,bbl,bcf,blg,run.xml,toc,out,lof,lot,nav,snm,vrb} 2>/dev/null || true
|
||||
rm -f _minted-* 2>/dev/null || true
|
||||
}
|
||||
|
||||
# 打开PDF
|
||||
open_pdf() {
|
||||
if [ -f "$BASE_NAME.pdf" ]; then
|
||||
if command -v xdg-open &> /dev/null; then
|
||||
xdg-open "$BASE_NAME.pdf" &
|
||||
elif command -v open &> /dev/null; then
|
||||
open "$BASE_NAME.pdf" &
|
||||
else
|
||||
echo "⚠️ 无法自动打开PDF,请手动查看"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# 运行主函数
|
||||
main "$@"
|
||||
6
config/configure.tex
普通文件
6
config/configure.tex
普通文件
@ -0,0 +1,6 @@
|
||||
\doctitle{中央民族大学课程论文——\textbf{《纳米材料制备与表征方法》}}
|
||||
\docsubtitle{副标题}
|
||||
\keywords{结题论文;模板;教务处;服务}
|
||||
\mucauthor{岚椿铧}
|
||||
\mucstudentid{24012345}
|
||||
\mucclass{24纳米2班}
|
||||
3
content/abstract.tex
普通文件
3
content/abstract.tex
普通文件
@ -0,0 +1,3 @@
|
||||
\begin{MUCAbstract}
|
||||
这里是摘要。
|
||||
\end{MUCAbstract}
|
||||
45
content/body.tex
普通文件
45
content/body.tex
普通文件
@ -0,0 +1,45 @@
|
||||
% 正文区
|
||||
\section{什么是LaTeX}
|
||||
\LaTeX{}是一个让你的文档看起来更专业的排版系统,而不是文字处理器。它尤其适合处理篇幅较长、结构严谨的文档,并且十分擅长处理公式表达。它是免费的软件,对大多数操作系统都适用。
|
||||
|
||||
\LaTeX{} 基于 TeX(Donald Knuth 在 1978 年为数字化排版设计的排版系统)。TeX 是一种电脑能够处理的低级语言,但大多数人发现它很难使用。\LaTeX{} 正是为了让它变得更加易用而设计的。目前 \LaTeX{} 的版本是 \LaTeX{} 2e。
|
||||
|
||||
如果你习惯于使用微软的 Office Word 处理文档,那么你会觉得 \LaTeX{} 的工作方式让你很不习惯。Word 是典型的「所见即所得」的编辑器,你可以在编排文档的时侯查看到最终的排版效果。但使用 \LaTeX{} 时你并不能方便地查看最终效果,这使得你专注于内容而不是外观的调整。
|
||||
|
||||
一个 \LaTeX{} 文档是一个以 .tex 结尾的文本文件,可以使用任意的文本编辑器编辑,比如 Notepad,但对于大多数人而言,使用一个合适的 \LaTeX{} 编辑器会使得编辑的过程容易很多。在编辑的过程中你可以标记文档的结构。完成后你可以进行编译——这意味着将它转化为另一种格式的文档。它支持多种格式,但最常用的是 PDF 文档格式。\cite{latexTemplate}
|
||||
|
||||
\section{为什么要使用LaTeX}
|
||||
\LaTeX{} 相比于 Word 等传统文字处理软件,具有诸多优势。它可以让你专注于内容创作,而将排版的工作交由系统自动完成。
|
||||
|
||||
\subsection{LaTeX 的优势}
|
||||
\LaTeX{} 能够自动编号和生成目录,这极大地提高了写作文档的效率。使用者无需手动调整格式即可得到专业级的排版效果。
|
||||
|
||||
\subsubsection{排版美观}
|
||||
\LaTeX{} 使用 Knuth 设计的断行算法,能够自动优化单词间距和连字符,使文字排版达到印刷级质量。这对于学术论文的撰写尤为重要。
|
||||
|
||||
\subsubsection{公式处理}
|
||||
\LaTeX{} 在数学公式排版方面的能力无与伦比。它支持各种复杂的数学符号和公式结构。
|
||||
|
||||
\subsection{LaTeX 的劣势}
|
||||
\LaTeX{} 的学习曲线较为陡峭,初学者需要花费一定时间熟悉其语法规则。此外,与他人协作时,如果对方不使用 \LaTeX{},则可能会遇到兼容性问题。
|
||||
|
||||
\section{LaTeX 基础语法}
|
||||
本节将介绍 \LaTeX{} 的一些基本语法和常用命令,帮助读者快速入门。
|
||||
|
||||
\subsection{文档结构}
|
||||
一个完整的 \LaTeX{} 文档包括导言区和正文区两部分。导言区用于设置文档类型和加载宏包,正文区则包含文档的实际内容。
|
||||
|
||||
\subsubsection{导言区}
|
||||
导言区以 \verb|\documentclass| 命令开始,包含各种宏包的加载和全局参数的设置。
|
||||
|
||||
\subsubsection{正文区}
|
||||
正文区位于 \verb|\begin{document}| 和 \verb|\end{document}| 之间,是文档内容的主体部分。
|
||||
|
||||
\subsection{常用命令}
|
||||
\LaTeX{} 的命令以反斜杠开头,用于控制文档的各种格式和功能。掌握常用命令是用好 \LaTeX{} 的基础。
|
||||
|
||||
\clearpage
|
||||
\section*{结论}
|
||||
\phantomsection
|
||||
\addcontentsline{toc}{section}{结论}
|
||||
综上所述,\LaTeX{} 是一个功能强大的排版系统,尤其适合用于学术论文和技术文档的撰写。虽然入门门槛较高,但一旦掌握,它将显著提高文档的质量和书写效率。对于需要进行大量文档排版的科研工作者和学生而言,学习 \LaTeX{} 是非常值得的投资。
|
||||
106
main.tex
普通文件
106
main.tex
普通文件
@ -0,0 +1,106 @@
|
||||
%!TeX encoding = UTF-8
|
||||
%!BIB program = biber
|
||||
|
||||
\documentclass[12pt,a4paper,UTF8]{ctexart}
|
||||
|
||||
\usepackage[top=1.56cm,bottom=3.1cm,left=1.5cm,right=1.5cm]{geometry}
|
||||
\usepackage{fancyhdr}
|
||||
\usepackage{titlesec}
|
||||
\usepackage{titletoc}
|
||||
|
||||
\setCJKmainfont{KaiTi}[AutoFakeBold=2.0]
|
||||
\setCJKfamilyfont{zhkai}{KaiTi}[AutoFakeBold=2.0]
|
||||
\setmainfont{Times New Roman}
|
||||
|
||||
\AtBeginDocument{\renewcommand*{\bibfont}{\xiaosi}}
|
||||
\usepackage{graphicx}
|
||||
\usepackage{enumitem}
|
||||
\usepackage{indentfirst}
|
||||
\usepackage{amsmath}
|
||||
\usepackage{multicol}
|
||||
\usepackage{url}
|
||||
\usepackage{environ}
|
||||
\usepackage[most]{tcolorbox}
|
||||
\usepackage[hidelinks]{hyperref}
|
||||
\usepackage[backend=biber, style=gb7714-2015]{biblatex}
|
||||
|
||||
\addbibresource{ref.bib}
|
||||
|
||||
\setcounter{tocdepth}{3}
|
||||
|
||||
\renewcommand{\thesection}{\chinese{section}}
|
||||
\renewcommand{\thesubsection}{\arabic{section}.\arabic{subsection}}
|
||||
|
||||
% 内建的功能 %
|
||||
\input{builtin/cover.tex}
|
||||
\input{builtin/header.tex}
|
||||
\input{builtin/config.tex}
|
||||
\input{builtin/abstract.tex}
|
||||
|
||||
\setupHeader{}
|
||||
|
||||
\newcommand{\sanhao}{\fontsize{15.6pt}{\baselineskip}\selectfont} % 三号
|
||||
\newcommand{\sihao}{\fontsize{14pt}{\baselineskip}\selectfont} % 四号
|
||||
\newcommand{\xiaosi}{\fontsize{12pt}{\baselineskip}\selectfont} % 小四
|
||||
\newcommand{\wuhao}{\fontsize{10.5pt}{\baselineskip}\selectfont} % 五号
|
||||
\newcommand{\xiaowu}{\fontsize{9pt}{\baselineskip}\selectfont} % 小五
|
||||
|
||||
\titlecontents{section}[0pt]{\songti\zihao{-4}}
|
||||
{第\thecontentslabel{}章\quad}{}
|
||||
{\titlerule*[0.5pc]{.}\contentspage}
|
||||
\titlecontents{subsection}[1.5em]{\songti\zihao{-4}}
|
||||
{\thecontentslabel\quad}{}
|
||||
{\titlerule*[0.5pc]{.}\contentspage}
|
||||
\titlecontents{subsubsection}[3em]{\songti\zihao{5}}
|
||||
{\thecontentslabel\quad}{}
|
||||
{\titlerule*[0.5pc]{.}\contentspage}
|
||||
|
||||
\titleformat{\subsection}{\bfseries\xiaosi}{\thesubsection}{1em}{}
|
||||
\titleformat{\subsubsection}{\bfseries\wuhao}{\thesubsubsection}{1em}{}
|
||||
\setlist[enumerate,1]{label=(\arabic*),leftmargin=2em}
|
||||
\setlist[enumerate,2]{label=\alph*.,leftmargin=4em}
|
||||
|
||||
\input{config/configure.tex}
|
||||
|
||||
\definecolor{titleGary}{rgb}{0.7765, 0.8510, 0.9412}
|
||||
\begin{document}
|
||||
% 封面页%
|
||||
\thispagestyle{empty}
|
||||
\begin{center}
|
||||
\begin{tcolorbox}[colback=titleGary, colframe=titleGary, sharp corners]
|
||||
\begin{minipage}[c]{\dimexpr\linewidth-2.4cm\relax}
|
||||
\raggedright
|
||||
\color{black}\songti\zihao{-3}
|
||||
\mucdoctitle{}
|
||||
\end{minipage}
|
||||
\hfill
|
||||
\begin{minipage}[c]{2.2cm}
|
||||
\flushright
|
||||
\includegraphics[width=2.2cm]{assets/MUC.jpg}
|
||||
\end{minipage}
|
||||
\end{tcolorbox}
|
||||
\end{center}
|
||||
|
||||
\vspace{0.5cm}
|
||||
|
||||
\makeauthorinfo{}
|
||||
|
||||
\vspace{0.3cm}
|
||||
|
||||
\input{content/abstract.tex}
|
||||
|
||||
\makekeywords{}
|
||||
|
||||
\clearpage
|
||||
\tableofcontents{}
|
||||
|
||||
\obeylines{}
|
||||
\ignorespaces{}
|
||||
\input{content/body.tex}
|
||||
|
||||
\clearpage
|
||||
\section*{参考文献}
|
||||
\phantomsection
|
||||
\addcontentsline{toc}{section}{参考文献}
|
||||
\printbibliography[heading=none]
|
||||
\end{document}
|
||||
在新工单中引用
屏蔽一个用户