feat: use subcaption as subfigure package.

This commit is contained in:
jackfiled 2025-04-13 14:44:14 +08:00
parent 38783733be
commit 61f6f7d045
2 changed files with 75 additions and 3 deletions

View File

@ -6,6 +6,7 @@
\usepackage{setspace}
\usepackage{subfiles}
\usepackage{fontawesome5}
\usepackage{float}
% Font family
\setmainfont[Mapping=tex-text]{Times New Roman}
@ -174,14 +175,16 @@ pdfborder=001, linkcolor=black, citecolor=black, urlcolor=black]{hyperref} %
\usepackage{longtable}
\usepackage{caption}
\usepackage[position=t,singlelinecheck=off]{subfig}
\usepackage[labelformat=simple]{subcaption}
\renewcommand{\captionfont}{\kaishu\zihao{5}}
\renewcommand{\captionlabelfont}{\kaishu\zihao{5}}
\DeclareCaptionLabelSeparator{twospace}{ ~}
\captionsetup{labelsep=twospace} %去掉图1后冒号
\renewcommand{\thesubfigure}{(\alph{subfigure})}
\renewcommand{\tablename}{表}
\renewcommand{\thetable}{~\arabic{chapter}-\arabic{table}~}
\renewcommand{\arraystretch}{1.5}
\renewcommand{\figurename}{图}
\renewcommand{\thefigure}{~\arabic{chapter}-\arabic{figure}~}
\renewcommand{\theequation}{\arabic{chapter}-\arabic{equation}~}
@ -217,7 +220,7 @@ pdfborder=001, linkcolor=black, citecolor=black, urlcolor=black]{hyperref} %
keywordstyle=\color{blue},
commentstyle=\color{green!30!black},
showspaces=false, % 显示空格
showstringspaces=true, % 字符串中显示空格
showstringspaces=false, % 字符串中显示空格
showtabs=false, % 显示 TAB
tabsize=2, % TAB 被当作两个空格
captionpos=t, % 标题位置
@ -243,6 +246,41 @@ pdfborder=001, linkcolor=black, citecolor=black, urlcolor=black]{hyperref} %
}
\makeatother
% C# 代码样式
\lstdefinelanguage{CSharp}{
morekeywords={%
abstract, as, base, bool, break, byte, case, catch, char, checked, class, const, continue, decimal, default, %
delegate, do, double, else, enum, event, explicit, extern, false, finally, fixed, float, for, foreach, goto, %
if, implicit, in, int, interface, internal, is, lock, long, namespace, new, null, object, operator, out, %
override, params, private, protected, public, readonly, ref, return, sbyte, sealed, sizeof, stackalloc, string, %
struct, switch, this, throw, true, try, typeof, uint, ulong, unchecked, unsafe, ushort, using, virtual, void, volatile, while, %
async, await, get, set, add, remove, yield, yield break, yield return, %
dynamic, var, partial, virtual, override, base, typeof, sizeof, %
delegate, event, nameof, ref, in, out, params, this, base, new, %
where, from, group, join, let, orderby, select, into, orderby, descending, ascending, %
get, set, checked, unchecked, lock, fixed, sizeof, nameof, default, nameof, %
fixed, stackalloc, nameof, await, async, %
% 可能需要的上下文关键字
await, async, get, set, add, remove, yield, %
% 根据需求添加更多关键字
},
sensitive=false, % 区分大小写建议设为false除非需要区分
morecomment=[l]{//}, % 单行注释
morecomment=[s]{/*}{*/}, % 多行注释
morestring=[b]", % 字符串用双引号包裹
literate=% % 处理特殊符号(如显示为直角引号)
{`}{{\textquotesingle}}1
{~}{{\textasciitilde}}1,
showstringspaces=false% 隐藏字符串中的空格
}
\lstdefinestyle{csharp}{
language=CSharp, % 使用定义的语言
stringstyle=\color{red}, % 字符串颜色
moredelim=[s][\color{magenta}]{<}{>}, % 泛型符号颜色(如<T>
moredelim=*[s][\color{magenta}]{[}{]}, % 数组符号颜色(如[]
}
% insert PDF
\usepackage[final]{pdfpages}

View File

@ -74,6 +74,40 @@ latexmk main.tex
从学校提供的官方Word模板中编辑好导出为PDF文件因为这两个文件使用Latex排版非常复杂排版的效果也不好。
### 发现仓库更新了怎么办?
为了方便模板的使用,我一般情况下只会更新`BUPTBachlorThesis.sty`文件和`BUPTBachlor.bst`文件,前者管理整个文档的样式,后者负责生成参考文件的引用格式,直接将这两个文件整体复制替换即可。
### 如何排版多张子图?
模板中提供了`subcaption`包作为子图排版的工具。一个示例如下:
```latex
\begin{figure}[htbp]
\centering
\begin{subfigure}{0.45\linewidth}
\includegraphics[width=0.9\linewidth]{assets/coala-example-cpu.png}
\subcaption{任务均运行在CPU上}
\label{fig:coala-example-cpu}
\end{subfigure}
\hfill
\begin{subfigure}{0.45\linewidth}
\includegraphics[width=0.9\linewidth]{assets/coala-example-gpu.png}
\subcaption{任务均运行在GPU上}
\label{fig:coala-example-gpu}
\end{subfigure}
\begin{subfigure}{0.9\linewidth}
\centering
\includegraphics[width=0.6\linewidth]{assets/coala-example-hybrid.png}
\subcaption{最优的调度方案}
\label{fig:coala-example-hybrid}
\end{subfigure}
\caption{任务调度对于任务完成时间的影响示意图}
\label{fig:coala-example}
\end{figure}
```
### ref.bib中的引用条目从哪里来的
1. 建议使用Zotero等文献管理工具自动生成。
@ -81,6 +115,6 @@ latexmk main.tex
### 为什么参考文献中英文文献出现了中文的“见”字而不是In
这是因为现在的`见`/`In`判断逻辑非常粗糙,是通过引用条目中是否存在`language`字段来判断的,所以中文文献添加任意取值的`language`字段都会生成为`见`,英文文献就只能手动删除`language`字段以生成为`In`。
这是因为现在的`见`/`In`判断逻辑非常粗糙,是通过引用条目中是否存在`language`字段来判断的,所以文献文件`ref.bib`中的引用条目添加任意取值的`language`字段都会生成为`见`因此引用英文文献就只能手动删除`language`字段以生成为`In`。