重庆邮电大学毕业论文latex模板使用笔记
Texstudio编译,使用官方letex模板2.0。主要是记录一下自己遇到的问题,以下遇到的问题也均在overleaf上遇到并完成修改,加粗部分为解决方案
本人也很菜,以下内容并不一定是最佳解决方案,遇到问题之后会继续更新。三角形是可以点击的,里面有代码
-
引用文献,模板里使用了\textsuperscript{\cite{ref1}}来完成上标。
但实际上在custom里面已经定义了\supercite{}来做上标的引用,直接用就行 -
如果图名称超过一行,word模板里要求中英文题目同时左右缩进4字符:“题名超过一行时,两端对齐,左右缩进4字符,必要时可适当调整左右缩进,避免末行只有1、2个字符的情况。”Latex模板里是只有中文左缩进了一个quad,如果中文超过一行的话编译会超过边界:
学校的latex模板的内容
\vspace{0.3cm}
\begin{figure}[!h]
\centering
\subfigure[]{
\label{fig:DE_J}
\includegraphics[width=12cm]{chapters/DE_J.pdf}}
\subfigure[]{
\label{fig:DE_CF}
\includegraphics[width=12cm]{chapters/DE_CF.pdf}}
\begin{itemize}[leftmargin=1.6cm,rightmargin=1.6cm]
\item[\quad] \bicaption[\xiaosi 理论效率与$\gamma$和$\varphi$的关系,测试测试测试测试测试测试测试]{\wuhao 理论效率与$\gamma$和$\varphi$的关系,测试测试测试测试测试测试测试 (a) $\alpha=1$; (b) $\alpha=2/\sqrt{3}$}{\wuhaob Theoretical DE versus $\gamma$ and $\varphi$. (a) $\alpha=1$; (b) $\alpha=2/\sqrt{3}$Theoretical DE versus $\gamma$ and $\varphi$. (a) $\alpha=1$; (b) $\alpha=2/\sqrt{3}$}
\end{itemize}
\vspace{-1cm}

实际上使用caption包后在环境里面加入\captionsetup{margin=4em}就可以达到要求了。
-
如果在图名字中使用了\supercite,那么在图索引中,由于图名出现的更早,会导致该引用在顺序排序时靠前。
直接把图索引表、表索引表、缩写和符号表全注释掉了,反正也不是必须的。 -
不喜欢bibitem
换成了bibtex并使用\bibliographystyle{gbt7714-2005-numerical}按照引用顺序排序 -
参考文献的人名,学校要求全部大写,但编译出来很多是只有首字母大写
部分文献库导出时信息过于丰富,比如ADS,会使用{}保护作者的姓,被{}保护的部分不会被强制大写,删掉即可。如果情况和我一致,可以使用以下的程序进行修改。
清除author中的{}
import re
import os
def process_author_line(line):
# 如果该行包含 "author =" 则进行处理
if re.search(r'^\s*author\s*=', line):
# 正则匹配
m = re.search(r'^(.*author\s*=\s*)(.*?)(\s*,\s*)$', line, re.IGNORECASE)
if m:
prefix = m.group(1) # author =
content = m.group(2) # 作者
suffix = m.group(3) # 包含逗号以及空白字符
# 去掉作者内容中的所有 { 和 }
new_content = content.replace('{', '').replace('}', '')
# 去除前后空白后,在前后添加新的花括号包围整个作者列表
new_content = '{' + new_content.strip() + '}'
# 返回修改后的行
return prefix + new_content + suffix
return line
def process_file(file_content):
# 按行处理文件内容
lines = file_content.splitlines()
new_lines = [process_author_line(line) for line in lines]
return "\n".join(new_lines)
def main():
# 将下面的路径修改为你的BibTeX文件路径
input_file = r"G:\WORK\test\references.bib"
with open(input_file, 'r', encoding='utf-8') as f:
content = f.read()
new_content = process_file(content)
dir_name = os.path.dirname(input_file)
base_name, ext = os.path.splitext(os.path.basename(input_file))
output_file = os.path.join(dir_name, base_name + "_cleaned" + ext)
# 将处理后的内容写入输出文件
with open(output_file, 'w', encoding='utf-8') as f:
f.write(new_content)
print(f"处理后的文件已保存到: {output_file}")
if __name__ == '__main__':
main()
- word版里要求脚标使用“①”的样式,并要求每一页都从1开始重新排序,latex模板里完全没涉及到脚标相关内容,默认的脚标不符合要求。
加几个包,在custom里定义一下新脚标:
脚注
\usepackage{pifont}
\usepackage{footmisc}
\usepackage{setspace}
\usepackage[perpage]{footmisc}
\makeatletter
% 设定脚注格式
\renewcommand\footnoterule{%
\kern-3\p@
\hrule width 0.4\columnwidth height 0.4pt
\kern 2.6\p@}
\renewcommand{\@makefntext}[1]{%
\noindent
\footnotesize
\hangindent=1.5em \hangafter=1
\thefootnote\hspace{0.5em}
#1
}
\makeatother
-
在\bicaption里无法引用。
用\protect\supercite{}保护一下,保持bicaption的中文内容一致 -
逗号在Overleaf上显示异常
Overleaf缺乏相关的中文字体,在本地使用Texstudio编译就好了 -
学校的图名里,Fig.和图X-X的要求不一致
在custom-chinese里面改一下,\captionsetup[figure][bi-second]{name=\wuhao Fig.\hspace{-0.08cm}}
\captionsetup[table][bi-second]{name=\wuhao Table\hspace{-0.05cm}},大概是对的,可以自行调整 -
学校要求参考文献要么都首字母大写,要么都除了介词都大写,那么就需要再改一改bib了,可以用以下代码进行。
点击查看代码
import re
# 常见的不需要大写的词
PREPOSITIONS = {'a', 'an', 'and', 'as', 'at', 'by', 'for', 'from', 'in', 'into', 'of', 'on', 'or', 'to', 'with'}
def capitalize_title(title):
# 读取tittle
title = title.strip('{}').strip()
words = title.split()
# 大写
capitalized_words = [
word.capitalize() if i == 0 or word.lower() not in PREPOSITIONS else word.lower()
for i, word in enumerate(words)
]
# 合并
return '{' + ' '.join(capitalized_words) + '}'
def process_bib_file(input_file, output_file):
with open(input_file, 'r', encoding='utf-8') as infile:
bib_content = infile.read()
# 匹配
def title_replacer(match):
full_match = match.group(0)
title_content = match.group(1)
return f'title = "{capitalize_title(title_content)}"'
# 替换
updated_content = re.sub(r'title\s*=\s*"{([^}]*)}"', title_replacer, bib_content)
with open(output_file, 'w', encoding='utf-8') as outfile:
outfile.write(updated_content)
if __name__ == "__main__":
input_file = "E:\\毕业论文-初稿\\毕业论文-匿名版\\references.bib"
output_file = "E:\\毕业论文-初稿\\毕业论文-匿名版\\formatted_references.bib"
process_bib_file(input_file, output_file)
print(f"Processed .bib file saved as {output_file}")

浙公网安备 33010602011771号