Skip to content

Commit

Permalink
v5.5.1.BJUT.07
Browse files Browse the repository at this point in the history
  • Loading branch information
mpskex committed Jun 8, 2019
1 parent f75c8e6 commit 5418544
Show file tree
Hide file tree
Showing 3 changed files with 219 additions and 4 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# 北京工业大学本科毕业论文latex模板
> 为优秀的毕业生们提供了latex排版小论文的可能。不过体现方式是以独立tex和独立cover定义实现
> 另外为需要查重的同学们准备了tex转plaintex的小工具,虽然这玩意不到半小时就能写完吧,主要希望抛砖引玉。
> 于2019/06/08晚
> 请注意,为方便大家一同打印翻译与论文,本模板增加了翻译页眉以及格式。
> 所有附录内容可参照更新后的appendix01.tex调整格式。
> 于2019/05/28凌晨
Expand Down
49 changes: 49 additions & 0 deletions plaintext.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#coding: utf-8
import os
"""
Beijing University of Technology Thesis LaTeX template
Plain text generator
Author: Fangrui Liu
NOTE:
This version is still under development
You can make improvement at any time :P
"""

basedir = 'data/'
trans_key = ['\\cite', '\\ref', '\\eqref', '$', '\\item', '\\footnote', '\\textbf']
replace_key = {'\\times':'*', '\\alpha':'alpha', '\\beta':'beta', '\\otimes':'*', '\\odot':'*'}
del_col_key = ['begin', 'label', 'end', 'section', 'chapter', 'subsection', 'subsubsection', '%',
'hskip', 'vskip', 'fangsong', 'includegraphics', '\centering', 'wuhao', 'adjustbox',
'minipage', 'figure', 'subfigure', 'caption', 'hline', 'noindent', 'rule', 'multicolumn',
]

def parse_tex(file_name):
out = []
with open(file_name, 'r', encoding='utf-8') as f:
lines = f.readlines()
for line in lines:
line = line.split('\n')[0]
is_plain = True
line = ''.join(line.split(' '))
line = ''.join(line.split('\t'))
for key in trans_key:
line = line.replace(key, '')
for key in replace_key.keys():
line = line.replace(key, replace_key[key])
if line != '':
for key in del_col_key:
if key in line:
is_plain = False
if is_plain:
out.append(line)
else:
print(line[:10])
return '\n'.join(out)


