该ghsystem
软件包允许生成欧盟 CLP 法规定义的危险和预防声明。
\documentclass[a4paper,12pt]{article}
\usepackage{ghsystem}
\begin{document}
\ghs{p}{302+352} \ghs{p}{210}
\underline{P302+P352}: IF ON SKIN: Wash with plenty of soap and water. \underline{P210}: Keep away from heat/sparks/open flames/hot surfaces. — No smoking.
\end{document}
编译后得到:
我无法找到修改生成的 H 和 P 语句外观的方法ghsystem
。具体来说,我希望组合语句 (P302+P352) 的标识符内没有空格,并且语句标识符也带有下划线,如第二段所示。是否可以配置ghsystem
使用第一段中的代码生成第二段的输出?
答案1
据我从文档和代码中了解,包+
中目前没有提供自定义组合语句周围空间以及类型和数字样式的选项ghsystem
。
这是添加这些选项的第一次粗略尝试,肯定仍需要改进。
使用新引入的选项plus-space
和number-style
(例如\ghssetup{plus-space=, number-style=\uline}
),您可以删除 周围的空格+
,并确保标识语句的字母和数字带有下划线。由于我使用了\ulem
的\uline
命令而不是\underline
,因此输出(上半部分)看起来与您的问题手动创建的输出(下半部分)略有不同:
\documentclass[a4paper,12pt]{article}
\usepackage{ulem} % Needed for the \uline command, that I used instead of \underline
\usepackage{ghsystem}
\ExplSyntaxOn
\tl_new:N \l__ghsystem_plus_space_tl
\tl_new:N \l__ghsystem_number_style_tl
\tl_new:N \l__ghsystem_text_style_tl
\keys_define:nn {ghsystem}
{
plus-space .tl_set:N =
\l__ghsystem_plus_space_tl ,
plus-space .initial:n = \nobreakspace ,
number-style .tl_set:N =
\l__ghsystem_number_style_tl ,
text-style .tl_set:N =
\l__ghsystem_text_style_tl ,
text-style .initial:n = \normalfont,
}
\cs_set:Npn \__ghsystem_is_combination_aux_i:w #1,#2+#3 \q_stop
{
\bool_if:NT \l__ghsystem_show_number_bool
{
\tl_use:N \l__ghsystem_number_style_tl{\text_uppercase:n {#1}}
\tl_use:N \l__ghsystem_number_space_tl
\tl_use:N \l__ghsystem_number_style_tl{#2 \tl_use:N \l__ghsystem_plus_space_tl + \tl_use:N \l__ghsystem_plus_space_tl}
\tl_if_in:nnTF {#3} { + }
{ \__ghsystem_is_combination_aux_iii:w #1,#3 \q_stop }
{
\tl_use:N \l__ghsystem_number_style_tl{\text_uppercase:n {#1}}
\tl_use:N \l__ghsystem_number_space_tl
\tl_use:N \l__ghsystem_number_style_tl{#3} \bool_if:NF \l__ghsystem_hide_statement_bool { \tl_use:N \l__ghsystem_number_style_tl{:} \l__ghsystem_text_style_tl{} ~ }
}
}
}
\cs_set:Npn \__ghsystem_is_combination_aux_ii:w #1,#2 \q_stop
{
\bool_if:NT \l__ghsystem_show_number_bool
{
\tl_use:N \l__ghsystem_number_style_tl{\text_uppercase:n {#1}}
\tl_use:N \l__ghsystem_number_space_tl
\tl_use:N \l__ghsystem_number_style_tl{#2} \bool_if:NF \l__ghsystem_hide_statement_bool { \tl_use:N \l__ghsystem_number_style_tl{:} \l__ghsystem_text_style_tl{} ~ }
}
}
\cs_set:Npn \__ghsystem_is_combination_aux_iii:w #1,#2+#3 \q_stop
{
\bool_if:NT \l__ghsystem_show_number_bool
{
\tl_use:N \l__ghsystem_number_style_tl{\text_uppercase:n {#1}}
\tl_use:N \l__ghsystem_number_space_tl
\tl_use:N \l__ghsystem_number_style_tl{#2 \tl_use:N \l__ghsystem_plus_space_tl + \tl_use:N \l__ghsystem_plus_space_tl}
\tl_use:N \l__ghsystem_number_style_tl{\text_uppercase:n {#1}}
\tl_use:N \l__ghsystem_number_space_tl
\tl_use:N \l__ghsystem_number_style_tl{#3} \bool_if:NF \l__ghsystem_hide_statement_bool { \tl_use:N \l__ghsystem_number_style_tl{:} \l__ghsystem_text_style_tl{} ~ }
}
}
\ExplSyntaxOff
\ghssetup{plus-space=, number-style=\uline}
\begin{document}
\ghs{p}{302+352} \ghs{p}{210}
\underline{P302+P352}: IF ON SKIN: Wash with plenty of soap and water. \underline{P210}: Keep away from heat/sparks/open flames/hot surfaces. — No smoking.
\end{document}
以下是一些其他输出,可以通过上面的 MWE 序言获得:
\ghssetup{number-style=\bfseries}
\ghs{p}{302+352} \ghs{p}{210}
\medskip
\ghssetup{number-style=\itshape}
\ghs{p}{302+352} \ghs{p}{210}
\medskip
\ghssetup{number-style=\bfseries\textcolor{red}} % additionally needs `\usepackage{xcolor}
\ghs{p}{302+352} \ghs{p}{210}
\medskip
\ghssetup{number-style=\bfseries\uline, text-style=\normalfont\itshape}
\ghs{p}{302+352} \ghs{p}{210}
\medskip
\ghssetup{number-style=\textit, text-style=\color{blue}} % additionally needs `\usepackage{xcolor}
\ghs{p}{302+352} \ghs{p}{210}