Debian Codegraph @

texmf-dist/doc/latex/bithesis/dtx-style.sty

raw
1 %%
2 %% This is file `dtx-style.sty',
3 %% generated with the docstrip utility.
4 %%
5 %% The original source files were:
6 %%
7 %% bithesis.dtx (with options: `dtx-style')
8 %% bithesis-doc-style.dtx
9 %% bithesis-finale.dtx
10 %%
11 %% Copyright (C) 2020–2026
12 %% Net Pioneer Association of BIT and any individual authors listed in the documentation.
13 %% ------------------------------------------------------------------------------
14 %%
15 %% This work may be distributed and/or modified under the
16 %% conditions of the LaTeX Project Public License, either
17 %% version 1.3c of this license or (at your option) any later
18 %% version. This version of this license is in
19 %% https://www.latex-project.org/lppl/lppl-1-3c.txt
20 %% and the latest version of this license is in
21 %% https://www.latex-project.org/lppl.txt
22 %% and version 1.3 or later is part of all distributions of
23 %% LaTeX version 2020/11/27 or later.
24 %%
25 %% This work has the LPPL maintenance status `maintained'.
26 %%
27 %% The Current Maintainer of this work is Feng Kaiyu.
28 %% ------------------------------------------------------------------------------
29 %%
30 \ProvidesPackage{dtx-style}
31 \RequirePackage{hypdoc}
32 \RequirePackage{ifthen}
33 \RequirePackage[quiet]{fontspec}
34 \RequirePackage{amsmath}
35 \RequirePackage{unicode-math}
36 \RequirePackage[UTF8,scheme=chinese,heading,sub3section]{ctex}
37 \RequirePackage[
38 top=2.5cm, bottom=2.5cm,
39 left=5cm, right=2cm,
40 headsep=3mm]{geometry}
41 \RequirePackage{graphicx}
42 \RequirePackage{multirow}
43 \RequirePackage{wrapfig}
44 \RequirePackage{hologo}
45 \RequirePackage{array,longtable,booktabs}
46 \RequirePackage{listings}
47 \RequirePackage{fancyhdr}
48 \RequirePackage[dvipsnames,table,xcdraw]{xcolor}
49 \RequirePackage{awesomebox}
50 \RequirePackage{dirtree}
51 \RequirePackage{metalogo}
52 \RequirePackage[tightLists=false]{markdown}
53 \RequirePackage{caption}
54 \RequirePackage{tikz}
55 \usetikzlibrary{positioning}
56 \RequirePackage{framed}
57 \RequirePackage{menukeys}
58 \RequirePackage{float}
59 \RequirePackage{subfig}
60
61 % 设置列表无间隔
62 \usepackage{enumitem}
63 \setlist{nosep}
64
65 \markdownSetup{
66 renderers = {
67 link = {\href{#2}{#1}},
68 }
69 }
70
71 \hypersetup{
72 pdflang = zh-CN,
73 pdftitle = {BIThesis:北京理工大学学位论文及报告模板},
74 pdfauthor = {冯开宇},
75 pdfsubject = {北京理工大学学位论文及报告模板使用说明},
76 pdfkeywords = {论文模板; 北京理工大学; 使用说明},
77 pdfdisplaydoctitle = true
78 }%
79
80 \renewcommand{\subsectionautorefname}{小节}
81 \renewcommand{\subsubsectionautorefname}{小节}
82 \renewcommand{\sectionautorefname}{节}
83 \renewcommand{\chapterautorefname}{章}
84
85 \newcommand{\BIThesisLaTeX}{{\BIThesis}北京理工大学学位论文及报告{\LaTeX}模板}
86 \newcommand{\BIThesisMacroPackage}{{\BIThesis}宏包}
87 \newcommand{\BIThesisWiki}{{\BIThesis}在线文档}
88 \newcommand{\BIThesisScaffold}{{\BIThesis}模板}
89 \newcommand{\BIThesisRelease}{{\BIThesis}模板}
90 \newcommand{\LPPL}{{\href{https://www.latex-project.org/lppl/lppl-1-3c.txt}{\LaTeX{} Project Public License (1.3.c)}}}
91 \newcommand{\versionold}{v2.0 BirthdayCake}
92 \newcommand{\version}{v3 Summer Time}
93
94 \ExplSyntaxOn
95
96 \AtBeginEnvironment { bitsyntax } {
97 \cs_set:Npn \lparen { \textup { ( } }
98 \cs_set:Npn \rparen { \textup { ) } }
99 \char_set_catcode_active:N |
100 \char_set_catcode_active:N <
101 \char_set_catcode_active:N (
102 \char_set_active_eq:NN | \orbar
103 \char_set_active_eq:NN < \syntaxopt@aux
104 \char_set_active_eq:NN ( \defaultval@aux
105 }
106
107 \NewDocumentCommand \BIThesisTemplates {m} {
108 \str_case:nn {#1} {
109 {UT}{本科生毕业论文模板(undergraduate-thesis)}
110 {UTE}{本科生全英文专业毕业论文模板(undergraduate-thesis-en)}
111 {GT}{研究生学位论文模板(graduate-thesis)}
112 {LR}{简易实验报告模板(lab-report)}
113 {PT}{本科生毕业设计外文翻译模板(paper-translation)}
114 {PS}{北理工主题的 Beamer 模板(presentation-slide)}
115 {UP}{本科生毕业设计开题报告(undergraduate-proposal,已废弃)}
116 {RR}{本科生读书报告模板(reading-report)}
117 }
118 }
119
120 \def\breakablethinspace{\hskip 0.16667em\relax}
121
122 \DeclareDocumentCommand\kvopt{mm}
123 {\texttt{#1\breakablethinspace=\breakablethinspace#2}}
124
125 \ExplSyntaxOff
126
127 \ctexset{
128 today=big,
129 abstractname=简介,
130 }
131
132 \pagestyle{fancy}
133
134 \ctexset{section={
135 format={\raggedright \bfseries \zihao{-3}},
136 name = {第,章}
137 }
138 }
139
140 \ctexset{subsection={
141 format = {\bfseries \raggedright \zihao{4}}
142 }
143 }
144
145 \ifthenelse{\equal{\@nameuse{g__ctex_fontset_tl}}{mac}}{
146 \setmainfont{Palatino}
147 \setsansfont[Scale=MatchLowercase]{Helvetica}
148 \setmonofont[Scale=MatchLowercase]{Menlo}
149 \xeCJKsetwidth{‘’“”}{1em}
150 }{
151 \setmainfont[
152 Extension = .otf,
153 UprightFont = *-regular,
154 BoldFont = *-bold,
155 ItalicFont = *-italic,
156 BoldItalicFont = *-bolditalic,
157 ]{texgyrepagella}
158 \setsansfont[
159 Extension = .otf,
160 UprightFont = *-regular,
161 BoldFont = *-bold,
162 ItalicFont = *-italic,
163 BoldItalicFont = *-bolditalic,
164 ]{texgyreheros}
165 \setmonofont[
166 Extension = .otf,
167 UprightFont = *-regular,
168 BoldFont = *-bold,
169 ItalicFont = *-italic,
170 BoldItalicFont = *-bolditalic,
171 Scale = MatchLowercase,
172 Ligatures = CommonOff,
173 ]{texgyrecursor}
174 }
175 \unimathsetup{
176 math-style=ISO,
177 bold-style=ISO,
178 }
179 \IfFontExistsTF{XITSMath-Regular.otf}{
180 \setmathfont[
181 Extension = .otf,
182 BoldFont = XITSMath-Bold,
183 StylisticSet = 8,
184 ]{XITSMath-Regular}
185 \setmathfont[range={cal,bfcal},StylisticSet=1]{XITSMath-Regular.otf}
186 }{
187 \setmathfont[
188 Extension = .otf,
189 BoldFont = *bold,
190 StylisticSet = 8,
191 ]{xits-math}
192 \setmathfont[range={cal,bfcal},StylisticSet=1]{xits-math.otf}
193 }
194
195 \colorlet{bit@macro}{blue!60!black}
196 \colorlet{bit@env}{blue!70!black}
197 \colorlet{bit@option}{purple}
198 \patchcmd{\PrintMacroName}{\MacroFont}{\MacroFont\bfseries\color{bit@macro}}{}{}
199 \patchcmd{\PrintDescribeMacro}{\MacroFont}{\MacroFont\bfseries\color{bit@macro}}{}{}
200 \patchcmd{\PrintDescribeEnv}{\MacroFont}{\MacroFont\bfseries\color{bit@env}}{}{}
201 \patchcmd{\PrintEnvName}{\MacroFont}{\MacroFont\bfseries\color{bit@env}}{}{}
202
203 \def\DescribeOption{%
204 \leavevmode\@bsphack\begingroup\MakePrivateLetters%
205 \Describe@Option}
206 \def\Describe@Option#1{\endgroup
207 \marginpar{\raggedleft\PrintDescribeOption{#1}}%
208 \bit@special@index{option}{#1}\@esphack\ignorespaces}
209 \def\PrintDescribeOption#1{\strut \MacroFont\bfseries\sffamily\color{bit@option} #1\ }
210 \def\bit@special@index#1#2{\@bsphack
211 \begingroup
212 \HD@target
213 \let\HDorg@encapchar\encapchar
214 \edef\encapchar usage{%
215 \HDorg@encapchar hdclindex{\the\c@HD@hypercount}{usage}%
216 }%
217 \index{#2\actualchar{\string\ttfamily\space#2}
218 (#1)\encapchar usage}%
219 \index{#1:\levelchar#2\actualchar
220 {\string\ttfamily\space#2}\encapchar usage}%
221 \endgroup
222 \@esphack}
223
224 \lstdefinestyle{lstStyleBase}{%
225 basicstyle=\small\ttfamily,
226 aboveskip=\medskipamount,
227 belowskip=\medskipamount,
228 lineskip=0pt,
229 boxpos=c,
230 showlines=false,
231 extendedchars=true,
232 escapeinside = {(*}{*)},
233 upquote=true,
234 tabsize=2,
235 showtabs=false,
236 showspaces=false,
237 showstringspaces=false,
238 numbers=none,
239 linewidth=\linewidth,
240 xleftmargin=4pt,
241 xrightmargin=0pt,
242 resetmargins=false,
243 breaklines=true,
244 breakatwhitespace=false,
245 breakindent=0pt,
246 breakautoindent=true,
247 columns=flexible,
248 keepspaces=true,
249 gobble=0,
250 framesep=3pt,
251 rulesep=1pt,
252 framerule=1pt,
253 backgroundcolor=\color{gray!5},
254 stringstyle=\color{green!40!black!100},
255 keywordstyle=\bfseries\color{blue!50!black},
256 commentstyle=\slshape\color{black!60}}
257
258 \lstdefinestyle{lstStyleShell}{%
259 style=lstStyleBase,
260 frame=l,
261 rulecolor=\color{purple},
262 language=bash,
263 }
264
265 \lstdefinestyle{lstStyleLaTeX}{%
266 style=lstStyleBase,
267 frame=l,
268 rulecolor=\color{violet},
269 language=[LaTeX]TeX,
270 emphstyle=[1]\color{teal},
271 }
272
273 \lstdefinestyle{lstStyleSyntax}{%
274 style=lstStyleBase,
275 frame=l,
276 rulecolor=\color{violet},
277 language=[LaTeX]TeX,
278 emphstyle=[1]\color{teal},
279 }
280
281 \lstnewenvironment{latex}[1][]{\lstset{style=lstStyleLaTeX, #1}}{}
282 \lstnewenvironment{shell}[1][]{\lstset{style=lstStyleShell, #1}}{}
283 \lstnewenvironment{bitsyntax}[1][]{\lstset{style=lstStyleSyntax, #1}}{}
284
285 \def\orbar{\textup{\textbar}}
286 \def\syntaxopt#1{\textit{#1}}
287 \def\defaultval#1{\textbf{\textup{#1}}}
288 \def\syntaxopt@aux#1>{\syntaxopt{#1}}
289 \def\defaultval@aux#1){\defaultval{#1}}
290
291 \setlist{nosep}
292
293 \DeclareDocumentCommand{\option}{m}{\textsf{#1}}
294 \DeclareDocumentCommand{\env}{m}{\texttt{#1}}
295 \newcommand{\myentry}[1]{%
296 \marginpar{\raggedleft\color{purple}\bfseries\strut #1}}
297 \newenvironment{note}[1][Note]
298 {{\color{magenta} \bfseries #1} \itshape}
299 {}
300
301 \DeclareDocumentCommand{\githubuser}{m}{\href{https://github.com/#1}{@#1}}
302
303 % 设置 caption 与 figure 之间的距离
304 \setlength{\abovecaptionskip}{11pt}
305 \setlength{\belowcaptionskip}{9pt}
306
307 % 设置图片的 caption 格式
308 \renewcommand{\thefigure}{\thesection-\arabic{figure}}
309 \captionsetup[figure]{font=small,labelsep=space}
310
311 % 设置表格的 caption 与 table 之间的垂直距离
312 \captionsetup[table]{skip=2pt}
313
314 % 设置表格的 caption 格式
315 \renewcommand{\thetable}{\thesection-\arabic{table}}
316 \captionsetup[table]{font=small,labelsep=space}
317
318 % 定义 BIThesis \LaTeX 风格的 Logo
319 \usepackage{relsize}
320 \makeatletter
321 \def\matex@ssize{\smaller\scshape}
322 \DeclareRobustCommand{\BIThesis}{
323 \texorpdfstring{\mbox{
324 \kern-0.5em{B}\kern-0.05em
325 {I}\kern-0.05em
326 {T}\kern-0.1em
327 \raisebox{-0.38ex}{\matex@ssize {H}}\kern-0.1em
328 {\matex@ssize {E}}\kern-0.05em
329 \raisebox{-0.38ex}{\matex@ssize {S}}\kern-0.05em
330 {\matex@ssize {I}}\kern-0.05em
331 \raisebox{-0.35ex}{\matex@ssize {S}}\kern-0.5em
332 \kern 1ex
333 }}{BIThesis}
334 }
335
336 %% from \pkg{ctxdoc}
337 \newlist{optdesc}{description}{3}
338 %% 设置间距为 \marginparsep,与 l3doc 一致
339 \setlist[optdesc]{%
340 font=\mdseries\small\ttfamily,align=right,listparindent=\parindent,
341 labelsep=\marginparsep,labelindent=-\marginparsep,leftmargin=0pt}
342
343 \makeatother
344
345 \endinput
346 %%
347 %% End of file `dtx-style.sty'.