summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/chemmacros/ghsystem.sty
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/latex/chemmacros/ghsystem.sty')
-rw-r--r--Master/texmf-dist/tex/latex/chemmacros/ghsystem.sty233
1 files changed, 160 insertions, 73 deletions
diff --git a/Master/texmf-dist/tex/latex/chemmacros/ghsystem.sty b/Master/texmf-dist/tex/latex/chemmacros/ghsystem.sty
index 90e387ff1d8..5f552b8e2a0 100644
--- a/Master/texmf-dist/tex/latex/chemmacros/ghsystem.sty
+++ b/Master/texmf-dist/tex/latex/chemmacros/ghsystem.sty
@@ -26,13 +26,29 @@
% - - %
% - The Current Maintainer of this work is Clemens Niederberger. - %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\RequirePackage{ chemmacros }
+\RequirePackage{ expl3, xparse, l3keys2e }
+\def\ghsystem@version{4.0}
+\def\ghsystem@date{2013/07/06}
\ProvidesExplPackage
{ghsystem}
- {\chemmacros@date}
- {\chemmacros@version}
+ {\ghsystem@date}
+ {\ghsystem@version}
{globally harmonised system}
+% --------------------------------------------------------------------------
+% check expl3 version:
+\@ifpackagelater { expl3 } { 2012/11/21 }
+ { }
+ {
+ \PackageError { ghsystem } { Support~package~expl3~too~old }
+ {
+ You~need~to~update~your~installation~of~the~bundles~'l3kernel'~and~
+ 'l3packages'.\MessageBreak
+ Loading~ghsystem~will~abort!
+ }
+ \tex_endinput:D
+ }
+
% --------------------------------------------------------------------------- %
% error and warning messages:
\msg_set:nnnn { ghsystem } { explicit }
@@ -62,6 +78,45 @@
sure~to~load~it~in~your~preamble.
}
+\cs_new_protected:Npn \ghsystem_msg:nnxx #1#2#3#4
+ {
+ \bool_if:NTF \l__ghsystem_strict_bool
+ { \msg_error:nnxx { #1 } { #2 } { #3 } { #4 } }
+ { \msg_warning:nnxx { #1 } { #2 } { #3 } { #4 } }
+ }
+
+% --------------------------------------------------------------------------
+% package options:
+\bool_new:N \l__ghsystem_strict_bool
+\keys_define:nn { chemmacros / ghsystem }
+ {
+ strict .bool_set:N = \l__ghsystem_strict_bool ,
+ strict .default:n = true ,
+ language .code:n = \ghsystem_load_language:n { #1 }
+ }
+
+\AtBeginDocument
+ {
+ \@ifpackageloaded{ chemmacros }
+ {
+ \bool_if:NT \l_chemmacros_strict_bool
+ { \bool_set_true:N \l__ghsystem_strict_bool }
+ }
+ {
+ \cs_new:Npn \iupac #1
+ {
+ \group_begin:
+ \cs_set_eq:NN \| \scan_stop:
+ #1
+ \group_end:
+ }
+ }
+ }
+
+% --------------------------------------------------------------------------- %
+% variants of kernel functions:
+\cs_generate_variant:Nn \file_if_exist:nTF { x }
+
% --------------------------------------------------------------------------- %
% scratch variables
\tl_new:N \l__ghsystem_tmpa_tl
@@ -69,13 +124,8 @@
\int_new:N \l__ghsystem_tmpa_int
\int_new:N \l__ghsystem_tmpb_int
-% --------------------------------------------------------------------------- %
-% gobble options
-\DeclareOption* { }
-\ProcessOptions \scan_stop:
-
% load required packages:
-\RequirePackage{ graphicx , tabu , longtable , ifpdf }
+\RequirePackage{ translations , siunitx , graphicx , longtable , ifpdf }
% --------------------------------------------------------------------------- %
% define variables:
@@ -126,7 +176,10 @@
\tl_new:N \l__ghsystem_table_caption_short_tl
\tl_new:N \l__ghsystem_table_label_tl
\tl_set:Nn \l__ghsystem_table_label_tl { tab : ghs-hp-statements }
+\tl_new:N \l__ghsystem_list_all_column_format_tl
+\dim_new:N \l__ghsystem_list_all_column_width_dim
+\dim_set:Nn \l__ghsystem_list_all_column_width_dim { .7\linewidth }
\dim_new:N \l__ghsystem_table_line_sep_dim
\dim_set:Nn \l__ghsystem_table_line_sep_dim { 3pt }
@@ -142,46 +195,63 @@
\bool_new:N \l__ghsystem_language_file_loaded_bool
\bool_new:N \l__ghsystem_language_directory_bool
-\file_if_exist:nTF { language / ghsystem_english_def }
- { \bool_set_true:N \l__ghsystem_language_directory_bool }
- { \bool_set_false:N \l__ghsystem_language_directory_bool }
+% load the language file -- it needs expl3 namespace but shouldn't care about
+% what catcode regime was before and simply restore it
-\bool_if:NTF \l__ghsystem_language_directory_bool
+\cs_new:Npn \__ghsystem_namespace_restore: {}
+
+\cs_new_protected:Npn \__ghsystem_expl_namespace:
{
- \prop_map_inline:Nn \l__chemmacros_language_prop
- {
- \bool_if:cT { l__chemmacros_#1_bool }
- {
- \file_if_exist:nTF { language / ghsystem_#2.def }
- {
- \bool_set_true:N \l__ghsystem_language_file_loaded_bool
- \input { language / ghsystem_#2.def } \ExplSyntaxOn
- }
- { \input { language / ghsystem_english.def } \ExplSyntaxOn }
- }
- }
+ \group_begin:
+ \cs_gset_protected:Npx \__ghsystem_namespace_restore:
+ {
+ \char_set_catcode:nn { 9 } { \char_value_catcode:n { 9 } }
+ \char_set_catcode:nn { 32 } { \char_value_catcode:n { 32 } }
+ \char_set_catcode:nn { 34 } { \char_value_catcode:n { 34 } }
+ \char_set_catcode:nn { 38 } { \char_value_catcode:n { 38 } }
+ \char_set_catcode:nn { 58 } { \char_value_catcode:n { 58 } }
+ \char_set_catcode:nn { 94 } { \char_value_catcode:n { 94 } }
+ \char_set_catcode:nn { 95 } { \char_value_catcode:n { 95 } }
+ \char_set_catcode:nn { 124 } { \char_value_catcode:n { 124 } }
+ \char_set_catcode:nn { 126 } { \char_value_catcode:n { 126 } }
+ \tex_endlinechar:D = \tex_the:D \tex_endlinechar:D \scan_stop:
+ }
+ \group_end:
+ \ExplSyntaxOn
+ }
+
+\cs_new:Npn \ghsystem_load_language_file:n #1
+ {
+ \__ghsystem_expl_namespace:
+ \input ghsystem_#1.def \scan_stop:
+ \__ghsystem_namespace_restore:
}
+
+\cs_new_protected:Npn \ghsystem_load_language:n #1
{
- \prop_map_inline:Nn \l__chemmacros_language_prop
+ \file_if_exist:xTF { ghsystem_ #1 .def }
{
- \bool_if:cT { l__chemmacros_#1_bool }
- {
- \file_if_exist:nTF { ghsystem_#2.def }
- {
- \bool_set_true:N \l__ghsystem_language_file_loaded_bool
- \input { ghsystem_#2.def } \ExplSyntaxOn
- }
- { \input { ghsystem_english.def } \ExplSyntaxOn }
- }
+ \bool_set_true:N \l__ghsystem_language_file_loaded_bool
+ \ghsystem_load_language_file:n { #1 }
}
+ { \ghsystem_load_language_file:n { english } }
}
+\cs_generate_variant:Nn \ghsystem_load_language:n { V }
-\bool_if:NF \l__ghsystem_language_file_loaded_bool
- {
- \bool_if:NTF \l__ghsystem_language_directory_bool
- { \input { language / ghsystem_english.def } \ExplSyntaxOn }
- { \input { ghsystem_english.def } \ExplSyntaxOn }
- }
+\NewDocumentCommand \loadghsystemlanguage { m }
+ { \ghsystem_load_language:n { #1 } }
+
+\AtBeginDocument{
+ \bool_if:NF \l__ghsystem_language_file_loaded_bool
+ {
+ \cs_if_exist:NTF \l_chemmacros_language_tl
+ { \ghsystem_load_language:V \l_chemmacros_language_tl }
+ {
+ \ghsystem_load_language:n
+ { \@trnslt@language{\@trnslt@current@language} }
+ }
+ }
+}
\cs_new_nopar:Nn \ghsystem_booktabs:n
{
@@ -193,12 +263,6 @@
% define options:
\keys_define:nn { chemmacros / ghsystem }
{
- % general options:
- language .code:n =
- \bool_set_true:c { l__ghsystem_#1_bool }
- \bool_if:NTF \l__ghsystem_language_directory_bool
- { \input { language / ghsystem_#1.def } }
- { \input { ghsystem_#1.def } } ,
% \ghs options:
hide .bool_set:N =
\l__ghsystem_hide_statement_bool ,
@@ -289,10 +353,16 @@
\tl_clear:N \l__ghsystem_table_top_head_rule_tl
\tl_clear:N \l__ghsystem_table_foot_rule_tl
\tl_clear:N \l__ghsystem_table_last_foot_rule_tl ,
- table-caption .tl_set:N = \l__ghsystem_table_caption_tl ,
+ table-caption .tl_set:N =
+ \l__ghsystem_table_caption_tl ,
table-caption-short .tl_set:N =
\l__ghsystem_table_caption_short_tl ,
- table-label .tl_set:N = \l__ghsystem_table_label_tl
+ table-label .tl_set:N =
+ \l__ghsystem_table_label_tl ,
+ table-column-format .tl_set:N =
+ \l__ghsystem_list_all_column_format_tl ,
+ table-column-width .dim_set:N =
+ \l__ghsystem_list_all_column_width_dim
}
% --------------------------------------------------------------------------- %
@@ -318,7 +388,7 @@
\bool_if:NF \l__ghsystem_hide_statement_bool
{ \tl_use:N \l__ghsystem_tmpb_tl }
}
- { \chemmacros_msg:nnxx { ghsystem } { statements } { #1 } { #2 } }
+ { \ghsystem_msg:nnxx { ghsystem } { statements } { #1 } { #2 } }
}
\cs_new_protected:Nn \__ghsystem_get_type:nN
@@ -400,8 +470,13 @@
\int_zero:N \l__ghsystem_tmpa_int
\int_zero:N \l__ghsystem_tmpb_int
\prop_map_inline:Nn \l__ghsystem_p_prop { \int_incr:N \l__ghsystem_tmpa_int }
- \dim_set_eq:NN \tabulinesep \l__ghsystem_table_line_sep_dim
- \begin { longtabu } { X[3]X[7,L] }
+ \dim_set_eq:NN \extrarowheight \l__ghsystem_table_line_sep_dim
+ \begin { longtable }
+ {
+ l
+ >{ \l__ghsystem_list_all_column_format_tl }
+ p{ \l__ghsystem_list_all_column_width_dim }
+ }
\caption [ \l__ghsystem_table_caption_short_tl ]
{
\l__ghsystem_table_caption_tl
@@ -435,7 +510,7 @@
\__ghsystem_read_number:nn { P } { ##1 } & ##2
\int_compare:nNnT { \l__ghsystem_tmpb_int } < { \l__ghsystem_tmpa_int } { \\ }
}
- \end { longtabu }
+ \end { longtable }
}
\cs_new:Nn \__ghsystem_read_number:nn
@@ -491,37 +566,49 @@
\cs_new_protected:Npn \ghsystem_pic:n #1
{
- \file_if_exist:nTF { pictures / ghsystem_ #1 . \l__ghsystem_picture_type_tl }
- { \bool_set_true:N \l__ghsystem_picture_directory_bool }
- { \bool_set_false:N \l__ghsystem_picture_directory_bool }
- \bool_if:NTF \l__ghsystem_picture_directory_bool
- {
- \__ghsystem_includegraphics:xn
- {
- scale = \fp_to_tl:N \l__ghsystem_picture_scale_fp
- \l__ghsystem_picture_includegraphics_tl
- }
- { pictures / ghsystem_ #1 . \l__ghsystem_picture_type_tl }
- }
+ \__ghsystem_includegraphics:xn
{
- \__ghsystem_includegraphics:xn
- {
- scale = \fp_to_tl:N \l__ghsystem_picture_scale_fp
- \l__ghsystem_picture_includegraphics_tl
- }
- { ghsystem_ #1 . \l__ghsystem_picture_type_tl }
+ scale = \fp_to_tl:N \l__ghsystem_picture_scale_fp
+ \exp_not:V \l__ghsystem_picture_includegraphics_tl
}
+ { ghsystem_ #1 . \l__ghsystem_picture_type_tl }
}
\cs_new:Nn \__ghsystem_includegraphics:nn
{ \includegraphics[#1]{#2} }
\cs_generate_variant:Nn \__ghsystem_includegraphics:nn { xn }
+% --------------------------------------------------------------------------
+% options and setup
+\ProcessKeysOptions{ chemmacros / ghsystem }
+
+\cs_new_protected:Npn \ghsystem_setup:n #1
+ { \keys_set:nn { chemmacros / ghsystem } { #1 } }
+
+\NewDocumentCommand \ghssetup { m }
+ { \ghsystem_setup:n { #1 } }
+
\tex_endinput:D
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
VERSION HISTORY
-see the chemmacros.sty file
+2012/01/30 - version 3.0a - renamed ghs => ghsystem to make the names unique
+ (following a request by Karl Berry for TeXlive)
+2012/02/05 - version 3.0c - renamed pictogram files (following a request by
+ Karl Berry for TeXlive)
+2012/05/13 - version 3.3a - Italian translations of the H, EUH and P statements
+2012/05/18 - version 3.3b - compatibility with MiKTeX
+2012/05/18 - version 3.3c - fix in the `ghsystem/language' option
+2012/07/24 - version 3.3d - additional picture file type `pdf'
+2013/02/19 - version 3.5a - bug fix: `ghsystem' recognizes language again
+2013/07/06 - version 4.0 - dropped requirement of `tabu' package.
+ - new options `table-column-width' and
+ `table-column-format'
+ - adapted to changed language setting mechanism in
+ `chemmacros'
+ - new command: \loadghsystemlanguage
+ - the package can be used independently from
+ `chemmacros'
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% TODO:
-- add option to switch between `longtable` and `supertabular` for \ghslistall ? \ No newline at end of file
+- add option to switch between `longtable` and `supertabular` for \ghslistall ?