summaryrefslogtreecommitdiff
path: root/Master
diff options
context:
space:
mode:
Diffstat (limited to 'Master')
-rw-r--r--Master/texmf-dist/doc/latex/chemgreek/README2
-rw-r--r--Master/texmf-dist/doc/latex/chemgreek/chemgreek_en.pdfbin541550 -> 705967 bytes
-rw-r--r--Master/texmf-dist/doc/latex/chemgreek/chemgreek_en.tex117
-rw-r--r--Master/texmf-dist/tex/latex/chemgreek/chemgreek.sty409
4 files changed, 387 insertions, 141 deletions
diff --git a/Master/texmf-dist/doc/latex/chemgreek/README b/Master/texmf-dist/doc/latex/chemgreek/README
index 7edb818815d..cd5704cd511 100644
--- a/Master/texmf-dist/doc/latex/chemgreek/README
+++ b/Master/texmf-dist/doc/latex/chemgreek/README
@@ -1,5 +1,5 @@
--------------------------------------------------------------------------
-the CHEMGREEK package v0.5a 2015/03/13
+the CHEMGREEK package v1.0 2015/04/09
typeset chemical compounds and reactions
diff --git a/Master/texmf-dist/doc/latex/chemgreek/chemgreek_en.pdf b/Master/texmf-dist/doc/latex/chemgreek/chemgreek_en.pdf
index d246f70af3f..dcd530adfae 100644
--- a/Master/texmf-dist/doc/latex/chemgreek/chemgreek_en.pdf
+++ b/Master/texmf-dist/doc/latex/chemgreek/chemgreek_en.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/chemgreek/chemgreek_en.tex b/Master/texmf-dist/doc/latex/chemgreek/chemgreek_en.tex
index cca1ef7ea47..3c04e63e8d8 100644
--- a/Master/texmf-dist/doc/latex/chemgreek/chemgreek_en.tex
+++ b/Master/texmf-dist/doc/latex/chemgreek/chemgreek_en.tex
@@ -1,6 +1,6 @@
% arara: pdflatex
-% !arara: biber
-% !arara: pdflatex
+% arara: biber
+% arara: pdflatex
% arara: pdflatex
% --------------------------------------------------------------------------
% the CHEMGREEK package
@@ -30,7 +30,7 @@
%
% The Current Maintainer of this work is Clemens Niederberger.
% --------------------------------------------------------------------------
-\documentclass[load-preamble+]{cnltx-doc}
+\documentclass[load-preamble+,scrartcl={listof=totoc}]{cnltx-doc}
\usepackage[utf8]{inputenc}
\usepackage[greek=newtx]{chemmacros}
\setcnltx{
@@ -48,12 +48,14 @@
activatechemgreekmapping,
changechemgreeksymbol, chemalpha, chembeta, chemgamma, chemdelta,
chemDelta, chemomega, chemphi, chemPhi,
+ chemgreekmappingsymbol,
declarechemgreekmapping,
newchemgreekmapping,
printchemgreekalphabet,
renewchemgreekmapping,
selectchemgreekmapping
- }
+ } ,
+ index-setup = { level = \section , headers={\indexname}{\indexname} }
}
\usepackage{booktabs}
@@ -84,7 +86,7 @@
accsupp = PDF
}
-\defbibheading{bibliography}{\addsec{References}}
+\defbibheading{bibliography}{\section{References}}
\newcommand*\tablehead[1]{\textrm{\bfseries#1}}
@@ -95,6 +97,8 @@
\begin{document}
+\listoftables
+
\section{Introduction}
The \chemgreek{} package is an auxiliary package for other chemistry packages
such as \pkg{chemmacros}. In chemistry there is often the need for upright
@@ -171,23 +175,47 @@ package~\cite{pkg:chemnum}.
will now cause an error is used.
\end{itemize}
-\section{Define Mappings}
+\subsection{Version~1.0}
+\begin{itemize}
+ \item If a mapping is activated that needs a package and the package is
+ missing \chemgreek\ falls back to the `default' mapping now.
+ \item If exactly one package for one of the mappings has been loaded the
+ corresponding mapping is activated at begin document, see also
+ section~\ref{sec:pred-mapp-select}.
+ \item expl3 versions of the letter macros (\verbcode+\chemgreek_alpha:+,
+ \verbcode+\chemgreek_Alpha:+ , \ldots)
+ \item New macros \cs{chemgreekmappingsymbol} (see
+ section~\ref{sec:additional-macros}), \cs{newchemgreekmappingalias},
+ \cs{renewchemgreekmappingalias} and \cs{declarechemgreekmappingalias} (see
+ section~\ref{sec:define-mappings}).
+\end{itemize}
+
+\section{Define Mappings}\label{sec:define-mappings}
\selectchemgreekmapping{default}
\chemgreek's main commands are:
\begin{commands}
\command{newchemgreekmapping}[\oarg{package}\marg{name}\marg{mapping list}]
- \changedversion{0.3}Add a new mapping to \chemgreek. Issue an error if it
+ \changedversion{0.3}Add a new mapping to \chemgreek. Issues an error if it
already exists. With the optional argument the package that is needed for
this mapping can (and should) be specified.
\command{renewchemgreekmapping}[\oarg{package}\marg{name}\marg{mapping list}]
- \changedversion{0.3}Renew a \chemgreek{} mapping. Issue an error if it
+ \changedversion{0.3}Renew a \chemgreek{} mapping. Issues an error if it
doesn't exist yet. With the optional argument the package that is needed
for this mapping can (and should) be specified.
\command{declarechemgreekmapping}[\oarg{package}\marg{name}\marg{mapping list}]
\changedversion{0.3}Declare a new mapping to \chemgreek. If the mapping
already exists it will be overwritten. With the optional argument the
package that is needed for this mapping can (and should) be specified.
+ \command{newchemgreekmappingalias}[\marg{new mapping name}\marg{existing mapping name}]
+ \sinceversion{1.0}Define an alias mapping. Issues an error if \meta{new
+ mapping name} already exists.
+ \command{renewchemgreekmappingalias}[\marg{new mapping name}\marg{existing mapping name}]
+ \sinceversion{1.0}Redefine a mapping to an alias of an existing mapping.
+ Issues an error if \meta{new mapping name} doesn't exist, yet.
+ \command{declarechemgreekmappingalias}[\marg{new mapping name}\marg{existing mapping name}]
+ \sinceversion{1.0}Define an alias mapping. Doesn't check, if \marg{new
+ mapping name} exists or not.
\end{commands}
The command \cs{newchemgreekmapping} needs to get a comma separated list of
@@ -243,7 +271,7 @@ available mappings.
Default mapping: \chemphi\ and \chemPhi, $\phi$ and $\Phi$
\end{example}
-\section{Predefined Mappings and Selection of a Mapping}
+\section{Predefined Mappings and Selection of a Mapping}\label{sec:pred-mapp-select}
\chemgreek{} predefines some mappings. Some of the mappings require additional
packages to be loaded. The mapping names and the required packages are listed
in table~\ref{tab:mappings}. Ths mapping \code{fontspec} is a bit different
@@ -273,19 +301,33 @@ use a font that has the Greek glyphs.
\label{tab:mappings}
\end{table}
-A mapping is selected and activated with one of the following commands:
+If exactly \emph{one} of the packages required by one of the mappings has been
+loaded such that an unambiguous choice is possible then \chemgreek{} will
+choose and activate the corresponding mapping at begin document. If an
+umbiguous choice isn't possible the n \chemgreek\ will select the `default'
+mapping at begin document. If a user has selected a mapping manually in the
+preamble (with one of the commands explained in a bit) then \chemgreek\ will
+do nothing on its own.
+
+A mapping is selected and activated manually with one of the following
+commands:
\begin{commands}
\command{activatechemgreekmapping}[\sarg\marg{name}]
- \changedversion{0.3}This commands selects and activates the mapping
+ \changedversion{1.0}This commands selects and activates the mapping
\meta{name}. If the star variant is used also the package of mapping
- \meta{name} (as defined with \cs{newchemgreekmapping} is loaded. The
- command can only be used in the document preamble.
+ \meta{name} (as defined with \cs{newchemgreekmapping} is loaded.
+ Otherwise a required package has to be loaded additionally the usual
+ way via \cs*{usepackage} or \cs*{RequirePackage}. If the package hasn't
+ been loaded a warning will be written to the log and the `default' mapping
+ will be activated instead. \emph{The command can only be used in the
+ document preamble}.
\command{selectchemgreekmapping}[\marg{name}]
- \changedversion{0.3}This commands selects and activates the mapping
+ \changedversion{1.0}This commands selects and activates the mapping
\meta{name}. A required package has to be loaded additionally the usual
way via \cs*{usepackage} or \cs*{RequirePackage}. If the package hasn't
- been loaded a warning will be written to the log. The command can be used
- throughout the document.
+ been loaded a warning will be written to the log and the `default' mapping
+ will be activated instead. \emph{The command can be used throughout the
+ document}.
\end{commands}
\begin{example}
@@ -310,7 +352,7 @@ to choose a font containing the needed glyphs.
\end{document}
\end{example}
-\section{Changing a Specific Symbol in an Existing Mapping}
+\section{Changing a Specific Symbol in an Existing Mapping}\label{sec:chang-spec-symb}
If you should want to change a specific entry of a specific mapping it would
be rather tedious to redefine the whole mapping. That is why \chemgreek\
provides a command for that purpose:
@@ -330,7 +372,7 @@ mapping afterwards:
\chemalpha
\end{example}
-\section{Inspecting a Mapping}
+\section{Inspecting a Mapping}\label{sec:inspecting-mapping}
\selectchemgreekmapping{newtx}
If you want to check if a mapping has been correctly set you can use the
following commands:
@@ -354,6 +396,43 @@ following commands:
\label{tab:showmapping}
\end{table}
-\clearpage
+\section{Additional Macros}\label{sec:additional-macros}
+
+\begin{commands}
+ \command{chemgreekmappingsymbol}[\marg{mapping name}\marg{symbol name}]
+ A command which prints a specific symbol of a specific mapping. The mapping
+ \meta{mapping name} doesn't need to be active but package dependencies
+ must be taken care of, \emph{i.e.}, if \meta{mapping name} needs a certain
+ package to be loaded you should make sure that it is.
+\end{commands}
+
+\appendix
+
+\section{Overviews Over the Mappings}\label{sec:overv-over-mapp}
+
+\newcommand*\demonstratemapping[2][]{%
+ \ifblank{#1}
+ {
+ \subsection{Mapping `\texttt{#2}'}
+ \includegraphics{chemgreek-#2.pdf}
+ }
+ {
+ \subsection{Mapping `\texttt{#2}' with package option \option*{#1}}
+ \includegraphics{chemgreek-#2-#1.pdf}
+ }
+}
+
+\demonstratemapping{default}
+\demonstratemapping{var-default}
+\demonstratemapping{textgreek}
+\demonstratemapping{upgreek}
+\demonstratemapping{newtx}
+\demonstratemapping{kpfonts}
+\demonstratemapping[utopia]{mathdesign}
+\demonstratemapping[charter]{mathdesign}
+\demonstratemapping{fourier}
+\demonstratemapping{textalpha}
+\subsection{Mapping `\texttt{fontspec}' with Font `Linux Libertine'}
+\includegraphics{chemgreek-fontspec.pdf}
\end{document}
diff --git a/Master/texmf-dist/tex/latex/chemgreek/chemgreek.sty b/Master/texmf-dist/tex/latex/chemgreek/chemgreek.sty
index 14e477c3e05..c1fe03e1109 100644
--- a/Master/texmf-dist/tex/latex/chemgreek/chemgreek.sty
+++ b/Master/texmf-dist/tex/latex/chemgreek/chemgreek.sty
@@ -27,8 +27,8 @@
% The Current Maintainer of this work is Clemens Niederberger.
% --------------------------------------------------------------------------
\RequirePackage{expl3,xparse}
-\def\chemgreek@version{0.5a}
-\def\chemgreek@date{2015/03/13}
+\def\chemgreek@version{1.0}
+\def\chemgreek@date{2015/04/09}
\ProvidesExplPackage{chemgreek}{\chemgreek@date}{\chemgreek@version}
{interface for upright greek letters for use in chemistry (CN)}
@@ -55,8 +55,10 @@
{ \prg_return_true: }
{ \prg_return_false: }
}
-\cs_generate_variant:Nn \chemgreek_if_package_loaded:nF { V }
+\cs_generate_variant:Nn \chemgreek_if_package_loaded:nTF { V }
+\cs_generate_variant:Nn \chemgreek_if_package_loaded:nF { V }
+% check if a package has been loaded with a certain option:
\prg_new_protected_conditional:Npnn \chemgreek_if_package_with:nn #1#2 {T,F,TF}
{
\cs_if_exist:cTF {opt@#1.sty}
@@ -68,9 +70,32 @@
{ \prg_return_false: }
}
+% check if a mapping needs a package:
+\tl_new:N \l__chemgreek_mapping_package_tl
+\prg_new_protected_conditional:Npnn \chemgreek_if_mapping_package:n #1 {T,F,TF}
+ {
+ \prop_get:NnN \l__chemgreek_packages_prop {#1}
+ \l__chemgreek_mapping_package_tl
+ \quark_if_no_value:VTF \l__chemgreek_mapping_package_tl
+ { \prg_return_false: }
+ { \prg_return_true: }
+ }
+
+% check if needed package has been loaded:
+\prg_new_protected_conditional:Npnn \chemgreek_if_mapping_package_loaded:n #1 {T,F,TF}
+ {
+ \chemgreek_if_mapping_package:nTF {#1}
+ {
+ \chemgreek_if_package_loaded:VTF \l__chemgreek_mapping_package_tl
+ { \prg_return_true: }
+ { \prg_return_false: }
+ }
+ { \prg_return_true: }
+ }
+
% ----------------------------------------------------------------------------
% messages
-\msg_new:nnn { chemgreek } { mapping-not-defined }
+\msg_new:nnn {chemgreek} {mapping-not-defined}
{
You~ chose~ the~ mapping~ `#1'~ \msg_line_context: \c_space_tl which~ has~
apparently~ not~ been~ defined,~ yet.~ If~ this~ is~ due~ to~ a~
@@ -79,7 +104,7 @@
\declarechemgreekmapping .
}
-\msg_new:nnn { chemgreek } { mapping-already-defined }
+\msg_new:nnn {chemgreek} {mapping-already-defined}
{
It~ seems~ you're~ trying~ to~ define~ the~ mapping~ `#1'~
\msg_line_context: .~ However,~ this~ mapping~ does~ already~ exist.~ If~
@@ -87,21 +112,23 @@
via~ \token_to_str:N \renewchemgreekmapping .
}
-\msg_new:nnn { chemgreek } { mapping-active }
+\msg_new:nnn {chemgreek} {mapping-active}
{
The~ mapping~ `#1'~ already~ is~ active~ \msg_line_context: .~ I'm~ doing~
nothing.
}
-\msg_new:nnn { chemgreek } { package-missing }
+\msg_new:nnn {chemgreek} {mapping-activated}
+ { Activating~ mapping~ `#1'~ \msg_line_context: . }
+
+\msg_new:nnn {chemgreek} {package-missing}
{
- You've~ activated~ mapping~ `#1'~ which~ needs~ package~ `#2'~ loaded.~
- However,~ package~ `#2'~ does~ not~ seem~ to~ be~ loaded~
- \msg_line_context: .~ Using~ the~ letter~ macros~ will~ probably~ not~
- work.~ If~ I'm~ mistaken~ then~ ignore~ this~ warning.
+ You're~ trying~ to~ activate~ the~ mapping~ `#1'~ which~ needs~ package~
+ `#2'~ loaded.~ However,~ package~ `#2'~ does~ not~ seem~ to~ be~ loaded~
+ \msg_line_context: .~ I'm~ loading~ the~ `default'~ mapping~ instead.
}
-\msg_new:nnn { chemgreek } { command-dropped }
+\msg_new:nnn {chemgreek} {command-dropped}
{
The~ command~ \token_to_str:N #1 has~ been~ dropped.~ Use~ \token_to_str:N #2
instead~ \msg_line_context: .
@@ -112,10 +139,7 @@
\cs_new_protected:Npn \chemgreek_define_dropped:NN #1#2
{
\cs_new_protected:Npn #1
- {
- \msg_error:nnnn { chemgreek } { command-dropped }
- { #1 } { #2 }
- }
+ { \msg_error:nnnn {chemgreek} {command-dropped} {#1} {#2} }
}
\cs_generate_variant:Nn \chemgreek_define_dropped:NN { cc }
@@ -152,16 +176,19 @@
% ----------------------------------------------------------------------------
% variants of kernel functions:
-\cs_generate_variant:Nn \prop_put:Nnn { cxV }
-\cs_generate_variant:Nn \tl_if_eq:nnTF { V }
+\cs_generate_variant:Nn \prop_put:Nnn { cxV }
+\cs_generate_variant:Nn \prop_get:Nn { cV }
+\cs_generate_variant:Nn \tl_if_eq:nnTF { V }
+\cs_generate_variant:Nn \msg_warning:nnnn { nnnV }
+\cs_generate_variant:Nn \quark_if_no_value:nTF { V }
% ----------------------------------------------------------------------------
% helper function to retrieve upper- and lowercase entries while the mapping
% happens:
\cs_new_protected:Npn \__chemgreek_get_upper_lower:w #1 / #2 \q_stop
{
- \tl_set:Nn \l__chemgreek_tmpa_tl { #1 }
- \tl_set:Nn \l__chemgreek_tmpb_tl { #2 }
+ \tl_set:Nn \l__chemgreek_tmpa_tl {#1}
+ \tl_set:Nn \l__chemgreek_tmpb_tl {#2}
}
% ----------------------------------------------------------------------------
@@ -178,11 +205,11 @@
}
% a conditional for testing if a mapping is active:
-\tl_new:N \l__chemgreek_active_mapping_tl
+\tl_new:N \l_chemgreek_active_mapping_tl
\prg_new_conditional:Npnn \chemgreek_if_mapping_active:n #1 {p,T,F,TF}
{
\tl_if_eq:NcTF
- \l__chemgreek_active_mapping_tl
+ \l_chemgreek_active_mapping_tl
{ c__chemgreek_mapping_#1_tl }
{ \prg_return_true: }
{ \prg_return_false: }
@@ -196,40 +223,33 @@
% the main mapping function:
% #1: mapping-name
% #2: package name
-% #3: mapping-entries
-\cs_new_protected:Npn \chemgreek_new_mapping:nnn #1#2#3
+% #3: mapping entries
+\cs_new_protected:Npn \chemgreek_declare_mapping:nnn #1#2#3
{
- \chemgreek_if_mapping_exists:nTF { #1 }
- { \msg_error:nnn { chemgreek } { mapping-already-defined } { #1 } }
- {
- \prop_new:c { l__chemgreek_uppercase_mapping_#1_prop }
- \prop_new:c { l__chemgreek_lowercase_mapping_#1_prop }
- \tl_const:cn { c__chemgreek_mapping_#1_tl } { #1 }
- \prop_put:Nnn \l__chemgreek_packages_prop { #1 } { #2 }
- \__chemgreek_set_mapping:nn { #1 } { #3 }
- }
+ \prop_if_exist:cF { l__chemgreek_uppercase_mapping_#1_prop }
+ { \prop_new:c { l__chemgreek_uppercase_mapping_#1_prop } }
+ \prop_if_exist:cF { l__chemgreek_lowercase_mapping_#1_prop }
+ { \prop_new:c { l__chemgreek_lowercase_mapping_#1_prop } }
+ \tl_if_exist:cF { c__chemgreek_mapping_#1_tl }
+ { \tl_const:cn { c__chemgreek_mapping_#1_tl } {#1} }
+ \tl_if_blank:nTF {#2}
+ { \prop_remove:Nn \l__chemgreek_packages_prop {#1} }
+ { \prop_put:Nnn \l__chemgreek_packages_prop {#1} {#2} }
+ \__chemgreek_set_mapping:nn {#1} {#3}
}
-\cs_new_protected:Npn \chemgreek_renew_mapping:nnn #1#2#3
+\cs_new_protected:Npn \chemgreek_new_mapping:nnn #1#2#3
{
- \chemgreek_if_mapping_exists:nTF { #1 }
- {
- \prop_put:Nnn \l__chemgreek_packages_prop { #1 } { #2 }
- \__chemgreek_set_mapping:nn { #1 } { #3 }
- }
- { \msg_error:nnn { chemgreek } { mapping-not-defined } { #1 } }
+ \chemgreek_if_mapping_exists:nTF {#1}
+ { \msg_error:nnn {chemgreek} {mapping-already-defined} {#1} }
+ { \chemgreek_declare_mapping:nnn {#1} {#2} {#3} }
}
-\cs_new_protected:Npn \chemgreek_declare_mapping:nnn #1#2#3
+\cs_new_protected:Npn \chemgreek_renew_mapping:nnn #1#2#3
{
- \chemgreek_if_mapping_exists:nF { #1 }
- {
- \prop_new:c { l__chemgreek_uppercase_mapping_#1_prop }
- \prop_new:c { l__chemgreek_lowercase_mapping_#1_prop }
- \tl_const:cn { c__chemgreek_mapping_#1_tl } { #1 }
- }
- \prop_put:Nnn \l__chemgreek_packages_prop { #1 } { #2 }
- \__chemgreek_set_mapping:nn { #1 } { #3 }
+ \chemgreek_if_mapping_exists:nTF {#1}
+ { \chemgreek_declare_mapping:nnn {#1} {#2} {#3} }
+ { \msg_error:nnn {chemgreek} {mapping-not-defined} {#1} }
}
\cs_new_protected:Npn \__chemgreek_set_mapping:nn #1#2
@@ -237,7 +257,7 @@
\prop_clear:c { l__chemgreek_lowercase_mapping_#1_prop }
\prop_clear:c { l__chemgreek_uppercase_mapping_#1_prop }
\int_zero:N \l__chemgreek_tmpa_int
- \clist_map_inline:nn { #2 }
+ \clist_map_inline:nn {#2}
{
\int_incr:N \l__chemgreek_tmpa_int
\__chemgreek_get_upper_lower:w ##1 \q_stop
@@ -250,16 +270,78 @@
}
}
+% aliasing mappings:
+% #1: new mapping
+% #2: existing mapping
+\cs_new_protected:Npn \chemgreek_new_mapping_alias:nn #1#2
+ {
+ \chemgreek_if_mapping_exists:nTF {#1}
+ { \msg_error:nnn {chemgreek} {mapping-already-defined} {#1} }
+ {
+ \chemgreek_if_mapping_exists:nTF {#2}
+ { \chemgreek_declare_mapping_alias:nn {#1} {#2} }
+ { \msg_error:nnn {chemgreek} {mapping-not-defined} {#2} }
+ }
+ }
+
+\cs_new_protected:Npn \chemgreek_renew_mapping_alias:nn #1#2
+ {
+ \chemgreek_if_mapping_exists:nTF {#1}
+ {
+ \chemgreek_if_mapping_exists:nTF {#2}
+ { \chemgreek_declare_mapping_alias:nn {#1} {#2} }
+ { \msg_error:nnn {chemgreek} {mapping-not-defined} {#2} }
+ }
+ { \msg_error:nnn {chemgreek} {mapping-not-defined} {#1} }
+ }
+
+\cs_new_protected:Npn \chemgreek_declare_mapping_alias:nn #1#2
+ {
+ \chemgreek_if_mapping_exists:nT {#2}
+ {
+ \prop_if_exist:cF { l__chemgreek_uppercase_mapping_#1_prop }
+ { \prop_new:c { l__chemgreek_uppercase_mapping_#1_prop } }
+ \prop_if_exist:cF { l__chemgreek_lowercase_mapping_#1_prop }
+ { \prop_new:c { l__chemgreek_lowercase_mapping_#1_prop } }
+ \prop_get:NnNT \l__chemgreek_packages_prop {#2} \l__chemgreek_tmpa_tl
+ { \prop_put:NnV \l__chemgreek_packages_prop {#1} \l__chemgreek_tmpa_tl }
+ \prop_put:Nnn \l__chemgreek_packages_prop {#1} {#2}
+ \tl_map_inline:Nn \c__chemgreek_alphabet_tl
+ {
+ \prop_put:cnx { l__chemgreek_uppercase_mapping_#1_prop } {##1}
+ { \prop_get:cn { l__chemgreek_uppercase_mapping_#2_prop } {##1} }
+ \prop_put:cnx { l__chemgreek_lowercase_mapping_#1_prop } {##1}
+ { \prop_get:cn { l__chemgreek_lowercase_mapping_#2_prop } {##1} }
+ }
+ }
+ }
+
+% ----------------------------------------------------------------------------
% the user commands:
+
+% #1: package name (optional)
+% #2: mapping-name
+% #3: mapping entries
\NewDocumentCommand \newchemgreekmapping { O{}mm }
- { \chemgreek_new_mapping:nn { #2 } { #1 } { #3 } }
+ { \chemgreek_new_mapping:nnn {#2} {#1} {#3} }
\NewDocumentCommand \renewchemgreekmapping { O{}mm }
- { \chemgreek_renew_mapping:nnn { #2 } { #1 } { #3 } }
+ { \chemgreek_renew_mapping:nnn {#2} {#1} {#3} }
\NewDocumentCommand \declarechemgreekmapping { O{}mm }
- { \chemgreek_declare_mapping:nnn { #2 } { #1 } { #3 } }
+ { \chemgreek_declare_mapping:nnn {#2} {#1} {#3} }
+% #1: new mapping
+% #2: existing mapping
+\NewDocumentCommand \newchemgreekmappingalias { mm }
+ { \chemgreek_new_mapping_alias:nn {#1} {#2} }
+
+\NewDocumentCommand \renewchemgreekmappingalias { mm }
+ { \chemgreek_renew_mapping_alias:nn {#1} {#2} }
+
+\NewDocumentCommand \declarechemgreekmappingalias { mm }
+ { \chemgreek_declare_mapping_alias:nn {#1} {#2} }
+
% ----------------------------------------------------------------------------
% a function to selectively change specific entries in a mapping:
@@ -274,106 +356,144 @@
% #4: entry
\cs_new_protected:Npn \chemgreek_change:nnnn #1#2#3#4
{
- \chemgreek_if_mapping_exists:nTF { #1 }
+ \chemgreek_if_mapping_exists:nTF {#1}
{
\prop_put:cnn { l__chemgreek_#2 case_mapping_#1_prop }
- { #3 }
- { #4 }
+ {#3}
+ {#4}
\prop_put:Nnn \l__chemgreek_changed_mappings_prop
- { #1 }
- { #1 }
+ {#1}
+ {#1}
}
- { \msg_error:nnn { chemgreek } { mapping-not-defined } { #1 } }
+ { \msg_error:nnn {chemgreek} {mapping-not-defined} {#1} }
}
% the user command:
\NewDocumentCommand \changechemgreeksymbol { mmmm }
- { \chemgreek_change:nnnn { #1 } { #2 } { #3 } { #4 } }
+ { \chemgreek_change:nnnn {#1} {#2} {#3} {#4} }
% ----------------------------------------------------------------------------
+\cs_new_protected:Npn \chemgreek_load_mapping_package:n #1
+ {
+ \chemgreek_if_mapping_package:nT {#1}
+ { \exp_args:NV \RequirePackage \l__chemgreek_mapping_package_tl }
+ }
+
% a function to activate a mapping:
% #1: mapping-name
-% TODO: error if needed package has not been loaded
\cs_new_protected:Npn \chemgreek_activate_mapping:n #1
{
- \chemgreek_if_mapping_exists:nTF { #1 }
+ \chemgreek_if_mapping_exists:nTF {#1}
{
\bool_if:nTF
{
- ( \chemgreek_if_mapping_active_p:n { #1 } )
+ ( \chemgreek_if_mapping_active_p:n {#1} )
&&
- !( \prop_if_in_p:Nn \l__chemgreek_changed_mappings_prop { #1 } )
+ !( \prop_if_in_p:Nn \l__chemgreek_changed_mappings_prop {#1} )
}
- { \msg_info:nnn { chemgreek } { mapping-active } { #1 } }
+ { \msg_info:nnn {chemgreek} {mapping-active} {#1} }
{
- \tl_set:Nn \l__chemgreek_active_mapping_tl { #1 }
- \prop_get:NnN \l__chemgreek_packages_prop { #1 }
- \l__chemgreek_tmpa_tl
- \tl_if_blank:VF \l__chemgreek_tmpa_tl
- {
- \chemgreek_if_package_loaded:VF \l__chemgreek_tmpa_tl
- {
- \msg_warning:nnxx { chemgreek } { package-missing }
- { #1 }
- { \l__chemgreek_tmpa_tl }
- }
- }
- \tl_map_inline:Nn \c__chemgreek_alphabet_tl
+ \chemgreek_if_mapping_package_loaded:nTF {#1}
+ { \__chemgreek_activate_mapping:n {#1} }
{
- \cs_set_protected:cpx
- {
- chem
- \str_upper_case:f { \tl_head:n {##1} }
- \str_lower_case:f { \tl_tail:n {##1} }
- }
- { \prop_get:cn { l__chemgreek_uppercase_mapping_#1_prop } { ##1 } }
- \cs_set_protected:cpx { chem \str_lower_case:f {##1} }
- { \prop_get:cn { l__chemgreek_lowercase_mapping_#1_prop } { ##1 } }
- }
+ \msg_warning:nnnV {chemgreek} {package-missing}
+ {#1}
+ \l__chemgreek_mapping_package_tl
+ \__chemgreek_activate_mapping:n {default}
+ }
\prop_get:NnNT \l__chemgreek_changed_mappings_prop
- { #1 }
+ {#1}
\l__chemgreek_tmpa_tl
- { \prop_remove:Nn \l__chemgreek_changed_mappings_prop { #1 } }
+ { \prop_remove:Nn \l__chemgreek_changed_mappings_prop {#1} }
}
}
- { \msg_error:nnn { chemgreek } { mapping-not-defined } { #1 } }
+ { \msg_error:nnn {chemgreek} {mapping-not-defined} {#1} }
}
+\cs_generate_variant:Nn \chemgreek_activate_mapping:n { V }
+
+\cs_new_protected:Npn \__chemgreek_activate_mapping:n #1
+ {
+ \tl_set:Nn \l_chemgreek_active_mapping_tl {#1}
+ \tl_map_inline:Nn \c__chemgreek_alphabet_tl
+ {
+ \cs_set_protected:cpx
+ {
+ chem
+ \str_upper_case:f { \tl_head:n {##1} }
+ \str_lower_case:f { \tl_tail:n {##1} }
+ }
+ { \prop_get:cn { l__chemgreek_uppercase_mapping_#1_prop } {##1} }
+ \cs_set_eq:cc
+ {
+ chemgreek_
+ \str_upper_case:f { \tl_head:n {##1} }
+ \str_lower_case:f { \tl_tail:n {##1} }
+ :
+ }
+ {
+ chem
+ \str_upper_case:f { \tl_head:n {##1} }
+ \str_lower_case:f { \tl_tail:n {##1} }
+ }
+ \cs_set_protected:cpx { chem \str_lower_case:f {##1} }
+ { \prop_get:cn { l__chemgreek_lowercase_mapping_#1_prop } {##1} }
+ \cs_set_eq:cc
+ { chemgreek_ \str_lower_case:f {##1} : }
+ { chem \str_lower_case:f {##1} }
+ }
+ \msg_info:nnn {chemgreek} {mapping-activated} {#1}
+ }
+
+% #1: mapping name
+% #2: symbol name
+\cs_new_protected:Npn \chemgreek_get_from_mapping:nn #1#2
+ {
+ \tl_set:Nx \l__chemgreek_tmpa_tl
+ {
+ \str_upper_case:f { \tl_head:n {#2} }
+ \str_lower_case:f { \tl_tail:n {#2} }
+ }
+ \str_if_eq:nVTF {#2} \l__chemgreek_tmpa_tl
+ {
+ \tl_set:Nx \l__chemgreek_tmpa_tl { \str_lower_case:f {#2} }
+ \prop_get:cV
+ { l__chemgreek_uppercase_mapping_#1_prop }
+ \l__chemgreek_tmpa_tl
+ }
+ { \prop_get:cn { l__chemgreek_lowercase_mapping_#1_prop } {#2} }
+ }
+
+\NewDocumentCommand \chemgreekmappingsymbol { mm }
+ { \chemgreek_get_from_mapping:nn {#1} {#2} }
% user command that also loads the needed package:
% #1: load package
% #2: mapping-name
\NewDocumentCommand \activatechemgreekmapping { sm }
{
- \IfBooleanT { #1 }
- {
- \prop_get:NnN \l__chemgreek_packages_prop
- { #2 }
- \l__chemgreek_tmpa_tl
- \tl_if_blank:VF \l__chemgreek_tmpa_tl
- { \exp_args:No \RequirePackage { \l__chemgreek_tmpa_tl } }
- }
- \chemgreek_activate_mapping:n { #2 }
+ \IfBooleanT {#1} { \chemgreek_load_mapping_package:n {#2} }
+ \chemgreek_activate_mapping:n {#2}
}
\@onlypreamble\activatechemgreekmapping
% user command that activates a new mapping without loading the package:
\NewDocumentCommand \selectchemgreekmapping { m }
- { \chemgreek_activate_mapping:n { #1 } }
+ { \chemgreek_activate_mapping:n {#1} }
% ----------------------------------------------------------------------------
% debugging commands:
\cs_new_protected:Npn \chemgreek_print_mapping:n #1
{
\int_gzero:N \g__chemgreek_tmpa_int
- \begin { tabular } { llcc }
+ \begin {tabular} {llcc}
pos & name & lower & upper \\
\tl_map_inline:Nn \c__chemgreek_alphabet_tl
{
\int_gincr:N \g__chemgreek_tmpa_int
\int_use:N \g__chemgreek_tmpa_int . &
##1 &
- \prop_get:cn { l__chemgreek_lowercase_mapping_#1_prop } { ##1 } &
- \prop_get:cn { l__chemgreek_uppercase_mapping_#1_prop } { ##1 } \\
+ \prop_get:cn { l__chemgreek_lowercase_mapping_#1_prop } {##1} &
+ \prop_get:cn { l__chemgreek_uppercase_mapping_#1_prop } {##1} \\
}
\end{tabular}
}
@@ -394,7 +514,7 @@
{
. \c_space_tl \c_space_tl \c_space_tl \c_space_tl \c_space_tl
\str_lower_case:f {##1} ~ => ~
- \prop_get:cn { l__chemgreek_lowercase_mapping_#1_prop } { ##1 }
+ \prop_get:cn { l__chemgreek_lowercase_mapping_#1_prop } {##1}
}
\iow_log:x
{
@@ -402,7 +522,7 @@
\str_upper_case:f { \tl_head:n {##1} }
\str_lower_case:f { \tl_tail:n {##1} }
\c_space_tl => ~
- \prop_get:cn { l__chemgreek_uppercase_mapping_#1_prop } { ##1 }
+ \prop_get:cn { l__chemgreek_uppercase_mapping_#1_prop } {##1}
}
}
\iow_log:n { ................................................. }
@@ -437,7 +557,7 @@
{
\tl_map_inline:Nn \c__chemgreek_alphabet_tl
{
- \chemgreek_drop_symbol:n { ##1 }
+ \chemgreek_drop_symbol:n {##1}
\chemgreek_drop_symbol:n
{
\str_upper_case:f { \tl_head:n {##1} }
@@ -453,7 +573,7 @@
% of \int_to_alph:n
\cs_new:Npn \chemgreek_int_to_greek:n #1
{
- \int_to_symbols:nnn { #1 } { 24 }
+ \int_to_symbols:nnn {#1} {24}
{
{ 1 } { \chemalpha }
{ 2 } { \chembeta }
@@ -484,7 +604,7 @@
\cs_new:Npn \chemgreek_int_to_Greek:n #1
{
- \int_to_symbols:nnn { #1 } { 24 }
+ \int_to_symbols:nnn {#1} {24}
{
{ 1 } { \chemAlpha }
{ 2 } { \chemBeta }
@@ -516,7 +636,7 @@
% ----------------------------------------------------------------------------
% predefine some mappings
% default:
-\chemgreek_new_mapping:nnn { default } { }
+\chemgreek_new_mapping:nnn {default} { }
{
\ensuremath{\alpha} / \ensuremath{\mathrm{A}} , % 1
\ensuremath{\beta} / \ensuremath{\mathrm{B}} , % 2
@@ -545,7 +665,7 @@
}
% default-variant:
-\chemgreek_new_mapping:nnn { var-default } { }
+\chemgreek_new_mapping:nnn {var-default} { }
{
\ensuremath{\alpha} / \ensuremath{\mathrm{A}} , % 1
\ensuremath{\beta} / \ensuremath{\mathrm{B}} , % 2
@@ -574,7 +694,7 @@
}
% mathdesign:
-\chemgreek_new_mapping:nnn { mathdesign } { mathdesign }
+\chemgreek_new_mapping:nnn {mathdesign} {mathdesign}
{
\ensuremath{\alphaup} / \ensuremath{\mathrm{A}} , % 1
\ensuremath{\betaup} / \ensuremath{\mathrm{B}} , % 2
@@ -603,7 +723,7 @@
}
% textgreek:
-\chemgreek_new_mapping:nnn { textgreek } { textgreek }
+\chemgreek_new_mapping:nnn {textgreek} {textgreek}
{
\mbox{\textalpha} / \mbox{\textAlpha} , % 1
\mbox{\textbeta} / \mbox{\textBeta} , % 2
@@ -632,7 +752,7 @@
}
% upgreek:
-\chemgreek_new_mapping:nnn { upgreek } { upgreek }
+\chemgreek_new_mapping:nnn {upgreek} {upgreek}
{
\ensuremath{\upalpha} / \ensuremath{\mathrm{A}} , % 1
\ensuremath{\upbeta} / \ensuremath{\mathrm{B}} , % 2
@@ -661,7 +781,7 @@
}
% kpfonts:
-\chemgreek_new_mapping:nnn { kpfonts } { kpfonts }
+\chemgreek_new_mapping:nnn {kpfonts} {kpfonts}
{
\ensuremath{\alphaup} / \ensuremath{\mathrm{A}} , % 1
\ensuremath{\betaup} / \ensuremath{\mathrm{B}} , % 2
@@ -690,7 +810,7 @@
}
% newtx:
-\chemgreek_new_mapping:nnn { newtx } { newtxmath }
+\chemgreek_new_mapping:nnn {newtx} {newtxmath}
{
\ensuremath{\upalpha} / \ensuremath{\mathrm{A}} , % 1
\ensuremath{\upbeta} / \ensuremath{\mathrm{B}} , % 2
@@ -733,7 +853,7 @@
{ \ensuremath { \use:c { other #1 } } }
}
-\chemgreek_new_mapping:nnn { fourier } { fourier }
+\chemgreek_new_mapping:nnn {fourier} {fourier}
{
\__chemgreek_lfourier:n {alpha} / \ensuremath{\mathrm{A}} , % 1
\__chemgreek_lfourier:n {beta} / \ensuremath{\mathrm{B}} , % 2
@@ -762,7 +882,7 @@
}
% textalpha:
-\chemgreek_new_mapping:nnn { textalpha } { textalpha }
+\chemgreek_new_mapping:nnn {textalpha} {textalpha}
{
\mbox{\textalpha} / \mbox{\textAlpha} , % 1
\mbox{\textbeta} / \mbox{\textBeta} , % 2
@@ -791,7 +911,7 @@
}
% textgreek:
-\chemgreek_new_mapping:nnn { fontspec } { fontspec }
+\chemgreek_new_mapping:nnn {fontspec} {fontspec}
{
\mbox{\textalpha} / \mbox{\textAlpha} , % 1
\mbox{\textbeta} / \mbox{\textBeta} , % 2
@@ -819,9 +939,32 @@
\mbox{\textomega} / \mbox{\textOmega} % 24
}
-% activate default mapping
-\chemgreek_activate_mapping:n { default }
+% ----------------------------------------------------------------------------
+% default activating of a mapping if a corresponding package has been loaded.
+
+\cs_new_protected:Npn \chemgreek_choose_mapping:
+ {
+ \tl_if_blank:VT \l_chemgreek_active_mapping_tl
+ {
+ \int_zero:N \l__chemgreek_tmpa_int
+ \prop_map_inline:Nn \l__chemgreek_packages_prop
+ {
+ \chemgreek_if_package_loaded:nT {##2}
+ {
+ \int_incr:N \l__chemgreek_tmpa_int
+ \tl_set:Nn \l__chemgreek_tmpa_tl {##1}
+ }
+ }
+ \int_compare:nTF { \l__chemgreek_tmpa_int = 1 }
+ { \chemgreek_activate_mapping:V \l__chemgreek_tmpa_tl }
+ { \chemgreek_activate_mapping:n {default} }
+ }
+ }
+
+\AtBeginDocument { \chemgreek_choose_mapping: }
+% ----------------------------------------------------------------------------
+% Greek letters in bookmarks:
\AtBeginDocument
{
\chemgreek_if_package_with:nnT {hyperref} {unicode}
@@ -843,7 +986,20 @@
\str_upper_case:f { \tl_head:n {#1} }
\str_lower_case:f { \tl_tail:n {#1} }
}
+ \cs_set_eq:cc
+ {
+ chemgreek_
+ \str_upper_case:f { \tl_head:n {#1} }
+ \str_lower_case:f { \tl_tail:n {#1} }
+ :
+ }
+ {
+ text
+ \str_upper_case:f { \tl_head:n {#1} }
+ \str_lower_case:f { \tl_tail:n {#1} }
+ }
\cs_set_eq:cc { chem #1 } { text #1 }
+ \cs_set_eq:cc { chemgreek_ #1 : } { text #1 }
}
}
}
@@ -882,6 +1038,17 @@ HISTORY:
2015/03/13 - v0.5a - adapt to expl3's new case changing functions
- change status of \Chem... macros from deprecated to
dropped
+2015/04/09 - v1.0 - if a mapping is activated that needs a package and the
+ package is missing the mapping falls back to `default'
+ - if exactly one package for one of the mappings has been
+ loaded the corresponding mapping is activated at begin
+ document
+ - expl3 versions of the letter macros (\chemgreek_alpha: ,
+ \chemgreek_Alpha: , ...)
+ - \chemgreek_get_from_mapping:nn
+ - \chemgreek_declare_mapping_alias:nn ,
+ \chemgreek_new_mapping_alias:nn ,
+ \chemgreek_renew_mapping_alias:nn
TODO: