% \iffalse meta-comment % % Copyright (C) 2021 - 2022 % by Nanjing University Linux User Group % % % It may be distributed and/or modified under the conditions of the % LaTeX Project Public License (LPPL), either version 1.3c of this % license or (at your option) any later version. The latest version % of this license is in the file % % https://www.latex-project.org/lppl.txt % % This work has the LPPL maintenance status `maintained'. % % The Current Maintainer of this work is Yu Xiong. % % This work consists of the files njuvisual.dtx, % njuvisual-emblem.dtx, % njuvisual-name.dtx, % njuvisual-motto.dtx, % njuvisual-spirit.dtx, % njuvisual-ai.dtx, % njuvisual-chem.dtx, % njuvisual-cs.dtx, % njuvisual-dii.dtx, % njuvisual-eng.dtx, % njuvisual-physics.dtx, % njuvisual-software.dtx, % njuvisual-end.dtx, % and the derived files njuvisual.ins, % njuvisual.sty, % njuvisual.pdf, % njuvisual-emblem-nju.def, % njuvisual-emblem-ai.def, % njuvisual-emblem-chem.def, % njuvisual-emblem-cs.def, % njuvisual-emblem-dii.def, % njuvisual-emblem-eng.def, % njuvisual-emblem-eng.def, % njuvisual-emblem-software.def, % njuvisual-motto-nju.def, % njuvisual-name-zh-nju.def, % njuvisual-name-en-nju.def, % njuvisual-spirit-nju.def, % njuvisual-example.tex. % % ----------------------------------------------------------------------- % % The development version of the template can be found at % % https://github.com/nju-lug/NJUVisual % % for those people who are interested. % %<*internal> \begingroup \def\NameOfLaTeXe{LaTeX2e} \expandafter\endgroup\ifx\NameOfLaTeXe\fmtname\else \csname fi\endcsname % % %<*install> \input docstrip.tex \keepsilent \askforoverwritefalse \preamble Copyright (C) 2021 - 2022 by Nanjing University Linux User Group % This file may be distributed and/or modified under the conditions of the LaTeX Project Public License, either version 1.3c of this license or (at your option) any later version. The latest version of this license is in: http://www.latex-project.org/lppl.txt and version 1.3 or later is part of all distributions of LaTeX version 2005/12/01 or later. To produce the documentation run the original source files ending with `.dtx' through XeTeX. \endpreamble \generate{ \usedir{tex/latex/njuvisual} \file{\jobname-example.tex} {\from{\jobname.dtx}{example} \from{\jobname-emblem.dtx}{example} \from{\jobname-name.dtx}{example} \from{\jobname-motto.dtx}{example} \from{\jobname-spirit.dtx}{example} \from{\jobname-ai.dtx}{example} \from{\jobname-chem.dtx}{example} \from{\jobname-cs.dtx}{example} \from{\jobname-dii.dtx}{example} \from{\jobname-eng.dtx}{example} \from{\jobname-physics.dtx}{example} \from{\jobname-software.dtx}{example} \from{\jobname-end.dtx}{example}} \file{\jobname.sty} {\from{\jobname.dtx}{package} \from{\jobname-emblem.dtx}{color} \from{\jobname-ai.dtx}{color} \from{\jobname-chem.dtx}{color} \from{\jobname-cs.dtx}{color} \from{\jobname-dii.dtx}{color} \from{\jobname-eng.dtx}{color} \from{\jobname-physics.dtx}{color} \from{\jobname-software.dtx}{color}} \nopreamble\nopostamble \file{\jobname-emblem-nju.def} {\from{\jobname-emblem.dtx}{emblem-nju}} \file{\jobname-name-zh-nju.def} {\from{\jobname-name.dtx}{name-zh-nju}} \file{\jobname-name-en-nju.def} {\from{\jobname-name.dtx}{name-en-nju}} \file{\jobname-motto-nju.def} {\from{\jobname-motto.dtx}{motto-nju}} \file{\jobname-spirit-nju.def} {\from{\jobname-spirit.dtx}{spirit-nju}} \file{\jobname-emblem-ai.def} {\from{\jobname-ai.dtx}{emblem-ai}} \file{\jobname-emblem-chem.def} {\from{\jobname-chem.dtx}{emblem-chem}} \file{\jobname-emblem-cs.def} {\from{\jobname-cs.dtx}{emblem-cs}} \file{\jobname-emblem-dii.def} {\from{\jobname-dii.dtx}{emblem-dii}} \file{\jobname-emblem-eng.def} {\from{\jobname-eng.dtx}{emblem-eng}} \file{\jobname-emblem-physics.def} {\from{\jobname-physics.dtx}{emblem-physics}} \file{\jobname-emblem-software.def} {\from{\jobname-software.dtx}{emblem-software}} %<*internal> \usedir{source/latex/njuvisual} \file{\jobname.ins} {\from{\jobname.dtx}{install}} % } \obeyspaces \Msg{*************************************************************} \Msg{* *} \Msg{* To finish the installation you have to move the following *} \Msg{* files into a directory searched by TeX: *} \Msg{* *} \Msg{* The recommended directory is TDS:tex/latex/njuvisual *} \Msg{* *} \Msg{* njuvisual.ins *} \Msg{* njuvisual.sty *} \Msg{* njuvisual-emblem-nju.def, *} \Msg{* njuvisual-emblem-ai.def, *} \Msg{* njuvisual-emblem-chem.def, *} \Msg{* njuvisual-emblem-cs.def, *} \Msg{* njuvisual-emblem-dii.def, *} \Msg{* njuvisual-emblem-eng.def, *} \Msg{* njuvisual-emblem-eng.def, *} \Msg{* njuvisual-emblem-software.def, *} \Msg{* njuvisual-motto-nju.def, *} \Msg{* njuvisual-name-zh-nju.def, *} \Msg{* njuvisual-name-en-nju.def, *} \Msg{* njuvisual-spirit-nju.def, *} \Msg{* *} \Msg{* To produce the documentation, run the file njuvisual.dtx *} \Msg{* through XeLaTeX. *} \Msg{* *} \Msg{* Happy TeXing! *} \Msg{* *} \Msg{*************************************************************} \endbatchfile % % %<*internal> \fi % % %\NeedsTeXFormat{LaTeX2e} %\GetIdInfo $Id: njuvisual.dtx 0.3.0 2022-12-13 18:00:00 % +0800 NJU LUG $ % {Nanjing University Visual Identity} %\ProvidesExplPackage{njuvisual} % {\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription} % %<*driver> \documentclass[fontset=fandol]{ctxdoc} \usepackage{listings,njuvisual,tabularray,zhlineskip} \usepackage[firstpage=true]{background} \backgroundsetup{contents={\njuemblem[white!85!gray]{22cm}{!}},scale=1,angle=0,hshift=-4cm} \DeclareGraphicsExtensions{.pdf} \UseTblrLibrary{booktabs,siunitx,diagbox} \DefTblrTemplate{caption-tag}{default}{表\hspace{0.25em}\thetable} \SetTblrStyle{caption-tag}{font=\bfseries} \DefTblrTemplate{caption-sep}{default}{\quad} \setlist[1]{labelindent=0.5em} \hypersetup{ pdftitle={ The njuvisual package - Display logos related to Nanjing University }, citecolor = njublue, linkcolor = njuviolet, urlcolor = njumagenta } \SetTextEnvironmentSinglespace{1.112} \SetMathEnvironmentSinglespace{1.112} \setsansfont{LexendDeca} \setmonofont{Iosevka}[ UprightFont = Iosevka Light, ItalicFont = Iosevka Light Italic, BoldFont = Iosevka Semibold ] \setCJKmainfont{Source Han Serif SC}[ UprightFont = Source Han Serif SC SemiBold, ItalicFont = Source Han Serif SC Bold, BoldFont = Source Han Serif SC Heavy, Language = Chinese Simplified ] \setmathfont{XITSMath-Regular}[ BoldFont = XITSMath-Bold, Extension = .otf] \lstdefinestyle{style@base} { basewidth = 0.5 em, gobble = 3, lineskip = 3 pt, frame = l, framerule = 1 pt, framesep = 0 pt, xleftmargin = 2 em, xrightmargin = 3 em, escapeinside = {(*}{*)}, breaklines = true, basicstyle = \small\ttfamily, keywordstyle = \bfseries\color{njuviolet}, commentstyle = \itshape\color{white!50!gray}, stringstyle = \color{nju-chem-red}, backgroundcolor = \color{white!95!gray} } \lstdefinestyle{style@shell} { style = style@base, rulecolor = \color{njumagenta}, language = bash, alsoletter = {-}, emphstyle = \color{green} } \lstdefinestyle{style@latex} { style = style@base, rulecolor = \color{njublue}, language = [LaTeX]TeX, alsoletter = {*, -}, texcsstyle = *\color{njuviolet}, emphstyle = [1]\color{nju-ai-orange}, emphstyle = [2]\color{nju-cs-green}, } \lstnewenvironment{shellexample}[1][]{% \lstset{style=style@shell, #1}}{} \lstnewenvironment{latexexample}[1][]{% \lstset{style=style@latex, #1}}{} \ExplSyntaxOn \cs_new_protected:Npn \__njudoc_module_angle:Nn #1#2 { \group_begin: \color { gray } \ttfamily \textlangle \group_end: \group_begin: \sffamily #2 \group_end: \group_begin: \color { gray } #1 \ttfamily \textrangle \group_end: } \cs_set_protected:Npn \__ctxdoc_module_angle:n #1 { \__njudoc_module_angle:Nn \c_empty_tl {#1} } \ExplSyntaxOff \begin{document} \DocInput{njuvisual.dtx} \DocInput{njuvisual-emblem.dtx} \DocInput{njuvisual-name.dtx} \DocInput{njuvisual-motto.dtx} \DocInput{njuvisual-spirit.dtx} \DocInput{njuvisual-ai.dtx} \DocInput{njuvisual-chem.dtx} \DocInput{njuvisual-cs.dtx} \DocInput{njuvisual-dii.dtx} \DocInput{njuvisual-eng.dtx} \DocInput{njuvisual-physics.dtx} \DocInput{njuvisual-software.dtx} \DocInput{njuvisual-end.dtx} \PrintChanges \PrintIndex \end{document} % % % \fi % % \title{\color{njuviolet}{^^A % The \pkg{njuvisual} package \\ \textbf{南京大学视觉形象规范化标准}}} % % \author{^^A % 南京大学 Linux 用户组 % \thanks{E-mail: \href{mailto:git+nju-lug-email-3104-issue-@yaoge123.cn}{git+nju-lug-email-3104-issue-@yaoge123.cn}}} % % \date{v0.3.0 \quad 2022-12-13} % % \changes{v0.1}{2021/11/21}{将 \pkg{njuvisual} 分离为独立宏包。} % \changes{v0.1}{2021/11/27}{完成文档编写并发布至 CTAN。} % \changes{v0.1}{2021/11/28}{使用 GitHub Action 进行自动打包发布。} % \changes{v0.3}{2022/12/08}{将贝塞尔曲线存储到单独文件。} % % \maketitle % % \let\abstractname\relax % \begin{abstract} % 南京大学视觉形象规范化标准(\pkg{njuvisual})宏包负责收集南京大学官方以及下属 % 各院系制定的配色方案和标识,将这些矢量图标通过 \pkg{tikz} 曲线进行存储,并提 % 供简明的接口以便在文档和幻灯片中使用。 % \end{abstract} % % \begin{abstract} % The \pkg{njuvisual} package collects standard colors and logos related to % Nanjing University, saves the vector logos as \pkg{tikz} pictures and % provides a user-friendly interface to display them in documents and beamers. % \end{abstract} % % \clearpage % % \tableofcontents % % % \begin{documentation} % % \section{宏包介绍} % % \pkg{njuvisual} 用于收录南京大学及其各院系制定的标准色彩及图标,并提供简洁的绘制指令。 % % 本宏包衍生自 \cls{njuthesis},依赖 \hologo{LaTeX3} 项目 % 中的 \pkg{expl3}、\pkg{xparse} 和 \pkg{l3keys2e} 宏包。 % 特别感谢 \cls{fduthesis} 与 \pkg{zhlipsum} 提供的处理思路。 % % 欲使用本宏包,在终端键入下述 \pkg{tlmgr} 的命令(很可能需要管理员权限): % \begin{shellexample}[morekeywords={tlmgr,install}] % tlmgr install njuvisual % \end{shellexample} % 即可完成安装。 % % % \section{宏包选项} % % \begin{function}{force} % 使用强制模式载入宏包。 % \end{function} % % 在强制模式下,\pkg{njuvisual} 将覆盖已有的 \cs{njuemblem}、 % \cs{njuname}、\cs{njuspirit}、\cs{njumotto} 命令定义。 % % % \section{使用方法} % % 本节提供命令的使用方法。关于绘制的内容,请参阅后文的 \ref{subsec:colors-and-curves}。 % % \subsection{标准色彩} % % \begin{function}{\color} % \begin{syntax} % \tn{color}\Arg{颜色} % \end{syntax} % 使用标准色彩。 % \end{function} % % 本宏包定义的所有标准色彩见表~\ref{tab:pre-defined-colors}。 % \begingroup % \def\B#1{\color{#1}$\blacksquare\blacksquare\blacksquare\blacksquare\blacksquare$} % \begin{table}[htb] % \caption{预定义标准色} \label{tab:pre-defined-colors} % \centering % \begin{tblr}[expand=\B]{cccc} % \toprule % 名称 & 颜色名称 & CMYK 数值 & 示例 \\ % \midrule % \SetCell[r=5]{c} 南京大学 % & |njuviolet| & \SetCell[r=2]{c} % $0.50, 1 , 0 , 0.40$ & % \SetCell[r=2]{c} \B{njuviolet} \\ % & |njupurple| & & \\ % & |njumagenta| & $0.05, 1 , 0.55, 0 $ & \B{njumagenta} \\ % & |njublue| & $0.80, 0.50, 0 , 0 $ & \B{njublue} \\ % & |njuyellow| & $0 , 0.30, 1 , 0 $ & \B{njuyellow} \\ % \SetCell[r=2]{c} 人工智能学院 % & |nju-ai-blue| & $0.75, 0.65, 0 , 0 $ & \B{nju-ai-blue} \\ % & |nju-ai-orange| & $0 , 0.75, 1 , 0 $ & \B{nju-ai-orange} \\ % \SetCell[r=2]{c} 计算机科学与技术系 % & |nju-cs-blue| & $0.89, 0.66, 0.13, 0 $ & \B{nju-cs-blue} \\ % & |nju-cs-green| & $0.60, 0.23, 1 , 0 $ & \B{nju-cs-green} \\ % \SetCell[r=2]{c} 化学化工学院 % & |nju-chem-red| & $0.28, 0.95, 0.84, 0 $ & \B{nju-chem-red} \\ % & |nju-chem-gold| & $0.40, 0.42, 0.60, 0 $ & \B{nju-chem-gold} \\ % 物理学院 % & |nju-physics-blue| & $0.86, 0.57, 0 , 0 $ & \B{nju-physics-blue} \\ % \bottomrule % \end{tblr} % \end{table} % \endgroup % % % \subsection{标准图标} % % \begin{function}[added=2021-09-24,updated=2021-11-27]{\njuemblem} % \begin{syntax} % \tn{njuemblem}\oarg{选项}\Arg{宽度}\Arg{高度} % \end{syntax} % 生成徽标,默认生成校徽。参数 \oarg{选项} 是可选的,详见下文说明。注意各 % 参数之间不可以有空格。 % \end{function} % % \begin{function}[added=2021-09-24,updated=2021-11-27]{\njuname,\njuname*} % \begin{syntax} % \tn{njuname}\oarg{选项}\Arg{宽度}\Arg{高度} % \tn{njuname*}\oarg{选项}\Arg{宽度}\Arg{高度} % \end{syntax} % 生成名称,带有可选星号的命令会生成英文名称,默认生成校名。要求同上。 % \end{function} % % 可选参数 \meta{选项} 可使用两种方式给出: % \begin{itemize} % \item 颜色名称,使用颜色名称即默认生成校徽、校名 % \item 使用英文半角逗号分隔的键值列表 % \end{itemize} % % 其中,键值列表支持的选项见下。 % % \begin{function}[added=2021-11-27]{color,color*} % \begin{syntax} % color = \meta{主要颜色} % color* = \meta{辅助颜色} % \end{syntax} % 定制图标颜色。 % \end{function} % % 对于绝大多数南京大学院系,其图标仅使用两种以内的颜色,因此本宏包仅提供两种颜色选项。 % 其中的 |color*| 选项一般无需修改,原因在于现有的图标可被总结为下列若干种情况: % \begin{description} % \item[纯色、透明底色] 如南大校名,无辅助颜色,|color*| 选项无效 % \item[纯色、白色底色] 如现工徽标,辅助颜色默认为白色,无需进行修改 % \item[双色] 如计科徽标,主要颜色、辅助颜色已预先进行定义,为美观考虑,修改主要颜色时会将图标颜色统一为一种 % \end{description} % 对于中空的图标,本宏包默认在内部空间填充白色(即上述第二种情况),以在复杂背景下保证图标的辨识度。遗憾的是,\pkg{xcolor} 并不能将某种颜色设置为透明。因此,如果希望实现类似于中空的效果,可以从背景中选取一种突出的颜色设为 |color*|。 % % \begin{function}[added=2021-11-27]{department} % \begin{syntax} % department = \meta{院系名称} % \end{syntax} % 院系名称。 % \end{function} % % 为保证无歧义,|department| 选项使用的名称来自于院系官网域名。如化学化工学院域名为 \url{https://chem.nju.edu.cn/},其选项名称即为 |chem|。 % % 目前的支持情况如表~\ref{tab:supported-departments-list}所示。对于不支持的院系,本宏包会抛出异常。 % \begingroup % \def\B{\bullet} % \begin{table}[htb] % \caption{收录院系列表} \label{tab:supported-departments-list} % \centering\small % \begin{tblr}[expand=\B]{cccccccc} % \toprule % 名称 & 选项名称 & emblem & name & name* \\ % \midrule % 人工智能学院 & |ai| & \B & & \\ % 计算机科学与技术系 & |cs| & \B & & \\ % 匡亚明学院 & |dii| & \B & & \\ % 现代工程与应用科学学院 & |eng| & \B & & \\ % 物理学院 & |physics| & \B & & \\ % 软件学院 & |software| & \B & & \\ % \bottomrule % \end{tblr} % \end{table} % \endgroup % % 对这两个命令的举例如下: % \begin{latexexample}[moretexcs={\njuemblem,\njuname,\njuname*}] % \njuemblem{!}{3cm} % 生成指定大小的紫色南大校徽 % \njuname{4cm}{!} % 生成指定大小的紫色南大中文校名 % \njuname*{4cm}{!} % 生成指定大小的紫色南大英文校名 % \njuemblem[black]{!}{3cm} % 黑色的南大校徽 % \njuemblem[department=dii]{!}{4cm} % 紫色匡院徽标 % \njuemblem[department=cs,color=blue]{!}{3cm} % 纯蓝色计科徽标 % \end{latexexample} % % \begin{function}[added=2021-09-24]{\njumotto} % \begin{syntax} % \tn{njumotto}\oarg{颜色}\Arg{宽度}\Arg{高度} % \end{syntax} % 生成指定颜色和大小的南京大学校训。 % \end{function} % % \begin{function}[added=2021-09-24]{\njuspirit} % \begin{syntax} % \tn{njuspirit}\oarg{颜色}\Arg{宽度}\Arg{高度} % \end{syntax} % 生成指定颜色和大小的南京大学校风。 % \end{function} % % % \subsection{导出图像} % \changes{v0.2}{2021/12/04}{提供导出 PNG 图像的方法。} % % 为了便于存储独立的图像,本宏包内置了 \file{njuvisual-example.tex},使用 \pkg{tikz} 的外置化功能生成独立的图片文件。编译此文件时需使用 |--shell-escape| 参数。 % % 对于大部分日常用途,PDF 格式的矢量图并没有受到良好的支持。在此提供将上述独立图像通过 inkscape 程序进行转换的方法,相应的自动转换脚本请从项目仓库内获取。关于命令行使用方法的请参考\href{https://inkscape.org/doc/inkscape-man.html}{官方手册}。 % \begin{description} % \item[|--export-type=|] 指定输出格式,|"png"| 即可,不支持 JPEG 格式。 % \item[|-w|] 指定输出宽度。 % \item[|-h|] 指定输出高度。 % \end{description} % % 以下为在 Linux 系统中将当前目录下全部 PDF 文件转化为高度为1000像素的 PNG 图片的命令示例。 % \begin{shellexample}[morekeywords={inkscape}] % inkscape --export-type="png" nju-*.pdf -h 1000 % \end{shellexample} % % 以下为在 Windows 系统的 Powershell 中将南大校名转化为 PNG 图片的命令示例。 % \begin{shellexample} % & 'C:\Program Files (x86)\Inkscape\bin\inkscape.exe' --export-type="png" nju-name.pdf % \end{shellexample} % % \end{documentation} % % % \begin{implementation} % % \section{实现细节} % % \begin{macrocode} %<@@=njuvis> %<*package> % \end{macrocode} % % \subsection{载入宏包} % % 导入所需宏包,其中 \pkg{tikz} 已包含 \pkg{xcolor},无需单独加载。 % \begin{macrocode} \RequirePackage { l3keys2e, tikz} % \end{macrocode} % % \subsection{定义变量} % % \begin{macro}{\l_@@_color_a_tl,\l_@@_color_b_tl} % 存储使用的颜色。 % \begin{macrocode} \tl_new:N \l_@@_color_a_tl \tl_new:N \l_@@_color_b_tl % \end{macrocode} % \end{macro} % % \begin{macro}{\l_@@_dept_tl} % 存储院系。 % \begin{macrocode} \tl_new:N \l_@@_dept_tl % \end{macrocode} % \end{macro} % % \begin{macro}{\l_@@_curve_tl} % 存储使用的贝塞尔曲线路径。 % \begin{macrocode} \tl_new:N \l_@@_curve_tl % \end{macrocode} % \end{macro} % % \begin{variable}{\c_@@_cmds_clist} % 本宏包定义的全部用户命令。 % \begin{macrocode} \clist_const:Nn \c_@@_cmds_clist { emblem, name, motto, spirit } % \end{macrocode} % \end{variable} % % \begin{variable}{\c_@@_dept_all_clist} % 定义南京大学全体院系名单。 % \begin{macrocode} \clist_const:Nn \c_@@_dept_all_clist { nju, dii, eng, chin, history, philo, jc, law, nubs, sfs, im, sociology, math, physics, astronomy, chem, cs, software, ai, ese, hjxy, sgos, as, life, med, sme, hwxy, arch, marxism, art, edu } % \end{macrocode} % \end{variable} % % \begin{variable}{\c_@@_dept_emblem_clist} % 定义受图标支持的南京大学院系名单。 % \begin{macrocode} \clist_const:Nn \c_@@_dept_emblem_clist { nju, ai, cs, chem, dii, eng, physics, software } % \end{macrocode} % \end{variable} % % \begin{variable}{\c_@@_dept_name_clist} % 定义受名称支持的南京大学院系名单。 % \begin{macrocode} \clist_const:Nn \c_@@_dept_name_clist { nju } % \end{macrocode} % \end{variable} % % \begin{variable}{\c_@@_dept_color_clist} % 定义受色彩支持的南京大学院系名单。 % \begin{macrocode} \clist_const:Nn \c_@@_dept_color_clist { ai, cs, chem, physics } % \end{macrocode} % \end{variable} % % \subsection{错误信息} % % 集中定义错误信息。 % \begin{macrocode} \msg_new:nnn { njuvisual } { unsupported-department } { "#1"~ is~ not~ an~ available~ option~ currently.\\ Please~ refer~ to~ the~ package~ documentation~ for~ supported~ departments~ and~ check~ your~ spelling. } \msg_new:nnn { njuvisual } { force-mode } { Force~ mode~ on.\\ I~ am~ overwriting~ all~ existing~ commands. } \msg_new:nnn { njuvisual } { duplicate-command } { The~ command~ "\string#1"~ is~ already~ defined.\\ I~ am~ not~ going~ to~ redefine~ it~ anyway.~ Or~ you~ can~ use~ the~ package~ option~ "force"~ to~ overwrite~ existing~ definitions. } % \end{macrocode} % % \subsection{宏包选项} % % \changes{v0.1}{2022/03/01}{新增选项 \opt{force}。} % \begin{macrocode} \keys_define:nn { njuvisual } { % \end{macrocode} % \begin{macro}{force} % 是否强制定义。 % \begin{macrocode} force .value_forbidden:n = true, force .code:n = { \msg_warning:nn { njuvisual } { force-mode } \clist_map_inline:Nn \c_@@_cmds_clist { \cs_undefine:c { nju ##1 } } } } % \end{macrocode} % \end{macro} % % \begin{macrocode} \ProcessKeysOptions { njuvisual } % \end{macrocode} % % \subsection{内部命令} % % \changes{v0.1}{2021/11/27}{使用键值对处理院系和颜色。} % \begin{macrocode} \keys_define:nn { njuvisual } { % \end{macrocode} % \begin{macro}{color,color*} % 颜色。设定主要色彩的初始值为 |default|,辅助色彩的初始值为白色。 % \begin{macrocode} color .tl_set:N = \l_@@_color_a_tl, color .initial:n = default, color* .tl_set:N = \l_@@_color_b_tl, color* .initial:n = white, % \end{macrocode} % \end{macro} % % \begin{macro}{department} % 院系。设定院系选项初始值为学校官方。 % \begin{macrocode} department .tl_set:N = \l_@@_dept_tl, department .initial:n = nju, } % \end{macrocode} % \end{macro} % % \begin{macro}{\@@_set_color:} % \changes{v0.1}{2021/11/25}{完善设定颜色的方法。} % 设定颜色。 % \begin{macrocode} \cs_new_protected:Nn \@@_set_color: { \str_if_eq:VnTF \l_@@_color_a_tl { default } { % \end{macrocode} % 如果没有单独设定,则使用默认颜色。 % \begin{macrocode} \clist_if_in:NVTF \c_@@_dept_color_clist \l_@@_dept_tl { \tl_set:Nn \l_@@_color_a_tl { \clist_item:cn { c_@@_color_ \l_@@_dept_tl _clist } { 1 } } \tl_set:Nn \l_@@_color_b_tl { \clist_item:cn { c_@@_color_ \l_@@_dept_tl _clist } { 2 } } } { \tl_set:Nn \l_@@_color_a_tl { njuviolet } } } { \clist_if_in:NVT \c_@@_dept_color_clist \l_@@_dept_tl % \end{macrocode} % 将双色图标设定为纯色。 % \begin{macrocode} { \tl_set_eq:NN \l_@@_color_b_tl \l_@@_color_a_tl } } } % \end{macrocode} % \end{macro} % % \begin{macro}{\@@_tikz_wrapper:nnn,\@@_tikz_wrapper:Vnn} % 可变大小的 tikz 容器。\footnote{此处手动调整了列表缩进,实际上\env{arguments}环境的缩进问题已在\href{https://github.com/CTeX-org/ctex-kit/commit/838ebab8378b6b0477f5aece81ace28ae2a8bcd9}{838ebab}提交中修复} % \begin{arguments} % \item 路径 % \item 宽度 % \item 高度 % \end{arguments} % 封装 resizebox 和 tikzpicture 环境,减少重复。 % ^^A 考虑转换到 \box_autosize_to_wd_and_ht:Nnn % \begin{macrocode} \cs_new_protected:Npn \@@_tikz_wrapper:nnn #1#2#3 { \resizebox { #2 } { #3 } { \begin{tikzpicture}[y=0.80pt, x=0.80pt, yscale=-1, xscale=1, inner~sep=0pt, outer~sep=0pt] #1 \end{tikzpicture} } } \cs_generate_variant:Nn \@@_tikz_wrapper:nnn { V } % \end{macrocode} % \end{macro} % % \begin{macro}{\@@_if_key_value_list:nTF} % 判断是否为键值列表,即是否含有 |=|。 % \begin{macrocode} \cs_new_protected:Npn \@@_if_key_value_list:nTF #1 { \tl_if_in:nnTF {#1} {=} } % \end{macrocode} % \end{macro} % % \begin{macro}{\@@_check_cmd:NF} % 检查载入宏包前相关命令是否有定义。 % \begin{macrocode} \cs_new_protected:Npn \@@_check_cmd:NF #1 { \cs_if_exist:NTF #1 { \msg_warning:nnn { njuvisual } { duplicate-command } {#1} } } % \end{macrocode} % \end{macro} % % \begin{macro}{\@@_import_curve:nF,\@@_import_curve:n} % 从相应的 \file{njuvisual-*.def} 文件读取内容,存储到 \cs{l_@@_curve_tl}。 % \begin{macrocode} \cs_new:Npn \@@_import_curve:nF #1 { \file_get:nnNF { njuvisual- #1 .def } { \ExplSyntaxOn } \l_@@_curve_tl } \cs_new:Npn \@@_import_curve:n #1 { \@@_import_curve:nF {#1} { \BOOM } } % \end{macrocode} % \end{macro} % % \begin{macro}{\@@_print:nnnn} % 输出 \pkg{tikz} 曲线。 % \begin{arguments} % \item 类别 % \item 颜色或者键值对 % \item 宽度 % \item 高度 % \end{arguments} % \begin{macrocode} \cs_new_protected:Npn \@@_print:nnnn #1#2#3#4 { \group_begin: % \end{macrocode} % 根据参数是否含有 |=| 来判断该参数是颜色还是选项列表。 % \begin{macrocode} \@@_if_key_value_list:nTF { #2 } { \keys_set:nn { njuvisual } { #2 } % \end{macrocode} % 检查是否受支持。 % \begin{macrocode} \@@_import_curve:nF { #1 - \l_@@_dept_tl } { \msg_error:nnx { njuvisual } { unsupported-department } { \l_@@_dept_tl } } \@@_set_color: \@@_tikz_wrapper:Vnn \l_@@_curve_tl { #3 } { #4 } } % \end{macrocode} % 单独设置颜色时输出官方徽标。 % \begin{macrocode} { \tl_set:Nn \l_@@_color_a_tl { #2 } \@@_import_curve:n { #1 - nju } \@@_tikz_wrapper:Vnn \l_@@_curve_tl { #3 } { #4 } } \group_end: } % \end{macrocode} % \end{macro} % % \begin{macro}{\@@_name:nnnn} % 通过是否含有可选星号区分输出中英文名称。 % \begin{macrocode} \cs_new_protected:Npn \@@_name:nnnn #1 { \bool_if:NTF #1 { \@@_print:nnnn { name-en } } { \@@_print:nnnn { name-zh } } } % \end{macrocode} % \end{macro} % % % \subsection{用户接口} % % \begin{macro}{\njuname,\njuname*} % 定义南京大学标准名称,分为中英文两种。 % \begin{arguments} % \item 可选星号 % \item 颜色或者键值对 % \item 宽度 % \item 高度 % \end{arguments} % \begin{macrocode} \@@_check_cmd:NF \njuname { \NewDocumentCommand \njuname { s O { njuviolet } m m } { \@@_name:nnnn { #1 } { #2 } { #3 } { #4 } } } % \end{macrocode} % \end{macro} % % \begin{macro}{\njuemblem} % \changes{v0.1}{2021/11/24}{将学校和院系的徽标和名称命令统一。} % 定义南京大学标准徽标。 % \begin{arguments} % \item 颜色或者键值对 % \item 宽度 % \item 高度 % \end{arguments} % \begin{macrocode} \@@_check_cmd:NF \njuemblem { \NewDocumentCommand \njuemblem { O { njuviolet } m m } { \@@_print:nnnn { emblem } { #1 } { #2 } { #3 } } } % \end{macrocode} % \end{macro} % % \begin{macro}{\njumotto} % 定义南京大学校训。参数定义同 \tn{njuemblem}。 % \begin{macrocode} \@@_check_cmd:NF \njumotto { \NewDocumentCommand \njumotto { O { black } m m } { \@@_print:nnnn { motto } { #1 } { #2 } { #3 } } } % \end{macrocode} % \end{macro} % % \begin{macro}{\njuspirit} % 定义南京大学校风。参数定义同 \tn{njuemblem}。 % \begin{macrocode} \@@_check_cmd:NF \njuspirit { \NewDocumentCommand \njuspirit { O { black } m m } { \@@_print:nnnn { spirit } { #1 } { #2 } { #3 } } } % % \end{macrocode} % \end{macro} % % % \subsection{生成文件} % \changes{v0.2}{2021/11/29}{提供导出 PDF 图像的方法。} % % 以下文件用于生成各图案。 % 需要在编译命令中加入 |--shell-escape| 参数。 % \DoNotIndex{\FIG} % \begin{macrocode} %<*example> \documentclass{article} \usepackage{njuvisual} % \end{macrocode} % 使用 \pkg{tikz} 库的外置化功能生成独立的 PDF 格式矢量图。每个图标仅需绘制一次,可以减轻编译负担。 % \begin{macrocode} \usetikzlibrary{backgrounds,external} \tikzexternalize[prefix=nju-] \let\FIG=\tikzsetnextfilename % \end{macrocode} % % \subsection{颜色与图形} % \label{subsec:colors-and-curves} % % 本部分定义标准色彩以及用于绘图的 \pkg{tikz} 路径。 % 由于路径本身长达数千行,故在此文档中隐去,仅保留介绍。 % 有兴趣的同学可以自行查阅 \file{njuvisual-curves.dtx}。 % % 此处为 \file{njuvisual-example.tex} 文件正文的开始。 % 以下标注 || 的行将会进入该文件,供外置化使用。 % \begin{macrocode} \begin{document} % % \end{macrocode} % % \end{implementation} %