diff options
Diffstat (limited to 'macros/latex/contrib/njuvisual/njuvisual.dtx')
-rw-r--r-- | macros/latex/contrib/njuvisual/njuvisual.dtx | 567 |
1 files changed, 567 insertions, 0 deletions
diff --git a/macros/latex/contrib/njuvisual/njuvisual.dtx b/macros/latex/contrib/njuvisual/njuvisual.dtx new file mode 100644 index 0000000000..8d2831c9c2 --- /dev/null +++ b/macros/latex/contrib/njuvisual/njuvisual.dtx @@ -0,0 +1,567 @@ +% \iffalse meta-comment +% +% Copyright (C) 2021 +% by Nanjing University Linux User Group <nju.lug@yaoge123.cn> +% +% 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 +% +% ----------------------------------------------------------------------- +% +% The development version of the template can be found at +% +% https://github.com/nju-lug/NJUVisual +% +% for those people who are interested. +% +% ----------------------------------------------------------------------- +% +%<*internal> +\iffalse +%</internal> +% +%<*internal> +\fi +\begingroup + \def\NameOfLaTeXe{LaTeX2e} +\expandafter\endgroup\ifx\NameOfLaTeXe\fmtname\else +\csname fi\endcsname +%</internal> +% +%<*install> +\input l3docstrip.tex +\keepsilent +\askforoverwritefalse + +\preamble + +Copyright (C) 2021 +by Nanjing University Linux User Group <nju.lug@yaoge123.cn> + +This file may be distributed and/or modified under the conditions of +the LaTeX Project Public License, either version 1.3 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.sty} {\from{\jobname.dtx}{visual} + \from{\jobname-curves.dtx}{visual}} +%</install> +%<*internal> + \usedir{source/latex/njuvisual} + \file{\jobname.ins} {\from{\jobname.dtx}{install}} +%</internal> +%<*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{* *} +\Msg{* To produce the documentation, run the file njuvisual.dtx *} +\Msg{* through XeLaTeX. *} +\Msg{* *} +\Msg{* Happy TeXing! *} +\Msg{* *} +\Msg{*************************************************************} + +\endbatchfile +%</install> +% +%<*internal> +\fi +%</internal> +% +%<visual>\NeedsTeXFormat{LaTeX2e} +%<visual>\RequirePackage{expl3} +%<!driver>\GetIdInfo $Id: njuvisual.dtx 0.1.1 2021-11-27 22:30:00 +0800 NJU LUG <nju.lug@yaoge123.cn> $ +%<visual> { LaTeX3 Package for NJU Visual Identity } +%<visual>\ProvidesExplPackage{njuvisual} +%<visual>{\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription} +% +%<*driver> +\documentclass{ctxdoc} +\usepackage{multirow,njuvisual} +\setlist[1]{labelindent=0.5em} +\begin{document} + \DocInput{njuvisual.dtx} + \DocInput{njuvisual-curves.dtx} + \PrintChanges + \PrintIndex +\end{document} +%</driver> +% +% \fi +% +% \title{\color{njuviolet}{The \pkg{njuvisual} package\\ 南京大学视觉形象规范化标准}} +% +% \author{^^A +% Nanjing University Linux User Group +% \thanks{E-mail: \href{mailto:nju.lug@yaoge123.cn}{nju.lug@yaoge123.cn}}} +% +% \date{v0.1.1 \\ Released 2021-11-21} +% +% \changes{v0.1}{2021/11/21}{将\pkg{njuvisual}分离为单独宏包。} +% \changes{v0.1}{2021/11/27}{完成文档编写并发布至 CTAN。} +% +% \maketitle +% +% \begin{abstract} +% 南京大学视觉形象规范化标准(\pkg{njuvisual})宏包负责实现\href{https://www.nju.edu.cn/3647/list.htm}{南京大学视觉形象规范化标准}以及各院系制定的配色方案和标识。 +% \end{abstract} +% +% \def\abstractname{Abstract} +% \begin{abstract} +% The \pkg{njuvisual} package provides an interface to display logos related to Nanjing University. +% \end{abstract} +% +% \clearpage +% +% \tableofcontents +% +% \EnableDocumentation +% +% +% \begin{documentation} +% +% \section{宏包介绍} +% +% \pkg{njuvisual} 用于收录南京大学及其各院系制定的标准色彩及图标,并提供简洁的绘制指令。 +% +% 本宏包衍生自 \pkg{njuthesis},依赖 \hologo{LaTeX3} 项目 +% 中的 \pkg{expl3}、\pkg{xparse} 和 \pkg{l3keys2e} 宏包。 +% 特别感谢 \pkg{fduthesis} 与 \pkg{zhlipsum} 提供的处理思路。 +% +% \section{使用方法} +% +% \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$} +% \def\M#1{\multirow{2}*{#1}} +% \def\MN#1{\multirow{4}*{#1}} +% \begin{table}[htb] +% \caption{预定义标准色} \label{tab:pre-defined-colors} +% \centering\small +% \begin{tabular}{cccc} +% \toprule +% 名称 & 颜色名称 & CMYK 数值 & 示例 \\ +% \midrule +% \MN{南京大学} & |njuviolet| & $0.50, 1 , 0 , 0.40$ & \B{njuviolet} \\ +% & |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} \\ +% \M{人工智能学院} & |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} \\ +% \M{计算机科学与技术系} & |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} \\ +% \bottomrule +% \end{tabular} +% \end{table} +% \endgroup +% +% \subsection{标准图标} +% +% \begin{function}[added=2021-09-24,updated=2021-11-27]{\njuemblem} +% \begin{syntax} +% \tn{njuemblem}\oarg{选项}\Arg{宽度}\Arg{高度} +% \end{syntax} +% 生成徽标,默认生成校徽。参数 \meta{选项} 是可选的。注意各 +% 参数之间不可以有空格。 +% \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} +% +% \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{tabular}{cccccccc} +% \toprule +% 名称 & 选项名称 & emblem & name & name* \\ +% \midrule +% 匡亚明学院 & |dii| & \B & & \\ +% 现代工程与应用科学学院 & |eng| & \B & & \\ +% 人工智能学院 & |ai| & \B & & \\ +% 计算机科学与技术系 & |cs| & \B & & \\ +% \bottomrule +% \end{tabular} +% \end{table} +% \endgroup +% +% 举例如下: +% \begin{ctexexam} +% \njuemblem{!}{3cm} % 默认生成指定大小的紫色南大校徽 +% \njuname{4cm}{!} % 默认生成指定大小的紫色南大中文校名 +% \njuname*{4cm}{!} % 默认生成指定大小的紫色南大英文校名 +% \njuemblem[black]{!}{3cm} % 黑色的南大校徽 +% \njuemblem[department=dii]{!}{4cm} % 紫色匡院徽标 +% \njuemblem[department=cs,color=blue]{!}{3cm} % 纯蓝色计科徽标 +% \end{ctexexam} +% +% +% \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} +% +% \end{documentation} +% +% \EnableImplementation +% +% \begin{implementation} +% +% \section{实现细节} +% +% \begin{macrocode} +%<@@=njuvis> +%<*visual> +% \end{macrocode} +% +% \subsection{载入宏包} +% +% 导入 \pkg{tikz} 宏包,其中已包含 \pkg{xcolor},无需单独加载。 +% \begin{macrocode} +\RequirePackage { 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_@@_department_tl} +% 存储院系 +% \begin{macrocode} +\tl_new:N \l_@@_department_tl +% \end{macrocode} +% \end{macro} +% +% \changes{v0.1}{2021/11/27}{使用键值对处理院系和颜色。} +% \begin{macrocode} +\keys_define:nn { njuvisual } + { +% \end{macrocode} +% \begin{macro}{color,color*} +% 颜色。设定初始辅助色为白色 +% \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_@@_department_tl, + department .initial:n = nju, + } +% \end{macrocode} +% \end{macro} +% +% \begin{variable}{\c_@@_department_all_clist} +% 定义南京大学全体院系名单。 +% \begin{macrocode} +\clist_const:Nn \c_@@_department_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_@@_department_emblem_clist} +% 定义受图标支持的南京大学院系名单。 +% \begin{macrocode} +\clist_const:Nn \c_@@_department_emblem_clist { nju, dii, eng, cs, ai } +% \end{macrocode} +% \end{variable} +% +% \begin{variable}{\c_@@_department_name_clist} +% 定义受名称支持的南京大学院系名单。 +% \begin{macrocode} +\clist_const:Nn \c_@@_department_name_clist { nju } +% \end{macrocode} +% \end{variable} +% +% \begin{variable}{\c_@@_department_color_clist} +% 定义受色彩支持的南京大学院系名单。 +% \begin{macrocode} +\clist_const:Nn \c_@@_department_color_clist { cs, ai } +% \end{macrocode} +% \end{variable} +% +% 定义对不支持的院系的报错信息。 +% \begin{macrocode} +\msg_new:nnn { njuvisual } { unsupported-department } +{ "#1"~ is~ not~ an~ valid~ option~ \\\\ + Please~ refer~ to~ the~ package~ documentation~ for~ supported~ + departments~ and~ check~ your~ spelling. \\ } +% \end{macrocode} +% +% \subsection{内部命令} +% +% \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_@@_department_color_clist \l_@@_department_tl + { \tl_set:Nn \l_@@_color_a_tl + { \clist_item:cn { c_@@_color_ \l_@@_department_tl _clist } { 1 } } + \tl_set:Nn \l_@@_color_b_tl + { \clist_item:cn { c_@@_color_ \l_@@_department_tl _clist } { 2 } } } + { \tl_set:Nn \l_@@_color_a_tl { njuviolet } } + } + { \clist_if_in:NVT \c_@@_department_color_clist \l_@@_department_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 容器。\footnote{此处手动调整了列表缩进,实际上\env{arguments}环境的缩进问题已在\href{https://github.com/CTeX-org/ctex-kit/commit/838ebab8378b6b0477f5aece81ace28ae2a8bcd9}{838ebab}提交中修复} +% \begin{arguments} +% \item 路径 +% \item 宽度 +% \item 高度 +% \end{arguments} +% 封装 resizebox 和 tikzpicture 环境,减少重复。 +% \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} } +} +% \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}{\@@_colon} +% 定义类别为 other 的冒号,用于在 Expl3 中表示路径 +% \begin{macrocode} +\def \@@_colon { \char_generate:nn { 58 } { 12 } } +% \end{macrocode} +% \end{macro} +% +% +% \subsection{用户接口} +% +% \begin{macro}{\njuemblem} +% \changes{v0.1}{2021/11/24}{将学校和院系的徽标和名称命令统一。} +% 定义南京大学标准徽标。 +% \begin{arguments} +% \item 颜色或者键值对 +% \item 宽度 +% \item 高度 +% \end{arguments} +% \begin{macrocode} +\NewDocumentCommand \njuemblem { O { njuviolet } m m } +{ + \group_begin: +% \end{macrocode} +% 根据参数是否含有 |=| 来判断该参数是段落数还是选项列表。 +% \begin{macrocode} + \@@_if_key_value_list:nTF { #1 } + { + \keys_set:nn { njuvisual } { #1 } +% \end{macrocode} +% 检查是否受支持。 +% \begin{macrocode} + \clist_if_in:NVTF \c_@@_department_emblem_clist \l_@@_department_tl + { \@@_set_color: + \@@_tikz_wrapper:nnn + { \use:c { @@_path_emblem_ \l_@@_department_tl } } { #2 } { #3 } } + { \msg_error:nnx { njuvisual } + { unsupported-department } { \l_@@_department_tl } } + } + { \tl_set:Nn \l_@@_color_a_tl { #1 } + \@@_tikz_wrapper:nnn { \@@_path_emblem_nju } { #2 } { #3 } } + \group_end: +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\njuname,\njuname*} +% 定义南京大学标准名称。 +% \begin{arguments} +% \item 可选星号 +% \item 颜色或者键值对 +% \item 宽度 +% \item 高度 +% \end{arguments} +% \begin{macrocode} +\NewDocumentCommand \njuname { t* O { njuviolet } m m } +{ + \group_begin: + \@@_if_key_value_list:nTF { #2 } + { + \keys_set:nn { njuvisual } { #2 } + \clist_if_in:NVTF \c_@@_department_name_clist \l_@@_department_tl + { + \@@_set_color: + \bool_if:NTF { #1 } + { \@@_tikz_wrapper:nnn + { \use:c { @@_path_name_ #2 _en } } { #3 } { #4 } } + { \@@_tikz_wrapper:nnn + { \use:c { @@_path_name_ #2 _cn } } { #3 } { #4 } } + } + { \msg_error:nnx { njuvisual } + { unsupported-department } { \l_@@_department_tl } } + } + { + \tl_set:Nn \l_@@_color_a_tl { #2 } + \bool_if:NTF { #1 } + { \@@_tikz_wrapper:nnn { \@@_path_name_nju_en } { #3 } { #4 } } + { \@@_tikz_wrapper:nnn { \@@_path_name_nju_cn } { #3 } { #4 } } + } + \group_end: +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\njumotto} +% 定义南京大学校训。 +% \begin{arguments} +% \item 颜色 +% \item 宽度 +% \item 高度 +% \end{arguments} +% \begin{macrocode} +\NewDocumentCommand \njumotto { o m m } +{ + \group_begin: + \tl_set:Nn \l_@@_color_a_tl { #1 } + \@@_tikz_wrapper:nnn { \@@_path_motto } { #2 } { #3 } + \group_end: +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\njuspirit} +% 定义南京大学校风。 +% \begin{arguments} +% \item 颜色 +% \item 宽度 +% \item 高度 +% \end{arguments} +% \begin{macrocode} +\NewDocumentCommand \njuspirit { o m m } +{ + \group_begin: + \tl_set:Nn \l_@@_color_a_tl { #1 } + \@@_tikz_wrapper:nnn { \@@_path_spirit } { #2 } { #3 } + \group_end: +} +%</visual> +% \end{macrocode} +% \end{macro} +% |