summaryrefslogtreecommitdiff
path: root/Master
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2015-09-23 23:35:58 +0000
committerKarl Berry <karl@freefriends.org>2015-09-23 23:35:58 +0000
commitf963602ba2f2ff3644f713c45b59b4f22c0c4b04 (patch)
tree84b92302a79a378db5d0f6bb4cb88ccdb7a0fa5a /Master
parentf2c1bd0a1a94f92d81946cb9195117f87f5d2471 (diff)
chemmacros (23sep15)
git-svn-id: svn://tug.org/texlive/trunk@38447 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r--Master/texmf-dist/doc/latex/chemmacros/README2
-rw-r--r--Master/texmf-dist/doc/latex/chemmacros/chemmacros_en.pdfbin954387 -> 960862 bytes
-rw-r--r--Master/texmf-dist/doc/latex/chemmacros/chemmacros_en.tex123
-rw-r--r--Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.base.code.tex22
-rw-r--r--Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.charges.code.tex15
-rw-r--r--Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.chemformula.code.tex76
-rw-r--r--Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.particles.code.tex4
-rw-r--r--Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.reactions.code.tex8
-rw-r--r--Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.scheme.code.tex115
-rw-r--r--Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty7
-rw-r--r--Master/texmf-dist/tex/latex/chemmacros/chemmacros5.sty57
11 files changed, 333 insertions, 96 deletions
diff --git a/Master/texmf-dist/doc/latex/chemmacros/README b/Master/texmf-dist/doc/latex/chemmacros/README
index d7bbd234cc6..6df29699053 100644
--- a/Master/texmf-dist/doc/latex/chemmacros/README
+++ b/Master/texmf-dist/doc/latex/chemmacros/README
@@ -1,5 +1,5 @@
--------------------------------------------------------------------------
-the CHEMMACROS package v5.0 2015/09/11
+the CHEMMACROS package v5.1 2015/09/23
comprehensive support for typesetting chemistry documents
diff --git a/Master/texmf-dist/doc/latex/chemmacros/chemmacros_en.pdf b/Master/texmf-dist/doc/latex/chemmacros/chemmacros_en.pdf
index 9affd83f227..2d244e91c23 100644
--- a/Master/texmf-dist/doc/latex/chemmacros/chemmacros_en.pdf
+++ b/Master/texmf-dist/doc/latex/chemmacros/chemmacros_en.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/chemmacros/chemmacros_en.tex b/Master/texmf-dist/doc/latex/chemmacros/chemmacros_en.tex
index 26d3d45e756..c7c283a6835 100644
--- a/Master/texmf-dist/doc/latex/chemmacros/chemmacros_en.tex
+++ b/Master/texmf-dist/doc/latex/chemmacros/chemmacros_en.tex
@@ -194,9 +194,10 @@
\chemsetup{
modules = all ,
greek = newtx ,
-% chemformula/format = \libertineLF
+ formula = chemformula ,
+ chemformula/format = \libertineLF
}
-\setchemformula{format = \libertineLF}
+% \setchemformula{format = \libertineLF}
\usepackage{siunitx}
@@ -543,10 +544,11 @@ call of \cs{chemsetup}.
You will see its macros \cs{ch} and \cs{chcpd} every now and then in this
manual. When using \chemmacros\ you can consider the \chemformula\
package~\cite{pkg:chemformula} to be loaded as \chemmacros\ makes use of it in
-various places. \chemmacros\ and \chemformula\ are tightly intertwined. In
-fact: \emph{when using \chemmacros\ you should prefer \chemformula\ over
- \pkg{mhchem} (which provides very similar functionality) for having
- consistent typesetting}.
+various places. \chemmacros\ and \chemformula\ are tightly intertwined.
+Nevertheless you should be able to use the \pkg{mhchem}~\cite{pkg:mhchem}
+package with \chemmacros. Please see section~\vref{sec:using-mhchem} for
+details and \latin{caveat}s. \emph{The recommendation is to use
+ \chemformula.}
A historical note: \chemformula\ started as a part of \chemmacros\ in
January~2012. Since July~2013 it is a completely independent package -- from
@@ -1587,6 +1589,33 @@ This is how the macros \cs{NewChemParticle}, \cs{RenewChemParticle},
{ \chemmacros_define_particle:Nn #1 {#2} }
\end{sourcecode}
+The following macros strictly speaking are not provided by the
+\chemmodule{base} module but this place fits best for their description.
+\begin{commands}
+ \expandable\command*{chemmacros_if_module_exist:n}[\TF\ \marg{module}
+ \marg{true} \marg{false}]
+ Checks if a file with the correct name for a module \meta{module} can be
+ found.
+ \expandable\command*{chemmacros_if_module_loaded:n}[\TF\ \marg{module}
+ \marg{true} \marg{false}]
+ Checks if the module \meta{module} has already been loaded or not.
+ \command*{chemmacros_load_module:n}[ \marg{module}]
+ Loads module \meta{module} if it hasn't been loaded, yet.
+ \command*{chemmacros_load_modules:n}[ \marg{csv list of modules}]
+ Loads every module in \meta{csv list of modules} if they haven't been
+ loaded, yet. This is the code level variant of \cs{usechemmodule}.
+ \command*{chemmacros_before_module:nn}[ \marg{module} \marg{code}]
+ Saves\sinceversion{5.1} \meta{code} and inserts it right before
+ \meta{module} is loaded. If \meta{module} is never loaded then
+ \meta{code} is never inserted. If \meta{module} already is loaded when
+ the command is used then \meta{code} also is never inserted.
+ \command*{chemmacros_after_module:nn}[ \marg{module} \marg{code}]
+ Saves\sinceversion{5.1} \meta{code} and inserts it right after
+ \meta{module} is loaded. If \meta{module} is never loaded then
+ \meta{code} is never inserted. If \meta{module} already is loaded when
+ the command is used then \meta{code} is inserted immediately.
+\end{commands}
+
\subsection{The \chemmodule*{chemformula} Module}\label{sec:chemformula-module}
The \chemmodule{chemformula} module loads the \pkg{chemformula}
@@ -1594,23 +1623,72 @@ package~\cite{pkg:chemformula} and the \pkg{amstext}
package~\cite{pkg:amstext}. It also loads the \chemmodule{charges} module.
\subsubsection{For Users}
-The \chemmodule{chemformula} module makes it possible that you can set all
-\chemformula\ options via the \cs{chemsetup} command using the module
-\module{chemformula}, for example:
+
+This module provides a general option:
+\begin{options}
+ \keychoice{formula}{chemformula,mhchem}\Default{chemformula}
+ This\sinceversion{5.1} option let's you choose if chemical formula's are
+ typeset using \pkg{chemformula}'s \cs{ch} and \cs{chcpd} or \pkg{mhchem}'s
+ \cs{ce}. The corresponding package is loaded.
+\end{options}
+If you explicitly set this option the corresponding package is loaded
+immediately. Otherwise the option is set at the end of the preamble.
+
+\paragraph{Using the \pkg*{chemformula} Package}
+If you set \keyis{formula}{chemformula} the \chemmodule{chemformula} module
+makes it possible that you can set all \chemformula\ options via the
+\cs{chemsetup} command using the module \module{chemformula}, for example:
\begin{sourcecode}
\chemsetup[chemformula]{format=\sffamily}
\end{sourcecode}
+Everywhere where \chemmacros\ typesets chemical formulas \chemformula's macros
+\cs{chcpd} or \cs{ch} are used, for example in the reaction environments
+provided by the \chemmodule{reactions} module.
+
+\paragraph{Using the \pkg*{mhchem} Package}\label{sec:using-mhchem}
+If you set \keyis{formula}{mhchem} the \chemmodule{chemformula} module makes
+it possible that you can set all of \pkg{mhchem}'s options via the
+\cs{chemsetup} command using the module \module{mhchem}, for example:
+\begin{sourcecode}
+ \chemsetup[mhchem]{format=\sffamily}
+\end{sourcecode}
+
+Everywhere where \chemmacros\ typesets chemical formulas \pkg{mhchem}'s macro
+\cs{ce} is used, for example in the reaction environments provided by the
+\chemmodule{reactions} module.
+
+There are a few \latin{caveat}s if you use this method:
+\begin{itemize}
+ \item This method has not been extensively tested, yet. There may be errors
+ and wrong output at unexpected places.
+ \item Using this method effectively disables the different values of the
+ \module{particles} option \option{elpair} (see
+ section~\ref{sec:particles-module}).
+ \item The different kinds of formal charges provided by the
+ \chemmodule{charges} module (see section~\ref{sec:ion-charges}) are
+ disabled. Formal charges always use the math method now.
+ \item There may also be other incompatibilities (\eg, \pkg{mhchem} has it's
+ own method of setting upright Greek letters so it may or may not disable
+ \chemmacros' mechanism).
+\end{itemize}
+
\subsubsection{For Module Writers}
-There's only one macro for module writers:
+There's are two macros for module writers:
\begin{commands}
\command*{chemmacros_chemformula:n}[ \marg{formula}]
- This is only a wrapper for \cs{chcpd}. It is recommended that module
- writers use this macro (or a variant thereof) inside of \chemmacros's
- macros whenever they want to display a chemical formula. Writers who
- prefer traditional \LaTeXe\ programming over expl3 should use \cs{chcpd}
- directly.
+ This is only a wrapper for \cs{chcpd} or \cs{ce}. It is recommended that
+ module writers use this macro (or a variant thereof) inside of
+ \chemmacros's macros whenever they want to display a chemical formula.
+ Writers who prefer traditional \LaTeXe\ programming over expl3 should use
+ \cs*{chemmacros@formula}.
+ \command*{chemmacros_reaction:n}[ \marg{reaction}]
+ This is only a wrapper for \cs{ch} or \cs{ce}. It is recommended that
+ module writers use this macro (or a variant thereof) inside of
+ \chemmacros's macros whenever they want to display a chemical reaction.
+ Writers who prefer traditional \LaTeXe\ programming over expl3 should use
+ \cs*{chemmacros@reaction}.
\end{commands}
\subsection{The \chemmodule*{greek} Module}\label{sec:greek-module}
@@ -2389,10 +2467,11 @@ The default length of the vertical lines can be customized with the option
\subsection{The \chemmodule*{scheme} Module}\label{sec:scheme-module}
-The \chemmodule{scheme} module defines a floating environment
+The \chemmodule{scheme} module loads the \pkg{chemnum}
+package~\cite{pkg:chemnum} and defines a floating environment
\showenv{scheme}. That is, it \emph{only} defines this float if no
-environment \env{scheme} exists at begin document. The module checks for
-different available float defining methods, in \emph{this} order:
+environment \env{scheme} exists at the end of the preamble. The module checks
+for different available float defining methods, in \emph{this} order:
\begin{itemize}
\item If the current class is a \KOMAScript\ class \cs*{DeclareNewTOC} will
be used.
@@ -2401,6 +2480,8 @@ different available float defining methods, in \emph{this} order:
be used.
\item If the package \pkg{newfloat} has been loaded
\cs*{DeclareFloatingEnvironment} will be used.
+ \item \sinceversion{5.1}If the package \pkg{floatrow} has been loaded its
+ method will be used.
\item If the package \pkg{float} has been loaded its method will be used.
\item If neither of the above the \enquote{manual} method is used. This
means the environment is defined the same way like \env*{figure} is
@@ -3157,7 +3238,7 @@ me (see section~\vref{sec:submitting-module}) so they can be added to the
If you have additional functionality which you think might be useful as a
\chemmacros\ module then you can easily write one yourself. The module must
be a file in a path where \TeX\ can find it following a certain naming
-scheme. The file for a module \chemmodule*{foo} must be named
+scheme. The file for a module \chemmodule*{foo} \emph{must be named}
\code{chemmacros.module.foo.code.tex}.
The first line in the file then should look similar to this:
@@ -3205,6 +3286,10 @@ which most likely is available on your system:
\begin{bash}
texdoc interface3
\end{bash}
+If you haven't read section~\vref{sec:base-module} about the \chemmodule{base}
+module, yet, please have a look. There some macros for module writers are
+described. Also other modules define macros for module writers which may be
+useful.
\subsection{Submitting a Module}\label{sec:submitting-module}
diff --git a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.base.code.tex b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.base.code.tex
index eab20de2076..d8a65a0096a 100644
--- a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.base.code.tex
+++ b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.base.code.tex
@@ -247,16 +247,24 @@
% load package #1 and add its options to chemmacros
% this requires that package #1 defines its options with l3keys using its
% name as module
-\cs_new_protected:Npn \chemmacros_integrate_package:nn #1#2
+\cs_new_protected:Npn \chemmacros_integrate_package:nnn #1#2#3
{
- \tl_if_blank:nTF {#2}
- { \RequirePackage {#1} }
- { \RequirePackage {#1} [#2] }
+ \tl_if_blank:nTF {#3}
+ {
+ \tl_if_blank:nTF {#1}
+ { \RequirePackage {#2} }
+ { \RequirePackage [#1] {#2} }
+ }
+ {
+ \tl_if_blank:nTF {#1}
+ { \RequirePackage {#2} [#3] }
+ { \RequirePackage [#1] {#2} [#3] }
+ }
\keys_define:nn {chemmacros}
{
- #1 .choice: ,
- #1 / unknown .code:n =
- \keys_set:no {#1} { \l_keys_key_tl = ##1 }
+ #2 .choice: ,
+ #2 / unknown .code:n =
+ \keys_set:no {#2} { \l_keys_key_tl = ##1 }
}
}
diff --git a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.charges.code.tex b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.charges.code.tex
index 36a190a85ed..e852764feed 100644
--- a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.charges.code.tex
+++ b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.charges.code.tex
@@ -50,12 +50,14 @@
circletype / math .code:n =
{
\bool_set_false:N \l__chemmacros_circled_chem_bool
- \bool_set_false:N \l_chemformula_formal_chem_bool
+ \chemmacros_if_package_loaded:nT {chemformula}
+ { \bool_set_false:N \l_chemformula_formal_chem_bool }
} ,
circletype / chem .code:n =
{
\bool_set_true:N \l__chemmacros_circled_chem_bool
- \bool_set_true:N \l_chemformula_formal_chem_bool
+ \chemmacros_if_package_loaded:nT {chemformula}
+ { \bool_set_true:N \l_chemformula_formal_chem_bool }
} ,
circletype .value_required:n = true ,
circled .choice: ,
@@ -63,19 +65,22 @@
{
\bool_set_false:N \l__chemmacros_circled_bool
\bool_set_false:N \l__chemmacros_circled_formal_bool
- \bool_set_false:N \l_chemformula_formal_charges_bool
+ \chemmacros_if_package_loaded:nT {chemformula}
+ { \bool_set_false:N \l_chemformula_formal_charges_bool }
} ,
circled / formal .code:n =
{
\bool_set_true:N \l__chemmacros_circled_bool
\bool_set_true:N \l__chemmacros_circled_formal_bool
- \bool_set_false:N \l_chemformula_formal_charges_bool
+ \chemmacros_if_package_loaded:nT {chemformula}
+ { \bool_set_false:N \l_chemformula_formal_charges_bool }
} ,
circled / all .code:n =
{
\bool_set_true:N \l__chemmacros_circled_bool
\bool_set_false:N \l__chemmacros_circled_formal_bool
- \bool_set_true:N \l_chemformula_formal_charges_bool
+ \chemmacros_if_package_loaded:nT {chemformula}
+ { \bool_set_true:N \l_chemformula_formal_charges_bool }
} ,
circled .default:n = all
}
diff --git a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.chemformula.code.tex b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.chemformula.code.tex
index 56c469f6245..d785ce6c795 100644
--- a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.chemformula.code.tex
+++ b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.chemformula.code.tex
@@ -25,13 +25,52 @@
%
% The Current Maintainer of this work is Clemens Niederberger.
% --------------------------------------------------------------------------
-\ChemModule{chemformula}{2015/07/25 chemformula integration}
+\ChemModule{chemformula}{2015/09/19 integration of chemical formulas}
+\RequirePackage{amstext}
\chemmacros_load_module:n {charges}
-\chemmacros_integrate_package:nn {chemformula} {2015/08/19}
+\msg_new:nnn {chemmacros} {unknown-formula-method}
+ {
+ You~ chose~ the~ formula~ method~ `#1'~ which~ is~ not~ available.~ Valid~
+ methods~ are~ (the~ recommended~ choice)~ `chemformula'~ and~ `mhchem'.~
+ I'm~ falling~ back~ to~ `chemformula'~ now.
+ }
-\RequirePackage{amstext}
+\bool_new:N \l__chemmacros_formula_method_set_bool
+
+\tl_new:N \g_chemmacros_formula_method_tl
+\tl_gset:Nn \g_chemmacros_formula_method_tl {chemformula}
+
+\cs_new_protected:Npn \chemmacros_set_formula_method:n #1
+ {
+ \str_case:nnTF {#1}
+ {
+ {chemformula} {
+ \chemmacros_integrate_package:nnn {} {chemformula} {2015/09/08}
+ \tl_gset:Nn \g_chemmacros_formula_method_tl {chemformula}
+ }
+ {mhchem} {
+ \chemmacros_integrate_package:nnn {version=4} {mhchem} {}
+ \cs_set_protected:Npn \chemmacros_chemformula:n ##1 { \ce {##1} }
+ \cs_set_protected:Npn \chemmacros_reaction:n ##1 { \ce {##1} }
+ \chemmacros_after_module:nn {charges}
+ {
+ \cs_set_protected:Npn \chemmacros_elpair:n ##1 { \ce{##1} : }
+ \cs_set_protected:Npn \chemmacros_plus: { + }
+ \cs_set_protected:Npn \chemmacros_minus: { - }
+ \cs_set_protected:Npn \chemmacros_formal_plus: { \ensuremath{\oplus} }
+ \cs_set_protected:Npn \chemmacros_formal_minus: { \ensuremath{\ominus} }
+ \cs_set_protected:Npn \fplus { \ensuremath{\oplus} }
+ \cs_set_protected:Npn \fminus { \ensuremath{\ominus} }
+ }
+ \tl_gset:Nn \g_chemmacros_formula_method_tl {mhchem}
+ }
+ }
+ { \bool_set_true:N \l__chemmacros_formula_method_set_bool }
+ { \bool_set_false:N \l__chemmacros_formula_method_set_bool }
+ }
+\cs_generate_variant:Nn \chemmacros_set_formula_method:n {V}
% --------------------------------------------------------------------------
% let's make use of `chemformula' inside some of `chemmacros' commands:
@@ -39,4 +78,35 @@
{ \chemformula_chcpd:nn {} {#1} }
\cs_generate_variant:Nn \chemmacros_chemformula:n { x,V }
+\cs_new_protected:Npn \chemmacros_reaction:n #1
+ { \chemformula_ch:nn {} {#1} }
+
+% for module writes prefering traditional 2e programming:
+\cs_new_protected:Npn \chemmacros@formula #1 { \chemmacros_chemformula:n {#1} }
+\cs_new_protected:Npn \chemmacros@reaction #1 { \chemmacros_reaction:n {#1} }
+
% --------------------------------------------------------------------------
+\ChemCompatibilityFrom{5.1}
+\keys_define:nn {chemmacros}
+ {
+ formula .choices:nn =
+ { chemformula , mhchem }
+ { \chemmacros_set_formula_method:V \l_keys_choice_tl } ,
+ formula / unknown .code:n =
+ \msg_warning:nnn {chemmacros} {unknown-formula-method} {#1}
+ \tl_gset:Nn \g_chemmacros_formula_method_tl {chemformula}
+ }
+\EndChemCompatibility
+
+\AtEndPreamble
+ {
+ \bool_if:NF \l__chemmacros_formula_method_set_bool
+ { \chemmacros_set_formula_method:V \g_chemmacros_formula_method_tl }
+ }
+
+% --------------------------------------------------------------------------
+\tex_endinput:D
+
+2015/09/22 - new general option `method' which allows a choice between
+ `chemformula' and `mhchem'
+
diff --git a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.particles.code.tex b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.particles.code.tex
index 110dd05c8ea..ccc506e8c23 100644
--- a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.particles.code.tex
+++ b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.particles.code.tex
@@ -32,7 +32,7 @@
% --------------------------------------------------------------------------
% particles
\cs_new_protected:Nn \chemmacros_define_particle:Nn
- { \cs_set_protected:Npn #1 { \chemformula_chcpd:nn {} {#2} } }
+ { \cs_set_protected:Npn #1 { \chemmacros_chemformula:n {#2} } }
\chemmacros_new_macroset:nnn {Particle} {mm}
{ \chemmacros_define_particle:Nn #1 {#2} }
@@ -72,7 +72,7 @@
\cs_set_protected:cpn {__chemmacros_ \chemmacros_remove_backslash:N #1:}
{
\bool_if:NTF \l__chemmacros_nucleophile_elpair_bool
- { \chemmacros_elpair:n { #2 } \chemmacros_chemformula:n { {}- } }
+ { \chemmacros_elpair:n { #2 } \chemmacros_chemformula:n { {}^{-} } }
{ \chemmacros_chemformula:n { #2- } }
}
\DeclareDocumentCommand #1 {o}
diff --git a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.reactions.code.tex b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.reactions.code.tex
index 087cd521e69..a3468239f06 100644
--- a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.reactions.code.tex
+++ b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.reactions.code.tex
@@ -25,7 +25,7 @@
%
% The Current Maintainer of this work is Clemens Niederberger.
% --------------------------------------------------------------------------
-\ChemModule{reactions}{2015/07/14 reaction environments}
+\ChemModule{reactions}{2015/09/15 reaction environments}
\chemmacros_load_module:n {chemformula}
@@ -169,7 +169,7 @@
\cs_new_protected:Npn \chemmacros_reaction_read:nnw #1#2#3 \end
{
\begin{#1}#2
- \chemformula_ch:nn {} {#3}
+ \chemmacros_reaction:n {#3}
\end{#1}
\end
}
@@ -183,3 +183,7 @@
\NewChemReaction {reactions*} {align*}
% --------------------------------------------------------------------------
+\tex_endinput:D
+
+2015/09/15 - adapt to `method' option => do not use chemformula's macros
+ directly
diff --git a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.scheme.code.tex b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.scheme.code.tex
index 5963e3e2260..d4dd3ae7691 100644
--- a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.scheme.code.tex
+++ b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.scheme.code.tex
@@ -25,7 +25,7 @@
%
% The Current Maintainer of this work is Clemens Niederberger.
% --------------------------------------------------------------------------
-\ChemModule{scheme}{2015/06/09 a scheme floating environment}
+\ChemModule{scheme}{2015/09/19 a scheme floating environment}
\RequirePackage {chemnum}
@@ -43,7 +43,7 @@
\seq_put_right:Nn \l__chemmacros_float_methods_seq {#1}
\prop_put:Nnn \l__chemmacros_float_methods_prop {#1} {#2}
\prop_put:Nnn \l__chemmacros_float_definitions_prop {#1}
- { \cs_set_protected:Npn \__chemmacros_define_float:n ##1 {#3} }
+ { \cs_set_protected:Npn \__chemmacros_define_float:nn ##1##2 {#3} }
}
% the order in which the methods are defined determines in which order the
@@ -57,28 +57,28 @@
float ,
name = \chemmacros_translate:n {#1-name} ,
listname = {\exp_not:N \chemmacros_translate:n {#1-list}}
- ]{los}
+ ]{#2}
}
\chemmacros_define_float_method:nnn {memoir}
{ \chemmacros_if_class_loaded_p:n {memoir} }
{
- \newfloat [chapter] {scheme} {los} {\chemmacros_translate:n {#1-name}}
- \cs_set:Npn \thescheme {\thechapter.\@arabic\c@scheme}
- \newlistof {listofschemes} {los} {\chemmacros_translate:n {#1-list}}
- \newlistentry [chapter] {scheme} {los} {0}
- \cftsetindents {scheme} {0em} {2.3em}
+ \newfloat [chapter] {#1} {#2} {\chemmacros_translate:n {#1-name}}
+ \cs_set:cpn {the#1} {\thechapter.\arabic {#1}}
+ \newlistof {listof#1s} {#2} {\chemmacros_translate:n {#1-list}}
+ \newlistentry [chapter] {#1} {#2} {0}
+ \cftsetindents {#1} {0em} {2.3em}
\tl_put_right:Nn \@memfront@floats
- { \counterwithout {scheme} {chapter} }
+ { \counterwithout {#1} {chapter} }
\tl_put_right:Nn \@memmain@floats
- { \counterwithin {scheme} {chapter} }
+ { \counterwithin {#1} {chapter} }
\tl_put_right:Nn \@memback@floats
{
- \counterwithin {scheme} {chapter}
- \setcounter {scheme} {0}
+ \counterwithin {#1} {chapter}
+ \setcounter {#1} {0}
}
\chemmacros_tex_if:nT {artopt}
- { \counterwithout {scheme} {chapter} }
+ { \counterwithout {#1} {chapter} }
}
\chemmacros_define_float_method:nnn {tocbasic}
@@ -90,26 +90,40 @@
float ,
name = \chemmacros_translate:n {#1-name} ,
listname = {\exp_not:N \chemmacros_translate:n {#1-list}}
- ]{los}
+ ]{#2}
}
\chemmacros_define_float_method:nnn {newfloat}
{ \chemmacros_if_package_loaded_p:n {newfloat} }
{
\DeclareFloatingEnvironment[{
- fileext = los ,
+ fileext = #2 ,
listname = {\exp_not:N \chemmacros_translate:n {#1-list}} ,
name = #2
}]{#1}
}
+\ChemCompatibilityFrom{5.1}
+\chemmacros_define_float_method:nnn {floatrow}
+ { \chemmacros_if_package_loaded_p:n {floatrow} }
+ {
+ \DeclareNewFloatType{#1}{%
+ fileext = #2,
+ placement = htp,
+ name = \chemmacros_translate:n {#1-name}
+ }
+ \cs_new_protected:cpn {listof#1s}
+ { \listof {#1} {\chemmacros_translate:n {#1-list}} }
+ }
+\EndChemCompatibility
+
\chemmacros_define_float_method:nnn {float}
{ \chemmacros_if_package_loaded_p:n {float} }
{
- \newfloat {scheme} {htp} {los}
- \floatname {scheme} {\chemmacros_translate:n {#1-name}}
- \cs_new_protected:Npn \listofschemes
- { \listof {scheme} {\chemmacros_translate:n {#1-list}} }
+ \newfloat {#1} {htp} {#2}
+ \floatname {#1} {\chemmacros_translate:n {#1-name}}
+ \cs_new_protected:cpn {listof#1s}
+ { \listof {#1} {\chemmacros_translate:n {#1-list}} }
}
% --------------------------------------------------------------------------
@@ -134,15 +148,15 @@
\chemmacros_check_float_method:n
}
-\AtBeginDocument
+\AtEndPreamble
{
\chemmacros_check_float_methods:
- \chemmacros_define_float:n {scheme}
+ \chemmacros_define_float:nn {scheme} {los}
}
% --------------------------------------------------------------------------
% #1: env name
-\cs_new_protected:Npn \chemmacros_define_float:n #1
+\cs_new_protected:Npn \chemmacros_define_float:nn #1#2
{
\bool_if:nT
{ !\cs_if_exist_p:c {#1} && !\cs_if_exist_p:c {#1} }
@@ -153,22 +167,25 @@
\l__chemmacros_float_method_tl
\l__chemmacros_tmpa_tl
\tl_use:N \l__chemmacros_tmpa_tl
- \__chemmacros_define_float:n {#1}
+ \__chemmacros_define_float:nn {#1} {#2}
}
{
- \newcounter {scheme}
- \cs_set:Npn \thescheme {\@arabic\c@scheme}
- \cs_new:Npn \fps@scheme {tbp}
- \cs_new:Npn \ftype@scheme {8}
- \cs_new:Npn \ext@scheme {los}
- \cs_new:Npn \fnum@scheme {\schemename\nobreakspace\thescheme}
- \cs_new:Npn \schemename {\chemmacros_translate:n {#1-name}}
- \cs_new:Npn \listschemename {\chemmacros_translate:n {#1-list}}
- \newenvironment {scheme}
- {\@float{scheme}}
+ \newcounter {#1}
+ \cs_set:cpn {the#1} {\arabic{#1}}
+ \cs_new:cpn {fps@#1} {tbp}
+ \cs_new:cpn {ftype@#1} {8}
+ \cs_new:cpn {ext@#1} {#2}
+ \cs_new:cpx {fnum@#1} {
+ \exp_not:c {#1name}
+ \exp_not:N \nobreakspace
+ \exp_not:c {the#1}}
+ \cs_new:cpn {#1name} {\chemmacros_translate:n {#1-name}}
+ \cs_new:cpn {list#1name} {\chemmacros_translate:n {#1-list}}
+ \newenvironment {#1}
+ {\@float{#1}}
{\end@float}
- \newenvironment {scheme*}
- {\@dblfloat{scheme}}
+ \newenvironment {#1*}
+ {\@dblfloat{#1}}
{\end@dblfloat}
\bool_if:nTF
{
@@ -176,38 +193,38 @@
\chemmacros_if_class_loaded_p:n {report}
}
{
- \cs_new_protected:Npn \listofschemes
+ \cs_new_protected:cpn {listof#1s}
{
\chemmacros_tex_if:nTF {@twocolumn}
{ \@restonecoltrue\onecolumn }
{ \@restonecolfalse }
- \chapter* {\listschemename}
+ \exp_args:NNx \chapter* {\exp_not:c {list#1name}}
\@mkboth
- {\MakeUppercase\listschemename}
- {\MakeUppercase\listschemename}
- \@starttoc {los}
+ { \MakeUppercase \use:c {list#1name} }
+ { \MakeUppercase \use:c {list#1name} }
+ \@starttoc {#2}
\chemmacros_tex_if:nT {@restonecol}
{ \twocolumn }
}
}
{
- \cs_new_protected:Npn \listofschemes
+ \cs_new_protected:cpn {listof#1s}
{
- \section* {\listschemename}
+ \exp_args:NNx \section* {\exp_not:c {list#1name}}
\@mkboth
- {\MakeUppercase\listschemename}
- {\MakeUppercase\listschemename}
- \@starttoc {los}
+ { \MakeUppercase \use:c {list#1name} }
+ { \MakeUppercase \use:c {list#1name} }
+ \@starttoc {#2}
}
}
- \cs_new_eq:NN \l@scheme \l@figure
- \chemmacros_if_package_loaded:nT
- {floatrow}
- { \flrow@restyle {scheme} }
+ \cs_new_eq:cN {l@#1} \l@figure
}
}
\cs_set:Npn \schemename {\chemmacros_translate:n {#1-name}}
\cs_set:Npn \listschemename {\chemmacros_translate:n {#1-list}}
}
+\tex_endinput:D
% --------------------------------------------------------------------------
+2015/09/19 - make the module compatible with floatrow
+
diff --git a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty
index 27fcc7a93cd..b2907ec4e2f 100644
--- a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty
+++ b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty
@@ -31,9 +31,9 @@
% --------------------------------------------------------------------------
% package information:
-\tl_const:Nn \c_chemmacros_date_tl {2015/09/11}
+\tl_const:Nn \c_chemmacros_date_tl {2015/09/23}
\tl_const:Nn \c_chemmacros_version_major_number_tl {5}
-\tl_const:Nn \c_chemmacros_version_minor_number_tl {0}
+\tl_const:Nn \c_chemmacros_version_minor_number_tl {1}
\tl_const:Nn \c_chemmacros_version_subrelease_tl {}
\tl_const:Nx \c_chemmacros_version_number_tl
{\c_chemmacros_version_major_number_tl.\c_chemmacros_version_minor_number_tl}
@@ -457,3 +457,6 @@ Version history
http://www.mychemistry.eu/2015/06/chemmacros-development/
and the manual section 3.4. Upgrading from version < 5.0
for details
+2015/09/23 - version 5.1 - add option `method' to `chemformula' module
+ - make module `scheme' compatible with `floatrow'
+ - add module hooks `before' and `after'
diff --git a/Master/texmf-dist/tex/latex/chemmacros/chemmacros5.sty b/Master/texmf-dist/tex/latex/chemmacros/chemmacros5.sty
index 7b191bf4948..e8fa9be35f1 100644
--- a/Master/texmf-dist/tex/latex/chemmacros/chemmacros5.sty
+++ b/Master/texmf-dist/tex/latex/chemmacros/chemmacros5.sty
@@ -143,24 +143,26 @@
{
\chemmacros_if_module_exist:nTF {#1}
{
+ \__chemmacros_use_module_hook:nn {before} {#1}
\msg_log:nnn {chemmacros} {loading-module} {#1}
\@onefilewithoptions
{\c__chemmacros_module_prefix_tl.#1}[][]
\c__chemmacros_module_extension_tl
+ \__chemmacros_use_module_hook:nn {after} {#1}
}
{ \msg_error:nnn {chemmacros} {module-missing} {#1} }
}
}
\cs_generate_variant:Nn \__chemmacros_load_module:n { V }
-\prg_new_conditional:Npnn \chemmacros_if_module_loaded:n #1 {T,F,TF}
+\prg_new_conditional:Npnn \chemmacros_if_module_loaded:n #1 {p,T,F,TF}
{
\cs_if_exist:cTF {chemmacros-module-#1-loaded}
{ \prg_return_true: }
{ \prg_return_false: }
}
-\prg_new_conditional:Npnn \chemmacros_if_module_exist:n #1 {T,F,TF}
+\prg_new_conditional:Npnn \chemmacros_if_module_exist:n #1 {p,T,F,TF}
{
\file_if_exist:nTF
{\c__chemmacros_module_prefix_tl.#1.\c__chemmacros_module_extension_tl}
@@ -168,6 +170,50 @@
{ \prg_return_false: }
}
+% --------------------------------------------------------------------------
+% module hooks:
+% #1: module
+% #2: code
+\ChemCompatibilityFrom{5.1}
+\cs_new_protected:Npn \chemmacros_after_module:nn #1#2
+ {
+ \chemmacros_if_module_loaded:nTF {#1}
+ {#2}
+ { \__chemmacros_add_to_module_hook:nnn {#1} {after} {#2} }
+ }
+
+% #1: module
+% #2: code
+\cs_new_protected:Npn \chemmacros_before_module:nn #1#2
+ {
+ \chemmacros_if_module_loaded:nF {#1}
+ { \__chemmacros_add_to_module_hook:nnn {#1} {before} {#2} }
+ }
+\EndChemCompatibility
+
+% #1: module
+% #2: hook name
+% #3: code
+\cs_new_protected:Npn \__chemmacros_add_to_module_hook:nnn #1#2#3
+ {
+ \chemmacros_if_module_loaded:nF {#1}
+ {
+ \tl_if_exist:cF {g__chemmacros_module_#1_#2_hook_tl}
+ { \tl_new:c {g__chemmacros_module_#1_#2_hook_tl} }
+ \tl_gput_right:cn {g__chemmacros_module_#1_#2_hook_tl} {#3}
+ }
+ }
+
+\cs_new_protected:Npn \__chemmacros_use_module_hook:nn #1#2
+ {
+ \tl_if_exist:cT {g__chemmacros_module_#1_#2_hook_tl}
+ {
+ \tl_use:c {g__chemmacros_module_#1_#2_hook_tl}
+ \tl_gclear:c {g__chemmacros_module_#1_#2_hook_tl}
+ }
+ }
+
+% --------------------------------------------------------------------------
\cs_new_protected:Npn \chemmacros_module:nnn #1#2#3
{
\cs_new:cpn {chemmacros-module-#2-loaded} {chemmacros:~module~`#2'}
@@ -182,8 +228,7 @@
]
\bool_if:nF {#1} { \ExplSyntaxOn }
}
-
-% --------------------------------------------------------------------------
+
% define a chemmacros module:
% standard modules are written in the expl3 programming environment, the
% starred version only uses a 2e programming environment, i.e., with @ as a
@@ -239,5 +284,5 @@ Modules: (* = preloaded)
% --------------------------------------------------------------------------
Version history
-2015/08/29 v5.0 - major update of chemmacros; please refer to the end of file
- chemmacros4.sty for the earlier history
+2015/08/29 - initial release v5.0
+2015/09/23 - add module hooks `before' and `after'