Skip to content

Commit

Permalink
feat: 使用 circledtext 生成脚注圈码 (#129)
Browse files Browse the repository at this point in the history
  • Loading branch information
atxy-blip committed Oct 16, 2022
1 parent d1198be commit 7f9c4c4
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 63 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
- 更正盲审模式隐藏的个人信息类别
- 修复 `\le``\ge` 的定义

### 变动

- 脚注中带圈数字选项修改为 `circled` - [#129]
- 删除 `pifont` 选项

### 杂项

- 手册中以黄色突出选项
Expand Down Expand Up @@ -452,6 +457,7 @@
[#117]: https://github.com/nju-lug/NJUThesis/issues/117
[#119]: https://github.com/nju-lug/NJUThesis/issues/119
[#121]: https://github.com/nju-lug/NJUThesis/issues/121
[#129]: https://github.com/nju-lug/NJUThesis/issues/129
[#130]: https://github.com/nju-lug/NJUThesis/issues/130
[#131]: https://github.com/nju-lug/NJUThesis/issues/131
[#134]: https://github.com/nju-lug/NJUThesis/discussions/134
Expand Down
2 changes: 1 addition & 1 deletion docs/njuthesis-setup.def
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@
}

% footnote 类用于设置脚注样式,功能详见手册
% \njusetup[footnote/style]{pifont}
% \njusetup[footnote/style]{circled}

% 页眉页脚内容设置
\njusetup{
Expand Down
131 changes: 69 additions & 62 deletions source/njuthesis.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -1662,12 +1662,20 @@ To produce the documentation run the original source files ending with
%
% \subsubsection{脚注}
%
% \begin{function}[added=2022-05-01,updated=2022-08-03]{footnote/style}
% \begin{function}[added=2022-05-01,updated=2022-10-16]{footnote/style}
% \begin{syntax}
% \OPT{style} = <(plain)|pifont>
% \OPT{style} = <(plain)|circled|circled*>
% \end{syntax}
% 设置脚注编号样式。默认为普通数字,使用 |pifont|
% 选项可修改为带圈数字。单一页面内请尽量避免超过 10 条脚注。
% 设置脚注编号样式。默认为普通数字,使用 \opt{circled} 或 \opt{circled*}
% 选项可修改为带圈数字,带星号的选项为黑底白字(阴文)。
% \end{function}
%
% \begin{function}[added=2022-10-16]{footnote/circledtext-option}
% \begin{syntax}
% \OPT{circledtext-option} = \meta{选项列表}
% \end{syntax}
% 带圈数字编号使用 \pkg{circledtext} 宏包绘制,
% 可使用本选项载入更多定制设置,详见其手册。
% \end{function}
%
% 脚注样式的调整依赖 \pkg{footmisc}。如果希望使用 \LaTeX 的默认样式,
Expand Down Expand Up @@ -5516,14 +5524,6 @@ To produce the documentation run the original source files ending with
% \end{variable}
%
% \begin{macrocode}
\msg_new:nnn { njuthesis } { extra-bib-style }
{
Wrongly-placed~ bib~ style.\\
Please~ use~ the~ `bib/style`~ field.
}
% \end{macrocode}
%
% \begin{macrocode}
\keys_define:nn { nju / bib }
{
% \end{macrocode}
Expand Down Expand Up @@ -5557,17 +5557,13 @@ To produce the documentation run the original source files ending with
% \changes{v0.15}{2022/02/15}{提供传入 \pkg{biblatex} 宏包选项的接口。}
% 待传入 \pkg{biblatex} 的额外宏包选项,以列表形式储存。
% 更为常见的参考文献样式设置已由 \opt{bib/style} 提供,
% 此处对重复的样式设置进行了检查。本设置项等效于在导言区使用
% 两者中后传入的设置会覆盖已有的设定。本设置项等效于在导言区使用
% |\PassoptionToPackage{|\meta{key}|=|\meta{value}|}{biblatex}| 命令。
% \begin{macrocode}
option .code:n =
{
\tl_if_in:VnTF \l_keys_value_tl { style = }
{ \msg_error:nn { njuthesis } { extra-bib-style } }
{
\clist_gput_right:NV \g_@@_blx_option_clist
\l_keys_value_tl
}
},
% \end{macrocode}
% \end{macro}
Expand All @@ -5577,10 +5573,7 @@ To produce the documentation run the original source files ending with
% 参考文献数据源,以列表形式储存。
% \begin{macrocode}
resource .code:n =
{
\clist_gput_right:NV \g_@@_blx_resource_clist
\l_keys_value_tl
},
{ \clist_gput_right:NV \g_@@_blx_resource_clist \l_keys_value_tl },
}
% \end{macrocode}
% \end{macro}
Expand All @@ -5606,8 +5599,7 @@ To produce the documentation run the original source files ending with
{
\cs_undefine:N \addbibresource
\clist_gput_right:Nn \g_@@_blx_option_clist { backend = biber }
\exp_args:NV \PassOptionsToPackage
\g_@@_blx_option_clist { biblatex }
\exp_args:NV \PassOptionsToPackage \g_@@_blx_option_clist { biblatex }
}
% \end{macrocode}
% \end{macro}
Expand Down Expand Up @@ -5640,9 +5632,9 @@ To produce the documentation run the original source files ending with
% 使用 \pkg{etoolbox} 提供的 \tn{BeforeBeginEnvironment},在 \env{document} 环境
% 开始的钩子前载入 \pkg{biblatex} 并进行相关设置。
% \begin{macrocode}
\BeforeBeginEnvironment { document }
\bool_if:NT \g_@@_opt_load_blx_bool
{
\bool_if:NT \g_@@_opt_load_blx_bool
\BeforeBeginEnvironment { document }
{
\@@_blx_pre_setup:
\RequirePackage { biblatex }
Expand Down Expand Up @@ -5718,61 +5710,76 @@ To produce the documentation run the original source files ending with
%
% \subsection{脚注}
% \changes{v0.18}{2022/05/01}{提供脚注设置项。}
% ^^A 来自 fduthesis
% ^^A 借鉴 fduthesis
%
% \begin{variable}{\g_@@_fn_ctext_option_clist}
% 存储传入 \pkg{circledtext} 宏包的选项列表。
% 由于当前版本放在编号位置的带圈数字无法正确缩放,这里手动指定了字体大小。
% \begin{macrocode}
\clist_set:Nn \g_@@_fn_ctext_option_clist { charf = \scriptsize }
% \end{macrocode}
% \end{variable}
%
% \begin{macrocode}
\tl_new:N \g_@@_fn_style_tl
\keys_define:nn { nju / footnote }
{
% \end{macrocode}
% \begin{macro}{footnote/style}
% \changes{v1.1}{2022/10/16}{将生成脚注圈码的 \pkg{pifont} 替换为 \pkg{circledtext}。}
% 脚注编号的样式。
% \begin{macrocode}
style .choices:nn = { plain, circled, circled* }
{
\int_case:nnTF { \l_keys_choice_int }
{
% \end{macrocode}
% \opt{circled} 类型,带星号的版本为阴文。
% \begin{macrocode}
style .choices:nn = { plain, pifont }
{ 2 } { \cs_set:Npn \@@_fn_number:N
{ \@@_fn_number_circled:NV \c_false_bool } }
{ 3 } { \cs_set:Npn \@@_fn_number:N
{ \@@_fn_number_circled:NV \c_true_bool } }
}
% \end{macrocode}
% 若使用 \opt{pifont} 类型,则需引入 \pkg{pifont} 宏包。
% 若使用 \opt{circled} 类型,则需引入 \pkg{circledtext} 宏包。
% \begin{macrocode}
{
\tl_gset_eq:NN \g_@@_fn_style_tl \l_keys_choice_tl
\int_compare:nT { \l_keys_choice_int = 2 }
{ \RequirePackage { pifont } }
}
}
{ \RequirePackage { circledtext } }
% \end{macrocode}
% \opt{plain} 或未知类型直接使用计数器的值。
% \begin{macrocode}
{ \cs_set_eq:NN \@@_fn_number:N \int_use:N }
},
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_fn_symbol_pifont:n}
% \opt{pifont} 普通版。以下四种都只包含 \numrange{1}{10}
% \begin{macro}{footnote/circledtext-option}
% \pkg{circledtext} 宏包选项
% \begin{macrocode}
\cs_new:Npn \@@_fn_symbol_pifont:n #1
{ \ding { \int_eval:n { 171 + #1 } } }
circledtext-option .code:n =
{ \clist_gput_right:Nn \g_@@_fn_ctext_option_clist {#1} }
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_footnote_number:N}
% 脚注编号样式
% \begin{macro}{\@@_fn_number_circled:Nn,\@@_fn_number_circled:NV}
% \opt{circled} 选项提供的带圈数字
% \begin{macrocode}
\tl_const:Nn \c_@@_fn_style_plain_tl { plain }
\tl_const:Nn \c_@@_fn_style_pifont_tl { pifont }
\cs_new:Npn \@@_footnote_number:N #1
\cs_generate_variant:Nn \__circledtext_handle:nn { Vn }
\cs_new_protected:Npn \@@_fn_number_circled:Nn #1#2
{
\tl_case:NnF \g_@@_fn_style_tl
{
% \end{macrocode}
% \opt{plain} 类型直接使用计数器 |footnote| 的值。
% \begin{macrocode}
\c_@@_fn_style_plain_tl
{ \int_use:N #1 }
% \end{macrocode}
% \opt{pifont} 类型无需进行额外的操作。
% \begin{macrocode}
\c_@@_fn_style_pifont_tl
{ \@@_fn_symbol_pifont:n {#1} }
}
\group_begin:
\bool_set_eq:NN \l__circledtext_negative_bool #1
\__circledtext_handle:Vn \g_@@_fn_ctext_option_clist { #2 }
\group_end:
}
\cs_generate_variant:Nn \@@_fn_number_circled:Nn { NV }
% \end{macrocode}
% 变量 \cs{l_@@_fn_style_tl} 保存的类型未知时,默认使用 \opt{plain}
% 类型。
% \end{macro}
%
% \begin{macro}{\@@_fn_number:N}
% 脚注编号。默认使用计数器 |footnote| 的值。
% \begin{macrocode}
{ \int_use:N #1 }
}
\cs_new_eq:NN \@@_fn_number:N \int_use:N
% \end{macrocode}
% \end{macro}
%
Expand All @@ -5781,7 +5788,7 @@ To produce the documentation run the original source files ending with
% \begin{macrocode}
\bool_if:NT \g_@@_opt_load_fm_bool
{
\cs_set:Npn \thefootnote { \@@_footnote_number:N \c@footnote }
\cs_set:Npn \thefootnote { \@@_fn_number:N \c@footnote }
% \end{macrocode}
% \end{macro}
%
Expand Down
5 changes: 5 additions & 0 deletions test/test.tex
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@
define,
}

\njusetup[footnote]{
style={circled},
circledtext-option={resize=none,boxcolor=blue,boxtype=ox+,boxfill=red!30}
}

% \addbibresource{test.bib}

% \ctexset{
Expand Down

0 comments on commit 7f9c4c4

Please sign in to comment.