if __name__ == '__main__':
texlist = ['cover.tex', 'chap01.tex', 'chap02.tex', 'chap03.tex', 'chap04.tex', 'conclusion.tex', 'ack.tex']
with open('report.txt', 'w', encoding='utf-8') as f:
for tex in texlist:
f.write(parse_tex(basedir + tex))
170 changes: 166 additions & 4 deletions thuthesis.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -1708,6 +1708,7 @@
% \changes{v4.7}{2012/05/29}{本科页码用小五号字。}
% \changes{v5.0.0}{2015/12/20}{利用 \pkg{fancyhdr} 设置页眉页脚。}
% \changes{v5.5.1.BJUT.05}{2019/05/27}{增加附录页眉}
% \changes{v5.5.1.BJUT.07}{2019/06/05}{增加优秀论文摘要选编格式}
% 定义三种页眉页脚格式:
% \begin{itemize}
% \item \texttt{thu@empty}:页眉页脚都没有
Expand All @@ -1727,6 +1728,12 @@
\fancyfoot[C]{\wuhao\thepage}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0pt}}
\fancypagestyle{thu@outstandingabstracthdr}{%
\fancyhead{}
\fancyfoot{}
\fancyfoot[C]{\wuhao\thepage}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}}
\fancypagestyle{thu@translatehdr}{%
\fancyhead{}
\fancyhead[C]{\lishu \sanhao 北京工业大学毕业设计(译文)}
Expand Down Expand Up @@ -2015,14 +2022,15 @@
% \changes{v2.5.3}{2006/06/07}{不管 caption 出现在什么位置,\cs{aboveskip} 总是出现在标题和浮动体之间的距离。}
% \changes{v4.3}{2008/03/11}{子图引用时加括号。}
% \changes{v5.0.0}{2015/06/27}{本科附录图表编号用-不用.(如图A-1,表A-2)。}
% \changes{v5.5.1.BJUT.07}{2019/06/05}{修改插图标题的字号以及表格内字号}
% \begin{macrocode}
\ifthu@bachelor
\g@addto@macro\appendix{\renewcommand*{\thefigure}{\thechapter-\arabic{figure}}}
\g@addto@macro\appendix{\renewcommand*{\thetable}{\thechapter-\arabic{table}}}
\fi
\let\old@tabular\@tabular
\def\thu@tabular{\dawu[1.5]\old@tabular}
\DeclareCaptionFont{thu}{\dawu[1.3]}
\def\thu@tabular{\wuhao[1.5]\old@tabular}
\DeclareCaptionFont{thu}{\wuhao[1.3]}
\DeclareCaptionLabelSeparator{thu}{\hspace{\ccwd}}
\captionsetup{
font = thu,
Expand All @@ -2042,7 +2050,7 @@
% 了。}
% \begin{macrocode}
\let\thu@LT@array\LT@array
\def\LT@array{\dawu[1.5]\thu@LT@array} % set default font size
\def\LT@array{\wuhao[1.5]\thu@LT@array} % set default font size
% \end{macrocode}
%
% \begin{macro}{\hlinewd}
Expand Down Expand Up @@ -2398,11 +2406,16 @@
% \cs{Collect@Body} 来实现。
% \changes{v3.1}{2006/06/17}{重新定义摘要成为环境。}
% \changes{v5.2.2}{2016/01/31}{用 \pkg{environ} 封装的 \cs{Collect@Body}。}
% \changes{v5.5.1.BJUT.07}{2019/06/04}{增加优秀论文附加摘要格式}
% \begin{macrocode}
\newcommand{\thu@@cabstract}[1]{\long\gdef\thu@cabstract{#1}}
\newenvironment{cabstract}{\Collect@Body\thu@@cabstract}{}
\newcommand{\thu@@eabstract}[1]{\long\gdef\thu@eabstract{#1}}
\newenvironment{eabstract}{\Collect@Body\thu@@eabstract}{}
\newcommand{\thu@@cabstractextra}[1]{\long\gdef\thu@cabstractextra{#1}}
\newenvironment{cabstractextra}{\Collect@Body\thu@@cabstractextra}{}
\newcommand{\thu@@eabstractextra}[1]{\long\gdef\thu@eabstractextra{#1}}
\newenvironment{eabstractextra}{\Collect@Body\thu@@eabstractextra}{}
% \end{macrocode}
%
% \begin{macro}{\thu@parse@keywords}
Expand Down Expand Up @@ -2985,6 +2998,12 @@
\ifthu@bachelor\indent\else\noindent\hangindent\wd\thu@kw\hangafter1\fi%
\box\thu@kw#2\par
\endgroup}
\newcommand\thu@put@keywordsextra[2]{%
\begingroup
\setbox\thu@kw=\hbox{#1}
\ifthu@bachelor\noindent\else\noindent\hangindent\wd\thu@kw\hangafter1\fi%
\box\thu@kw#2\par
\endgroup}
% \end{macrocode}
% \end{macro}
%
Expand Down Expand Up @@ -3096,7 +3115,150 @@
% \begin{macrocode}
\NewDocumentEnvironment{conclusion}{o}{%
\clearpage
\thu@chapter*{结论}
\thu@chapter*{结论与展望}
}
{
\relax
}
% \end{macrocode}
% \end{environment}
%
% \changes{v5.5.1.BJUT.07}{2019/06/04}{根据北京工业大学本科生优秀毕业设计(论文)摘要撰写规范添加论文摘要格式}
% \subsubsection{《摘要选编》相关(优秀论文整理)}
% \label{sec:outstandingabstract}
%
% \begin{environment}{outstandingabstract}
% 结论章节定义
% \begin{macrocode}
\newcommand{\thu@makeabstractextra}{%
\thu@setchinese
{
{\heiti\xiaosi[1.75]\centerline{摘要}}
\songti\wuhao[1.75]
\thu@cabstractextra

\thu@put@keywordsextra{\textbf{\thu@ckeywords@title}}{\thu@ckeywords}
}

\thu@setenglish
{
{\xiaosi[1.75]\centerline{\eabstractname}}
\wuhao[1.75]
\thu@eabstractextra

\thu@put@keywordsextra{%
\textbf{\ifthu@bachelor Keywords:\else Key Words:\fi\enskip}}{\thu@ekeywords}
}

\thu@setdefaultlanguage
}
\NewDocumentEnvironment{outstandingabstract}{o}{%
\clearpage
% 应用新的页面边距信息
\newgeometry{
asymmetric,
top=25.4mm,
left=25.4mm,
headheight=5mm,
headsep=5mm,
right=20mm,
bottom=25.4mm,
footskip=12mm}
% 设置页面格式
\pagestyle{thu@outstandingabstracthdr}
% 标题以及作者信息以及指导教师
\heiti\sanhao[1.75]\centerline{\thu@ctitle}
\kaishu\xiaosi[1.75]
\centerline{\textbf{\thu@cmajor\hskip1em\thu@studentno\hskip1em\thu@cauthor}}
\centerline{\textbf{\thu@supervisor@title\hskip1em\thu@csupervisor}}
\thu@makeabstractextra
% 设置节格式
\setcounter{chapter}{0}
\setcounter{section}{0}
\ctexset{%
section={
beforeskip={0pt},
afterskip={0pt},
number={\arabic{section}},
format={\wuhao[1.75]\songti\bfseries},
numberformat={\wuhao[1.75]\songti\bfseries},
},
subsection={
beforeskip={0pt},
afterskip={0pt},
number={\arabic{section}.\arabic{subsection}},
format={\wuhao[1.75]\songti},
numberformat={\wuhao\songti},
},
subsubsection={
beforeskip={0pt},
afterskip={0pt},
number={(\arabic{subsubsection})},
numberformat={\wuhao[1.75]\songti},
indent=2em,
format={\wuhao[1.75]\songti},
}
}

% 参考文献格式
\renewcommand\bibsection{\heiti\xiaosi[1.75]\centerline{\bibname}}
\renewcommand\bibfont{\wuhao[1.75]}

\songti\wuhao[1.75]
}
{
\restoregeometry
\ctexset{%
chapter={
afterindent=true,
pagestyle={\ifthu@bachelor thu@plain\else thu@headings\fi},
beforeskip={\ifthu@bachelor 15bp\else 9bp\fi},
aftername=\hskip\ccwd,
afterskip={\ifthu@bachelor 20bp\else 24bp\fi},
format={\centering\songti\ifthu@bachelor\xiaoer[1.333]\bfseries\else\sanhao[1]\fi},
nameformat=\relax,
numberformat=\relax,
titleformat=\thu@chapter@titleformat,
lofskip=0pt,
lotskip=0pt,
},
section={
afterindent=true,
beforeskip={\ifthu@bachelor 25bp\else 24bp\fi\@plus 1ex \@minus .2ex},
afterskip={\ifthu@bachelor 12bp\else 6bp\fi \@plus .2ex},
format={\songti\ifthu@bachelor\xiaosan[1.286]\bfseries\else\sihao[1.429]\fi},
},
subsection={
afterindent=true,
beforeskip={\ifthu@bachelor 12bp\else 16bp\fi\@plus 1ex \@minus .2ex},
afterskip={6bp \@plus .2ex},
format={\songti\ifthu@bachelor\sihao[1.25]\bfseries\else\banxiaosi[1.538]\fi},
numberformat={\songti\ifthu@bachelor\sihao[1.154]\bfseries\else\banxiaosi[1.538]\fi},
},
subsubsection={
afterindent=true,
beforeskip={\ifthu@bachelor 12bp\else 16bp\fi\@plus 1ex \@minus .2ex},
afterskip={6bp \@plus .2ex},
indent={0em},
format={\songti\ifthu@bachelor\xiaosi[1.25]\bfseries\else\xiaosi[1.667]\fi},
},
paragraph/afterindent=true,
subparagraph/afterindent=true}
\relax
}
% \end{macrocode}
% \end{environment}
%
% \changes{v5.5.1.BJUT.06}{2019/05/28}{根据一些导师呼应增加已提交的学术论文和专利}
% \subsubsection{已提交工作和学术专利}
% \label{sec:subwork}
%
% \begin{environment}{submittedwork}
% 已提交工作和学术专利
% \begin{macrocode}
\NewDocumentEnvironment{submittedwork}{o}{%
\clearpage
\thu@chapter*{已提交的学术论文和专利}
}
{
\relax
Expand Down

0 comments on commit 5418544

Please sign in to comment.