blob: cbc6fe2303981a7d5eb364a0235fa1127a459fa6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
% --------------------------------------------------------------------------
%
% the CHEMMACROS package -- module: `phases'
%
% --------------------------------------------------------------------------
% Clemens Niederberger
% --------------------------------------------------------------------------
% https://github.org/cgnieder/chemmacros/
% contact@mychemistry.eu
% --------------------------------------------------------------------------
% If you have any ideas, questions, suggestions or bugs to report, please
% feel free to contact me.
% --------------------------------------------------------------------------
% Copyright 2011-2015 Clemens Niederberger
%
% This work 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.
%
% This work has the LPPL maintenance status `maintained'.
%
% The Current Maintainer of this work is Clemens Niederberger.
% --------------------------------------------------------------------------
\ChemModule{phases}{2015/06/09 phase descriptors}
\chemmacros_load_module:n {chemformula}
\bool_new:N \l__chemmacros_phases_sub_bool
\dim_new:N \l__chemmacros_phases_space_dim
\dim_set:Nn \l__chemmacros_phases_space_dim { .1333 em }
\keys_define:nn {chemmacros/phases}
{
pos .choice: ,
pos / sub .code:n = \bool_set_true:N \l__chemmacros_phases_sub_bool ,
pos / side .code:n = \bool_set_false:N \l__chemmacros_phases_sub_bool ,
space .dim_set:N = \l__chemmacros_phases_space_dim
}
\chemmacros_new_macroset:nnn {Phase} {mm} { \chemmacros_define_phase:Nn #1 {#2} }
\cs_new_protected:Npn \chemmacros_define_phase:Nn #1#2
{
\tl_set:Nx \l__chemmacros_tmpa_tl { phase-\chemmacros_remove_backslash:N #1 }
\exp_args:NV \@trnslt@declare@translation
\l__chemmacros_tmpa_tl
{fallback}
{#2}
\__chemmacros_define_phase:Nx #1
{ \exp_not:N \chemmacros_translate:n { \exp_not:V \l__chemmacros_tmpa_tl } }
}
\cs_new_protected:Npn \__chemmacros_define_phase:Nn #1#2
{
\cs_if_exist:NF #1 { \cs_new:Npn #1 {} }
\DeclareDocumentCommand #1 {o}
{ \chemmacros_phase:n { #2 \IfNoValueF {##1} {,~##1} } }
}
\cs_generate_variant:Nn \__chemmacros_define_phase:Nn { Nx }
\cs_new_protected:Npn \chemmacros_phase:n #1
{
\chemmacros_leave_vmode:
\bool_if:NTF \l__chemmacros_phases_sub_bool
{ \chemformula_subscript:n { (#1) } }
{
\skip_horizontal:N \l__chemmacros_phases_space_dim
\chemmacros_text:n { (#1) }
}
}
% --------------------------------------------------------------------------
\NewDocumentCommand \phase {m} { \chemmacros_phase:n {#1} }
\NewChemPhase \sld {s}
\NewChemPhase \lqd {l}
\NewChemPhase \gas {g}
\NewChemPhase \aq {aq}
% --------------------------------------------------------------------------
|