Debian Codegraph @

texmf-dist/source/latex/njuvisual/njuvisual.dtx

raw
1 % \iffalse meta-comment
2 %
3 % Copyright (C) 2021 - 2022
4 % by Nanjing University Linux User Group
5 % <[email protected]>
6 %
7 % It may be distributed and/or modified under the conditions of the
8 % LaTeX Project Public License (LPPL), either version 1.3c of this
9 % license or (at your option) any later version. The latest version
10 % of this license is in the file
11 %
12 % https://www.latex-project.org/lppl.txt
13 %
14 % This work has the LPPL maintenance status `maintained'.
15 %
16 % The Current Maintainer of this work is Yu Xiong.
17 %
18 % This work consists of the files njuvisual.dtx,
19 % njuvisual-emblem.dtx,
20 % njuvisual-name.dtx,
21 % njuvisual-motto.dtx,
22 % njuvisual-spirit.dtx,
23 % njuvisual-ai.dtx,
24 % njuvisual-chem.dtx,
25 % njuvisual-cs.dtx,
26 % njuvisual-dii.dtx,
27 % njuvisual-eng.dtx,
28 % njuvisual-physics.dtx,
29 % njuvisual-software.dtx,
30 % njuvisual-end.dtx,
31 % and the derived files njuvisual.ins,
32 % njuvisual.sty,
33 % njuvisual.pdf,
34 % njuvisual-emblem-nju.def,
35 % njuvisual-emblem-ai.def,
36 % njuvisual-emblem-chem.def,
37 % njuvisual-emblem-cs.def,
38 % njuvisual-emblem-dii.def,
39 % njuvisual-emblem-eng.def,
40 % njuvisual-emblem-eng.def,
41 % njuvisual-emblem-software.def,
42 % njuvisual-motto-nju.def,
43 % njuvisual-name-zh-nju.def,
44 % njuvisual-name-en-nju.def,
45 % njuvisual-spirit-nju.def,
46 % njuvisual-example.tex.
47 %
48 % -----------------------------------------------------------------------
49 %
50 % The development version of the template can be found at
51 %
52 % https://github.com/nju-lug/NJUVisual
53 %
54 % for those people who are interested.
55 %
56 %<*internal>
57 \begingroup
58 \def\NameOfLaTeXe{LaTeX2e}
59 \expandafter\endgroup\ifx\NameOfLaTeXe\fmtname\else
60 \csname fi\endcsname
61 %</internal>
62 %
63 %<*install>
64 \input docstrip.tex
65 \keepsilent
66 \askforoverwritefalse
67
68 \preamble
69
70 Copyright (C) 2021 - 2022
71 by Nanjing University Linux User Group
72 % <[email protected]>
73
74 This file may be distributed and/or modified under the conditions of
75 the LaTeX Project Public License, either version 1.3c of this license
76 or (at your option) any later version. The latest version of this
77 license is in:
78
79 http://www.latex-project.org/lppl.txt
80
81 and version 1.3 or later is part of all distributions of LaTeX version
82 2005/12/01 or later.
83
84 To produce the documentation run the original source files ending with `.dtx'
85 through XeTeX.
86
87 \endpreamble
88
89 \generate{
90 \usedir{tex/latex/njuvisual}
91 \file{\jobname-example.tex} {\from{\jobname.dtx}{example}
92 \from{\jobname-emblem.dtx}{example}
93 \from{\jobname-name.dtx}{example}
94 \from{\jobname-motto.dtx}{example}
95 \from{\jobname-spirit.dtx}{example}
96 \from{\jobname-ai.dtx}{example}
97 \from{\jobname-chem.dtx}{example}
98 \from{\jobname-cs.dtx}{example}
99 \from{\jobname-dii.dtx}{example}
100 \from{\jobname-eng.dtx}{example}
101 \from{\jobname-physics.dtx}{example}
102 \from{\jobname-software.dtx}{example}
103 \from{\jobname-end.dtx}{example}}
104 \file{\jobname.sty} {\from{\jobname.dtx}{package}
105 \from{\jobname-emblem.dtx}{color}
106 \from{\jobname-ai.dtx}{color}
107 \from{\jobname-chem.dtx}{color}
108 \from{\jobname-cs.dtx}{color}
109 \from{\jobname-dii.dtx}{color}
110 \from{\jobname-eng.dtx}{color}
111 \from{\jobname-physics.dtx}{color}
112 \from{\jobname-software.dtx}{color}}
113 \nopreamble\nopostamble
114 \file{\jobname-emblem-nju.def} {\from{\jobname-emblem.dtx}{emblem-nju}}
115 \file{\jobname-name-zh-nju.def} {\from{\jobname-name.dtx}{name-zh-nju}}
116 \file{\jobname-name-en-nju.def} {\from{\jobname-name.dtx}{name-en-nju}}
117 \file{\jobname-motto-nju.def} {\from{\jobname-motto.dtx}{motto-nju}}
118 \file{\jobname-spirit-nju.def} {\from{\jobname-spirit.dtx}{spirit-nju}}
119 \file{\jobname-emblem-ai.def} {\from{\jobname-ai.dtx}{emblem-ai}}
120 \file{\jobname-emblem-chem.def} {\from{\jobname-chem.dtx}{emblem-chem}}
121 \file{\jobname-emblem-cs.def} {\from{\jobname-cs.dtx}{emblem-cs}}
122 \file{\jobname-emblem-dii.def} {\from{\jobname-dii.dtx}{emblem-dii}}
123 \file{\jobname-emblem-eng.def} {\from{\jobname-eng.dtx}{emblem-eng}}
124 \file{\jobname-emblem-physics.def} {\from{\jobname-physics.dtx}{emblem-physics}}
125 \file{\jobname-emblem-software.def} {\from{\jobname-software.dtx}{emblem-software}}
126 %<*internal>
127 \usedir{source/latex/njuvisual}
128 \file{\jobname.ins} {\from{\jobname.dtx}{install}}
129 %</internal>
130 }
131
132 \obeyspaces
133 \Msg{*************************************************************}
134 \Msg{* *}
135 \Msg{* To finish the installation you have to move the following *}
136 \Msg{* files into a directory searched by TeX: *}
137 \Msg{* *}
138 \Msg{* The recommended directory is TDS:tex/latex/njuvisual *}
139 \Msg{* *}
140 \Msg{* njuvisual.ins *}
141 \Msg{* njuvisual.sty *}
142 \Msg{* njuvisual-emblem-nju.def, *}
143 \Msg{* njuvisual-emblem-ai.def, *}
144 \Msg{* njuvisual-emblem-chem.def, *}
145 \Msg{* njuvisual-emblem-cs.def, *}
146 \Msg{* njuvisual-emblem-dii.def, *}
147 \Msg{* njuvisual-emblem-eng.def, *}
148 \Msg{* njuvisual-emblem-eng.def, *}
149 \Msg{* njuvisual-emblem-software.def, *}
150 \Msg{* njuvisual-motto-nju.def, *}
151 \Msg{* njuvisual-name-zh-nju.def, *}
152 \Msg{* njuvisual-name-en-nju.def, *}
153 \Msg{* njuvisual-spirit-nju.def, *}
154 \Msg{* *}
155 \Msg{* To produce the documentation, run the file njuvisual.dtx *}
156 \Msg{* through XeLaTeX. *}
157 \Msg{* *}
158 \Msg{* Happy TeXing! *}
159 \Msg{* *}
160 \Msg{*************************************************************}
161
162 \endbatchfile
163 %</install>
164 %
165 %<*internal>
166 \fi
167 %</internal>
168 %
169 %<package>\NeedsTeXFormat{LaTeX2e}
170 %<!(driver|example)>\GetIdInfo $Id: njuvisual.dtx 0.3.0 2022-12-13 18:00:00
171 %<!(driver|example)> +0800 NJU LUG <[email protected]>$
172 %<package> {Nanjing University Visual Identity}
173 %<package>\ProvidesExplPackage{njuvisual}
174 %<package> {\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription}
175 %
176 %<*driver>
177 \documentclass[fontset=fandol]{ctxdoc}
178 \usepackage{listings,njuvisual,tabularray,zhlineskip}
179 \usepackage[firstpage=true]{background}
180 \backgroundsetup{contents={\njuemblem[white!85!gray]{22cm}{!}},scale=1,angle=0,hshift=-4cm}
181 \DeclareGraphicsExtensions{.pdf}
182 \UseTblrLibrary{booktabs,siunitx,diagbox}
183 \DefTblrTemplate{caption-tag}{default}{表\hspace{0.25em}\thetable}
184 \SetTblrStyle{caption-tag}{font=\bfseries}
185 \DefTblrTemplate{caption-sep}{default}{\quad}
186 \setlist[1]{labelindent=0.5em}
187 \hypersetup{
188 pdftitle={
189 The njuvisual package -
190 Display logos related to Nanjing University
191 },
192 citecolor = njublue,
193 linkcolor = njuviolet,
194 urlcolor = njumagenta
195 }
196 \SetTextEnvironmentSinglespace{1.112}
197 \SetMathEnvironmentSinglespace{1.112}
198 \setsansfont{LexendDeca}
199 \setmonofont{Iosevka}[
200 UprightFont = Iosevka Light,
201 ItalicFont = Iosevka Light Italic,
202 BoldFont = Iosevka Semibold
203 ]
204 \setCJKmainfont{Source Han Serif SC}[
205 UprightFont = Source Han Serif SC SemiBold,
206 ItalicFont = Source Han Serif SC Bold,
207 BoldFont = Source Han Serif SC Heavy,
208 Language = Chinese Simplified
209 ]
210 \setmathfont{XITSMath-Regular}[
211 BoldFont = XITSMath-Bold,
212 Extension = .otf]
213 \lstdefinestyle{style@base}
214 {
215 basewidth = 0.5 em,
216 gobble = 3,
217 lineskip = 3 pt,
218 frame = l,
219 framerule = 1 pt,
220 framesep = 0 pt,
221 xleftmargin = 2 em,
222 xrightmargin = 3 em,
223 escapeinside = {(*}{*)},
224 breaklines = true,
225 basicstyle = \small\ttfamily,
226 keywordstyle = \bfseries\color{njuviolet},
227 commentstyle = \itshape\color{white!50!gray},
228 stringstyle = \color{nju-chem-red},
229 backgroundcolor = \color{white!95!gray}
230 }
231 \lstdefinestyle{style@shell}
232 {
233 style = style@base,
234 rulecolor = \color{njumagenta},
235 language = bash,
236 alsoletter = {-},
237 emphstyle = \color{green}
238 }
239 \lstdefinestyle{style@latex}
240 {
241 style = style@base,
242 rulecolor = \color{njublue},
243 language = [LaTeX]TeX,
244 alsoletter = {*, -},
245 texcsstyle = *\color{njuviolet},
246 emphstyle = [1]\color{nju-ai-orange},
247 emphstyle = [2]\color{nju-cs-green},
248 }
249 \lstnewenvironment{shellexample}[1][]{%
250 \lstset{style=style@shell, #1}}{}
251 \lstnewenvironment{latexexample}[1][]{%
252 \lstset{style=style@latex, #1}}{}
253 \ExplSyntaxOn
254 \cs_new_protected:Npn \__njudoc_module_angle:Nn #1#2
255 {
256 \group_begin: \color { gray } \ttfamily \textlangle \group_end:
257 \group_begin: \sffamily #2 \group_end:
258 \group_begin: \color { gray } #1 \ttfamily \textrangle \group_end:
259 }
260 \cs_set_protected:Npn \__ctxdoc_module_angle:n #1
261 { \__njudoc_module_angle:Nn \c_empty_tl {#1} }
262 \ExplSyntaxOff
263 \begin{document}
264 \DocInput{njuvisual.dtx}
265 \DocInput{njuvisual-emblem.dtx}
266 \DocInput{njuvisual-name.dtx}
267 \DocInput{njuvisual-motto.dtx}
268 \DocInput{njuvisual-spirit.dtx}
269 \DocInput{njuvisual-ai.dtx}
270 \DocInput{njuvisual-chem.dtx}
271 \DocInput{njuvisual-cs.dtx}
272 \DocInput{njuvisual-dii.dtx}
273 \DocInput{njuvisual-eng.dtx}
274 \DocInput{njuvisual-physics.dtx}
275 \DocInput{njuvisual-software.dtx}
276 \DocInput{njuvisual-end.dtx}
277 \PrintChanges
278 \PrintIndex
279 \end{document}
280 %</driver>
281 %
282 % \fi
283 %
284 % \title{\color{njuviolet}{^^A
285 % The \pkg{njuvisual} package \\ \textbf{南京大学视觉形象规范化标准}}}
286 %
287 % \author{^^A
288 % 南京大学 Linux 用户组
289 % \thanks{E-mail: \href{mailto:[email protected]}{[email protected]}}}
290 %
291 % \date{v0.3.0 \quad 2022-12-13}
292 %
293 % \changes{v0.1}{2021/11/21}{将 \pkg{njuvisual} 分离为独立宏包。}
294 % \changes{v0.1}{2021/11/27}{完成文档编写并发布至 CTAN。}
295 % \changes{v0.1}{2021/11/28}{使用 GitHub Action 进行自动打包发布。}
296 % \changes{v0.3}{2022/12/08}{将贝塞尔曲线存储到单独文件。}
297 %
298 % \maketitle
299 %
300 % \let\abstractname\relax
301 % \begin{abstract}
302 % 南京大学视觉形象规范化标准(\pkg{njuvisual})宏包负责收集南京大学官方以及下属
303 % 各院系制定的配色方案和标识,将这些矢量图标通过 \pkg{tikz} 曲线进行存储,并提
304 % 供简明的接口以便在文档和幻灯片中使用。
305 % \end{abstract}
306 %
307 % \begin{abstract}
308 % The \pkg{njuvisual} package collects standard colors and logos related to
309 % Nanjing University, saves the vector logos as \pkg{tikz} pictures and
310 % provides a user-friendly interface to display them in documents and beamers.
311 % \end{abstract}
312 %
313 % \clearpage
314 %
315 % \tableofcontents
316 %
317 %
318 % \begin{documentation}
319 %
320 % \section{宏包介绍}
321 %
322 % \pkg{njuvisual} 用于收录南京大学及其各院系制定的标准色彩及图标,并提供简洁的绘制指令。
323 %
324 % 本宏包衍生自 \cls{njuthesis},依赖 \hologo{LaTeX3} 项目
325 % 中的 \pkg{expl3}、\pkg{xparse} 和 \pkg{l3keys2e} 宏包。
326 % 特别感谢 \cls{fduthesis} 与 \pkg{zhlipsum} 提供的处理思路。
327 %
328 % 欲使用本宏包,在终端键入下述 \pkg{tlmgr} 的命令(很可能需要管理员权限):
329 % \begin{shellexample}[morekeywords={tlmgr,install}]
330 % tlmgr install njuvisual
331 % \end{shellexample}
332 % 即可完成安装。
333 %
334 %
335 % \section{宏包选项}
336 %
337 % \begin{function}{force}
338 % 使用强制模式载入宏包。
339 % \end{function}
340 %
341 % 在强制模式下,\pkg{njuvisual} 将覆盖已有的 \cs{njuemblem}、
342 % \cs{njuname}、\cs{njuspirit}、\cs{njumotto} 命令定义。
343 %
344 %
345 % \section{使用方法}
346 %
347 % 本节提供命令的使用方法。关于绘制的内容,请参阅后文的 \ref{subsec:colors-and-curves}。
348 %
349 % \subsection{标准色彩}
350 %
351 % \begin{function}{\color}
352 % \begin{syntax}
353 % \tn{color}\Arg{颜色}
354 % \end{syntax}
355 % 使用标准色彩。
356 % \end{function}
357 %
358 % 本宏包定义的所有标准色彩见表~\ref{tab:pre-defined-colors}。
359 % \begingroup
360 % \def\B#1{\color{#1}$\blacksquare\blacksquare\blacksquare\blacksquare\blacksquare$}
361 % \begin{table}[htb]
362 % \caption{预定义标准色} \label{tab:pre-defined-colors}
363 % \centering
364 % \begin{tblr}[expand=\B]{cccc}
365 % \toprule
366 % 名称 & 颜色名称 & CMYK 数值 & 示例 \\
367 % \midrule
368 % \SetCell[r=5]{c} 南京大学
369 % & |njuviolet| & \SetCell[r=2]{c}
370 % $0.50, 1 , 0 , 0.40$ &
371 % \SetCell[r=2]{c} \B{njuviolet} \\
372 % & |njupurple| & & \\
373 % & |njumagenta| & $0.05, 1 , 0.55, 0 $ & \B{njumagenta} \\
374 % & |njublue| & $0.80, 0.50, 0 , 0 $ & \B{njublue} \\
375 % & |njuyellow| & $0 , 0.30, 1 , 0 $ & \B{njuyellow} \\
376 % \SetCell[r=2]{c} 人工智能学院
377 % & |nju-ai-blue| & $0.75, 0.65, 0 , 0 $ & \B{nju-ai-blue} \\
378 % & |nju-ai-orange| & $0 , 0.75, 1 , 0 $ & \B{nju-ai-orange} \\
379 % \SetCell[r=2]{c} 计算机科学与技术系
380 % & |nju-cs-blue| & $0.89, 0.66, 0.13, 0 $ & \B{nju-cs-blue} \\
381 % & |nju-cs-green| & $0.60, 0.23, 1 , 0 $ & \B{nju-cs-green} \\
382 % \SetCell[r=2]{c} 化学化工学院
383 % & |nju-chem-red| & $0.28, 0.95, 0.84, 0 $ & \B{nju-chem-red} \\
384 % & |nju-chem-gold| & $0.40, 0.42, 0.60, 0 $ & \B{nju-chem-gold} \\
385 % 物理学院
386 % & |nju-physics-blue| & $0.86, 0.57, 0 , 0 $ & \B{nju-physics-blue} \\
387 % \bottomrule
388 % \end{tblr}
389 % \end{table}
390 % \endgroup
391 %
392 %
393 % \subsection{标准图标}
394 %
395 % \begin{function}[added=2021-09-24,updated=2021-11-27]{\njuemblem}
396 % \begin{syntax}
397 % \tn{njuemblem}\oarg{选项}\Arg{宽度}\Arg{高度}
398 % \end{syntax}
399 % 生成徽标,默认生成校徽。参数 \oarg{选项} 是可选的,详见下文说明。注意各
400 % 参数之间不可以有空格。
401 % \end{function}
402 %
403 % \begin{function}[added=2021-09-24,updated=2021-11-27]{\njuname,\njuname*}
404 % \begin{syntax}
405 % \tn{njuname}\oarg{选项}\Arg{宽度}\Arg{高度}
406 % \tn{njuname*}\oarg{选项}\Arg{宽度}\Arg{高度}
407 % \end{syntax}
408 % 生成名称,带有可选星号的命令会生成英文名称,默认生成校名。要求同上。
409 % \end{function}
410 %
411 % 可选参数 \meta{选项} 可使用两种方式给出:
412 % \begin{itemize}
413 % \item 颜色名称,使用颜色名称即默认生成校徽、校名
414 % \item 使用英文半角逗号分隔的键值列表
415 % \end{itemize}
416 %
417 % 其中,键值列表支持的选项见下。
418 %
419 % \begin{function}[added=2021-11-27]{color,color*}
420 % \begin{syntax}
421 % color = \meta{主要颜色}
422 % color* = \meta{辅助颜色}
423 % \end{syntax}
424 % 定制图标颜色。
425 % \end{function}
426 %
427 % 对于绝大多数南京大学院系,其图标仅使用两种以内的颜色,因此本宏包仅提供两种颜色选项。
428 % 其中的 |color*| 选项一般无需修改,原因在于现有的图标可被总结为下列若干种情况:
429 % \begin{description}
430 % \item[纯色、透明底色] 如南大校名,无辅助颜色,|color*| 选项无效
431 % \item[纯色、白色底色] 如现工徽标,辅助颜色默认为白色,无需进行修改
432 % \item[双色] 如计科徽标,主要颜色、辅助颜色已预先进行定义,为美观考虑,修改主要颜色时会将图标颜色统一为一种
433 % \end{description}
434 % 对于中空的图标,本宏包默认在内部空间填充白色(即上述第二种情况),以在复杂背景下保证图标的辨识度。遗憾的是,\pkg{xcolor} 并不能将某种颜色设置为透明。因此,如果希望实现类似于中空的效果,可以从背景中选取一种突出的颜色设为 |color*|。
435 %
436 % \begin{function}[added=2021-11-27]{department}
437 % \begin{syntax}
438 % department = \meta{院系名称}
439 % \end{syntax}
440 % 院系名称。
441 % \end{function}
442 %
443 % 为保证无歧义,|department| 选项使用的名称来自于院系官网域名。如化学化工学院域名为 \url{https://chem.nju.edu.cn/},其选项名称即为 |chem|。
444 %
445 % 目前的支持情况如表~\ref{tab:supported-departments-list}所示。对于不支持的院系,本宏包会抛出异常。
446 % \begingroup
447 % \def\B{\bullet}
448 % \begin{table}[htb]
449 % \caption{收录院系列表} \label{tab:supported-departments-list}
450 % \centering\small
451 % \begin{tblr}[expand=\B]{cccccccc}
452 % \toprule
453 % 名称 & 选项名称 & emblem & name & name* \\
454 % \midrule
455 % 人工智能学院 & |ai| & \B & & \\
456 % 计算机科学与技术系 & |cs| & \B & & \\
457 % 匡亚明学院 & |dii| & \B & & \\
458 % 现代工程与应用科学学院 & |eng| & \B & & \\
459 % 物理学院 & |physics| & \B & & \\
460 % 软件学院 & |software| & \B & & \\
461 % \bottomrule
462 % \end{tblr}
463 % \end{table}
464 % \endgroup
465 %
466 % 对这两个命令的举例如下:
467 % \begin{latexexample}[moretexcs={\njuemblem,\njuname,\njuname*}]
468 % \njuemblem{!}{3cm} % 生成指定大小的紫色南大校徽
469 % \njuname{4cm}{!} % 生成指定大小的紫色南大中文校名
470 % \njuname*{4cm}{!} % 生成指定大小的紫色南大英文校名
471 % \njuemblem[black]{!}{3cm} % 黑色的南大校徽
472 % \njuemblem[department=dii]{!}{4cm} % 紫色匡院徽标
473 % \njuemblem[department=cs,color=blue]{!}{3cm} % 纯蓝色计科徽标
474 % \end{latexexample}
475 %
476 % \begin{function}[added=2021-09-24]{\njumotto}
477 % \begin{syntax}
478 % \tn{njumotto}\oarg{颜色}\Arg{宽度}\Arg{高度}
479 % \end{syntax}
480 % 生成指定颜色和大小的南京大学校训。
481 % \end{function}
482 %
483 % \begin{function}[added=2021-09-24]{\njuspirit}
484 % \begin{syntax}
485 % \tn{njuspirit}\oarg{颜色}\Arg{宽度}\Arg{高度}
486 % \end{syntax}
487 % 生成指定颜色和大小的南京大学校风。
488 % \end{function}
489 %
490 %
491 % \subsection{导出图像}
492 % \changes{v0.2}{2021/12/04}{提供导出 PNG 图像的方法。}
493 %
494 % 为了便于存储独立的图像,本宏包内置了 \file{njuvisual-example.tex},使用 \pkg{tikz} 的外置化功能生成独立的图片文件。编译此文件时需使用 |--shell-escape| 参数。
495 %
496 % 对于大部分日常用途,PDF 格式的矢量图并没有受到良好的支持。在此提供将上述独立图像通过 inkscape 程序进行转换的方法,相应的自动转换脚本请从项目仓库内获取。关于命令行使用方法的请参考\href{https://inkscape.org/doc/inkscape-man.html}{官方手册}。
497 % \begin{description}
498 % \item[|--export-type=|] 指定输出格式,|"png"| 即可,不支持 JPEG 格式。
499 % \item[|-w|] 指定输出宽度。
500 % \item[|-h|] 指定输出高度。
501 % \end{description}
502 %
503 % 以下为在 Linux 系统中将当前目录下全部 PDF 文件转化为高度为1000像素的 PNG 图片的命令示例。
504 % \begin{shellexample}[morekeywords={inkscape}]
505 % inkscape --export-type="png" nju-*.pdf -h 1000
506 % \end{shellexample}
507 %
508 % 以下为在 Windows 系统的 Powershell 中将南大校名转化为 PNG 图片的命令示例。
509 % \begin{shellexample}
510 % & 'C:\Program Files (x86)\Inkscape\bin\inkscape.exe' --export-type="png" nju-name.pdf
511 % \end{shellexample}
512 %
513 % \end{documentation}
514 %
515 %
516 % \begin{implementation}
517 %
518 % \section{实现细节}
519 %
520 % \begin{macrocode}
521 %<@@=njuvis>
522 %<*package>
523 % \end{macrocode}
524 %
525 % \subsection{载入宏包}
526 %
527 % 导入所需宏包,其中 \pkg{tikz} 已包含 \pkg{xcolor},无需单独加载。
528 % \begin{macrocode}
529 \RequirePackage { l3keys2e, tikz}
530 % \end{macrocode}
531 %
532 % \subsection{定义变量}
533 %
534 % \begin{macro}{\l_@@_color_a_tl,\l_@@_color_b_tl}
535 % 存储使用的颜色。
536 % \begin{macrocode}
537 \tl_new:N \l_@@_color_a_tl
538 \tl_new:N \l_@@_color_b_tl
539 % \end{macrocode}
540 % \end{macro}
541 %
542 % \begin{macro}{\l_@@_dept_tl}
543 % 存储院系。
544 % \begin{macrocode}
545 \tl_new:N \l_@@_dept_tl
546 % \end{macrocode}
547 % \end{macro}
548 %
549 % \begin{macro}{\l_@@_curve_tl}
550 % 存储使用的贝塞尔曲线路径。
551 % \begin{macrocode}
552 \tl_new:N \l_@@_curve_tl
553 % \end{macrocode}
554 % \end{macro}
555 %
556 % \begin{variable}{\c_@@_cmds_clist}
557 % 本宏包定义的全部用户命令。
558 % \begin{macrocode}
559 \clist_const:Nn \c_@@_cmds_clist { emblem, name, motto, spirit }
560 % \end{macrocode}
561 % \end{variable}
562 %
563 % \begin{variable}{\c_@@_dept_all_clist}
564 % 定义南京大学全体院系名单。
565 % \begin{macrocode}
566 \clist_const:Nn \c_@@_dept_all_clist
567 { nju, dii, eng, chin, history, philo, jc, law, nubs, sfs, im, sociology,
568 math, physics, astronomy, chem, cs, software, ai, ese, hjxy, sgos,
569 as, life, med, sme, hwxy, arch, marxism, art, edu }
570 % \end{macrocode}
571 % \end{variable}
572 %
573 % \begin{variable}{\c_@@_dept_emblem_clist}
574 % 定义受图标支持的南京大学院系名单。
575 % \begin{macrocode}
576 \clist_const:Nn \c_@@_dept_emblem_clist
577 { nju, ai, cs, chem, dii, eng, physics, software }
578 % \end{macrocode}
579 % \end{variable}
580 %
581 % \begin{variable}{\c_@@_dept_name_clist}
582 % 定义受名称支持的南京大学院系名单。
583 % \begin{macrocode}
584 \clist_const:Nn \c_@@_dept_name_clist { nju }
585 % \end{macrocode}
586 % \end{variable}
587 %
588 % \begin{variable}{\c_@@_dept_color_clist}
589 % 定义受色彩支持的南京大学院系名单。
590 % \begin{macrocode}
591 \clist_const:Nn \c_@@_dept_color_clist { ai, cs, chem, physics }
592 % \end{macrocode}
593 % \end{variable}
594 %
595 % \subsection{错误信息}
596 %
597 % 集中定义错误信息。
598 % \begin{macrocode}
599 \msg_new:nnn { njuvisual } { unsupported-department }
600 {
601 "#1"~ is~ not~ an~ available~ option~ currently.\\
602 Please~ refer~ to~ the~ package~ documentation~ for~ supported~
603 departments~ and~ check~ your~ spelling.
604 }
605 \msg_new:nnn { njuvisual } { force-mode }
606 { Force~ mode~ on.\\ I~ am~ overwriting~ all~ existing~ commands. }
607 \msg_new:nnn { njuvisual } { duplicate-command }
608 {
609 The~ command~ "\string#1"~ is~ already~ defined.\\
610 I~ am~ not~ going~ to~ redefine~ it~ anyway.~
611 Or~ you~ can~ use~ the~ package~ option~ "force"~
612 to~ overwrite~ existing~ definitions.
613 }
614 % \end{macrocode}
615 %
616 % \subsection{宏包选项}
617 %
618 % \changes{v0.1}{2022/03/01}{新增选项 \opt{force}。}
619 % \begin{macrocode}
620 \keys_define:nn { njuvisual }
621 {
622 % \end{macrocode}
623 % \begin{macro}{force}
624 % 是否强制定义。
625 % \begin{macrocode}
626 force .value_forbidden:n = true,
627 force .code:n =
628 {
629 \msg_warning:nn { njuvisual } { force-mode }
630 \clist_map_inline:Nn \c_@@_cmds_clist
631 { \cs_undefine:c { nju ##1 } }
632 }
633 }
634 % \end{macrocode}
635 % \end{macro}
636 %
637 % \begin{macrocode}
638 \ProcessKeysOptions { njuvisual }
639 % \end{macrocode}
640 %
641 % \subsection{内部命令}
642 %
643 % \changes{v0.1}{2021/11/27}{使用键值对处理院系和颜色。}
644 % \begin{macrocode}
645 \keys_define:nn { njuvisual }
646 {
647 % \end{macrocode}
648 % \begin{macro}{color,color*}
649 % 颜色。设定主要色彩的初始值为 |default|,辅助色彩的初始值为白色。
650 % \begin{macrocode}
651 color .tl_set:N = \l_@@_color_a_tl,
652 color .initial:n = default,
653 color* .tl_set:N = \l_@@_color_b_tl,
654 color* .initial:n = white,
655 % \end{macrocode}
656 % \end{macro}
657 %
658 % \begin{macro}{department}
659 % 院系。设定院系选项初始值为学校官方。
660 % \begin{macrocode}
661 department .tl_set:N = \l_@@_dept_tl,
662 department .initial:n = nju,
663 }
664 % \end{macrocode}
665 % \end{macro}
666 %
667 % \begin{macro}{\@@_set_color:}
668 % \changes{v0.1}{2021/11/25}{完善设定颜色的方法。}
669 % 设定颜色。
670 % \begin{macrocode}
671 \cs_new_protected:Nn \@@_set_color:
672 {
673 \str_if_eq:VnTF \l_@@_color_a_tl { default }
674 {
675 % \end{macrocode}
676 % 如果没有单独设定,则使用默认颜色。
677 % \begin{macrocode}
678 \clist_if_in:NVTF \c_@@_dept_color_clist \l_@@_dept_tl
679 { \tl_set:Nn \l_@@_color_a_tl
680 { \clist_item:cn { c_@@_color_ \l_@@_dept_tl _clist } { 1 } }
681 \tl_set:Nn \l_@@_color_b_tl
682 { \clist_item:cn { c_@@_color_ \l_@@_dept_tl _clist } { 2 } } }
683 { \tl_set:Nn \l_@@_color_a_tl { njuviolet } }
684 }
685 { \clist_if_in:NVT \c_@@_dept_color_clist \l_@@_dept_tl
686 % \end{macrocode}
687 % 将双色图标设定为纯色。
688 % \begin{macrocode}
689 { \tl_set_eq:NN \l_@@_color_b_tl \l_@@_color_a_tl } }
690 }
691 % \end{macrocode}
692 % \end{macro}
693 %
694 % \begin{macro}{\@@_tikz_wrapper:nnn,\@@_tikz_wrapper:Vnn}
695 % 可变大小的 tikz 容器。\footnote{此处手动调整了列表缩进,实际上\env{arguments}环境的缩进问题已在\href{https://github.com/CTeX-org/ctex-kit/commit/838ebab8378b6b0477f5aece81ace28ae2a8bcd9}{838ebab}提交中修复}
696 % \begin{arguments}
697 % \item 路径
698 % \item 宽度
699 % \item 高度
700 % \end{arguments}
701 % 封装 resizebox 和 tikzpicture 环境,减少重复。
702 % ^^A 考虑转换到 \box_autosize_to_wd_and_ht:Nnn
703 % \begin{macrocode}
704 \cs_new_protected:Npn \@@_tikz_wrapper:nnn #1#2#3
705 {
706 \resizebox { #2 } { #3 } {
707 \begin{tikzpicture}[y=0.80pt, x=0.80pt, yscale=-1,
708 xscale=1, inner~sep=0pt, outer~sep=0pt] #1
709 \end{tikzpicture} }
710 }
711 \cs_generate_variant:Nn \@@_tikz_wrapper:nnn { V }
712 % \end{macrocode}
713 % \end{macro}
714 %
715 % \begin{macro}{\@@_if_key_value_list:nTF}
716 % 判断是否为键值列表,即是否含有 |=|。
717 % \begin{macrocode}
718 \cs_new_protected:Npn \@@_if_key_value_list:nTF #1
719 { \tl_if_in:nnTF {#1} {=} }
720 % \end{macrocode}
721 % \end{macro}
722 %
723 % \begin{macro}{\@@_check_cmd:NF}
724 % 检查载入宏包前相关命令是否有定义。
725 % \begin{macrocode}
726 \cs_new_protected:Npn \@@_check_cmd:NF #1
727 {
728 \cs_if_exist:NTF #1
729 { \msg_warning:nnn { njuvisual } { duplicate-command } {#1} }
730 }
731 % \end{macrocode}
732 % \end{macro}
733 %
734 % \begin{macro}{\@@_import_curve:nF,\@@_import_curve:n}
735 % 从相应的 \file{njuvisual-*.def} 文件读取内容,存储到 \cs{l_@@_curve_tl}。
736 % \begin{macrocode}
737 \cs_new:Npn \@@_import_curve:nF #1
738 { \file_get:nnNF { njuvisual- #1 .def } { \ExplSyntaxOn } \l_@@_curve_tl }
739 \cs_new:Npn \@@_import_curve:n #1
740 { \@@_import_curve:nF {#1} { \BOOM } }
741 % \end{macrocode}
742 % \end{macro}
743 %
744 % \begin{macro}{\@@_print:nnnn}
745 % 输出 \pkg{tikz} 曲线。
746 % \begin{arguments}
747 % \item 类别
748 % \item 颜色或者键值对
749 % \item 宽度
750 % \item 高度
751 % \end{arguments}
752 % \begin{macrocode}
753 \cs_new_protected:Npn \@@_print:nnnn #1#2#3#4
754 {
755 \group_begin:
756 % \end{macrocode}
757 % 根据参数是否含有 |=| 来判断该参数是颜色还是选项列表。
758 % \begin{macrocode}
759 \@@_if_key_value_list:nTF { #2 }
760 {
761 \keys_set:nn { njuvisual } { #2 }
762 % \end{macrocode}
763 % 检查是否受支持。
764 % \begin{macrocode}
765 \@@_import_curve:nF { #1 - \l_@@_dept_tl }
766 {
767 \msg_error:nnx { njuvisual }
768 { unsupported-department } { \l_@@_dept_tl }
769 }
770 \@@_set_color:
771 \@@_tikz_wrapper:Vnn \l_@@_curve_tl { #3 } { #4 }
772 }
773 % \end{macrocode}
774 % 单独设置颜色时输出官方徽标。
775 % \begin{macrocode}
776 {
777 \tl_set:Nn \l_@@_color_a_tl { #2 }
778 \@@_import_curve:n { #1 - nju }
779 \@@_tikz_wrapper:Vnn \l_@@_curve_tl { #3 } { #4 }
780 }
781 \group_end:
782 }
783 % \end{macrocode}
784 % \end{macro}
785 %
786 % \begin{macro}{\@@_name:nnnn}
787 % 通过是否含有可选星号区分输出中英文名称。
788 % \begin{macrocode}
789 \cs_new_protected:Npn \@@_name:nnnn #1
790 {
791 \bool_if:NTF #1
792 { \@@_print:nnnn { name-en } }
793 { \@@_print:nnnn { name-zh } }
794 }
795 % \end{macrocode}
796 % \end{macro}
797 %
798 %
799 % \subsection{用户接口}
800 %
801 % \begin{macro}{\njuname,\njuname*}
802 % 定义南京大学标准名称,分为中英文两种。
803 % \begin{arguments}
804 % \item 可选星号
805 % \item 颜色或者键值对
806 % \item 宽度
807 % \item 高度
808 % \end{arguments}
809 % \begin{macrocode}
810 \@@_check_cmd:NF \njuname
811 {
812 \NewDocumentCommand \njuname { s O { njuviolet } m m }
813 { \@@_name:nnnn { #1 } { #2 } { #3 } { #4 } }
814 }
815 % \end{macrocode}
816 % \end{macro}
817 %
818 % \begin{macro}{\njuemblem}
819 % \changes{v0.1}{2021/11/24}{将学校和院系的徽标和名称命令统一。}
820 % 定义南京大学标准徽标。
821 % \begin{arguments}
822 % \item 颜色或者键值对
823 % \item 宽度
824 % \item 高度
825 % \end{arguments}
826 % \begin{macrocode}
827 \@@_check_cmd:NF \njuemblem
828 {
829 \NewDocumentCommand \njuemblem { O { njuviolet } m m }
830 { \@@_print:nnnn { emblem } { #1 } { #2 } { #3 } }
831 }
832 % \end{macrocode}
833 % \end{macro}
834 %
835 % \begin{macro}{\njumotto}
836 % 定义南京大学校训。参数定义同 \tn{njuemblem}。
837 % \begin{macrocode}
838 \@@_check_cmd:NF \njumotto
839 {
840 \NewDocumentCommand \njumotto { O { black } m m }
841 { \@@_print:nnnn { motto } { #1 } { #2 } { #3 } }
842 }
843 % \end{macrocode}
844 % \end{macro}
845 %
846 % \begin{macro}{\njuspirit}
847 % 定义南京大学校风。参数定义同 \tn{njuemblem}。
848 % \begin{macrocode}
849 \@@_check_cmd:NF \njuspirit
850 {
851 \NewDocumentCommand \njuspirit { O { black } m m }
852 { \@@_print:nnnn { spirit } { #1 } { #2 } { #3 } }
853 }
854 %</package>
855 % \end{macrocode}
856 % \end{macro}
857 %
858 %
859 % \subsection{生成文件}
860 % \changes{v0.2}{2021/11/29}{提供导出 PDF 图像的方法。}
861 %
862 % 以下文件用于生成各图案。
863 % 需要在编译命令中加入 |--shell-escape| 参数。
864 % \DoNotIndex{\FIG}
865 % \begin{macrocode}
866 %<*example>
867 \documentclass{article}
868 \usepackage{njuvisual}
869 % \end{macrocode}
870 % 使用 \pkg{tikz} 库的外置化功能生成独立的 PDF 格式矢量图。每个图标仅需绘制一次,可以减轻编译负担。
871 % \begin{macrocode}
872 \usetikzlibrary{backgrounds,external}
873 \tikzexternalize[prefix=nju-]
874 \let\FIG=\tikzsetnextfilename
875 % \end{macrocode}
876 %
877 % \subsection{颜色与图形}
878 % \label{subsec:colors-and-curves}
879 %
880 % 本部分定义标准色彩以及用于绘图的 \pkg{tikz} 路径。
881 % 由于路径本身长达数千行,故在此文档中隐去,仅保留介绍。
882 % 有兴趣的同学可以自行查阅 \file{njuvisual-curves.dtx}。
883 %
884 % 此处为 \file{njuvisual-example.tex} 文件正文的开始。
885 % 以下标注 |<example>| 的行将会进入该文件,供外置化使用。
886 % \begin{macrocode}
887 \begin{document}
888 %</example>
889 % \end{macrocode}
890 %
891 % \end{implementation}
892 %