summaryrefslogtreecommitdiff
path: root/macros/xetex/latex/exam-zh/tex
diff options
context:
space:
mode:
Diffstat (limited to 'macros/xetex/latex/exam-zh/tex')
-rw-r--r--macros/xetex/latex/exam-zh/tex/exam-zh-chinese-english.sty4
-rw-r--r--macros/xetex/latex/exam-zh/tex/exam-zh-choices.sty123
-rw-r--r--macros/xetex/latex/exam-zh/tex/exam-zh-font.sty12
-rw-r--r--macros/xetex/latex/exam-zh/tex/exam-zh-question.sty114
-rw-r--r--macros/xetex/latex/exam-zh/tex/exam-zh-symbols.sty4
-rw-r--r--macros/xetex/latex/exam-zh/tex/exam-zh-textfigure.sty651
-rw-r--r--macros/xetex/latex/exam-zh/tex/exam-zh.cls28
7 files changed, 881 insertions, 55 deletions
diff --git a/macros/xetex/latex/exam-zh/tex/exam-zh-chinese-english.sty b/macros/xetex/latex/exam-zh/tex/exam-zh-chinese-english.sty
index b2d1d39baf..eefffdac7d 100644
--- a/macros/xetex/latex/exam-zh/tex/exam-zh-chinese-english.sty
+++ b/macros/xetex/latex/exam-zh/tex/exam-zh-chinese-english.sty
@@ -1,14 +1,14 @@
%
% Copyright (c) 2022 Kangwei Xia, Lijun Guo
% Released under the LaTeX Project Public License v1.3c License.
-% Repository: https://gitee.com/zepinglee/exam-zh
+% Repository: https://gitee.com/xkwxdyy/exam-zh
%
\NeedsTeXFormat{LaTeX2e}
\RequirePackage{expl3}
-\ProvidesExplPackage {exam-zh-chinese-english} {2022-08-15} {v0.1.18}
+\ProvidesExplPackage {exam-zh-chinese-english} {2022-08-28} {v0.1.19}
{exam-zh chinese and english module}
\PassOptionsToPackage { tcolorbox } { most }
diff --git a/macros/xetex/latex/exam-zh/tex/exam-zh-choices.sty b/macros/xetex/latex/exam-zh/tex/exam-zh-choices.sty
index ef7c39ba88..05f66871c3 100644
--- a/macros/xetex/latex/exam-zh/tex/exam-zh-choices.sty
+++ b/macros/xetex/latex/exam-zh/tex/exam-zh-choices.sty
@@ -9,7 +9,7 @@
\RequirePackage{expl3}
\RequirePackage{xparse}
-\ProvidesExplPackage {exam-zh-choices} {2022-08-15} {v0.1.18}
+\ProvidesExplPackage {exam-zh-choices} {2022-08-28} {v0.1.19}
{exam-zh choices module}
\dim_new:N \l__examzh_choices_column_sep_dim
@@ -36,7 +36,13 @@
label-sep .dim_set:N = \l__examzh_choices_label_sep_dim ,
label-width .dim_set:N = \l__examzh_choices_label_width_dim ,
max-columns .int_set:N = \l__examzh_choices_max_columns_int ,
- index .int_set:N = \l__examzh_choices_item_index_int
+ index .int_set:N = \l__examzh_choices_item_index_int,
+ % 环境上方的额外距离
+ top-sep .skip_set:N = \l__examzh_choices_top_sep_skip,
+ % 环境下方的额外距离
+ bottom-sep .skip_set:N = \l__examzh_choices_bottom_sep_skip,
+ % 若不是单行排版,则可以控制行之间的额外间距
+ linesep .skip_set:N = \l__examzh_choices_line_sep_skip
}
\keys_set:nn { exam-zh / choices }
@@ -45,11 +51,14 @@
columns = 0 ,
label = \Alph*. ,
label-pos = auto ,
- label-align = right ,
+ label-align = left ,
label-sep = .5em ,
label-width = 0pt ,
max-columns = 4 ,
index = 1,
+ top-sep = 0pt,
+ bottom-sep = 0pt,
+ linesep = 0pt plus .5ex
}
\NewDocumentCommand \setchoices { m }
@@ -83,17 +92,19 @@
\NewDocumentEnvironment { choices } { O { } +b }
{
+ \keys_set:nn { exam-zh / choices } {#1}
\par \nopagebreak
% 严格禁止孤行和寡行
\int_set:Nn \clubpenalty { 10000 }
\int_set:Nn \widowpenalty { 10000 }
% 尽量避免在选项中间换行
\int_set:Nn \interlinepenalty { 301 }
+ \vspace* { \l__examzh_choices_top_sep_skip }
\noindent
- \dim_set_eq:NN \l__examzh_choices_total_width_dim \linewidth
+ % \dim_set_eq:NN \l__examzh_choices_total_width_dim \linewidth
+ \dim_set:Nn \l__examzh_choices_total_width_dim { \linewidth - \leftskip - \rightskip }
\int_zero:N \l__examzh_choices_columns_int
\dim_zero:N \l__examzh_choices_label_width_dim
- \keys_set:nn { exam-zh / choices } {#1}
}
{
% 用 \item 分割选项
@@ -119,6 +130,7 @@
\__examzh_print_choices:N \l__examzh_choices_seq
% 输出正确选项
\__examzh_print_correctchoice:
+ \vspace* { \l__examzh_choices_bottom_sep_skip }
}
% 用来存正确选项的序号(entry)
@@ -368,7 +380,9 @@
{ \l__examzh_choices_current_col_int } > { \l__examzh_choices_columns_int }
{
% \par \noindent
- \newline
+ \\[ \l__examzh_choices_line_sep_skip ]
+ % \newline
+ % \skip_vertical:N \l__examzh_choices_line_sep_skip
\int_set:Nn \l__examzh_choices_current_col_int {1}
}
% TODO 为什么 > 1 才加呢? 这样的话第 1 列和第 2 列之间就没有这个间距?
@@ -386,52 +400,116 @@
\coffin_new:N \l__examzh_choices_item_coffin
\coffin_new:N \l__examzh_choices_label_coffin
-
+% \box_new:N \l__examzh_choices_item_box
+% \box_new:N \l__examzh_choices_label_box
\cs_new:Npn \__examzh_print_single_choice:nn #1#2
{
% 选项标签
\__examzh_choices_make_label_coffin:n {#1}
+ % \__examzh_choices_make_label_box:n {#1}
% 选项内容
\__examzh_choices_make_item_coffin:n {#2}
+ % \__examzh_choices_make_item_box:n {#2}
% 合并选项的标签和内容
\str_case:Vn \l__examzh_choices_label_pos_tl
{
{ top-left }
{
\coffin_join:NnnNnnnn
- \l__examzh_choices_item_coffin {l} {H}
\l__examzh_choices_label_coffin {r} {H}
- { - \l__examzh_choices_label_sep_dim }
+ \l__examzh_choices_item_coffin {l} {H}
+ { \l__examzh_choices_label_sep_dim }
{ 0pt }
+ % \hbox_set:Nn \l__examzh_choices_item_box
+ % {
+ % \box_use_drop:N \l__examzh_choices_label_box
+ % \kern \l__examzh_choices_label_sep_dim
+ % \box_use_drop:N \l__examzh_choices_item_box
+ % }
}
{ left }
{
\coffin_join:NnnNnnnn
- \l__examzh_choices_item_coffin {l} {vc}
\l__examzh_choices_label_coffin {r} {vc}
- { - \l__examzh_choices_label_sep_dim }
+ \l__examzh_choices_item_coffin {l} {vc}
+ { \l__examzh_choices_label_sep_dim }
{ 0pt }
+ % \hbox_set:Nn \l__examzh_choices_item_box
+ % {
+ % \box_move_down:nn
+ % {
+ % (
+ % \box_ht:N \l__examzh_choices_label_box -
+ % \box_dp:N \l__examzh_choices_label_box -
+ % \box_ht:N \l__examzh_choices_item_box +
+ % \box_dp:N \l__examzh_choices_item_box
+ % ) / 2
+ % }
+ % { \box_use_drop:N \l__examzh_choices_label_box }
+ % \kern \l__examzh_choices_label_sep_dim
+ % \box_use_drop:N \l__examzh_choices_item_box
+ % }
}
{ bottom }
{
\coffin_join:NnnNnnnn
- \l__examzh_choices_item_coffin {hc} {b}
\l__examzh_choices_label_coffin {hc} {t}
+ \l__examzh_choices_item_coffin {hc} {b}
{ 0pt }
% { - \l__examzh_choices_label_sep_dim }
{ 0pt }
+ % \hbox_set:Nn \l__examzh_choices_item_box
+ % {
+ % % \vbox_top:n
+ % % {
+ % % \box_use:N \l__examzh_choices_item_box
+ % % \nointerlineskip
+ % % % \kern \l__examzh_choices_label_sep_dim
+ % % \box_move_left:nn
+ % % {
+ % % (
+ % % \box_wd:N \l__examzh_choices_label_box -
+ % % \box_wd:N \l__examzh_choices_item_box
+ % % ) / 2
+ % % }
+ % % { \box_use_drop:N \l__examzh_choices_label_box }
+ % % \box_clear:N \l__examzh_choices_item_box
+ % % }
+ % \hbox_set:Nn \l__examzh_choices_item_box
+ % {
+ % \box_use:N \l__examzh_choices_item_box
+ % \kern \dim_eval:n
+ % {
+ % ( - \box_wd:N \l__examzh_choices_label_box
+ % - \box_wd:N \l__examzh_choices_item_box ) / 2
+ % }
+ % \box_move_down:nn
+ % {
+ % \box_ht:N \l__examzh_choices_label_box +
+ % \box_dp:N \l__examzh_choices_item_box
+ % % + \l__examzh_choices_label_sep_dim
+ % }
+ % { \box_use_drop:N \l__examzh_choices_label_box }
+ % \box_clear:N \l__examzh_choices_item_box
+ % }
+ % }
}
}
% 输出合并后
- \coffin_typeset:Nnnnn \l__examzh_choices_item_coffin {l} {H} {0pt} {0pt}
+ % \coffin_typeset:Nnnnn \l__examzh_choices_item_coffin {l} {H} {0pt} {0pt}
+ \coffin_typeset:Nnnnn \l__examzh_choices_label_coffin {l} {H} {0pt} {0pt}
\coffin_clear:N \l__examzh_choices_item_coffin
\coffin_clear:N \l__examzh_choices_label_coffin
+ % \box_use_drop:N \l__examzh_choices_item_box
}
% 将标签内容存入 coffin
\cs_new:Npn \__examzh_choices_make_label_coffin:n #1
+% 将标签内容存入 box
+% \cs_new:Npn \__examzh_choices_make_label_box:n #1
{
\hcoffin_set:Nn \l__examzh_choices_label_coffin
+ % \hbox_set:Nn \l__examzh_choices_label_box
{
\hbox_to_wd:nn { \l__examzh_choices_label_width_dim }
{ \__examzh_choices_make_label:n {#1} \strut }
@@ -452,10 +530,13 @@
% 将选项内容存入 coffin
\cs_new:Npn \__examzh_choices_make_item_coffin:n #1
+% 将选项内容存入 box
+% \cs_new:Npn \__examzh_choices_make_item_box:n #1
{
\hcoffin_set:Nn \l__examzh_choices_item_coffin
+ % \hbox_set:Nn \l__examzh_choices_item_box
{
- % 优先尝试使用 hbox,这是因为在 \vcoffin_set 外部能保留原来的 \linewidth 和
+ % 优先尝试使用 hbox,这是因为在 \vbox_set 外部能保留原来的 \linewidth 和
% \textwidth,方便用户在 \includegraphics 中使用
\hbox_set:Nn \l_tmpa_box {#1}
% 若盒子的自然高度大于 2 行,且深度为 0pt,设置为插图模式
@@ -468,9 +549,17 @@
{ \bool_set_true:N \l__examzh_choices_figure_mode_bool }
\vcoffin_set:Nnn \l_tmpa_coffin
{ \l__examzh_choices_item_width_dim }
+ % \vbox_set:Nn \l_tmpa_box
{
+ % \dim_set_eq:NN \parskip \c_zero_dim
+ % \dim_set_eq:NN \parindent \listparindent
+ \dim_set_eq:NN \hsize \l__examzh_choices_item_width_dim
+ \dim_set_eq:NN \linewidth \hsize
+ \dim_set_eq:NN \columnwidth \hsize
\dim_set_eq:NN \parskip \c_zero_dim
\dim_set_eq:NN \parindent \listparindent
+ \dim_set:Nn \leftskip { 0pt }
+ \dim_set:Nn \rightskip { 0pt }
\noindent
% \strut
% 若标签在底部,将图片居中对齐。
@@ -485,9 +574,15 @@
}
\dim_set:Nn \l_tmpa_dim { \coffin_ht:N \l_tmpa_coffin }
\bool_if:NT \l__examzh_choices_figure_mode_bool
+ % \dim_set:Nn \l_tmpa_dim { \box_ht:N \l_tmpa_box }
+ % \bool_if:NTF \l__examzh_choices_figure_mode_bool
+ % {
+ % \box_move_up:nn { \l_tmpa_dim - 0.7 \baselineskip } { \box_use_drop:N \l_tmpa_box }
+ % }
{
\coffin_set_horizontal_pole:Nnn \l_tmpa_coffin {T}
{ \l_tmpa_dim - 0.7 \baselineskip }
+ % \vbox_top:n { \vbox_unpack_drop:N \l_tmpa_box }
}
\coffin_typeset:Nnnnn \l_tmpa_coffin {l} {T} {0pt} {0pt}
\coffin_clear:N \l_tmpa_coffin
diff --git a/macros/xetex/latex/exam-zh/tex/exam-zh-font.sty b/macros/xetex/latex/exam-zh/tex/exam-zh-font.sty
index cda4062101..76f943de1d 100644
--- a/macros/xetex/latex/exam-zh/tex/exam-zh-font.sty
+++ b/macros/xetex/latex/exam-zh/tex/exam-zh-font.sty
@@ -1,7 +1,7 @@
%
% Copyright (c) 2022 Zeping Lee and AlphaZTX
% Released under the LaTeX Project Public License v1.3c License.
-% Repository: https://gitee.com/zepinglee/exam-zh
+% Repository: https://gitee.com/xkwxdyy/exam-zh
%
\NeedsTeXFormat{LaTeX2e}
@@ -9,7 +9,7 @@
\RequirePackage{expl3}
\RequirePackage{xparse}
-\ProvidesExplPackage {exam-zh-font} {2022-08-15} {v0.1.18}
+\ProvidesExplPackage {exam-zh-font} {2022-08-28} {v0.1.19}
{exam-zh font module}
\RequirePackage { unicode-math }
@@ -456,7 +456,7 @@
\setmathfont { \g__examzh_font_font_name_stix_math_tl }
[
Extension = .otf,
- range = { \complement } ,
+ range = { \complement, \bigstar } ,
]
\setmathrm { NewCM10 }
[
@@ -495,7 +495,7 @@
\setmathfont { \g__examzh_font_font_name_stix_math_tl }
[
Extension = .otf,
- range = { \complement } ,
+ range = { \complement, \bigstar } ,
]
\setmathrm { lmroman10 }
[
@@ -600,7 +600,7 @@
\setmathfont { \g__examzh_font_font_name_stix_math_tl }
[
Extension = .otf,
- range = { \complement } ,
+ range = { \complement, \bigstar } ,
]
\message
{
@@ -638,7 +638,7 @@
\setmathfont { \g__examzh_font_font_name_stix_math_tl }
[
Extension = .otf,
- range = { \complement } ,
+ range = { \complement, \bigstar } ,
]
}
diff --git a/macros/xetex/latex/exam-zh/tex/exam-zh-question.sty b/macros/xetex/latex/exam-zh/tex/exam-zh-question.sty
index 7cf7524e08..9afcba5f7b 100644
--- a/macros/xetex/latex/exam-zh/tex/exam-zh-question.sty
+++ b/macros/xetex/latex/exam-zh/tex/exam-zh-question.sty
@@ -1,7 +1,7 @@
%
% Copyright (c) 2022 Zeping Lee
% Released under the LaTeX Project Public License v1.3c License.
-% Repository: https://gitee.com/zepinglee/exam-zh
+% Repository: https://gitee.com/xkwxdyy/exam-zh
%
\NeedsTeXFormat{LaTeX2e}
@@ -9,7 +9,7 @@
\RequirePackage{expl3}
\RequirePackage{xparse}
-\ProvidesExplPackage {exam-zh-question} {2022-08-15} {v0.1.18}
+\ProvidesExplPackage {exam-zh-question} {2022-08-28} {v0.1.19}
{exam-zh question module}
@@ -755,6 +755,7 @@
{ \bool_set_true:N \l__examzh_fillin_paren_banjiao_bool },
paren-type / quanjiao .code:n =
{ \bool_set_false:N \l__examzh_fillin_paren_banjiao_bool },
+ depth .dim_set:N = \l__examzh_fillin_line_depth_dim
}
\keys_set:nn { exam-zh / fillin }
{
@@ -767,7 +768,8 @@
no-answer-counter-index = 1,
no-answer-counter-label = \arabic*,
paren-type = banjiao,
- width-type = fill,
+ width-type = normal,
+ depth = 0.4em
}
\keys_define:nn { exam-zh }
@@ -801,7 +803,9 @@
}
{
% 不显示答案
- \__examzh_fillin_no_answer_typeset:
+ \IfBooleanTF {#1}
+ { \__examzh_fillin_no_answer_breakble_typeset: }
+ { \__examzh_fillin_no_answer_unbreakble_typeset: }
}
}
{
@@ -821,7 +825,9 @@
}
{
% 不显示答案
- \__examzh_fillin_no_answer_typeset:
+ \IfBooleanTF {#1}
+ { \__examzh_fillin_no_answer_breakble_typeset: }
+ { \__examzh_fillin_no_answer_unbreakble_typeset: }
}
}
\group_end:
@@ -832,13 +838,26 @@
There~is~no~such~noanswertype~named~#1!\\
Please~read~the~manual~carefully!
}
-\cs_new:Npn \__examzh_fillin_no_answer_typeset:
+\cs_new:Npn \__examzh_fillin_no_answer_unbreakble_typeset:
+ {
+ \str_case:VnF \l__examzh_fillin_no_answer_type_str
+ {
+ { blacktriangle } { \__examzh_fillin_no_answer_typeset_blacktriangle: }
+ { counter } { \__examzh_fillin_no_answer_typeset_counter: }
+ { none } { \__examzh_fillin_output_unbreakable_F: }
+ }
+ {
+ \msg_error:nnx { exam-zh / fillin } { no-such-noanswertype }
+ { \l__examzh_fillin_no_answer_type_str }
+ }
+ }
+\cs_new:Npn \__examzh_fillin_no_answer_breakble_typeset:
{
\str_case:VnF \l__examzh_fillin_no_answer_type_str
{
{ blacktriangle } { \__examzh_fillin_no_answer_typeset_blacktriangle: }
{ counter } { \__examzh_fillin_no_answer_typeset_counter: }
- { none } { \__examzh_fillin_no_answer_typeset_none: }
+ { none } { \__examzh_fillin_output_breakable_F: }
}
{
\msg_error:nnx { exam-zh / fillin } { no-such-noanswertype }
@@ -856,10 +875,6 @@
{ \__examzh_fillin_the_label: }
% { \int_eval:n { \g__examzh_fillin_no_answer_counter_int - 1 } }
}
-\cs_new:Npn \__examzh_fillin_no_answer_typeset_none:
- {
- \__examzh_fillin_output_F:
- }
\cs_new:Npn \__examzh_fillin_without_judge:n #1
{
% \ULdepth 是 \uline 的下划线的深度
@@ -887,7 +902,7 @@
\__examzh_fillin_output_T:
}
{
- \__examzh_fillin_output_F:
+ \__examzh_fillin_output_unbreakable_F:
}
}
\cs_new:Npn \__examzh_fillin_breakline:n #1
@@ -900,7 +915,7 @@
\__examzh_fillin_output_breakline_T:
}
{
- \__examzh_fillin_output_F:
+ \__examzh_fillin_output_breakable_F:
}
}
\msg_new:nnn { exam-zh } { no-fillin-type }
@@ -940,14 +955,29 @@
{
The~type~:~#1~ cannot~be~used~in~breakable~fillin~cmd.
}
-\cs_new:Npn \__examzh_fillin_output_F:
+\cs_new:Npn \__examzh_fillin_output_breakable_F:
+ {
+ \str_case:VnF \l__examzh_fillin_type_str
+ {
+ { line } { \__examzh_fillin_uline_breakable_F: }
+ { paren } { \__examzh_fillin_paren_breakable_F: }
+ { circle } { \__examzh_fillin_circle_F: }
+ { blank } { \__examzh_fillin_blank_breakable_F: }
+ { rectangle } { \__examzh_fillin_rectangle_F: }
+ }
+ {
+ \msg_error:nnx { exam-zh } { no-fillin-type }
+ { \l__examzh_fillin_type_str }
+ }
+ }
+\cs_new:Npn \__examzh_fillin_output_unbreakable_F:
{
\str_case:VnF \l__examzh_fillin_type_str
{
- { line } { \__examzh_fillin_uline_F: }
- { paren } { \__examzh_fillin_paren_F: }
+ { line } { \__examzh_fillin_uline_unbreakable_F: }
+ { paren } { \__examzh_fillin_paren_unbreakable_F: }
{ circle } { \__examzh_fillin_circle_F: }
- { blank } { \__examzh_fillin_blank_F: }
+ { blank } { \__examzh_fillin_blank_unbreakable_F: }
{ rectangle } { \__examzh_fillin_rectangle_F: }
}
{
@@ -957,7 +987,9 @@
}
\cs_new:Npn \__examzh_fillin_uline_T:
{
- \uline
+ % \uline
+ \CJKunderline*
+ [ depth = \l__examzh_fillin_line_depth_dim ]
{
\hspace* { 0.5em plus .5em minus .5em }
\dim_compare:nNnTF { \l__examzh_question_answer_depth_dim } > { 0.2em }
@@ -970,11 +1002,18 @@
\hspace* { 0.5em plus .5em minus .5em }
}
}
-\cs_new:Npn \__examzh_fillin_uline_F:
+\cs_new:Npn \__examzh_fillin_uline_breakable_F:
{
% \uline { \hspace* { \l__examzh_fillin_F_width_dim } }
\__examzh_fillin_breakable_hspace:NN \CJKunderline \allowbreak
}
+\cs_new:Npn \__examzh_fillin_uline_unbreakable_F:
+ {
+ \unskip
+ \hspace* { 0.5em plus .5em minus .5em }
+ \uline { \hspace* { \l__examzh_fillin_F_width_dim } }
+ \ignorespaces
+ }
% \cs_new:Nn \__examzh_fillin_uline:
% {
% \bgroup
@@ -1006,6 +1045,7 @@
\cs_new:Npn \__examzh_fillin_uline_breakline_T:
{
\CJKunderline*
+ [ depth = \l__examzh_fillin_line_depth_dim ]
% \uline
% \__examzh_fillin_uline:
{
@@ -1018,6 +1058,7 @@
}
\cs_new:Npn \__examzh_fillin_paren_T:
{
+ \unskip
\bool_if:NTF \l__examzh_fillin_paren_banjiao_bool
{
(
@@ -1037,9 +1078,11 @@
\hspace* { 0.5em plus .5em minus .5em }
}
+ \ignorespaces
}
\cs_new:Npn \__examzh_fillin_paren_breakline_T:
{
+ \unskip
\bool_if:NTF \l__examzh_fillin_paren_banjiao_bool
{
(
@@ -1059,6 +1102,7 @@
\hspace* { 0.5em plus .5em minus .5em }
}
+ \ignorespaces
}
\box_new:N \c__examzh_banjiao_right_brace_box
\box_new:N \c__examzh_quanjiao_right_brace_box
@@ -1068,8 +1112,10 @@
{ \box_wd:N \c__examzh_banjiao_right_brace_box }
\dim_const:Nn \c__examzh_quanjiao_right_brace_width_dim % (
{ \box_wd:N \c__examzh_quanjiao_right_brace_box }
-\cs_new:Npn \__examzh_fillin_paren_F:
+\cs_new:Npn \__examzh_fillin_paren_breakable_F:
{
+ \unskip
+ \hspace* { 0.5em plus .5em minus .5em }
\bool_if:NTF \l__examzh_fillin_paren_banjiao_bool
{
( \__examzh_fillin_breakable_hspace:NN \use:n \nobreak \kern-\c__examzh_banjiao_right_brace_width_dim ) \allowbreak
@@ -1077,28 +1123,49 @@
{
( \__examzh_fillin_breakable_hspace:NN \use:n \nobreak \kern-\c__examzh_quanjiao_right_brace_width_dim )\allowbreak
}
+ \ignorespaces
+ }
+\cs_new:Npn \__examzh_fillin_paren_unbreakable_F:
+ {
+ \unskip
+ \hspace* { 0.5em plus .5em minus .5em }
+ \bool_if:NTF \l__examzh_fillin_paren_banjiao_bool
+ {
+ ( \hspace* { \l__examzh_fillin_F_width_dim } )
+ }
+ {
+ ( \hspace* { \l__examzh_fillin_F_width_dim } )
+ }
+ \ignorespaces
}
\cs_new:Npn \__examzh_fillin_blank_T:
{
+ \unskip
\hspace* { 0.5em plus .5em minus .5em }
\group_begin:
\box_use_drop:N \l_tmpa_box
\group_end:
- \hspace* { 0.5em plus .5em minus .5em }
+ \ignorespaces
}
\cs_new:Npn \__examzh_fillin_blank_breakline_T:
{
+ \unskip
\hspace* { 0.5em plus .5em minus .5em }
\group_begin:
\l_tmpa_tl
\group_end:
- \hspace* { 0.5em plus .5em minus .5em }
+ \ignorespaces
}
-\cs_new:Npn \__examzh_fillin_blank_F:
+\cs_new:Npn \__examzh_fillin_blank_breakble_F:
{
% \hspace* { \l__examzh_fillin_F_width_dim }
\__examzh_fillin_breakable_hspace:NN \use:n \allowbreak
}
+\cs_new:Npn \__examzh_fillin_blank_unbreakble_F:
+ {
+ \hspace* { \l__examzh_fillin_F_width_dim }
+ % \__examzh_fillin_breakable_hspace:NN \use:n \allowbreak
+ }
\tikzset
{
fillin-circle/.style =
@@ -1235,6 +1302,7 @@
\keys_define:nn { exam-zh / solution }
{
show-solution .bool_set:N = \l__examzh_solution_show_bool,
+ show-answer .bool_set:N = \l__examzh_solution_show_bool,
show-qed .bool_set:N = \l__examzh_solution_show_qed_bool,
qedsymbol .tl_set:N = \l__examzh_solution_qedsymbol_tl,
label-content .tl_set:N = \l__examzh_solution_label_content_tl,
diff --git a/macros/xetex/latex/exam-zh/tex/exam-zh-symbols.sty b/macros/xetex/latex/exam-zh/tex/exam-zh-symbols.sty
index 2b0490284d..37115aa5a8 100644
--- a/macros/xetex/latex/exam-zh/tex/exam-zh-symbols.sty
+++ b/macros/xetex/latex/exam-zh/tex/exam-zh-symbols.sty
@@ -1,14 +1,14 @@
%
% Copyright (c) 2022 Kangwei Xia
% Released under the LaTeX Project Public License v1.3c License.
-% Repository: https://gitee.com/zepinglee/exam-zh
+% Repository: https://gitee.com/xkwxdyy/exam-zh
%
\NeedsTeXFormat{LaTeX2e}
\RequirePackage{expl3}
-\ProvidesExplPackage {exam-zh-symbols} {2022-08-15} {v0.1.18}
+\ProvidesExplPackage {exam-zh-symbols} {2022-08-28} {v0.1.19}
{exam-zh symbols module}
\RequirePackage { tikz }
diff --git a/macros/xetex/latex/exam-zh/tex/exam-zh-textfigure.sty b/macros/xetex/latex/exam-zh/tex/exam-zh-textfigure.sty
new file mode 100644
index 0000000000..77a98eb0ba
--- /dev/null
+++ b/macros/xetex/latex/exam-zh/tex/exam-zh-textfigure.sty
@@ -0,0 +1,651 @@
+%
+% Copyright (c) 2022 Kangwei Xia
+% Released under the LaTeX Project Public License v1.3c License.
+% Repository: https://gitee.com/xkwxdyy/exam-zh
+%
+\NeedsTeXFormat{LaTeX2e}
+
+\RequirePackage{expl3}
+
+\ProvidesExplPackage {exam-zh-textfigure} {2022-08-28} {v0.1.19}
+ {exam-zh text with figure module}
+
+\RequirePackage { wrapstuff }
+\RequirePackage { tabularray }
+\RequirePackage { varwidth }
+\RequirePackage { graphicx }
+\RequirePackage { filehook }
+
+\AtEndOfPackageFile* { exam-zh-choices }
+ {
+ \AddToHook { env / choices / before }
+ { \wrapstuffclear }
+ }
+
+%% multifigures 环境,排版多张图片 %%
+
+% \begin{multifigures}
+% \item[题 9 图:勾股数] \includegraphics[width=3cm]{example-image.png}
+% \item[题 11 图:圆锥曲线] \includegraphics[width=3cm]{example-image.png}
+% \end{multifigures}
+
+% 图片相对于 label 的方位
+\str_new:N \l__examzh_multifigures_figure_position_str
+% coffin type 的对齐方式
+\str_new:N \l__examzh_multifigures_coffin_align_str
+
+
+\keys_define:nn { exam-zh / multifigures }
+ {
+ % 每行多少个(等价于有多少列)
+ columns .int_set:N = \l__examzh_multifigures_column_int,
+ % 图片相对于文字的位置(上下左右)
+ fig-pos .choices:nn =
+ { top, above, bottom, below, left, right }
+ { \str_set:Nx \l__examzh_multifigures_figure_position_str { \l_keys_choice_tl } },
+ % 环境上方的额外距离
+ top-sep .skip_set:N = \l__examzh_multifigures_top_sep_skip,
+ % 环境下方的额外距离
+ bottom-sep .skip_set:N = \l__examzh_multifigures_bottom_sep_skip,
+ % 整体的偏移量
+ xshift .dim_set:N = \l__examzh_multifigures_xshift_dim,
+ hshift .dim_set:N = \l__examzh_multifigures_xshift_dim,
+ yshift .dim_set:N = \l__examzh_multifigures_yshift_dim,
+ vshift .dim_set:N = \l__examzh_multifigures_yshift_dim,
+ % label 的偏移量
+ label-xshift .dim_set:N = \l__examzh_multifigures_label_xshift_dim,
+ label-hshift .dim_set:N = \l__examzh_multifigures_label_xshift_dim,
+ label-yshift .dim_set:N = \l__examzh_multifigures_label_yshift_dim,
+ label-vshift .dim_set:N = \l__examzh_multifigures_label_yshift_dim,
+ % 对齐方式
+ align .choices:nn =
+ { t, m, b }
+ { \str_set:Nx \l__examzh_multifigures_coffin_align_str { \l_keys_choice_tl } }
+ }
+\keys_set:nn { exam-zh / multifigures }
+ {
+ columns = 3,
+ fig-pos = above,
+ label-xshift = 0pt,
+ label-yshift = 0pt,
+ align = b,
+ top-sep = 1ex plus .5ex minus .5ex,
+ bottom-sep = 0pt,
+ }
+
+% item 的 index 指标(即第几个 item)
+\int_new:N \l__examzh_multifigures_item_index_int
+% 将拼接后的 coffin 存到 seq 里
+\seq_new:N \l__examzh_multifigures_store_seq
+% 上面的 seq 的 item 数
+\int_new:N \l__examzh_multifigures_store_seq_item_int
+% 最终放在 tblr 里的内容
+\tl_new:N \l__examzh_multifigures_tblr_content_tl
+
+\NewDocumentEnvironment { multifigures } { O{ } +O{ } }
+ {
+ \group_begin:
+ \RenewDocumentCommand \item { O{ } }
+ { \__examzh_multifigures_item:n {##1} }
+ \int_set:Nn \l__examzh_multifigures_item_index_int {0}
+ \seq_clear:N \l__examzh_multifigures_store_seq
+ \tl_clear:N \l__examzh_multifigures_tblr_content_tl
+ \keys_set:nn { exam-zh / multifigures } {#1}
+ }
+ {
+ % 结束收集
+ \unskip
+ \end{varwidth}
+ \hcoffin_set_end:
+ % 拼接 label 和 figure
+ \__examzh_multifigures_coffin_join:
+ % 输出
+ \__examzh_multifigures_coffin_typeset:n {#2}
+ % \par \int_use:N \l__examzh_multifigures_item_index_int
+ \group_end:
+ }
+% 拼接 label 和 figure
+\cs_new:Npn \__examzh_multifigures_coffin_join:
+ {
+ \int_step_inline:nn { \l__examzh_multifigures_item_index_int }
+ {
+ \__examzh_multifigures_coffin_join_position_set:n {##1}
+ \seq_gput_right:Nn \l__examzh_multifigures_store_seq
+ {
+ \__examzh_multifigures_coffin_align_set:n {##1}
+ }
+ }
+ }
+\cs_new:Npn \__examzh_multifigures_coffin_align_set:n #1
+ {
+ \str_case:Vn \l__examzh_multifigures_coffin_align_str
+ {
+ {t} { \__examzh_multifigures_coffin_align_set_t:n {#1} }
+ {m} { \__examzh_multifigures_coffin_align_set_m:n {#1} }
+ {b} { \__examzh_multifigures_coffin_align_set_b:n {#1} }
+ }
+ }
+\cs_new:Npn \__examzh_multifigures_coffin_align_set_t:n #1
+ {
+ \coffin_typeset:cnnnn
+ { l__examzh_multifigures_figure_ \int_to_roman:n { #1 } _coffin }
+ { l } { t } % align = t
+ { \l__examzh_multifigures_xshift_dim } { \l__examzh_multifigures_yshift_dim + 1em }
+ }
+\cs_new:Npn \__examzh_multifigures_coffin_align_set_m:n #1
+ {
+ \coffin_typeset:cnnnn
+ { l__examzh_multifigures_figure_ \int_to_roman:n { #1 } _coffin }
+ { l } { vc } % align = m
+ { \l__examzh_multifigures_xshift_dim } { \l__examzh_multifigures_yshift_dim }
+ }
+\cs_new:Npn \__examzh_multifigures_coffin_align_set_b:n #1
+ {
+ \coffin_typeset:cnnnn
+ { l__examzh_multifigures_figure_ \int_to_roman:n { #1 } _coffin }
+ { l } { b } % align = b
+ { \l__examzh_multifigures_xshift_dim } { \l__examzh_multifigures_yshift_dim }
+ }
+\cs_new:Npn \__examzh_multifigures_coffin_join_position_set:n #1
+ {
+ \use:c { __examzh_multifigures_coffin_join_position_set_ \l__examzh_multifigures_figure_position_str :n } {#1}
+ }
+\cs_new:Npn \__examzh_multifigures_coffin_join_position_set_top:n #1
+ {
+ \coffin_join:cnncnnnn
+ { l__examzh_multifigures_figure_ \int_to_roman:n {#1} _ coffin }
+ { hc } { b }
+ { l__examzh_multifigures_label_ \int_to_roman:n {#1} _ coffin }
+ { hc } { t }
+ { \l__examzh_multifigures_label_xshift_dim }
+ { \l__examzh_multifigures_label_yshift_dim - 6pt }
+ }
+\cs_set_eq:NN
+ \__examzh_multifigures_coffin_join_position_set_above:n
+ \__examzh_multifigures_coffin_join_position_set_top:n
+\cs_new:Npn \__examzh_multifigures_coffin_join_position_set_bottom:n #1
+ {
+ \coffin_join:cnncnnnn
+ { l__examzh_multifigures_figure_ \int_to_roman:n {#1} _ coffin }
+ { hc } { t }
+ { l__examzh_multifigures_label_ \int_to_roman:n {#1} _ coffin }
+ { hc } { b }
+ { \l__examzh_multifigures_label_xshift_dim }
+ { \l__examzh_multifigures_label_yshift_dim + 6pt }
+ }
+\cs_set_eq:NN
+ \__examzh_multifigures_coffin_join_position_set_below:n
+ \__examzh_multifigures_coffin_join_position_set_bottom:n
+\cs_new:Npn \__examzh_multifigures_coffin_join_position_set_left:n #1
+ {
+ \coffin_join:cnncnnnn
+ { l__examzh_multifigures_figure_ \int_to_roman:n {#1} _ coffin }
+ { l } { vc }
+ { l__examzh_multifigures_label_ \int_to_roman:n {#1} _ coffin }
+ { r } { vc }
+ { \l__examzh_multifigures_label_xshift_dim - 6pt }
+ { \l__examzh_multifigures_label_yshift_dim }
+ }
+\cs_new:Npn \__examzh_multifigures_coffin_join_position_set_right:n #1
+ {
+ \coffin_join:cnncnnnn
+ { l__examzh_multifigures_figure_ \int_to_roman:n {#1} _ coffin }
+ { r } { vc }
+ { l__examzh_multifigures_label_ \int_to_roman:n {#1} _ coffin }
+ { l } { vc }
+ { \l__examzh_multifigures_label_xshift_dim + 2pt }
+ { \l__examzh_multifigures_label_yshift_dim }
+ }
+\cs_new:Npn \__examzh_multifigures_coffin_typeset:n #1
+ {
+ \__examzh_multifigures_coffin_typeset_count:
+ \seq_map_indexed_inline:Nn \l__examzh_multifigures_store_seq
+ % ##1: index
+ % ##2: content
+ {
+ \int_compare:nNnTF { \int_mod:nn {##1} { \l__examzh_multifigures_column_int } } = {0}
+ {
+ \tl_gput_right:Nn \l__examzh_multifigures_tblr_content_tl { ##2 \\ }
+ }
+ {
+ \tl_gput_right:Nn \l__examzh_multifigures_tblr_content_tl { ##2 & }
+ }
+ }
+ % 如果 seq 的 item 比 column 多且不整除 column 的话,要补 &
+ \int_compare:nNnT { \l__examzh_multifigures_store_seq_item_int } > { \l__examzh_multifigures_column_int }
+ {
+ \int_compare:nNnF { \l__examzh_multifigures_item_num_mod_column_left_int } = { 0 }
+ {
+ \tl_gput_right:Nx \l__examzh_multifigures_tblr_content_tl
+ {
+ \prg_replicate:nn { \l__examzh_multifigures_item_num_mod_column_left_int -1 } {&}
+ }
+ % \int_use:N \l__examzh_multifigures_item_num_mod_column_left_int
+ }
+ }
+ \par
+ \vspace*{ \l__examzh_multifigures_top_sep_skip }
+ \noindent \centering
+ % \SetTblrInner
+ % {
+ % rowsep = 4pt,
+ % % colsep = 0pt
+ % }
+ \begin{tblr}
+ [ expand = \l__examzh_multifigures_tblr_content_tl ]
+ {
+ width = \textwidth,
+ cells = {c},
+ column{1} = {leftsep = 0pt},
+ column{Z} = {rightsep = 0pt},
+ rows =
+ {
+ abovesep = 0pt,
+ belowsep = 0pt,
+ },
+ % vlines,hlines,
+ #1
+ }
+ \l__examzh_multifigures_tblr_content_tl
+ \end{tblr}
+ \vspace*{ \l__examzh_multifigures_bottom_sep_skip }
+ \par
+ }
+\int_new:N \l__examzh_multifigures_item_num_mod_column_left_int
+\cs_new:Npn \__examzh_multifigures_coffin_typeset_count:
+ {
+ % 计算 seq 有多少项
+ \int_set:Nn \l__examzh_multifigures_store_seq_item_int
+ { \seq_count:N \l__examzh_multifigures_store_seq }
+ % seq 项数小于 column 的话,column 设置为 seq 项数
+ \int_compare:nNnTF { \l__examzh_multifigures_store_seq_item_int } < { \l__examzh_multifigures_column_int }
+ { \int_set_eq:NN \l__examzh_multifigures_column_int \l__examzh_multifigures_store_seq_item_int }
+ {
+ % 计算 \l__examzh_multifigures_store_seq_item_int mod \l__examzh_multifigures_column_int 的余数,用于补 &
+ \int_set:Nn \l__examzh_multifigures_item_num_mod_column_left_int { \int_mod:nn { \l__examzh_multifigures_store_seq_item_int } { \l__examzh_multifigures_column_int } }
+ }
+ }
+\cs_new:Npn \__examzh_multifigures_item:n #1
+ {
+ % 增加指标(g 是关键)
+ \int_gincr:N \l__examzh_multifigures_item_index_int
+ % 新建 coffin
+ \__examzh_multifigures_item_new_coffin:
+ % 储存 label(一直出不来的原因是因为没改成 gset)
+ \hcoffin_gset:cn { l__examzh_multifigures_label_ \int_to_roman:n { \l__examzh_multifigures_item_index_int } _coffin } {#1}
+ % 储存 figure
+ \int_compare:nNnF { \l__examzh_multifigures_item_index_int } = {1}
+ {
+ \unskip
+ \end{varwidth}
+ % 结束上一个 item 的收集
+ \hcoffin_set_end:
+ }
+ % 收集
+ \hcoffin_set:cw { l__examzh_multifigures_figure_ \int_to_roman:n { \l__examzh_multifigures_item_index_int } _coffin }
+ \begin{varwidth}{\hsize}
+ \ignorespaces
+ }
+
+% 新建 coffin
+\cs_new:Npn \__examzh_multifigures_item_new_coffin:
+ {
+ % 放图片的 coffin
+ \coffin_if_exist:cF { l__examzh_multifigures_figure_ \int_to_roman:n { \l__examzh_multifigures_item_index_int } _coffin }
+ { \coffin_new:c { l__examzh_multifigures_figure_ \int_to_roman:n { \l__examzh_multifigures_item_index_int } _coffin } }
+ % 放 label 的 coffin
+ \coffin_if_exist:cF { l__examzh_multifigures_label_ \int_to_roman:n { \l__examzh_multifigures_item_index_int } _coffin }
+ { \coffin_new:c { l__examzh_multifigures_label_ \int_to_roman:n { \l__examzh_multifigures_item_index_int } _coffin } }
+ }
+
+
+
+%% \textfigure
+
+
+\coffin_new:N \l__examzh_textfigure_text_coffin % 用于存文本
+\coffin_new:N \l__examzh_textfigure_figure_coffin % 用于存图片
+
+\str_new:N \l__examzh_textfigure_current_figure_position_str % 用来存当前的 anchor值
+
+\fp_new:N \l__examzh_textfigure_text_ratio_fp % 文本的比例
+
+\dim_new:N \l__examzh_textfigure_text_width_dim % 文本的宽度
+\dim_new:N \l__examzh_textfigure_text_coffin_width_dim % 文本c offin 的宽度
+\dim_new:N \l__examzh_textfigure_figure_width_dim % 图片的 varwidth 环境的宽度
+
+% 用于 top-center, top-right, bottom-center, bottom-right 的水平偏移量储存
+\dim_new:N \l__examzh_textfigure_figure_coffin_horizontal_transform_dim
+\dim_new:N \l__examzh_textfigure_tmpa_dim % 临时变量
+
+\skip_new:N \l__examzh_textfigure_tmpa_skip % 临时变量
+
+
+\keys_define:nn { exam-zh }
+ {
+ textfigure .meta:nn = { exam-zh / textfigure } {#1}
+ }
+
+\keys_define:nn { exam-zh / textfigure }
+ {
+ % fig-pos为图片位于文本的方位
+ fig-pos .choices:nn =
+ {
+ left , right , top , bottom ,
+ top-left , top-right , top-center ,
+ top-flushright , bottom-flushright ,
+ bottom-left , bottom-right , bottom-center ,
+ right-top , right-bottom , right-center ,
+ left-top , left-bottom , left-center
+ }
+ {
+ \str_set:NV \l__examzh_textfigure_current_figure_position_str \l_keys_choice_tl
+ },
+ % figure-yshift:调整图片的垂直额外偏移量
+ figure-yshift .dim_set:N = \l__examzh_textfigure_figure_yshift_dim,
+ figure-vshift .dim_set:N = \l__examzh_textfigure_figure_yshift_dim,
+ % figure-xshift:调整图片的水平额外偏移量
+ figure-xshift .dim_set:N = \l__examzh_textfigure_figure_xshift_dim,
+ figure-hshift .dim_set:N = \l__examzh_textfigure_figure_xshift_dim,
+ % yshift:调整整体的垂直额外偏移量
+ yshift .dim_set:N = \l__examzh_textfigure_yshift_dim,
+ vshift .dim_set:N = \l__examzh_textfigure_yshift_dim,
+ % xshift:调整整体的水平额外偏移量
+ xshift .dim_set:N = \l__examzh_textfigure_xshift_dim,
+ hshift .dim_set:N = \l__examzh_textfigure_xshift_dim,
+ % text-width:手动设置文本的 varwidth 环境的宽度
+ text-width .dim_set:N = \l__examzh_textfigure_text_width_dim,
+ % figure-width:手动设置 figure 的 varwidth 环境的宽度
+ figure-width .dim_set:N = \l__examzh_textfigure_figure_width_dim,
+ % ratio / text-ratio:文本 coffin 占行宽的比例,范围0-1
+ ratio .fp_set:N = \l__examzh_textfigure_text_ratio_fp,
+ text-ratio .fp_set:N = \l__examzh_textfigure_text_ratio_fp,
+ % 环境上方的额外距离
+ top-sep .skip_set:N = \l__examzh_textfigure_top_sep_skip,
+ % 环境下方的额外距离
+ bottom-sep .skip_set:N = \l__examzh_textfigure_bottom_sep_skip,
+ % 类似于 wrapstuff 的 top
+ top .int_set:N = \l__examzh_textfigure_top_int
+ }
+
+\keys_set:nn { exam-zh / textfigure }
+ {
+ fig-pos = right,
+ yshift = .5\baselineskip,
+ text-width = \columnwidth,
+ figure-width = \columnwidth,
+ text-ratio = 0.95,
+ top-sep = 0pt,
+ bottom-sep = 1.5ex plus .5ex minus 0.5ex,
+ top = 0
+ }
+
+
+% 【已解决】判断anchor是不是west或者east,是的话就自动调整调整一下text-ratio
+% - 问题在于要知道key-val设置了什么anchor才能判断
+% - 但是这个key-val设置和手动设置ratio是同一接口
+% - 理想是:
+% - 先用户设置anchor
+% - 然后自动判断是否是west或者east,并自动调整ratio
+% 【思考】其实也就是说anchor的时候要判断是否是east和west来设置ratio(关键)
+% - 然后用户手动的话以手动的为准
+% 【解决关键】既然不可能中途处理,那只能在 key-val 设置的时候就要处理掉这个自动的ratio,所以重新设计了anchor键值代码
+
+\NewDocumentCommand{ \textfigure }{ O{} +m +m }
+ {
+ \group_begin:
+ \keys_set:nn { exam-zh / textfigure } {#1}
+ \par
+ \vspace*{ \l__examzh_textfigure_top_sep_skip }
+ \noindent
+ \__examzh_textfigure_output:nn {#2} {#3}
+ \vspace*{ \l__examzh_textfigure_bottom_sep_skip }
+ \group_end:
+ }
+
+
+% 最终的拼接命令
+\cs_new:Npn \__examzh_textfigure_output:nn #1#2
+ {
+ \__examzh_textfigure_text_width_dim_set:
+ % issue:https://gitee.com/xkwxdyy/text-figure/issues/I4RVQX
+ % 关键点在于要离开垂直模式
+ % https://ask.latexstudio.net/ask/question/7238.html
+ \mode_leave_vertical:
+ % 将内容存到 coffin 中
+ \__examzh_textfigure_coffin_store:nn {#1}{#2}
+ % coffin 的拼接
+ \__examzh_textfigure_coffin_join:
+ % coffin 的 typeset
+ \__examzh_textfigure_coffin_typeset:
+ }
+\cs_new:Npn \__examzh_textfigure_text_width_dim_set:
+ {
+ % \str_case:VnT \l__examzh_textfigure_current_figure_position_str
+ % {
+ % {bottom-flushright} {}
+ % {bottom-left} {}
+ % {bottom-right} {}
+ % {bottom-center} {}
+ % }
+ % { \fp_set:Nn \l__examzh_textfigure_text_ratio_fp {1} }
+ % \fp_compare:nNnF { \l__examzh_textfigure_text_ratio_fp } = { 1 }
+ % {
+ % \str_case:VnT \l__examzh_textfigure_current_figure_position_str
+ % {
+ % {left} {}
+ % {right} {}
+ % {left-center} {}
+ % {right-center} {}
+ % {right-top} {}
+ % {right-bottom} {}
+ % {left-top} {}
+ % {left-bottom} {}
+ % }
+ % { \fp_set:Nn \l__examzh_textfigure_text_ratio_fp {0.7} }
+ % }
+ \dim_set_eq:NN \l__examzh_textfigure_tmpa_dim \l__examzh_textfigure_text_width_dim
+ \dim_set:Nn \l__examzh_textfigure_text_width_dim
+ {
+ \l__examzh_textfigure_tmpa_dim * \dim_ratio:nn { \fp_use:N \l__examzh_textfigure_text_ratio_fp pt } { 1 pt }
+ }
+ }
+\cs_new:Npn \__examzh_textfigure_coffin_store:nn #1#2
+ {
+ \hcoffin_set:Nn \l__examzh_textfigure_text_coffin
+ {
+ \begin{varwidth}{ \l__examzh_textfigure_text_width_dim }
+ \dim_set:Nn \parindent {2em}
+ \ignorespaces
+ #1
+ \unskip
+ \end{varwidth}
+ }
+ \hcoffin_set:Nn \l__examzh_textfigure_figure_coffin
+ {
+ \begin{varwidth}{ \l__examzh_textfigure_figure_width_dim }
+ \centering
+ \ignorespaces
+ #2
+ \unskip
+ \end{varwidth}
+ }
+ }
+\cs_new:Npn \__examzh_textfigure_coffin_join:
+ {
+ \use:c { __examzh_textfigure_fig_pos_set_ \l__examzh_textfigure_current_figure_position_str :NN }
+ \l__examzh_textfigure_text_coffin
+ \l__examzh_textfigure_figure_coffin
+ }
+\cs_new:Npn \__examzh_textfigure_coffin_typeset:
+ {
+ \coffin_typeset:Nnnnn \l__examzh_textfigure_text_coffin
+ { l } { t }
+ { \l__examzh_textfigure_xshift_dim }
+ { \l__examzh_textfigure_yshift_dim }
+ }
+
+% top表示位于文本正上方
+\cs_new_protected:cpn { __examzh_textfigure_fig_pos_set_top:NN } #1#2
+ {
+ \coffin_join:NnnNnnnn
+ #1 { t } { hc }
+ #2 { b } { hc }
+ { \l__examzh_textfigure_figure_xshift_dim }
+ { 1em + \l__examzh_textfigure_figure_yshift_dim }
+ }
+% top-center表示位于文本上方,但是处于水平的中线处
+\cs_new_protected:cpn { __examzh_textfigure_fig_pos_set_top-center:NN } #1#2
+ {
+ \dim_set:Nn \l__examzh_textfigure_tmpa_dim
+ { \coffin_wd:N #1 }
+ \dim_set:Nn \l__examzh_textfigure_figure_coffin_horizontal_transform_dim
+ {
+ \linewidth * \dim_ratio:nn { 1 pt } { 2 pt }
+ -
+ \l__examzh_textfigure_tmpa_dim * \dim_ratio:nn { 1 pt } { 2 pt }
+ }
+ \coffin_join:NnnNnnnn
+ #1 { t } { hc }
+ #2 { b } { hc }
+ { \l__examzh_textfigure_figure_coffin_horizontal_transform_dim + \l__examzh_textfigure_figure_xshift_dim }
+ { 1em + \l__examzh_textfigure_figure_yshift_dim }
+ }
+% bottom-center表示位于文本下方,但是处于水平的中线处
+\cs_new_protected:cpn { __examzh_textfigure_fig_pos_set_bottom-center:NN } #1#2
+ {
+ \dim_set:Nn \l__examzh_textfigure_tmpa_dim
+ { \coffin_wd:N #1 }
+ \dim_set:Nn \l__examzh_textfigure_figure_coffin_horizontal_transform_dim
+ {
+ \linewidth * \dim_ratio:nn { 1 pt } { 2 pt }
+ -
+ \l__examzh_textfigure_tmpa_dim * \dim_ratio:nn { 1 pt } { 2 pt }
+ }
+ \coffin_join:NnnNnnnn
+ #1 { b } { hc }
+ #2 { t } { hc }
+ { \l__examzh_textfigure_figure_coffin_horizontal_transform_dim + \l__examzh_textfigure_figure_xshift_dim }
+ { -1em + \l__examzh_textfigure_figure_yshift_dim }
+ }
+% bottom 表示位于文本正下方
+\cs_new_protected:cpn { __examzh_textfigure_fig_pos_set_bottom:NN } #1#2
+ {
+ \coffin_join:NnnNnnnn
+ #1 { b } { hc }
+ #2 { t } { hc }
+ { \l__examzh_textfigure_figure_xshift_dim }
+ { -1em + \l__examzh_textfigure_figure_yshift_dim }
+ }
+\cs_new_protected:cpn { __examzh_textfigure_fig_pos_set_left:NN } #1#2
+ {
+ \coffin_join:NnnNnnnn
+ #1 { vc } { l }
+ #2 { vc } { r }
+ { -1em + \l__examzh_textfigure_figure_xshift_dim }
+ { \l__examzh_textfigure_figure_yshift_dim }
+ }
+\cs_set_eq:cc { __examzh_textfigure_fig_pos_set_left-center:NN } { __examzh_textfigure_fig_pos_set_left:NN }
+\cs_new_protected:cpn { __examzh_textfigure_fig_pos_set_left-top:NN } #1#2
+ {
+ \dim_set:Nn \l__examzh_textfigure_tmpa_dim
+ { \baselineskip * \dim_ratio:nn { \int_use:N \l__examzh_textfigure_top_int pt } { 1pt } }
+ \coffin_join:NnnNnnnn
+ #1 { t } { l }
+ #2 { t } { r }
+ { -1em + \l__examzh_textfigure_figure_xshift_dim }
+ { - \l__examzh_textfigure_tmpa_dim + \l__examzh_textfigure_figure_yshift_dim }
+ }
+\cs_new_protected:cpn { __examzh_textfigure_fig_pos_set_left-bottom:NN } #1#2
+ {
+ \coffin_join:NnnNnnnn
+ #1 { b } { l }
+ #2 { b } { r }
+ { -1em + \l__examzh_textfigure_figure_xshift_dim }
+ { 0pt + \l__examzh_textfigure_figure_yshift_dim }
+ }
+\cs_new_protected:cpn { __examzh_textfigure_fig_pos_set_right-top:NN } #1#2
+ {
+ \dim_set:Nn \l__examzh_textfigure_tmpa_dim
+ { \baselineskip * \dim_ratio:nn { \int_use:N \l__examzh_textfigure_top_int pt } { 1pt } }
+ \coffin_join:NnnNnnnn
+ #1 { t } { r }
+ #2 { t } { l }
+ { 1em + \l__examzh_textfigure_figure_xshift_dim }
+ { - \l__examzh_textfigure_tmpa_dim + \l__examzh_textfigure_figure_yshift_dim }
+ }
+\cs_new_protected:cpn { __examzh_textfigure_fig_pos_set_right-center:NN } #1#2
+ {
+ \coffin_join:NnnNnnnn
+ #1 { vc } { r }
+ #2 { vc } { l }
+ { 1em + \l__examzh_textfigure_figure_xshift_dim }
+ { 0pt + \l__examzh_textfigure_figure_yshift_dim }
+ }
+\cs_new_protected:cpn { __examzh_textfigure_fig_pos_set_right-bottom:NN } #1#2
+ {
+ \coffin_join:NnnNnnnn
+ #1 { b } { r }
+ #2 { b } { l }
+ { 1em + \l__examzh_textfigure_figure_xshift_dim }
+ { 0pt + \l__examzh_textfigure_figure_yshift_dim }
+ }
+\cs_set_eq:cc { __examzh_textfigure_fig_pos_set_right:NN } { __examzh_textfigure_fig_pos_set_right-center:NN }
+% top-flushright:文本上方,水平方向是在行尾
+\cs_new_protected:cpn { __examzh_textfigure_fig_pos_set_top-flushright:NN } #1#2
+ {
+ \dim_set:Nn \l__examzh_textfigure_tmpa_dim
+ { \coffin_wd:N #1 }
+ \dim_set:Nn \l__examzh_textfigure_figure_coffin_horizontal_transform_dim
+ { \linewidth - \l__examzh_textfigure_tmpa_dim }
+ \coffin_join:NnnNnnnn
+ #1 { t } { r }
+ #2 { b } { r }
+ { \l__examzh_textfigure_figure_coffin_horizontal_transform_dim + \l__examzh_textfigure_figure_xshift_dim }
+ { 1em + \l__examzh_textfigure_figure_yshift_dim }
+ }
+\cs_new_protected:cpn { __examzh_textfigure_fig_pos_set_top-right:NN } #1#2
+ {
+ \coffin_join:NnnNnnnn
+ #1 { t } { r }
+ #2 { b } { r }
+ { \l__examzh_textfigure_figure_xshift_dim }
+ { 1em + \l__examzh_textfigure_figure_yshift_dim }
+ }
+% bottom-flushright:文本下方,水平方向在行尾
+\cs_new_protected:cpn { __examzh_textfigure_fig_pos_set_bottom-flushright:NN } #1#2
+ {
+ \dim_set:Nn \l__examzh_textfigure_tmpa_dim
+ { \coffin_wd:N #1 }
+ \dim_set:Nn \l__examzh_textfigure_figure_coffin_horizontal_transform_dim
+ { \linewidth - \l__examzh_textfigure_tmpa_dim }
+ \coffin_join:NnnNnnnn
+ #1 { b } { r }
+ #2 { t } { r }
+ { \l__examzh_textfigure_figure_coffin_horizontal_transform_dim + \l__examzh_textfigure_figure_xshift_dim }
+ { -1em + \l__examzh_textfigure_figure_yshift_dim }
+ }
+\cs_new_protected:cpn { __examzh_textfigure_fig_pos_set_bottom-right:NN } #1#2
+ {
+ \coffin_join:NnnNnnnn
+ #1 { b } { r }
+ #2 { t } { r }
+ { \l__examzh_textfigure_figure_xshift_dim }
+ { -1em + \l__examzh_textfigure_figure_yshift_dim }
+ }
+\cs_new_protected:cpn { __examzh_textfigure_fig_pos_set_top-left:NN } #1#2
+ {
+ \coffin_join:NnnNnnnn
+ #1 { t } { l }
+ #2 { b } { l }
+ { 0pt + \l__examzh_textfigure_figure_xshift_dim }
+ { 1em + \l__examzh_textfigure_figure_yshift_dim }
+ }
+\cs_new_protected:cpn { __examzh_textfigure_fig_pos_set_bottom-left:NN } #1#2
+ {
+ \coffin_join:NnnNnnnn
+ #1 { b } { l }
+ #2 { t } { l }
+ { 0pt + \l__examzh_textfigure_figure_xshift_dim }
+ { -1em + \l__examzh_textfigure_figure_yshift_dim }
+ } \ No newline at end of file
diff --git a/macros/xetex/latex/exam-zh/tex/exam-zh.cls b/macros/xetex/latex/exam-zh/tex/exam-zh.cls
index 817ee767e5..3f98de7858 100644
--- a/macros/xetex/latex/exam-zh/tex/exam-zh.cls
+++ b/macros/xetex/latex/exam-zh/tex/exam-zh.cls
@@ -1,12 +1,12 @@
%
% Copyright (c) 2022 Zeping Lee
% Released under the LaTeX Project Public License v1.3c License.
-% Repository: https://gitee.com/zepinglee/exam-zh
+% Repository: https://gitee.com/xkwxdyy/exam-zh
%
\NeedsTeXFormat{LaTeX2e}[2017/04/15]
\RequirePackage{expl3}
-\ProvidesExplClass {exam-zh} {2022-08-15} {v0.1.18} {LaTeX template for Chinese exam}
+\ProvidesExplClass {exam-zh} {2022-08-28} {v0.1.19} {LaTeX template for Chinese exam}
% 检查 LaTeX2e kernel 版本
\msg_new:nnn { exam-zh } { latex-too-old }
@@ -86,6 +86,7 @@
\RequirePackage { exam-zh-choices }
\RequirePackage { exam-zh-symbols }
\RequirePackage { exam-zh-chinese-english }
+\RequirePackage { exam-zh-textfigure }
\AtEndPreamble
{
@@ -182,8 +183,9 @@
\NewDocumentCommand { \ExamPrintAnswer } { }
{
- \clist_use:Nn \g__examzh_print_answer_cmd_set_clist {}
- \clist_if_empty:NF \g__examzh_print_answer_keys_set_clist
+ \clist_if_exist:NT \g__examzh_print_answer_cmd_set_clist
+ { \clist_use:Nn \g__examzh_print_answer_cmd_set_clist {} }
+ \clist_if_exist:NT \g__examzh_print_answer_keys_set_clist
{
\keys_set:nx { exam-zh }
{ \g__examzh_print_answer_keys_set_clist }
@@ -499,6 +501,11 @@
\dim_set:Nn \lineskiplimit { .5em }
\skip_set:Nn \lineskip { .5em }
+% 增加对 minipage 的处理
+% https://tex.stackexchange.com/a/358080/246645
+\dim_set:Nn \normallineskiplimit { .5em }
+\skip_set:Nn \normallineskip { .5em }
+
% 设置 enumitem 列表格式
@@ -534,9 +541,14 @@
\setlist[enumerate, 2]
{
- left = 2em,
- labelsep = 0pt,
- label = { ( \arabic * ) }
+ % labelindent = *,
+ leftmargin = 0pt,
+ widest = 0,
+ itemindent = 4em,
+ labelsep = 0pt,
+ % labelwidth = 2em,
+ listparindent = \parindent,
+ label = {( \arabic * )},
}
% 多种方法: method环境
@@ -1193,7 +1205,7 @@
}
\keys_set:nn { exam-zh / page }
{
- show-columnline = true,
+ show-columnline = false,
columnline-width = 0.4pt
}