diff options
Diffstat (limited to 'macros/latex/contrib')
19 files changed, 5893 insertions, 732 deletions
diff --git a/macros/latex/contrib/babel-contrib/polish/README.md b/macros/latex/contrib/babel-contrib/polish/README.md new file mode 100644 index 0000000000..26f525fcf6 --- /dev/null +++ b/macros/latex/contrib/babel-contrib/polish/README.md @@ -0,0 +1,9 @@ +# Babel support for Polish # + +This is a language module for the Babel system that supports +typesetting in Polish. + +Released under the LaTeX Project Public License v1.3 or later. +See <http://www.latex-project.org/lppl.txt> + +The Current Maintainer is Marcin Woliński <mailto:wolinski@gust.org.pl>. diff --git a/macros/latex/contrib/babel-contrib/polish/polish.dtx b/macros/latex/contrib/babel-contrib/polish/polish.dtx index a2e6697855..8109869b98 100644 --- a/macros/latex/contrib/babel-contrib/polish/polish.dtx +++ b/macros/latex/contrib/babel-contrib/polish/polish.dtx @@ -1,10 +1,11 @@ % \iffalse meta-comment % -% Copyright 1989-2005 Johannes L. Braams and any individual authors +% Copyright © 1989–2005 Johannes L. Braams and any individual authors % listed elsewhere in this file. All rights reserved. +% Copyright © 2022 by Marcin Woliński % -% This file is part of the Babel system. -% -------------------------------------- +% This file is intended to be used with the Babel system. +% ------------------------------------------------------ % % It may be distributed and/or modified under the % conditions of the LaTeX Project Public License, either version 1.3 @@ -16,17 +17,13 @@ % % This work has the LPPL maintenance status "maintained". % -% The Current Maintainer of this work is Johannes Braams. -% -% The list of all files belonging to the Babel system is -% given in the file `manifest.bbl. See also `legal.bbl' for additional -% information. +% The Current Maintainer of this work is Marcin Woliński. % % The list of derived (unpacked) files belonging to the distribution % and covered by LPPL is defined by the unpacking scripts (with % extension .ins) which are part of the distribution. % \fi -% \CheckSum{543} +% \CheckSum{700} % % \iffalse % Tell the \LaTeX\ system who we are and write an entry on the @@ -34,39 +31,20 @@ %<*dtx> \ProvidesFile{polish.dtx} %</dtx> -%<code>\ProvidesLanguage{polish} +%<code|compat>\ProvidesLanguage{polish} %\fi %\ProvidesFile{polish.dtx} - [2005/03/31 v1.2l Polish support from the babel system] + [2022/03/12 1.3 Babel support for Polish] %\iffalse -%% File `polish.dtx' -%% Babel package for LaTeX version 2e -%% Copyright (C) 1989 -- 2005 -%% by Johannes Braams, TeXniek -% -%% Polish Language Definition File -%% Copyright (C) 1989 - 2005 -%% by Elmar Schalueck, Michael Janich -% Universitaet-Gesamthochschule Paderborn -% Warburger Strasse 100 -% 4790 Paderborn -% Germany -% elmar at uni-paderborn.de -% massa at uni-paderborn.de -% -%% Please report errors to: J.L. Braams -%% babel at braams.cistron.nl -% -% This file is part of the babel system, it provides the source -% code for the Polish language definition file. It was developped -% out of Polish.tex, which was written by Elmar Schalueck and -% Michael Janich. Polish.tex was based on code by Leszek -% Holenderski, Jerzy Ryll and J. S. Bie\'n from Faculty of -% Mathematics,Informatics and Mechanics of Warsaw University, exept -% of Jerzy Ryll (Instytut Informatyki Uniwersytetu Warszawskiego). %<*filedriver> \documentclass{ltxdoc} -\newcommand*\TeXhax{\TeX hax} +\usepackage{lmodern} +\usepackage[QX]{fontenc} +\usepackage{array,ot1patch} +\usepackage[hidelinks]{hyperref} +\title{Babel support for Polish} +\author{\normalsize current maintainer: Marcin Woliński} +\date{Version \fileversion, \filedate} \newcommand*\babel{\textsf{babel}} \newcommand*\langvar{$\langle \it lang \rangle$} \newcommand*\note[1]{} @@ -78,6 +56,7 @@ %</filedriver> %\fi % \GetFileInfo{polish.dtx} +% \maketitle % % \changes{polish-1.1c}{1994/06/26}{Removed the use of \cs{filedate} % and moved identification after the loading of babel.def} @@ -86,57 +65,399 @@ % with \LaTeX, moved the definition of \cs{atcatcode} right to the % beginning.} % -% \section{The Polish language} -% -% The file \file{\filename}\footnote{The file described in this -% section has version number \fileversion\ and was last revised on -% \filedate.} defines all the language-specific macros for the -% Polish language. -% -% For this language the character |"| is made active. In -% table~\ref{tab:polish-quote} an overview is given of its purpose. +% \section{Basic Usage} +% +% Typesetting Polish with \TeX\ is, surprisingly, more difficult +% than setting most other European languages. Polish uses several +% accented characters. Some of them, including \textit{ć, ń, ó, ś, +% ź, ż, Ć, Ń, Ó, Ś, Ź, Ż}, can be reasonably rendered by attaching +% “floating diacritics” to Latin letters. More problematic is the +% letter \textit{ł/Ł}, but legend has it that Donald Knuth needed +% to include the name \textit{Łukasiewicz} in his TAOCP, so he +% included a “diacritic” stroke in his Computer Modern fonts. +% Unfortunately, he had no reason to mention \textit{Wałęsa} +% anywhere in TAOCP, and in result the +% “ogonek\footnote{The Polish name seems to also be the official +% English name of the diacritic:\\ +% \url{https://en.wikipedia.org/wiki/Ogonek}.} accent” is not +% present in original \TeX\ fonts. A different set of fonts is +% necessary to properly render Polish characters with ogonek: +% \emph{ą, ę, Ą, Ę} (these characters are also used in Lithuanian +% along with \textit{į, ų, Į, Ų}). +% +% In Unicode \TeX\ engines (Xe\LaTeX, lua\LaTeX), Latin Modern +% fonts are used by default and these include a rich repertoire of +% accented Latin characters. With these engines, it’s enough to +% load Babel with the Polish module: +% \begin{verbatim} +% \usepackage[polish]{babel} +% \end{verbatim} +% +% The matter is more complicated in the case of classical \LaTeX\ +% (including pdf\LaTeX). To obtain correct Polish letters, it is +% necessary to switch the document to a suitable font encoding. +% One possibility is: +% \begin{verbatim} +% \usepackage[OT4]{fontenc} +% \usepackage[polish]{babel} +% \end{verbatim} +% This will result in a document typeset using the Polish +% adaptation of Knuth’s classical Computer Modern fonts. +% +% A more flexible option is the European font encoding T1, which +% covers most of European languages written in the Latin script. +% Unfortunately, the default fonts in this encoding are bitmap +% based, which will result in sub-optimal rendering. So with T1 it +% is necessary to select a different font family as well. A safe +% option is to use Latin Modern (Latin Modern is practically +% identical to Computer Modern, a new name was needed to keep +% backward compatibility of Computer Modern): +% \begin{verbatim} +% \usepackage{lmodern} +% \usepackage[T1]{fontenc} +% \usepackage[polish]{babel} +% \end{verbatim} +% Many font switching packages work with T1. Besides Latin Modern, +% you can expect well designed Polish characters to be present in +% all fonts from the \TeX\ Gyre collection (in particular the Times +% lookalike \file{tgtermes}, Bookmanish \file{tgbonum}, Century +% Schoolbook-like \file{tgschola}, etc.) and in other fonts +% originating from the Polish \TeX\ Users Group +% GUST\footnote{\url{http://www.gust.org.pl/projects/e-foundry}}. +% With Unicode engines you can also use any OpenType font present +% on your system (see the \texttt{fontspec} package). +% +% It is also worth noting, that ogonek is not really an accent: it +% has to be separately designed for each base letter to get a +% typographically acceptable result. This is not the case, e.g., +% for the packages in the PSNFSS set, in particular +% \file{times.sty}. Although these support the T1 encoding, the +% ogonek protrudes from the characters at some random angle (this +% is particularly visible in the case of the letter~ę): +% \begin{center}\fontencoding{T1} +% \begin{tabular}{l>\Huge l<{gąbkę}>{\Huge\itshape\strut} l<{gąbkę}} +% \TeX\ Gyre Termes & \fontfamily{qtm}\selectfont & +% \fontfamily{qtm}\selectfont \\ +% PSNFF Times & \fontfamily{ptm}\selectfont & +% \fontfamily{ptm}\selectfont \\ +% \end{tabular} +% \end{center} +% If quality is your goal, do not use \file{times.sty} for Polish, +% use \file{tgtermes.sty}. +% +% Another element necessary for successful typesetting of Polish is +% a way to encode Polish accented characters in the source file. +% Fortunately, nowadays all \LaTeX\ engines assume input files to +% be in Unicode, in its UTF-8 form, so if you are on a modern +% system, this will work by default. (If you are forced to use +% some old byte-based encoding like the standard ISO 8859-2 or its +% Windows counterpart CP1250, please consult the documentation of +% the \file{inputenc} package.) +% +% +%\section{The Functions of this Module} +% +% As of version 1.3 the code has been updated to the new syntax +% provided by Babel to declare language specific elements. In its +% current form, the module is pretty typical \texttt{.ldf} file: it +% defines Polish translation of language specific strings used by +% \LaTeX, it ensures Polish hyphenation patterns are used, and +% activates the setting known as \cs{frenchspacing}. +% +% Language modules of Babel typically check for the hyphenation +% patterns for the language in question. In their absence, a +% warning is issued and English hyphenation patterns are activated. +% We find this behaviour inappropriate. Polish hyphenation +% patterns are a part of standard \TeX\ distributions for over 20 +% years. Inability to load them signals some configuration problem +% in the system. Moreover, the use of English patterns would lead +% to very badly chosen breaks in a Polish text. Thus, we have +% decided to block automatic hyphenation in Polish text in this +% case. In consequence, system configuration has to be corrected or +% hyphenation points selected manually. +% +% American typography has a rule, that space after punctuation +% characters is larger than typical inter-word space. This rule is +% by default followed by \TeX. In Polish tradition all spaces +% should be of equal width, so we activate \cs{frenchspacing} for +% Polish text. +% +% Babel provides a mechanism for language-specific short commands +% (shorthands) consisting of the character \texttt{"} followed by +% one more character. Table~\ref{tab:polish-short} lists the +% commands available for Polish. The shorthand \texttt{"-} is +% similar to the command \cs{-} but the former does not block +% automatic hyphenation in the rest of the word. The shorthand +% \texttt{"=} should be used for explicit hyphens in the text. +% According to Polish rules, when a break occurs at an explicit +% hyphen, the hyphen gets repeated at the beginning of the new +% line. So, e.g., Polish compound adjectives like +% \emph{biało-czerwony} `white-and-red' should be input as +% \texttt{biało"=czerwony}. +% \begin{table}[ht] +% \caption{Shorthands provided by the Polish module} +% \label{tab:polish-short} +% \begin{center} +% \begin{tabular}{lp{10cm}} +% |"-| & soft hyphen\\ +% |"=| & explicit hyphen repeated after the break \\ +% \verb="|= & disable ligature at this position.\\ +% |"`| & Polish left double quote: „ \\ +% |"'| & Polish right double quote: ” \\ +% |"<| & French left double quote: « (used in Polish as +% second level quotes)\\ +% |">| & French right double quote: »\\ +% \end{tabular} +% \end{center} +% \end{table} +% +% +% \section{A Note on Compatibility} +% \label{sec:compat} +% +% Incompatible changes were introduced in version 1.3 of this module. +% In case of problems with processing legacy documents, please +% try replacing the module invocation with the following: +% \begin{verbatim} +% \usepackage[polish-compat]{babel} +% \end{verbatim} +% This causes an exact copy of the module version v1.2l of +% 2005/03/31 to be loaded. However, please be aware that this old +% code has known problems (see Section~\ref{sec:compat-code}). In +% compatibility mode a different list of shorthands is available, +% they are listed in Table~\ref{tab:polish-quote}. % \begin{table}[htb] -% \begin{center} -% \begin{tabular}{lp{8cm}} -% |"a| & or |\aob|, for tailed-a (like \c{a})\\ -% |"A| & or |\Aob|, for tailed-A (like \c{A})\\ -% |"e| & or |\eob|, for tailed-e (like \c{e})\\ -% |"E| & or |\Eob|, for tailed-E (like \c{E})\\ -% |"c| & or |\'c|, for accented c (like \'c), -% same with uppercase letters and n,o,s\\ -% |"l| & or |\lpb{}|, for l with stroke (like \l)\\ -% |"L| & or |\Lpb{}|, for L with stroke (like \L)\\ -% |"r| & or |\zkb{}|, for pointed z (like \.z), cf. +% \caption{Shortcuts and commands provided in the compatibility +% mode. Be aware that these do not provide typographically +% acceptable shapes of Polish accented characters.} +% \label{tab:polish-quote} +% \begin{center}\fontencoding{OT1}\selectfont +% \begin{tabular}{lp{10cm}} +% |"a| & or |\aob|, for a-ogonek (rendered ą)\\ +% |"A| & or |\Aob|, for A-ogonek (rendered \k{A})\\ +% |"e| & or |\eob|, for e-ogonek (rendered \k{e})\\ +% |"E| & or |\Eob|, for E-ogonek (rendered \k{E})\\ +% |"c| & or |\'c|, for accented c (\'c), +% same with uppercase letters and n, o, s\\ +% |"l| & or |\lpb{}|, for l with stroke (\l)\\ +% |"L| & or |\Lpb{}|, for L with stroke (\L)\\ +% |"r| & or |\zkb{}|, for z-dot-accent (\.z), cf. % pronounciation\\ -% |"R| & or |\Zkb{}|, for pointed Z (like \.Z)\\ -% |"z| & or |\'z|, for accented z\\ -% |"Z| & or |\'Z|, for accented Z\\ +% |"R| & or |\Zkb{}|, for Z-dot-accent (\.Z)\\ +% |"z| & or |\'z|, for accented z (ź)\\ +% |"Z| & or |\'Z|, for accented Z (Ź)\\ % \verb="|= & disable ligature at this position.\\ % |"-| & an explicit hyphen sign, allowing hyphenation % in the rest of the word.\\ % |""| & like |"-|, but producing no hyphen sign % (for compund words with hyphen, e.g.\ |x-""y|). \\ -% |"`| & for German left double quotes (looks like ,,). \\ -% |"'| & for German right double quotes. \\ -% |"<| & for French left double quotes (similar to $<<$). \\ -% |">| & for French right double quotes (similar to $>>$).\\ +% |"`| & for Polish left double quote (,,). \\ +% |"'| & for Polish right double quote (''). \\ +% |"<| & for French left double quote (\guillemotleft). \\ +% |">| & for French right double quote (\guillemotright).\\ % \end{tabular} -% \caption{The extra definitions made by \file{polish.sty}} -% \label{tab:polish-quote} % \end{center} % \end{table} % -% \StopEventually{} +% \StopEventually{}\newpage +% +% \section{The code} +% \begin{macrocode} +%<*code> +\LdfInit{polish}\captionspolish +% \end{macrocode} +% +% The new code requires at least the version 3.63 of Babel where +% the macro \cs{babel@texpdf} was first introduced. +% \begin{macrocode} +\@ifpackagelater{babel}{2021/08/30}{% +}{\PackageError{polish.ldf}{Babel too old, at least version 2021/08/30 + required}{}% + \providecommand\babel@texpdf[4]{#1}% +} +% \end{macrocode} +% +% When this file is read as an option, i.e. by the |\usepackage| +% command, \texttt{polish} could be an `unknown' language in which +% case we have to make it known. So we check for the existence of +% |\l@polish| to see whether we have to do something here. +% +% \begin{macrocode} +\ifx\l@polish\@undefined + \@nopatterns{Polish} + \adddialect\l@polish\l@unhyphenated\fi +% \end{macrocode} +% +% \begin{macro}{\captionspolish} +% The macro |\captionspolish| defines all strings used in the four +% standard documentclasses provided with \LaTeX. +% \begin{macrocode} +\StartBabelCommands*{polish}{captions} + [unicode, charset=utf8, fontenc=TU EU1 EU2] + \SetString{\prefacename}{Przedmowa} + \SetString{\refname}{Literatura} + \SetString{\abstractname}{Streszczenie} + \SetString{\bibname}{Bibliografia} + \SetString{\chaptername}{Rozdział} + \SetString{\appendixname}{Dodatek} + \SetString{\contentsname}{Spis treści} + \SetString{\listfigurename}{Spis rysunków} + \SetString{\listtablename}{Spis tabel} + \SetString{\indexname}{Skorowidz} + \SetString{\figurename}{Rysunek} + \SetString{\tablename}{Tabela} + \SetString{\partname}{Część} + \SetString{\enclname}{Załączniki} + \SetString{\ccname}{Do wiadomości} + \SetString{\headtoname}{Do} + \SetString{\pagename}{Strona} + \SetString{\seename}{zob.} + \SetString{\alsoname}{zob. także} + \SetString{\proofname}{Dowód} + \SetString{\glossaryname}{Słowniczek} + +\StartBabelCommands*{polish}{date} + [unicode, charset=utf8, fontenc=TU EU1 EU2] + \SetStringLoop{month#1name}{% + stycznia,lutego,marca,kwietnia,maja,czerwca,% + lipca,sierpnia,września,października,listopada,grudnia} +% \end{macrocode} +% And now, the generic branch, using the LICR and assuming T1. +% \begin{macrocode} +\StartBabelCommands*{polish}{captions} + \SetString{\prefacename}{Przedmowa} + \SetString{\refname}{Literatura} + \SetString{\abstractname}{Streszczenie} + \SetString{\bibname}{Bibliografia} + \SetString{\chaptername}{Rozdzia\l} + \SetString{\appendixname}{Dodatek} + \SetString{\contentsname}{Spis tre\'sci} + \SetString{\listfigurename}{Spis rysunk\'ow} + \SetString{\listtablename}{Spis tabel} + \SetString{\indexname}{Skorowidz} + \SetString{\figurename}{Rysunek} + \SetString{\tablename}{Tabela} + \SetString{\partname}{Cz\k{e}\'s\'c} + \SetString{\enclname}{Za\l\k{a}czniki} + \SetString{\ccname}{Do wiadomo\'sci} + \SetString{\headtoname}{Do} + \SetString{\pagename}{Strona} + \SetString{\seename}{zob.} + \SetString{\alsoname}{zob. tak\.ze} + \SetString{\proofname}{Dow\'od} + \SetString{\glossaryname}{S\l owniczek} + +\StartBabelCommands*{polish}{date} + \SetStringLoop{month#1name}{% + stycznia,lutego,marca,kwietnia,maja,czerwca,% + lipca,sierpnia,wrze\'snia,pa\'zdziernika,listopada,grudnia} + \SetString\today{% + {\number\day}~\@nameuse{month\romannumeral\month name} {\number\year}} +\EndBabelCommands +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\extraspolish} +% \begin{macro}{\noextraspolish} +% The macro |\extraspolish| will perform all the extra definitions +% needed for the Polish language. The macro |\noextraspolish| is +% used to cancel the actions of |\extraspolish|. +% +% \begin{macrocode} +\initiate@active@char{"} +\declare@shorthand{polish}{"-}{\bbl@hy@soft} +\declare@shorthand{polish}{"=}{\babel@texpdf{\bbl@hy@repeat}{-}{-}{\textminus}} +\declare@shorthand{polish}{"|}{\babel@texpdf{\discretionary{-}{}{\kern.03em}}{}{}{}} +\declare@shorthand{polish}{"`}{\quotedblbase} +\declare@shorthand{polish}{"'}{\textquotedblright} +\declare@shorthand{polish}{"<}{\guillemotleft} +\declare@shorthand{polish}{">}{\guillemotright} +% \end{macrocode} +% We specify that the polish group of shorthands should be used. +% These characters are `turned on' once, later their definition may +% vary. +% \begin{macrocode} +\addto\extraspolish{% + \bbl@frenchspacing + \languageshorthands{polish}% + \bbl@activate{"}} +% \end{macrocode} +% +% For Polish texts |\frenchspacing| should be in effect. We +% make sure this is the case and reset it if necessary. +% +% \begin{macrocode} +\addto\noextraspolish{% + \bbl@nonfrenchspacing + \bbl@deactivate{"}} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macrocode} +\ldf@finish{polish} +%</code> +% \end{macrocode} % +% \subsection{Compatibility code} +% \label{sec:compat-code} +% +% This section contains the code and documentation of version v1.2l +% (2005/03/31) of \file{polish.ldf}, which is used for +% \file{polish-compat}. We keep +% it as a compatibility fallback, since (more or less) this version was +% available for almost 20 years and some documents may depend on its +% idiosyncratic features. There are known problems with this code: +% \begin{itemize} +% \item The \texttt{"}-shorthands for Polish characters do not use +% LICR, so even with modern fonts the precomposed characters from +% the font are not used (in the case of \textit{ą, ę, ł, ż}). +% \item The substitute for ogonek accent defined for OT1 is not +% accessible with standard \cs{k} (besides being hideous). +% \item Wrong shape of \textit{ę} is used in the word +% \textit{Część} generated by the command \cs{part}. +% \item The code is \textbf{evil}: it redefines \cs{selectfont}, +% which leads to conflicts with some standard \LaTeX\ packages. +% Another known incompatibility is the macro \cs{lll}, which +% conflicts with AMS-\LaTeX. +% \end{itemize} +% % The macro |\LdfInit| takes care of preventing that this file is % loaded more than once, checking the category code of the % \texttt{@} sign, etc. % \changes{polish-1.2d}{1996/11/03}{Now use \cs{LdfInit} to perform % initial checks} % \begin{macrocode} -%<*code> +%<*compat> \LdfInit{polish}\captionspolish % \end{macrocode} +% \iffalse +%% File `polish.dtx' +%% Babel package for LaTeX version 2e +%% Copyright (C) 1989 -- 2005 +%% by Johannes Braams, TeXniek +% +%% Polish Language Definition File +%% Copyright (C) 1989 - 2005 +%% by Elmar Schalueck, Michael Janich +% Universitaet-Gesamthochschule Paderborn +% Warburger Strasse 100 +% 4790 Paderborn +% Germany +% elmar at uni-paderborn.de +% massa at uni-paderborn.de +% +%% Please report errors to: J.L. Braams +%% babel at braams.cistron.nl +% \fi +% +% This file is part of the babel system, it provides the source +% code for the Polish language definition file. It was developped +% out of Polish.tex, which was written by Elmar Schalueck and +% Michael Janich. Polish.tex was based on code by Leszek +% Holenderski, Jerzy Ryll and J. S. Bie\'n from Faculty of +% Mathematics,Informatics and Mechanics of Warsaw University, exept +% of Jerzy Ryll (Instytut Informatyki Uniwersytetu Warszawskiego). % % When this file is read as an option, i.e. by the |\usepackage| % command, \texttt{polish} could be an `unknown' language in which @@ -539,7 +860,7 @@ % up} % \begin{macrocode} \ldf@finish{polish} -%</code> +%</compat> % \end{macrocode} % % \Finale @@ -561,3 +882,9 @@ %% Right brace \} Tilde \~} %% \endinput + +% \endinput +% Local Variables: +% mode: doctex +% TeX-master: t +% End: diff --git a/macros/latex/contrib/babel-contrib/polish/polish.ins b/macros/latex/contrib/babel-contrib/polish/polish.ins index 00a5e50a92..178ffe1953 100644 --- a/macros/latex/contrib/babel-contrib/polish/polish.ins +++ b/macros/latex/contrib/babel-contrib/polish/polish.ins @@ -53,11 +53,11 @@ \declarepreamble\mainpreamble This is a generated file. -Copyright 1989-2005 Johannes L. Braams and any individual authors +Copyright 2022 Marcin Woliński and any individual authors listed elsewhere in this file. All rights reserved. -This file was generated from file(s) of the Babel system. ---------------------------------------------------------- +This file is intended to be used with the Babel system. +------------------------------------------------------ It may be distributed and/or modified under the conditions of the LaTeX Project Public License, either version 1.3 @@ -69,15 +69,7 @@ version 2003/12/01 or later. This work has the LPPL maintenance status "maintained". -The Current Maintainer of this work is Johannes Braams. - -This file may only be distributed together with a copy of the Babel -system. You may however distribute the Babel system without -such generated files. - -The list of all files belonging to the Babel distribution is -given in the file `manifest.bbl'. See also `legal.bbl for additional -information. +The Current Maintainer of this work is Marcin Woliński. The list of derived (unpacked) files belonging to the distribution and covered by LPPL is defined by the unpacking scripts (with @@ -87,11 +79,11 @@ extension .ins) which are part of the distribution. \declarepreamble\fdpreamble This is a generated file. -Copyright 1989-2005 Johannes L. Braams and any individual authors +Copyright 2022 Marcin Woliński and any individual authors listed elsewhere in this file. All rights reserved. -This file was generated from file(s) of the Babel system. ---------------------------------------------------------- +This file is intended to be used with the Babel system. +------------------------------------------------------ It may be distributed and/or modified under the conditions of the LaTeX Project Public License, either version 1.3 @@ -103,15 +95,7 @@ version 2003/12/01 or later. This work has the LPPL maintenance status "maintained". -The Current Maintainer of this work is Johannes Braams. - -This file may only be distributed together with a copy of the Babel -system. You may however distribute the Babel system without -such generated files. - -The list of all files belonging to the Babel distribution is -given in the file `manifest.bbl'. See also `legal.bbl for additional -information. +The Current Maintainer of this work is Marcin Woliński. In particular, permission is granted to customize the declarations in this file to serve the needs of your installation. @@ -122,12 +106,15 @@ of this file under its original name. \endpreamble \keepsilent +%\askforoverwritefalse \usedir{tex/generic/babel} \usepreamble\mainpreamble -\generate{\file{polish.ldf}{\from{polish.dtx}{code}} - } +\generate{ + \file{polish.ldf}{\from{polish.dtx}{code}} + \file{polish-compat.ldf}{\from{polish.dtx}{compat}} +} \usepreamble\fdpreamble \ifToplevel{ diff --git a/macros/latex/contrib/babel-contrib/polish/polish.pdf b/macros/latex/contrib/babel-contrib/polish/polish.pdf Binary files differindex 19b5c0b01b..a4e4db2a3b 100644 --- a/macros/latex/contrib/babel-contrib/polish/polish.pdf +++ b/macros/latex/contrib/babel-contrib/polish/polish.pdf diff --git a/macros/latex/contrib/chemmacros/HISTORY b/macros/latex/contrib/chemmacros/HISTORY index b746778d8b..82de8871c4 100644 --- a/macros/latex/contrib/chemmacros/HISTORY +++ b/macros/latex/contrib/chemmacros/HISTORY @@ -451,3 +451,7 @@ Version history - re-write translations module giving keys per language rather than vice versa - fix issue with phases/sub=true (issue #49) +2022/03/12 - version 6.2a - use LaTeX's release mechanism and provide v4 and + v5 + - fix small but annoying bug in the reactions + module diff --git a/macros/latex/contrib/chemmacros/README b/macros/latex/contrib/chemmacros/README index 303cc4f854..8cc7a9b8ea 100644 --- a/macros/latex/contrib/chemmacros/README +++ b/macros/latex/contrib/chemmacros/README @@ -1,5 +1,5 @@ -------------------------------------------------------------------------- -the CHEMMACROS package v6.2 2022/03/05 +the CHEMMACROS package v6.2a 2022/03/12 comprehensive support for typesetting chemistry documents @@ -25,6 +25,8 @@ The Current Maintainers of this work are Clemens Niederberger and Sonja K. The chemmacros package consists of the following files == STYLE FILES == chemmacros.sty + chemmacros-2015-02-08.sty + chemmacros-2020-03-07.sty == DOCUMENTATION FILES == chemmacros-manual.tex chemmacros-manual.pdf diff --git a/macros/latex/contrib/chemmacros/chemmacros-2015-02-08.sty b/macros/latex/contrib/chemmacros/chemmacros-2015-02-08.sty new file mode 100644 index 0000000000..85e1c475c1 --- /dev/null +++ b/macros/latex/contrib/chemmacros/chemmacros-2015-02-08.sty @@ -0,0 +1,4112 @@ +% -------------------------------------------------------------------------- +% the CHEMMACROS package +% +% loads of little helpers for chemists +% +% -------------------------------------------------------------------------- +% 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. +% -------------------------------------------------------------------------- +\RequirePackage{ expl3 , xparse , l3keys2e } +\def\chemmacros@version{4.7} +\def\chemmacros@date{2015/02/08} + +\ProvidesExplPackage + {chemmacros} + {\chemmacros@date} + {\chemmacros@version} + {loads of little helpers for chemists (CN)} + +% -------------------------------------------------------------------------- +% check expl3 version: +\@ifpackagelater { expl3 } { 2013/12/14 } + { } + { + \PackageError { chemmacros } { Support~package~expl3~too~old } + { + You~need~to~update~your~installation~of~the~bundles~'l3kernel'~and~ + 'l3packages'.\MessageBreak + Loading~chemmacros~will~abort! + } + \tex_endinput:D + } + +% -------------------------------------------------------------------------- +% variants of kernel commands: +\cs_generate_variant:Nn \prop_if_in:NnTF { NV , Nx } +\cs_generate_variant:Nn \prop_put:Nnn { NV , NVV , NVx } +\cs_generate_variant:Nn \prop_get:NnNTF { NV } +\cs_generate_variant:Nn \tl_set_rescan:Nnn { NnV } +\cs_generate_variant:Nn \tl_if_eq:nnTF { V } +\cs_generate_variant:Nn \tl_const:cn { cV } +\cs_generate_variant:Nn \tl_to_lowercase:n { f } + +% -------------------------------------------------------------------------- +% load required packages +% the technical ones: +\RequirePackage { environ , scrlfile , etoolbox , translations } +% related to other topics like mathematics or graphics: +\RequirePackage { xfrac , siunitx , tikz, mathtools , bm } +% other packages of this bundle -- ghsystem is not loaded here but at the end +% of the preamble depending on a package option: +\RequirePackage { chemformula , chemgreek } +% TikZ libraries (the don't like expl3 syntax): +\ExplSyntaxOff +\usetikzlibrary{calc,arrows} +\ExplSyntaxOn + +% -------------------------------------------------------------------------- +% boolean variables for the package options +\bool_new:N \l__chemmacros_xspace_bool +\bool_set_true:N \l__chemmacros_xspace_bool + +\bool_new:N \l__chemmacros_circled_bool +\bool_set_true:N \l__chemmacros_circled_bool +\bool_new:N \l__chemmacros_circled_formal_bool +\bool_set_true:N \l__chemmacros_circled_formal_bool +\bool_new:N \l__chemmacros_circled_chem_bool +\bool_set_true:N \l__chemmacros_circled_chem_bool + +\bool_new:N \l__chemmacros_EZ_cool_bool +\bool_new:N \l__chemmacros_Nu_mathspec_bool +\bool_new:N \l__chemmacros_chemstyle_bool +\bool_new:N \l__chemmacros_hyperref_bool +\bool_new:N \l__chemmacros_varioref_bool +\bool_new:N \l__chemmacros_chemfig_bool +\bool_new:N \l__chemmacros_ghsystem_bool +% \bool_set_true:N \l__chemmacros_ghsystem_bool + +\bool_new:N \l__chemmacros_iupac_restricted_bool +\bool_new:N \l__chemmacros_iupac_strict_bool +\bool_new:N \l__chemmacros_in_document_bool + +\AtBeginDocument + { + \bool_set_true:N \l__chemmacros_in_document_bool + \@ifpackageloaded { chemstyle } + { \bool_set_true:N \l__chemmacros_chemstyle_bool } + { \bool_set_false:N \l__chemmacros_chemstyle_bool } + \@ifpackageloaded { varioref } + { \bool_set_true:N \l__chemmacros_varioref_bool } + { \bool_set_false:N \l__chemmacros_varioref_bool } + \@ifpackageloaded { hyperref } + { \bool_set_true:N \l__chemmacros_hyperref_bool } + { \bool_set_false:N \l__chemmacros_hyperref_bool } + \@ifpackageloaded { chemfig } + { \bool_set_true:N \l__chemmacros_chemfig_bool } + { \bool_set_false:N \l__chemmacros_chemfig_bool } + } + +% -------------------------------------------------------------------------- +% warning / error messages +\msg_new:nnnn { chemmacros } { language-not-defined } + { The~ language~ `#1'~ is~ not~ defined~ by~ chemmacros. } + { + You~ chose~ the~ language~ `#1'~ which~ is~ not~ defined~ by~ chemmacros.~ + `english'~ is~ used~ instead.~ If~ you~ just~ mistyped~ try~ again!~ + Otherwise~ contact~ the~ author~ and~ he'll~ probably~ add~ your~ language. + } + +\msg_new:nnnn { chemmacros } { already-defined } + { The~ command~ #1~ is~ already~ defined. } + { + The~ command~ #1~ has~ already~ been~ otherwise.~ chemmacros~ also~ tries~ + to~ define~ it~ and~ fails.~ + } + +\msg_new:nnnn { chemmacros } { not-defined } + { The~ command~ #1~ is~ not~ defined,~ yet. } + { + The~ command~ #1~ is~ not~ defined,~ yet.~ chemmacros~ tries~ to~ + redefine~ it~ and~ fails.~ + } + +\msg_new:nnnn { chemmacros } { option-deprecated } + { The~ option~ `#1'~ is~ deprecated.~ I~ will~ ignore~ it. } + { + The~ package~ option~ `#1'~ is~ deprecated~ and~ not~ used~ by~ + chemmacros~ any~ more.~ It~ will~ therefore~ simply~ be~ ignored. + } + +\msg_new:nnnn { chemmacros } { command-deprecated } + { + The~ command~ \token_to_str:N #1 \c_space_tl is~ deprecated.~ Use~ + \token_to_str:N #2 \c_space_tl instead. + } + { + The~ command~ \token_to_str:N #1 \c_space_tl is~ deprecated.~ Use~ + \token_to_str:N #2 \c_space_tl instead. + } + +\msg_new:nnnn { chemmacros } { command-dropped } + { + The~ command~ \token_to_str:N #1 \c_space_tl has~ been~ dropped.~ I'm~ + sorry. + } + { + The~ command~ \token_to_str:N #1 \c_space_tl has~ been~ dropped.~ I'm~ + sorry. + } + +\msg_new:nnnn { chemmacros } { new-particle } + { + The~ command~ sequence~ \token_to_str:N #1 \c_space_tl is~ already~ + defined. + } + { + You've~ tried~ to~ define~ a~ particle~ with~ \token_to_str:N + \NewChemParticle ,~ but~ the~ command~ sequence~ \token_to_str:N #1 + \c_space_tl already~ exists.~ Please~ choose~ another~ name. + } + +\msg_new:nnnn { chemmacros } { renew-particle } + { The~ particle~ \token_to_str:N #1 \c_space_tl is~ not~ defined. } + { + You've~ tried~ to~ renew~ the~ particle~ \token_to_str:N #1 ,~ but~ it~ + doesn't~ exist. + } + +\msg_new:nnnn { chemmacros } { new-latin } + { + The~ command~ sequence~ \token_to_str:N #1 \c_space_tl is~ already~ + defined. + } + { + You've~ tried~ to~ define~ a~ latin~ phrase~ with~\token_to_str:N + \NewChemLatin ,~ but~ the~ command~ sequence~ \token_to_str:N #1 + \c_space_tl already~ exists.~ Please~ choose~ another~ name. + } + +\msg_new:nnnn { chemmacros } { renew-latin } + { The~ latin~ phrase \token_to_str:N #1 \c_space_tl is~ not~ defined. } + { + You've~ tried~ to~ renew~ the~ latin~ phrase~ \token_to_str:N #1 ,~ but~ + it~ doesn't~ exist. + } + +\msg_new:nnnn { chemmacros } { new-nmr } + { + The~ command~ sequence~ \token_to_str:N #1 \c_space_tl is~ already~ + defined. + } + { + You've~ tried~ to~ define~ a~ NMR~ command~ with~\token_to_str:N + \NewChemParticle ,~ but~ the~ command~ sequence~ \token_to_str:N #1 + \c_space_tl already~ exists.~ Please~ choose~ another~ name. + } + +\msg_new:nnnn { chemmacros } { renew-nmr } + { The~ NMR~ command~ \token_to_str:N #1 \c_space_tl is~ not~ defined. } + { + You've~ tried~ to~ renew~ the~ NMR~ command~ \token_to_str:N #1 ,~ but~ + it~ doesn't~ exist. + } + +\msg_new:nnnn { chemmacros } { new-phase } + { + The~ command~ sequence~ \token_to_str:N #1 \c_space_tl is~ already~ + defined. + } + { + You've~ tried~ to~ define~ a~ phase~ with~ \token_to_str:N + \NewChemPhase ,~ but~ the~ command~ sequence~ \token_to_str:N #1 + \c_space_tl already~ exists.~ Please~ choose~ another~ name. + } + +\msg_new:nnnn { chemmacros } { renew-phase } + { The~ phase~ \token_to_str:N #1 \c_space_tl is~ not~ defined. } + { + You've~ tried~ to~ renew~ the~ phase~ \token_to_str:N #1 ,~ but~ it~ + doesn't~ exist. + } + +\msg_new:nnnn { chemmacros } { new-iupac } + { + The~ iupac~ naming~ command~ \token_to_str:N #1 \c_space_tl is~ already~ + defined. + } + { + You've~ tried~ to~ define~ a~ iupac~ naming~ command~ with~ + \token_to_str:N \NewChemIUPAC ,~ but~ the~ iupac~ command~ + \token_to_str:N #1 \c_space_tl already~ exists.~ Choose~ another~ name~ + or~ use~ \token_to_str:N \RenewChemIUPAC . + } + +\msg_new:nnnn { chemmacros } { renew-iupac } + { + The~ iupac~ naming~ command~ \token_to_str:N #1 \c_space_tl is~ not~ + defined. + } + { + You've~ tried~ to~ renew~ the~ iupac~ command~ \token_to_str:N #1 ,~ but~ + it~ doesn't~ exist.~ Use~ \token_to_str:N \NewChemIUPAC \c_space_tl + instead. + } + +\msg_new:nnnn { chemmacros } { let-iupac } + { + The~ iupac~ naming~ command~ \token_to_str:N #2 \c_space_tl is~ not~ + defined. + } + { + You've~ tried~ to~ let~ the~ iupac~ command~ \token_to_str:N #1 ~ to~ the~ + iupac~ command~ \token_to_str:N #2 ,~ but~ the~ latter~ doesn't~ exist.~ + Use~ \token_to_str:N \NewChemIUPAC \c_space_tl instead~ or~declare~ + \token_to_str:N #2 \c_space_tl first. + } + +\msg_new:nnnn { chemmacros } { ox } + { \token_to_str:N \ox \c_space_tl : ~ #1 ~ \msg_line_context: . } + { \token_to_str:N \ox \c_space_tl : ~ #1 ~ \msg_line_context: . } + +\msg_new:nnnn { chemmacros } { OX } + { \token_to_str:N \OX \c_space_tl : ~ #1 ~ \msg_line_context: . } + { \token_to_str:N \OX \c_space_tl : ~ #1 ~ \msg_line_context: . } + +\msg_new:nnnn { chemmacros } { redox } + { \token_to_str:N \redox \c_space_tl : ~ #1 ~ \msg_line_context: . } + { \token_to_str:N \redox \c_space_tl : ~ #1 ~ \msg_line_context: . } + +\msg_new:nnnn { chemmacros } { chemfig } + { + You~ need~ to~ load~ the~ `chemfig'~ package~ in~ order~ to~ make~ + \exp_after:wN \token_to_str:N \cs:w #1 \cs_end: \c_space_tl work~ + properly~ \msg_line_context: . + } + { + You~ need~ to~ load~ the~ `chemfig'~ package~ in~ order~ to~ make~ + \exp_after:wN \token_to_str:N \cs:w #1 \cs_end: \c_space_tl work~ + properly~ \msg_line_context: . + } + +\msg_new:nnnn { chemmacros } { new-state } + { + The~ state~ \exp_after:wN \token_to_str:N \cs:w #1 \cs_end: \c_space_tl + already~ exists.~ You~ need~ to~ use~ \token_to_str:N \RenewChemState + \c_space_tl to~ alter~ it~ \msg_line_context: . + } + { + The~ state~ \exp_after:wN \token_to_str:N \cs:w #1 \cs_end: \c_space_tl + already~ exists.~ You~ need~ to~ use~ \token_to_str:N \RenewChemState + \c_space_tl to~ alter~ it~ \msg_line_context: . + } + +\msg_new:nnnn { chemmacros } { renew-state } + { + The~ state~ \exp_after:wN \token_to_str:N \cs:w #1 \cs_end: \c_space_tl + isn't~ set~ up~ yet.~ You~ need~ to~ use~ \token_to_str:N + \NewChemState \c_space_tl to~ create~ it~ \msg_line_context: . + } + { + The~ state~ \exp_after:wN \token_to_str:N \cs:w #1 \cs_end: \c_space_tl + isn't~ set~ up~ yet.~ You~ need~ to~ use~ \token_to_str:N + \NewChemState \c_space_tl to~ create ~it~ \msg_line_context: . + } + +\msg_new:nnn { chemmacros } { state-syntax } + { + You're~ using~ a~ no~ longer~ recommended~ syntax~ to~ (re-)define~ a~ + state~ variable~ \msg_line_context: .~ This~ syntax~ may~ deprecate~ and~ + be~ removed~ in~ the~ future. + } + +% declare an option as deprecated: +\cs_new_protected:Npn \chemmacros_option_deprecated:n #1 + { \msg_warning:nnn { chemmacros } { option-deprecated } { #1 } } + +% define a deprecated command with hints to the corresponding new one: +\cs_new_protected:Npn \chemmacros_define_deprecated:NN #1#2 + { + \cs_set_protected:Npn #1 + { + \msg_warning:nnxx { chemmacros } { command-deprecated } + { #1 } { #2 } + #2 + } + } + +\NewDocumentCommand \DeclareChemDeprecated { mm } + { \chemmacros_define_deprecated:NN #1 #2 } + +% define a command as dropped! +\cs_new_protected:Npn \chemmacros_define_dropped:N #1 + { + \cs_set_protected:Npn #1 + { \msg_error:nnn { chemmacros } { command-dropped } { #1 } } + } + +\NewDocumentCommand \DeclareChemDropped { m } + { \chemmacros_define_dropped:N #1 } + +% -------------------------------------------------------------------------- +% temporary variables +\tl_new:N \l__chemmacros_tmpa_tl +\tl_new:N \l__chemmacros_tmpb_tl +\int_new:N \l__chemmacros_tmpa_int +\box_new:N \l__chemmacros_tmpa_box + +% -------------------------------------------------------------------------- +% language settings: +\bool_new:N \l__chemmacros_language_auto_bool +\bool_set_true:N \l__chemmacros_language_auto_bool +% this token list will hold the chosen language for chemmacros; since the +% language is either chosen automatically or by option it is only available at +% begin document +\tl_new:N \l_chemmacros_language_tl +\tl_set:Nn \l_chemmacros_language_tl { english } +\tl_new:N \l__chemmacros_current_language_tl + +% translate the key #1 +\cs_new:Npn \chemmacros_translate:n #1 + { + \bool_if:NTF \l__chemmacros_language_auto_bool + { \GetTranslation{#1} } + { \GetTranslationFor{\l_chemmacros_language_tl}{#1} } + } + +\AtBeginDocument{ + \bool_if:NTF \l__chemmacros_language_auto_bool + { + \tl_set:Nx \l_chemmacros_language_tl + { \@trnslt@language{\@trnslt@current@language} } + } + { + \tl_set_eq:NN + \l_chemmacros_language_tl + \l__chemmacros_current_language_tl + } +} + +% -------------------------------------------------------------------------- +% package options +% circled => circle charges +% detect-bold => behaviour when font series bold +% EZ => cool or chemmacros version of \E +% german => change pKA => pKS etc +% iupac => behaviour of nomenclature commands +% ngerman => an alias :) +% ghsystem => load ghsystem or don't +% method => use `chemformula' or `mhchem' +% strict => errors or warnings +% synchronize => let particles et.al. adapt chemformula's font selection +% ugreek => behaviour of \chemDelta, \chemalpha, ... +% version=1 => compatibility for documents set with v1.* +% xspace => add an \xspace after a whole bunch of macros + +% this boolean has to be public since the other packages of the bundle may +% want to know its value + +\bool_new:N \l__chemmacros_detect_bold_bool +\bool_set_true:N \l__chemmacros_detect_bold_bool + +\bool_new:N \l__chemmacros_option_greek_set_bool +\bool_new:N \l__chemmacros_use_upgreek_bool +\bool_new:N \l__chemmacros_use_textgreek_bool +\bool_new:N \l__chemmacros_use_kpfonts_bool +\bool_new:N \l__chemmacros_use_newtx_bool + +\cs_new:Npn \chemmacros_inner_font: {} + +\keys_define:nn { chemmacros / option } + { + bpchem .code:n = \chemmacros_option_deprecated:n { bpchem } , + circletype .choice: , + circletype / math .code:n = + { \bool_set_false:N \l__chemmacros_circled_chem_bool } , + circletype / chem .code:n = + { \bool_set_true:N \l__chemmacros_circled_chem_bool } , + circletype .default:n = chem , + circled .choice: , + circled / none .code:n = + { + \bool_set_false:N \l__chemmacros_circled_bool + \bool_set_false:N \l__chemmacros_circled_formal_bool + } , + circled / formal .code:n = + { + \bool_set_true:N \l__chemmacros_circled_bool + \bool_set_true:N \l__chemmacros_circled_formal_bool + } , + circled / all .code:n = + { + \bool_set_true:N \l__chemmacros_circled_bool + \bool_set_false:N \l__chemmacros_circled_formal_bool + } , + circled .default:n = all , + detect-bold .code:n = \chemmacros_option_deprecated:n { detect-bold } , + EZ .code:n = \chemmacros_option_deprecated:n { EZ } , + german .code:n = + \tl_set:Nn \l__chemmacros_current_language_tl { german } , + ngerman .code:n = + \tl_set:Nn \l__chemmacros_current_language_tl { ngerman } , + ghsystem .bool_set:N = \l__chemmacros_ghsystem_bool , + ghsystem .default:n = true , + iupac .choice: , + iupac / restricted .code:n = + \bool_set_true:N \l__chemmacros_iupac_restricted_bool + \bool_set_false:N \l__chemmacros_iupac_strict_bool , + iupac / auto .code:n = + \bool_set_false:N \l__chemmacros_iupac_restricted_bool + \bool_set_false:N \l__chemmacros_iupac_strict_bool , + iupac / strict .code:n = + \bool_set_false:N \l__chemmacros_iupac_restricted_bool + \bool_set_true:N \l__chemmacros_iupac_strict_bool , + language .code:n = + \tl_if_eq:nnTF { #1 } { auto } + { \bool_set_true:N \l__chemmacros_language_auto_bool } + { + \bool_set_false:N \l__chemmacros_language_auto_bool + \tl_set:Nn \l__chemmacros_current_language_tl { #1 } + } , + method .choice: , + method / chemformula .code:n = + \chemmacros_option_deprecated:n { method } , + method / mhchem .code:n = + \chemmacros_option_deprecated:n { method } , + Nu .choice: , + Nu / mathspec .code:n = + \bool_set_true:N \l__chemmacros_Nu_mathspec_bool , + Nu / chemmacros .code:n = + \bool_set_false:N \l__chemmacros_Nu_mathspec_bool , + strict .code:n = + \chemmacros_option_deprecated:n { strict } , + synchronize .choice: , + synchronize / true .code:n = + \cs_set_eq:NN \chemmacros_inner_font: \chemformula_font_inner: , + synchronize / false .code:n = \cs_set:Nn \chemmacros_inner_font: {} , + synchronize .default:n = true , + greek .choice: , + greek / upgreek .code:n = + \chemgreek_activate_mapping:n { upgreek } + \bool_set_true:N \l__chemmacros_option_greek_set_bool , + greek / textgreek .code:n = + \chemgreek_activate_mapping:n { textgreek } + \bool_set_true:N \l__chemmacros_option_greek_set_bool , + greek / kpfonts .code:n = + \chemgreek_activate_mapping:n { kpfonts } + \bool_set_true:N \l__chemmacros_option_greek_set_bool , + greek / newtx .code:n = + \chemgreek_activate_mapping:n { newtx } + \bool_set_true:N \l__chemmacros_option_greek_set_bool , + greek / mathdesign .code:n = + \chemgreek_activate_mapping:n { mathdesign } + \bool_set_true:N \l__chemmacros_option_greek_set_bool , + greek / fourier .code:n = + \chemgreek_activate_mapping:n { fourier } + \bool_set_true:N \l__chemmacros_option_greek_set_bool , + greek / textalpha .code:n = + \chemgreek_activate_mapping:n { textalpha } + \bool_set_true:N \l__chemmacros_option_greek_set_bool , + greek / math .code:n = + \chemgreek_activate_mapping:n { default } + \bool_set_true:N \l__chemmacros_option_greek_set_bool , + greek / auto .code:n = + \bool_set_false:N \l__chemmacros_option_greek_set_bool , + greek .default:n = auto , + upgreek .code:n = \chemmacros_option_deprecated:n { upgreek } , + version .code:n = \chemmacros_option_deprecated:n { version } , + cmversion .code:n = \chemmacros_option_deprecated:n { cmversion } , + cmversion .choice: , + xspace .bool_set:N = \l__chemmacros_xspace_bool , + xspace .default:n = true + } + + + +\ProcessKeysOptions { chemmacros / option } + +% -------------------------------------------------------------------------- +% set up a few things: +% - is `ghsystem' requested? +% - do we need `xspace'? +% - what about the greek letters? + +\seq_new:N \l__chemmacros_greek_packages_seq +\prop_new:N \l__chemmacros_greek_mapping_prop + +\cs_new_protected:Npn \chemmacros_add_greek_package_mapping:nn #1#2 + { + \seq_put_right:Nn \l__chemmacros_greek_packages_seq {#1} + \prop_put:Nnn \l__chemmacros_greek_mapping_prop {#1} {#2} + } + +\cs_generate_variant:Nn \chemgreek_activate_mapping:n { V } + +\cs_new_protected:Npn \__chemmacros_select_greek_mapping:n #1 + { + \bool_if:NF \l__chemmacros_option_greek_set_bool + { + \@ifpackageloaded { #1 } + { + \prop_get:NnN + \l__chemmacros_greek_mapping_prop + { #1 } + \l__chemmacros_tmpa_tl + \chemgreek_activate_mapping:V \l__chemmacros_tmpa_tl + \bool_set_true:N \l__chemmacros_option_greek_set_bool + \seq_map_break: + } + { } + } + } + +\chemmacros_add_greek_package_mapping:nn {upgreek} {upgreek} +\chemmacros_add_greek_package_mapping:nn {textgreek} {textgreek} +\chemmacros_add_greek_package_mapping:nn {mathdesign} {mathdesign} +\chemmacros_add_greek_package_mapping:nn {kpfonts} {kpfonts} +\chemmacros_add_greek_package_mapping:nn {newtxmath} {newtx} +\chemmacros_add_greek_package_mapping:nn {fourier} {fourier} +\chemmacros_add_greek_package_mapping:nn {textalpha} {textalpha} + +\AtEndPreamble + { + \bool_if:NT \l__chemmacros_ghsystem_bool + { \RequirePackage { ghsystem } } + \bool_if:NT \l__chemmacros_xspace_bool + { \RequirePackage { xspace } } + \seq_map_function:NN + \l__chemmacros_greek_packages_seq + \__chemmacros_select_greek_mapping:n + } + +\cs_new_protected:Npn \chemmacros_xspace: + { \bool_if:NT \l__chemmacros_xspace_bool { \xspace } } + +% -------------------------------------------------------------------------- +% TikZ drawings - helper macros +\cs_new_protected:Npn \chemmacros_tikz_picture:nn #1#2 + { \tikzpicture[#1] #2 \endtikzpicture } +\cs_generate_variant:Nn \chemmacros_tikz_picture:nn { fn,xn } + +\cs_new_protected:Npn \chemmacros_tikz_draw:n #1 + { \draw[#1] } +\cs_generate_variant:Nn \chemmacros_tikz_draw:n { f,x } + +\cs_new_protected:Npn \chemmacros_tikz_node:n #1 + { \node[#1] } +\cs_generate_variant:Nn \chemmacros_tikz_node:n { f,x } + +\cs_new_protected:Npn \chemmacros_tikz_shade:n #1 + { \shade[#1] } +\cs_generate_variant:Nn \chemmacros_tikz_shade:n { f,x } + +\cs_new_protected:Npn \chemmacros_tikz_shadedraw:n #1 + { \shadedraw[#1] } +\cs_generate_variant:Nn \chemmacros_tikz_shadedraw:n { f,x } + +\cs_new_protected:Npn \chemmacros_tikz_node_in_draw:n #1 + { node[#1] } +\cs_generate_variant:Nn \chemmacros_tikz_node_in_draw:n { f,x } + +% -------------------------------------------------------------------------- +% a few general functions: +\cs_new_eq:NN \chemmacros_leave_vmode: \chemformula_leave_vmode: +\cs_new_eq:NN \chemmacros_ignore_spaces: \tex_ignorespaces:D +\cs_new_eq:NN \chemmacros_nobreak: \chemformula_nobreak: +\cs_new_eq:NN \chemmacros_allow_break: \chemformula_allow_break: +\cs_new_eq:NN \chemmacros_skip_nobreak:N \chemformula_skip_nobreak:N +\cs_new:Npn \chemmacros_remove_backslash:N #1 + { \exp_after:wN \use_none:n \token_to_str:N #1 } + +\prg_new_protected_conditional:Npnn \chemmacros_if_is_cs:n #1 { T,F,TF } + { + \tl_set:Nx \l__chemmacros_tmpa_tl { \token_if_cs:NTF #1 { } { x } } + \tl_if_blank:VTF \l__chemmacros_tmpa_tl + { \prg_return_true: } + { \prg_return_false: } + } + +% detection and handling of bold face: +\prg_new_protected_conditional:Npnn \chemmacros_if_bold: { T,F,TF } + { + \seq_if_in:NVTF \l__chemmacros_if_bf_seq \f@series + { \prg_return_true: } + { \prg_return_false: } + } + +\seq_new:N \l__chemmacros_if_bf_seq + +\seq_set_split:Nnn \l__chemmacros_if_bf_seq { , } + { + b , bc , bm , bx , bux , + eb , ebc , ebx , mb , + sb , sbc , sbx , + ub , ubc , ubx + } + +\cs_new_protected:Npn \chemmacros_bm:n #1 + { + \bool_if:NTF \l__chemmacros_detect_bold_bool + { \bm { #1 } } + { #1 } + } + +\cs_new_protected:Npn \chemmacros_bf:n #1 + { + \bool_if:NTF \l__chemmacros_detect_bold_bool + { { \normalfont \bfseries #1 } } + { { \normalfont #1 } } + } + +\cs_new_protected:Npn \chemmacros_detect_bold:n #1 + { + \chemmacros_if_bold:TF + { + \mode_if_math:TF + { \chemmacros_bm:n { #1 } } + { \chemmacros_bf:n { #1 } } + } + { #1 } + } + +% --------------------------------------------------------------------------- +% transition state symbol +\cs_new_protected:Npn \__chemmacros_transition_state: + { + \text + { + \skip_horizontal:n { .1ex } + \hbox_overlap_right:n + { \rule { .6ex } { 0pt } \rule { .05ex } { 1.3ex } } + \hbox_overlap_right:n { \rule [ .4ex ] { 1.3ex } { .05ex } } + \rule [ .85ex ] { 1.3ex } { .05ex } + \skip_horizontal:n { .1ex } + } + } + +\cs_new_protected:Npn \chemmacros_transition_state: + { + \ensuremath + { + \mathchoice + { \displaystyle } + { \textstyle } + { \scriptstyle } + { \scriptscriptstyle } + \__chemmacros_transition_state: + } + } + +% \DeclareDocumentCommand? +\cs_new_eq:NN \transitionstatesymbol \chemmacros_transition_state: + +% -------------------------------------------------------------------------- +% let's make use of `chemformula' inside some of `chemmacros' commands: +\cs_new_protected:Nn \chemmacros_atom:n + { + \mode_if_math:TF + { \text { \chemmacros_inner_font: #1 } } + { \group_begin: \chemmacros_inner_font: #1 \group_end: } + } +\cs_generate_variant:Nn \chemmacros_atom:n { V } + +\cs_new_protected:Npn \chemmacros_text:n #1 + { \mode_if_math:TF { \text { #1 } } { #1 } } + +\tl_new:N \l__chemmacros_chemformula_tl + +\cs_new_protected:Npn \chemmacros_chemformula:n #1 + { + \group_begin: + \cs_set_eq:NN \chemformula_font_inner: \chemmacros_inner_font: + \chemformula_chcpd:nn {} { #1 } + \group_end: + } +\cs_generate_variant:Nn \chemmacros_chemformula:n { x,V } + +% -------------------------------------------------------------------------- +% particles, charges +\NewDocumentCommand \NewChemParticle { mm } + { + \cs_if_free:NTF #1 + { \chemmacros_define_particle:Nn #1 { #2 } } + { \msg_error:nnn { chemmacros } { new-particle } { #1 } } + } + +\NewDocumentCommand \RenewChemParticle { mm } + { + \cs_if_free:NTF #1 + { \msg_error:nnn { chemmacros } { renew-particle } { #1 } } + { \chemmacros_define_particle:Nn #1 { #2 } } + } + +\NewDocumentCommand \DeclareChemParticle { mm } + { \chemmacros_define_particle:Nn #1 { #2 } } + +\cs_new_protected:Nn \chemmacros_define_particle:Nn + { + \cs_set_protected:Npn #1 + { + \chemformula_chcpd:nn {} { #2 } + \chemmacros_xspace: + } + } + +\NewChemParticle \el { e- } +\NewChemParticle \prt { p+ } +\NewChemParticle \ntr { n^0 } + +% -------------------------------------------------------------------------- +% charges +% circled charge signs: they are defined in the `chemformula' module: +% use directly: + +\cs_new_protected:Npn \fplus { { \chemformula_fplus: } } +\cs_new_protected:Npn \fminus { { \chemformula_fminus: } } + +% change output depending on circled-option +\cs_new_eq:NN \chemmacros_plus: \chemformula_plus: +\cs_new_eq:NN \chemmacros_minus: \chemformula_minus: + +\cs_new_protected:Npn \chemmacros_formal_plus: + { + \group_begin: + \bool_set_true:N \l__chemformula_formal_charges_bool + \chemformula_plus: + \group_end: + } + +\cs_new_protected:Npn \chemmacros_formal_minus: + { + \group_begin: + \bool_set_true:N \l__chemformula_formal_charges_bool + \chemformula_minus: + \group_end: + } + +\cs_new_protected:Npn \chemmacros_charge:n #1 + { + \chemformula_superscript:n + { \chemmacros_detect_bold:n { #1 } } + } + +\keys_define:nn { chemmacros / charges } + { append .code:n = \chemmacros_option_deprecated:n { append } } + +\NewDocumentCommand \mch { o } + { + \IfNoValueTF { #1 } + { \chemmacros_charge:n { \chemmacros_minus: } } + { \chemmacros_charge:n { #1 \chemmacros_minus: } } + } + +\NewDocumentCommand \pch { o } + { + \IfNoValueTF { #1 } + { \chemmacros_charge:n { \chemmacros_plus: } } + { \chemmacros_charge:n { #1 \chemmacros_plus: } } + } + +\NewDocumentCommand \fmch { o } + { + \IfNoValueTF { #1 } + { \chemmacros_charge:n { \chemmacros_formal_minus: } } + { \chemmacros_charge:n { #1 \chemmacros_formal_minus: } } + } + +\NewDocumentCommand \fpch { o } + { + \IfNoValueTF { #1 } + { \chemmacros_charge:n { \chemmacros_formal_plus: } } + { \chemmacros_charge:n { #1 \chemmacros_formal_plus: } } + } + +\tl_new:N \l__chemmacros_partial_charge_format_tl +\tl_set:Nn \l__chemmacros_partial_charge_format_tl { \tiny } + +\cs_new_protected:Npn \delm + { + \mbox { + \l__chemmacros_partial_charge_format_tl + \c_math_toggle_token \delta \chemmacros_minus: \c_math_toggle_token + } + \chemmacros_xspace: + } +\cs_new_protected:Npn \delp + { + \mbox { + \l__chemmacros_partial_charge_format_tl + \c_math_toggle_token \delta \chemmacros_plus: \c_math_toggle_token + } + \chemmacros_xspace: + } +\cs_new_protected:Npn \fdelm + { + \mbox { + \l__chemmacros_partial_charge_format_tl + \c_math_toggle_token \delta \chemmacros_formal_minus: \c_math_toggle_token + } + \chemmacros_xspace: + } +\cs_new_protected:Npn \fdelp + { + \mbox { + \l__chemmacros_partial_charge_format_tl + \c_math_toggle_token \delta \chemmacros_formal_plus: \c_math_toggle_token + } + \chemmacros_xspace: + } + +\cs_new_protected:Npn \scrm + { \ensuremath { \scriptstyle \chemmacros_minus: } } +\cs_new_protected:Npn \scrp + { \ensuremath { \scriptstyle \chemmacros_plus: } } +\cs_new_protected:Npn \fscrm + { \ensuremath { \scriptstyle \chemmacros_formal_minus: } } +\cs_new_protected:Npn \fscrp + { \ensuremath { \scriptstyle \chemmacros_formal_plus: } } +\cs_new_protected:Npn \fsscrm + { \ensuremath { \scriptscriptstyle \chemmacros_formal_minus: } } +\cs_new_protected:Npn \fsscrp + { \ensuremath { \scriptscriptstyle \chemmacros_formal_plus: } } + +\keys_define:nn { chemmacros / charges } + { + partial-format .tl_set:N = \l__chemmacros_partial_charge_format_tl + } + +% -------------------------------------------------------------------------- +% ions, molecules +% proton, hydroxide, hydronium/oxonium, water, nucleophile, electrophile +\NewChemParticle \Hpl { H+ } +\NewChemParticle \Hyd { OH- } +\NewChemParticle \HtO { H3O+ } +\NewChemParticle \El { E+ } +\NewChemParticle \water { H2O } + +\NewDocumentCommand \chemmacros_Nu:w { o } + { + \IfNoValueF { #1 } { \keys_set:nn { chemmacros / particle } { #1 } } + \bool_if:NTF \l__chemmacros_particle_elpair_bool + { \chemmacros_elpair:n { Nu } \mch } + { \chemmacros_chemformula:n { Nu- } } + \chemmacros_xspace: + } + +\AtBeginDocument + { + \bool_if:NTF \l__chemmacros_Nu_mathspec_bool + { \cs_set_eq:NN \Nuc \chemmacros_Nu:w } + { \cs_set_eq:NN \Nu \chemmacros_Nu:w } + } + +\cs_new_protected:Npn \chemmacros_ba: + { + \bool_if:NTF \l__chemmacros_particle_elpair_bool + { \chemmacros_elpair:n { ba } \mch } + { \chemmacros_chemformula:n { ba- } } + \chemmacros_xspace: + } + +\NewDocumentCommand \ba { o } + { + \group_begin: + \IfNoValueF { #1 } { \keys_set:nn { chemmacros / particle } { #1 } } + \chemmacros_ba: + \group_end: + } + +\cs_new_protected:Npn \chemmacros_elpair:n #1 + { + \bool_if:NTF \l__chemmacros_chemfig_bool + { + \bool_if:NTF \l__chemmacros_elpair_dots_bool + { \chlewis { 0: } { #1 } } + { \chlewis { 0| } { #1 } } +% { { \chemmacros_inner_font: #1 \chlewis { 0=| } { \vphantom { #1 } } } } + } + { + \msg_error:nnn { chemmacros } { chemfig } { #1 } + \chemmacros_atom:n { #1 } + } + } + +\bool_new:N \l__chemmacros_particle_elpair_bool +\bool_new:N \l__chemmacros_elpair_dots_bool + +\keys_define:nn { chemmacros / particle } + { + elpair .choice: , + elpair / false .code:n = + { \bool_set_false:N \l__chemmacros_particle_elpair_bool } , + elpair / dots .code:n = + { + \bool_set_true:N \l__chemmacros_particle_elpair_bool + \bool_set_true:N \l__chemmacros_elpair_dots_bool + } , + elpair / dash .code:n = + { + \bool_set_true:N \l__chemmacros_particle_elpair_bool + \bool_set_false:N \l__chemmacros_elpair_dots_bool + } , + elpair .default:n = dots + } + +% -------------------------------------------------------------------------- +% IUPAC +\prop_new:N \l__chemmacros_iupac_prop + +\cs_new_protected:Npn \chemmacros_new_iupac:Nn #1#2 + { + \tl_set:Nx \l__chemmacros_tmpa_tl + { \chemmacros_remove_backslash:N #1 } + \prop_if_in:NVTF \l__chemmacros_iupac_prop \l__chemmacros_tmpa_tl + { \msg_error:nnn { chemmacros } { new-iupac } { #1 } } + { + \prop_put:NVn \l__chemmacros_iupac_prop + \l__chemmacros_tmpa_tl + { #2 } + } + \chemmacros_make_iupac: + } + +\cs_new_protected:Npn \chemmacros_define_iupac:Nn #1#2 + { + \tl_set:Nx \l__chemmacros_tmpa_tl + { \chemmacros_remove_backslash:N #1 } + \prop_put:NVn \l__chemmacros_iupac_prop + \l__chemmacros_tmpa_tl + { #2 } + \chemmacros_make_iupac: + } + +\cs_new_protected:Npn \chemmacros_renew_iupac:Nn #1#2 + { + \tl_set:Nx \l__chemmacros_tmpa_tl + { \chemmacros_remove_backslash:N #1 } + \prop_if_in:NVTF \l__chemmacros_iupac_prop \l__chemmacros_tmpa_tl + { + \prop_put:NVn \l__chemmacros_iupac_prop + \l__chemmacros_tmpa_tl + { #2 } + } + { \msg_error:nnn { chemmacros } { renew-iupac } { #1 } } + \chemmacros_make_iupac: + } + +\cs_new_protected:Npn \chemmacros_let_iupac:NN #1#2 + { + \tl_set:Nx \l__chemmacros_tmpa_tl + { \chemmacros_remove_backslash:N #1 } + \tl_set:Nx \l__chemmacros_tmpb_tl + { \chemmacros_remove_backslash:N #2 } + \prop_get:NVNTF \l__chemmacros_iupac_prop + \l__chemmacros_tmpb_tl + \l__chemmacros_tmpc_tl + { + \prop_put:NVV \l__chemmacros_iupac_prop + \l__chemmacros_tmpa_tl + \l__chemmacros_tmpc_tl + } + { \msg_error:nnnn { chemmacros } { let-iupac } { #1 } { #2 } } + \chemmacros_make_iupac: + } + +\cs_new_protected:Npn \chemmacros_define_deprecated_iupac:NN #1#2 + { + \chemmacros_define_iupac:Nn #1 + { + \msg_warning:nnnn { chemmacros } { command-deprecated } + { #1 } { #2 } + #2 + } + } + + +\cs_new_protected:Npn \chemmacros_make_iupac: + { + \bool_if:NT \l__chemmacros_in_document_bool + { + \bool_if:NTF \l__chemmacros_inside_iupac_bool + { + \prop_map_inline:Nn \l__chemmacros_iupac_prop + { \cs_set_protected:cpn { ##1 } { ##2 } } + } + { + \bool_if:NF \l__chemmacros_iupac_restricted_bool + { + \bool_if:NTF \l__chemmacros_iupac_strict_bool + { + \prop_map_inline:Nn \l__chemmacros_iupac_prop + { \cs_set_protected:cpn { ##1 } { ##2 } } + } + { + \prop_map_inline:Nn \l__chemmacros_iupac_prop + { + \cs_if_exist:cF { ##1 } + { \cs_set_protected:cpn { ##1 } { ##2 } } + } + } + } + } + } + } + +\AtBeginDocument { \chemmacros_make_iupac: } + +\NewDocumentCommand \DeclareChemIUPAC { mm } + { \chemmacros_define_iupac:Nn #1 { #2 } } + +\NewDocumentCommand \NewChemIUPAC { mm } + { \chemmacros_new_iupac:Nn #1 { #2 } } + +\NewDocumentCommand \RenewChemIUPAC { mm } + { \chemmacros_renew_iupac:Nn #1 { #2 } } + +\NewDocumentCommand \LetChemIUPAC { mm } + { \chemmacros_let_iupac:NN #1 #2 } + +\NewDocumentCommand \DeprecateChemIUPAC { mm } + { \chemmacros_define_deprecated_iupac:NN #1 #2 } + +% stereo descriptors and other nomenclature commands +% Cahn-Ingold-Prelog +\dim_new:N \l__chemmacros_cip_kern_dim +\dim_set:Nn \l__chemmacros_cip_kern_dim { .075em } + +\keys_define:nn { chemmacros / iupac } + { cip-kern .dim_set:N = \l__chemmacros_cip_kern_dim } + +\NewDocumentCommand \cip { m } + { \chemmacros_cip:n { #1 } } + +\cs_new_protected:Npn \chemmacros_cip:n #1 + { ( \textit{#1} \tex_kern:D \l__chemmacros_cip_kern_dim ) } + +\DeprecateChemIUPAC \Rcip \rectus +\DeprecateChemIUPAC \Scip \sinister + +\NewChemIUPAC \rectus { \cip { R } } +\NewChemIUPAC \sinister { \cip { S } } + +\LetChemIUPAC \R \rectus +\LetChemIUPAC \S \sinister + +% TikZ needs : to be other +\ExplSyntaxOff +\protected\def\chemmacros@sconf#1% + {% + \begingroup + \tikz[baseline,text height=1.5ex,text depth=.25ex] + { + \node[anchor=base] (chemmacros@@Sconf) {#1} ; + \draw[->,thick,rotate=90] + ($(chemmacros@@Sconf.center)+(20:.8em)$) arc (20:340:.8em); + }% + \endgroup + } + +\protected\def\chemmacros@rconf#1% + {% + \begingroup + \tikz[baseline,text height=1.5ex,text depth=.25ex] + { + \node[anchor=base] (chemmacros@@Rconf) {#1} ; + \draw[<-,thick,rotate=90] + ($(chemmacros@@Rconf.center)+(20:.8em)$) arc (20:340:.8em) ; + }% + \endgroup + } +\ExplSyntaxOn + +\NewDocumentCommand \Sconf { O{S} } { \chemmacros@sconf { #1 } } +\NewDocumentCommand \Rconf { O{R} } { \chemmacros@rconf { #1 } } + +% E(ntgegen)/Z(usammen) +\NewChemIUPAC \entgegen { \cip { E } } +\NewChemIUPAC \zusammen { \cip { Z } } + +\LetChemIUPAC \E \entgegen +\LetChemIUPAC \Z \zusammen + +% cis/trans +\NewChemIUPAC \cis { \textit { cis } } +\NewChemIUPAC \trans { \textit { trans } } + +% fac/mer +\NewChemIUPAC \fac { \textit { fac } } +\NewChemIUPAC \mer { \textit { mer } } + +% tert +\NewChemIUPAC \tert { \textit { tert } } + +% Fischer +\NewChemIUPAC \dexter { \textsc { d } } +\NewChemIUPAC \laevus { \textsc { l } } + +\LetChemIUPAC \D \dexter +\LetChemIUPAC \L \laevus + +% ortho/meta/para +\NewChemIUPAC \ortho { \textit { o } } +\NewChemIUPAC \meta { \textit { m } } +\NewChemIUPAC \para { \textit { p } } + +% syn/anti +\NewChemIUPAC \syn { \textit { syn } } +\NewChemIUPAC \anti { \textit { anti } } + +% coordination chemistry +\bool_new:N \l__chemmacros_bridge_super_bool + +\keys_define:nn { chemmacros / iupac } + { + bridge-number .choice: , + bridge-number / sub .code:n = + \bool_set_false:N \l__chemmacros_bridge_super_bool , + bridge-number / super .code:n = + \bool_set_true:N \l__chemmacros_bridge_super_bool , + coord-use-hyphen .bool_set:N = \l__chemmacros_coord_use_hyphen_bool , + coord-use-hyphen .default:n = true + } + +\cs_new_protected:Npn \chemformula_hapto:n #1 + { + \chemeta \chemformula_superscript:n { #1 } + \bool_if:NT \l__chemmacros_coord_use_hyphen_bool + { \chemmacros_break_point_hyphen: } + } + +\cs_new_protected:Npn \chemformula_dento:n #1 + { + \chemkappa \chemformula_superscript:n { #1 } + \bool_if:NT \l__chemmacros_coord_use_hyphen_bool + { \chemmacros_break_point_hyphen: } + } + +\cs_new_protected:Npn \chemformula_bridge:n #1 + { + \chemmu + \tl_if_blank:nF { #1 } + { + \bool_if:NTF \l__chemmacros_bridge_super_bool + { \chemformula_superscript:n { #1 } } + { \chemformula_subscript:n { #1 } } + } + \bool_if:NT \l__chemmacros_coord_use_hyphen_bool + { \chemmacros_break_point_hyphen: } + } + +\NewChemIUPAC \hapto { \chemformula_hapto:n } +\NewChemIUPAC \dento { \chemformula_dento:n } +\NewChemIUPAC \bridge { \chemformula_bridge:n } + +% attachments to heteroatoms / added hydrogen +\NewChemIUPAC \hydrogen { \textit { H } } +\NewChemIUPAC \oxygen { \textit { O } } +\NewChemIUPAC \nitrogen { \textit { N } } +\NewChemIUPAC \sulfur { \textit { S } } +\NewChemIUPAC \phosphorus { \textit { P } } + +\LetChemIUPAC \H \hydrogen +\LetChemIUPAC \O \oxygen +\LetChemIUPAC \N \nitrogen +\LetChemIUPAC \Sf \sulfur +\LetChemIUPAC \P \phosphorus + +% language specific settings +\AtBeginDocument + { + \bool_if:NT \l__chemmacros_italian_bool + { + \NewChemIUPAC \sin { \textit { sin } } + \NewChemIUPAC \ter { \textit { ter } } + } + } + +% greek letters +\NewChemIUPAC \a { \chemalpha } +\NewChemIUPAC \b { \chembeta } +\NewChemIUPAC \g { \chemgamma } +\NewChemIUPAC \d { \chemdelta } +\NewChemIUPAC \k { \chemkappa } +\NewChemIUPAC \m { \chemmu } +\NewChemIUPAC \n { \chemeta } +\NewChemIUPAC \w { \chemomega } + +% \iupac (basically the same as bpchem's \IUPAC) +% - allows multiple breaking points as compound names can get really long and +% especially in multicolumn documents can span more than two lines +% - add a (very) little space before the hyphen and a little negative space +% after it +% - add a little space at breaking points if not broken +% - enables all naming commands regardless if they're definied otherwise or not +\cs_new_protected:Nn \chemmacros_allow_hyphens: + { + \chemmacros_nobreak: + \skip_horizontal:N \c_zero_dim + } + +\dim_new:N \l__chemmacros_iupac_hyphen_pre_dim +\dim_set:Nn \l__chemmacros_iupac_hyphen_pre_dim { .01em } +\dim_new:N \l__chemmacros_iupac_hyphen_post_dim +\dim_set:Nn \l__chemmacros_iupac_hyphen_post_dim { -.03em } +\dim_new:N \l__chemmacros_iupac_break_dim +\dim_set:Nn \l__chemmacros_iupac_break_dim { .03em } + +\keys_define:nn { chemmacros / iupac } + { + hyphen-pre-space .dim_set:N = \l__chemmacros_iupac_hyphen_pre_dim , + hyphen-post-space .dim_set:N = \l__chemmacros_iupac_hyphen_post_dim , + break-space .dim_set:N = \l__chemmacros_iupac_break_dim + } + +\cs_new_protected:Nn \chemmacros_break_point_hyphen: + { + \chemmacros_nobreak: + \tex_discretionary:D { - } { } + { + \tex_kern:D \l__chemmacros_iupac_hyphen_pre_dim + - + \tex_kern:D \l__chemmacros_iupac_hyphen_post_dim + } + \chemmacros_allow_hyphens: + } + +\cs_new_protected:Npn \chemmacros_break_point: + { + \chemmacros_nobreak: + \tex_discretionary:D { - } { } + { \tex_kern:D \l__chemmacros_iupac_break_dim } + \chemmacros_allow_hyphens: + } + +\cs_new_protected:Npn \chemmacros_superscript: + { \mode_if_math:TF { \sb } { \textsuperscript } } + +\bool_new:N \l__chemmacros_inside_iupac_bool + +\group_begin: +\char_set_catcode_active:N \~ +\char_set_lccode:nn {`~} {`|} +\tl_to_lowercase:n { \group_end: \cs_set_eq:NN ~ } \chemmacros_break_point: + +\group_begin: +\char_set_catcode_active:N \~ +\char_set_lccode:nn {`~} {`^} +\tl_to_lowercase:n { \group_end: \cs_set_protected:Npn ~ } + { \chemmacros_superscript: } + +\group_begin: +\char_set_catcode_active:N \| +\char_set_catcode_active:N \^ + +\cs_new_protected:Npn \chemmacros_iupac:n #1 + { + \group_begin: + \bool_set_true:N \l__chemmacros_inside_iupac_bool + \chemmacros_make_iupac: + \chemmacros_ignore_spaces: + \cs_set_eq:NN \- \chemmacros_break_point_hyphen: + \chemmacros_define_deprecated:NN \| | + \chemmacros_define_deprecated:NN \^ ^ + \tl_set_rescan:Nnn \l__chemmacros_tmpa_tl + { + \char_set_catcode_active:N \| + \char_set_catcode_active:N \^ + } + {#1} + \l__chemmacros_tmpa_tl + \group_end: + } + +% \cs_new_protected:Npn \chemmacros_iupac_aux:n #1 +% { +% #1 +% \group_end: +% } +\group_end: + +% Thanks to Joseph Wright and Enrico Gregorio for the help on the curious +% redefinition of \- and the end of the compilation +% see http://tex.stackexchange.com/q/42405/5049 for reference +\cs_set_protected:Npx \| { \exp_not:o { \| } } +\cs_set_protected:Npx \- { \exp_not:o { \- } } +\cs_set_eq:NN \@dischyph \- + +\NewDocumentCommand \iupac { } + { \chemmacros_iupac:n } + +% -------------------------------------------------------------------------- +% latin phrases +\tl_new:N \l__chemmacros_latin_format_tl +\tl_set:Nn \l__chemmacros_latin_format_tl { \itshape } + +\keys_define:nn { chemmacros / latin } + { format . tl_set:N = \l__chemmacros_latin_format_tl } + +\cs_new_protected:Npn \chemmacros_latin:n #1 + { { \l__chemmacros_latin_format_tl #1 } } + +\prop_new:N \l__chemmacros_latin_prop + +\cs_new_protected:Npn \chemmacros_new_latin:Nn #1#2 + { + \cs_if_free:NTF #1 + { + \cs_new_protected:Npn #1 + { \chemmacros_latin:n { #2 } \chemmacros_xspace: } + \prop_put:Nnn \l__chemmacros_latin_prop { #1 } { #2 } + } + { \msg_error:nnn { chemmacros } { new-latin } { #1 } } + } + +\cs_new_protected:Npn \chemmacros_define_latin:Nn #1#2 + { + \cs_if_free:NTF #1 + { + \cs_new_protected:Npn #1 + { \chemmacros_latin:n { #2 } \chemmacros_xspace: } + \prop_put:Nnn \l__chemmacros_latin_prop { #1 } { #2 } + } + { + \cs_set_protected:Npn #1 + { \chemmacros_latin:n { #2 } \chemmacros_xspace: } + \prop_put:Nnn \l__chemmacros_latin_prop { #1 } { #2 } + } + } + +\cs_new_protected:Npn \chemmacros_renew_latin:Nn #1#2 + { + \prop_if_in:NnTF \l__chemmacros_latin_prop { #1 } + { \cs_set:Npn #1 { \chemmacros_latin:n { #2 } \chemmacros_xspace: } } + { \msg_error:nnn { chemmacros } { renew-latin } { #1 } } + } + +\NewDocumentCommand \NewChemLatin { mm } + { \chemmacros_new_latin:Nn #1 { #2 } } + +\NewDocumentCommand \RenewChemLatin { mm } + { \chemmacros_renew_latin:Nn #1 { #2 } } + +\NewDocumentCommand \DeclareChemLatin { mm } + { \chemmacros_define_latin:Nn #1 { #2 } } + +\AtBeginDocument + { + \bool_if:NTF \l__chemmacros_chemstyle_bool + { + \AfterPackage* { chemstyle } + { + \cs_undefine:N \invacuo + \cs_set_eq:NN \chemmacros_latin:n \cst@latin + } + } + { + \cs_new_eq:NN \latin \chemmacros_latin:n + } + \NewChemLatin \insitu { in~situ } + \NewChemLatin \abinitio { ab~initio } + \NewChemLatin \invacuo { in~vacuo } + } + +% --------------------------------------------------------------------------- % +% acid / base +\tl_new:N \l__chemmacros_k_acid_tl +\tl_new:N \l__chemmacros_k_base_tl +\tl_new:N \l__chemmacros_k_water_tl + +% \bool_new:N \l__chemmacros_subscript_lowercase_bool + +\tl_set:Nn \l__chemmacros_k_acid_tl + { \chemmacros_translate:n {K-acid} } + +\tl_set:Nn \l__chemmacros_k_base_tl + { \chemmacros_translate:n {K-base} } + +\tl_set:Nn \l__chemmacros_k_water_tl + { \chemmacros_translate:n {K-water} } + +\keys_define:nn { chemmacros / acid-base } + { + p-style .choice: , + p-style / slanted .code:n = \cs_set_eq:NN \chemmacros_p_style:n \textsl , + p-style / italics .code:n = \cs_set_eq:NN \chemmacros_p_style:n \textit , + p-style / upright .code:n = \cs_set_eq:NN \chemmacros_p_style:n \textup , + K-acid .tl_set:N = \l__chemmacros_k_acid_tl , + K-base .tl_set:N = \l__chemmacros_k_base_tl , + K-water .tl_set:N = \l__chemmacros_k_water_tl , + subscript .code:n = \chemmacros_option_deprecated:n {#1} + % subscript / lowercase .code:n = + % \bool_set_true:N \l__chemmacros_subscript_lowercase_bool , + % subscript / uppercase .code:n = + % \bool_set_false:N \l__chemmacros_subscript_lowercase_bool + } + +\cs_new_eq:NN \chemmacros_p_style:n \textup + +\cs_new_protected:Npn \Ka + { + \ensuremath + { + \chemmacros_detect_bold:n + { + K + \c_math_subscript_token + { \l__chemmacros_k_acid_tl } + } + } + \chemmacros_xspace: + } + +\cs_new_protected:Npn \Kb + { + \ensuremath + { + \chemmacros_detect_bold:n + { + K + \c_math_subscript_token + { \l__chemmacros_k_base_tl } + } + } + \chemmacros_xspace: + } + +\cs_new_protected:Npn \Kw + { + \ensuremath + { + \chemmacros_detect_bold:n + { + K + \c_math_subscript_token + { \l__chemmacros_k_water_tl } + } + } + \chemmacros_xspace: + } + +\cs_new_protected:Npn \chemmacros_p:n #1 + { + \group_begin: + \mbox + { + \chemmacros_p_style:n { p } + \ensuremath { #1 } + } + \group_end: + } + +\NewDocumentCommand \p { m } + { \chemmacros_p:n { #1 } } + +\cs_new_protected:Npn \pH + { + \chemmacros_p:n { \chemmacros_chemformula:n { H } } + \chemmacros_xspace: + } + +\cs_new_protected:Npn \pOH + { + \chemmacros_p:n { \chemmacros_chemformula:n { OH } } + \chemmacros_xspace: + } + +\NewDocumentCommand \pKa { o } + { + \chemmacros_p:n + { + \Ka \IfNoValueF { #1 } + { {} \c_math_subscript_token { \chemmacros_detect_bold:n { #1 } } } + } + \chemmacros_xspace: + } + +\NewDocumentCommand \pKb { o } + { + \chemmacros_p:n + { + \Kb \IfNoValueF { #1 } + { {} \c_math_subscript_token { \chemmacros_detect_bold:n { #1 } } } + } + \chemmacros_xspace: + } + +% -------------------------------------------------------------------------- +% units +\DeclareSIUnit { \atm } { atm } +\DeclareSIUnit { \atmosphere } { atm } +\DeclareSIUnit { \calory } { cal } +\DeclareSIUnit { \cal } { cal } + +\AtBeginDocument + { + \bool_if:NF \l__chemmacros_chemstyle_bool + { + \DeclareSIUnit { \cmc } { \cubic\centi\metre } + \DeclareSIUnit { \molar } { \mole\per\cubic\deci\metre } + \DeclareSIUnit { \Molar } { \textsc{m} } + } + } + +\DeclareSIUnit { \moLar } { \mole\per\liter } +\DeclareSIUnit { \MolMass } { \gram\per\mole } +\DeclareSIUnit { \normal } { \textsc{n} } +\DeclareSIUnit { \torr } { torr } + +% -------------------------------------------------------------------------- +% reaction mechanisms +% \mech[<type>] +% <type> - substitutions: {}, 1, 2, se, 1e, 2e, ar +% - eliminations: e, e1, e2, cb +\tl_new:N \l__chemmacros_mech_type_tl +\tl_new:N \l__chemmacros_mech_mol_tl +\tl_new:N \l__chemmacros_mech_ar_tl + +\cs_new_protected:Npn \__chemmacros_set_mech:nnn #1#2#3 + { + \tl_set:Nn \l__chemmacros_mech_type_tl { #1 } + \tl_set:Nn \l__chemmacros_mech_mol_tl { #2 } + \tl_set:Nn \l__chemmacros_mech_ar_tl { #3 } + } + +\keys_define:nn { chemmacros / mech } + { + type .choice: , + type / .code:n = + { + \__chemmacros_set_mech:nnn { S } + { + \c_math_toggle_token + \c_math_subscript_token { \text {N} } + \c_math_toggle_token + } + { } + } , + type / 1 .code:n = + { + \__chemmacros_set_mech:nnn { S } + { + \c_math_toggle_token + \c_math_subscript_token { \text {N} } + \c_math_toggle_token + 1 + } + { } + } , + type / 2 .code:n = + { + \__chemmacros_set_mech:nnn { S } + { + \c_math_toggle_token + \c_math_subscript_token { \text {N} } + \c_math_toggle_token + 2 + } + { } + } , + type / se .code:n = + { + \__chemmacros_set_mech:nnn { S } + { + \c_math_toggle_token + \c_math_subscript_token { \text {E} } + \c_math_toggle_token + } + { } + } , + type / 1e .code:n = + { + \__chemmacros_set_mech:nnn { S } + { + \c_math_toggle_token + \c_math_subscript_token { \text {E} } + \c_math_toggle_token + 1 + } + { } + } , + type / 2e .code:n = + { + \__chemmacros_set_mech:nnn { S } + { + \c_math_toggle_token + \c_math_subscript_token { \text {E} } + \c_math_toggle_token + 2 + } + { } + } , + type / ar .code:n = + { + \__chemmacros_set_mech:nnn { S } + { + \c_math_toggle_token + \c_math_subscript_token { \text {E} } + \c_math_toggle_token + } + { Ar - } + } , + type / e .code:n = + { \__chemmacros_set_mech:nnn { E } { } { } } , + type / e1 .code:n = + { \__chemmacros_set_mech:nnn { E } { 1 } { } } , + type / e2 .code:n = + { \__chemmacros_set_mech:nnn { E } { 2 } { } } , + type / cb .code:n = + { + \__chemmacros_set_mech:nnn { E } + { + 1 + \c_math_toggle_token + \c_math_subscript_token { \text {cb} } + \c_math_toggle_token + } + { } + } , + type .default:n = + } + +\cs_new_protected:Npn \chemmacros_mech:n #1 + { + \tl_if_blank:nTF { #1 } + { \keys_set:nn { chemmacros / mech } { type } } + { \keys_set:nn { chemmacros / mech } { type = #1 } } + \mbox + { + \tl_use:N \l__chemmacros_mech_ar_tl + \tl_use:N \l__chemmacros_mech_type_tl + \tl_use:N \l__chemmacros_mech_mol_tl + } + \chemmacros_xspace: + } + +\NewDocumentCommand \mech { o } + { + \IfNoValueTF { #1 } + { \chemmacros_mech:n { } } + { \chemmacros_mech:n { #1 } } + } + +% -------------------------------------------------------------------------- +% oxidation numbers +% \ox{<number>,<atom>} +\bool_new:N \l__chemmacros_ox_sign_bool +\bool_new:N \l__chemmacros_ox_integer_bool +\bool_new:N \l__chemmacros_ox_explicit_sign_bool +\bool_set_false:N \l__chemmacros_ox_explicit_sign_bool +\bool_new:N \l__chemmacros_ox_format_roman_bool +\bool_set_true:N \l__chemmacros_ox_format_roman_bool +\bool_new:N \l__chemmacros_ox_decimal_marker_comma_bool +\bool_set_false:N \l__chemmacros_ox_decimal_marker_comma_bool +\bool_new:N \l__chemmacros_ox_parse_bool +\bool_set_true:N \l__chemmacros_ox_parse_bool +\bool_new:N \l__chemmacros_ox_side_bool +\bool_new:N \l__chemmacros_ox_super_bool +\bool_new:N \l__chemmacros_ox_top_bool +\bool_set_true:N \l__chemmacros_ox_top_bool +\bool_new:N \l__chemmacros_ox_align_center_bool + +\int_new:N \l__chemmacros_ox_number_int +\fp_new:N \l__chemmacros_ox_number_fp + +\cs_new_protected:Npn \__chemmacros_ox_process_number:n #1 + { + \bool_if:NTF \l__chemmacros_ox_parse_bool + { + \tl_if_in:nnTF { #1 } { / } + { \__chemmacros_ox_fraction:w #1 \q_stop } + { + \__chemmacros_ox_sign:n { #1 } + \__chemmacros_ox_value:n { #1 } + } + } + { #1 } + } + +\DeclareInstance { xfrac } { chemmacros-ox-frac } { text } + { + scale-factor = 1.2 , + denominator-bot-sep = -.5ex , + numerator-top-sep = -.3ex , + slash-left-kern = -.2em , + slash-right-kern = -.2em , + slash-symbol-font = lmr + } + +\cs_new_protected:Npn \__chemmacros_ox_fraction:w #1/#2 \q_stop + { + \bool_set_false:N \l__chemmacros_ox_format_roman_bool + \__chemmacros_ox_sign:n { #1 } + \bool_if:NTF \l__chemmacros_ox_side_bool + { \sfrac { \__chemmacros_ox_value:n { #1 } } { #2 } } + { + \sfrac [ chemmacros-ox-frac ] + { \__chemmacros_ox_value:n { #1 } } + { #2 } + } + } + +\cs_new_protected:Npn \__chemmacros_ox_sign:n #1 + { + \fp_compare:nNnT { #1 } > { 0 } + { + \bool_if:NT \l__chemmacros_ox_explicit_sign_bool + { \c_math_toggle_token + \c_math_toggle_token } + } + \fp_compare:nNnT { #1 } = { 0 } + { + \bool_if:NT \l__chemmacros_ox_explicit_sign_bool + { \c_math_toggle_token \pm \c_math_toggle_token } + } + \fp_compare:nNnT { #1 } < { 0 } + { \c_math_toggle_token - \c_math_toggle_token } + } + +\cs_new_protected:Npn \__chemmacros_ox_value:n #1 + { + \fp_set:Nn \l__chemmacros_ox_number_fp { abs(#1) } + \__chemmacros_ox_is_integer:V \l__chemmacros_ox_number_fp + \bool_if:NTF \l__chemmacros_ox_format_roman_bool + { \__chemmacros_fp_to_Roman:V \l__chemmacros_ox_number_fp } + { + \bool_if:NTF \l__chemmacros_ox_integer_bool + { + \c_math_toggle_token + \__chemmacros_fp_to_arabic:V \l__chemmacros_ox_number_fp + \c_math_toggle_token + } + { + \c_math_toggle_token + \__chemmacros_fp_show:V \l__chemmacros_ox_number_fp + \c_math_toggle_token + } + } + } + +\cs_new_protected:Npn \__chemmacros_ox_is_integer:n #1 + { + \fp_set:Nn \l__chemmacros_tmpa_fp { round(#1 + 1 , 0 ) - 1 } + \fp_compare:nNnTF { \l__chemmacros_tmpa_fp } = { #1 } + { \bool_set_true:N \l__chemmacros_ox_integer_bool } + { + \bool_set_false:N \l__chemmacros_ox_integer_bool + \bool_set_false:N \l__chemmacros_ox_format_roman_bool + } + } +\cs_generate_variant:Nn \__chemmacros_ox_is_integer:n { V } + +\cs_new_protected:Npn \__chemmacros_fp_to_Roman:n #1 + { + \group_begin: + \fp_set:Nn \l__chemmacros_tmpa_fp { round(#1 , 0 ) } + \int_set:Nn \l__chemmacros_tmpa_int + { \fp_to_tl:N \l__chemmacros_tmpa_fp } + \int_compare:nTF { \l__chemmacros_tmpa_int = 0 } + { 0 } + { \int_to_Roman:n { \l__chemmacros_tmpa_int } } + \group_end: + } +\cs_generate_variant:Nn \__chemmacros_fp_to_Roman:n { V } + +\cs_new_protected:Npn \__chemmacros_fp_to_arabic:n #1 + { + \group_begin: + \fp_set:Nn \l__chemmacros_tmpa_tl { #1 } + \fp_to_tl:N \l__chemmacros_tmpa_tl + \group_end: + } +\cs_generate_variant:Nn \__chemmacros_fp_to_arabic:n { V } + +\cs_new_protected:Npn \__chemmacros_fp_show:n #1 + { + \group_begin: + \fp_set:Nn \l__chemmacros_tmpa_tl { #1 } + \bool_if:NTF \l__chemmacros_ox_decimal_marker_comma_bool + { + \tl_set:Nx \l__chemmacros_tmpb_tl + { \fp_to_tl:N \l__chemmacros_tmpa_tl } + \tl_replace_once:Nnn \l__chemmacros_tmpb_tl { . } { {,} } + \tl_use:N \l__chemmacros_tmpb_tl + } + { \fp_to_tl:N \l__chemmacros_tmpa_tl } + \group_end: + } +\cs_generate_variant:Nn \__chemmacros_fp_show:n { V } + +\cs_new_protected:Npn \__chemmacros_ox_write:nn #1#2 + { + \tl_if_blank:nT { #1 } + { \msg_error:nnx { chemmacros } { ox } { oxidation~number~missing } } + \tl_if_blank:nT { #2 } + { \msg_error:nnx { chemmacros } { ox } { atom~missing } } + \ensuremath + { + \bool_if:NT \l__chemmacros_ox_super_bool + { + \chemmacros_text:n + { + #2 + \c_math_toggle_token + \c_math_superscript_token + { \text { \tiny \__chemmacros_ox_process_number:n { #1 } } } + \c_math_toggle_token + } + } + \bool_if:NT \l__chemmacros_ox_side_bool + { + \chemmacros_text:n + { #2 ( \text { \__chemmacros_ox_process_number:n { #1 } } ) } + } + \bool_if:NT \l__chemmacros_ox_top_bool + { + \overset + { + \bool_if:NTF \l__chemmacros_ox_align_center_bool + { \clap } { \rlap } + { + \chemmacros_text:n + { \tiny \__chemmacros_ox_process_number:n { #1 } } + } + } + { \chemmacros_text:n { #2 } } + } + } + } + +\cs_new_protected:Npn \__chemmacros_ox_pos_top: + { + \bool_set_true:N \l__chemmacros_ox_top_bool + \bool_set_false:N \l__chemmacros_ox_super_bool + \bool_set_false:N \l__chemmacros_ox_side_bool + } + +\cs_new_protected:Npn \__chemmacros_ox_pos_super: + { + \bool_set_false:N \l__chemmacros_ox_top_bool + \bool_set_true:N \l__chemmacros_ox_super_bool + \bool_set_false:N \l__chemmacros_ox_side_bool + } + +\cs_new_protected:Npn \__chemmacros_ox_pos_side: + { + \bool_set_false:N \l__chemmacros_ox_top_bool + \bool_set_false:N \l__chemmacros_ox_super_bool + \bool_set_true:N \l__chemmacros_ox_side_bool + } + +\keys_define:nn { chemmacros / ox } + { + pos .choice: , + pos / top .code:n = \__chemmacros_ox_pos_top: , + pos / super .code:n = \__chemmacros_ox_pos_super: , + pos / side .code:n = \__chemmacros_ox_pos_side: , + roman .bool_set:N = \l__chemmacros_ox_format_roman_bool , + roman .default:n = true , + parse .bool_set:N = \l__chemmacros_ox_parse_bool , + parse .default:n = true , + explicit-sign .bool_set:N = \l__chemmacros_ox_explicit_sign_bool , + explicit-sign .default:n = true , + decimal-marker .choice: , + decimal-marker / comma .code:n = + { \bool_set_true:N \l__chemmacros_ox_decimal_marker_comma_bool } , + decimal-marker / point .code:n = + { \bool_set_false:N \l__chemmacros_ox_decimal_marker_comma_bool } , + align .choice: , + align / center .code:n = \bool_set_true:N \l__chemmacros_ox_align_center_bool , + align / right .code:n = \bool_set_false:N \l__chemmacros_ox_align_center_bool + } + +% \ox[<keyval>]{<num>,<atom>} +% \ox*[<keyval>]{<num>,<atom>} => always number on the side +\cs_new_protected:Npn \chemmacros_ox:nnnn #1#2#3#4 + { + \group_begin: + \tl_if_blank:nF { #1 } { \__chemmacros_ox_pos_super: } + \keys_set:nn { chemmacros / ox } { #2 } + \__chemmacros_ox_write:nn { #3 } { #4 } + \group_end: + } + +\NewDocumentCommand \ox { s o > { \SplitArgument { 1 } { , } } m } + { + \IfBooleanTF { #1 } + { + \IfNoValueTF { #2 } + { \chemmacros_ox:nnnn { #1 } { } #3 } + { \chemmacros_ox:nnnn { #1 } { #2 } #3 } + } + { + \IfNoValueTF { #2 } + { \chemmacros_ox:nnnn { } { } #3 } + { \chemmacros_ox:nnnn { } { #2 } #3 } + } + } + +% --------------------------------------------------------------------------- % +% - oxidation arrows +\tl_new:N \l__chemmacros_redox_begin_tl +\tl_new:N \l__chemmacros_redox_end_tl +\tl_new:N \l__chemmacros_redox_tikz_tl +\tl_new:N \l__chemmacros_redox_shift_tl +\tl_new:N \l__chemmacros_redox_anchor_tl +\tl_new:N \l__chemmacros_redox_side_tl + +\fp_new:N \l__chemmacros_redox_shift_fp + +\dim_new:N \l__chemmacros_redox_sep_dim +\dim_new:N \l__chemmacros_redox_sep_default_dim +\dim_set:Nn \l__chemmacros_redox_sep_default_dim { .2em } +\dim_new:N \l__chemmacros_redox_dist_dim +\dim_set:Nn \l__chemmacros_redox_dist_dim {.6em} + +% place and name nodes: +% \OX{<name>,<atom>} +\NewDocumentCommand \OX { > { \SplitArgument { 1 } { , } } m } + { \chemmacros_redox_partner:nn #1 } + +\cs_new_protected:Npn \chemmacros_redox_partner:nn #1#2 + { + \chemformula_latex_if:nTF { measuring@ } + { + \group_begin: + \tikz[baseline=(#1.base)] + { \node [inner~sep=0pt] (#1) { #2 } ; } + \group_end: + } + { + \tl_if_blank:nT { #1 } + { \msg_error:nnx { chemmacros } { OX } { node~name~missing } } + \tl_if_blank:nT { #2 } + { \msg_error:nnx { chemmacros } { OX } { atom~missing } } + \tikz[baseline=(#1.base),remember~picture] + { \node [inner~sep=0pt] (#1) { #2 } ; } + } + } + +\cs_new_protected:Npn \__chemmacros_redox_coordinates:nn #1#2 + { + \tl_set:Nn \l__chemmacros_redox_begin_tl { #1 } + \tl_set:Nn \l__chemmacros_redox_end_tl { #2 } + } + +\cs_new_protected:Npn \chemmacros_redox:nnnnn #1#2#3#4#5 + { + \tl_clear:N \l__chemmacros_redox_begin_tl + \tl_clear:N \l__chemmacros_redox_end_tl + \tl_clear:N \l__chemmacros_redox_tikz_tl + \__chemmacros_redox_coordinates:nn { #1 } { #2 } + \tl_if_blank:nF { #3 } + { \tl_set:Nn \l__chemmacros_redox_tikz_tl { #3 } } + \tl_if_blank:nTF { #4 } + { + \fp_set:Nn \l__chemmacros_redox_shift_fp { 1 } + \tl_set:Nn \l__chemmacros_redox_anchor_tl { above } + \tl_set:Nn \l__chemmacros_redox_side_tl { north } + \dim_set_eq:NN + \l__chemmacros_redox_sep_dim + \l__chemmacros_redox_sep_default_dim + } + { + \fp_compare:nNnTF { #4 } < { 0 } + { + \tl_set:Nn \l__chemmacros_redox_anchor_tl { below } + \tl_set:Nn \l__chemmacros_redox_side_tl { south } + \exp_args:NNo \dim_set:Nn \l__chemmacros_redox_sep_dim + { - \l__chemmacros_redox_sep_default_dim } + } + { + \tl_set:Nn \l__chemmacros_redox_anchor_tl { above } + \tl_set:Nn \l__chemmacros_redox_side_tl { north } + \dim_set_eq:NN + \l__chemmacros_redox_sep_dim + \l__chemmacros_redox_sep_default_dim + } + \fp_set:Nn \l__chemmacros_redox_shift_fp { #4 } + } + \tl_set:Nn \l__chemmacros_redox_shift_tl + { \fp_to_tl:N \l__chemmacros_redox_shift_fp } + \tikz[remember~picture,overlay] + { + \chemmacros_tikz_draw:f { \tl_use:N \l__chemmacros_redox_tikz_tl } + ($ + (\l__chemmacros_redox_begin_tl . + \l__chemmacros_redox_side_tl)+(0,\l__chemmacros_redox_sep_dim) + $) + -- + ++(0,\l__chemmacros_redox_shift_tl * \l__chemmacros_redox_dist_dim) -| + node [pos=.25,\l__chemmacros_redox_anchor_tl] { { #5 } } + ($ + (\l__chemmacros_redox_end_tl . + \l__chemmacros_redox_side_tl)+(0,\l__chemmacros_redox_sep_dim) + $) ; + } + } + +\NewDocumentCommand \redox { > { \SplitArgument { 1 } { , } } r() o o G{} } + { + \IfNoValueT { #1 } + { + \msg_error:nnx { chemmacros } { redox } + { You~need~to~specify~coordinates } + } + \IfNoValueTF { #2 } + { \chemmacros_redox:nnnnn #1 { } { } { #4 } } + { + \IfNoValueTF { #3 } + { \chemmacros_redox:nnnnn #1 { #2 } { } { #4 } } + { \chemmacros_redox:nnnnn #1 { #2 } { #3 } { #4 } } + } + } + +% redox-keys +\keys_define:nn { chemmacros / redox } + { + dist .dim_set:N = \l__chemmacros_redox_dist_dim , + dist .default:n = { .6em } , + sep .dim_set:N = \l__chemmacros_redox_sep_default_dim , + sep .default:n = { .2em } + } + +% --------------------------------------------------------------------------- % +% spectroscopy +\tl_new:N \g__chemmacros_nmr_isotope_tl +\tl_new:N \l__chemmacros_nmr_isotope_default_tl +\tl_set:Nn \l__chemmacros_nmr_isotope_default_tl { 1 } +\tl_new:N \l__chemmacros_nmr_coupling_nuclei_tl +\tl_new:N \l__chemmacros_nmr_coupling_nuclei_pre_tl +\tl_set:Nn \l__chemmacros_nmr_coupling_nuclei_pre_tl { ( } +\tl_new:N \l__chemmacros_nmr_coupling_nuclei_post_tl +\tl_set:Nn \l__chemmacros_nmr_coupling_nuclei_post_tl { ) } +\tl_new:N \l__chemmacros_nmr_coupling_bonds_tl +\tl_new:N \l__chemmacros_nmr_coupling_bonds_pre_tl +\tl_set:Nn \l__chemmacros_nmr_coupling_bonds_pre_tl { } +\tl_set:Nn \l__chemmacros_nmr_coupling_bonds_post_tl { \! } +\tl_new:N \l__chemmacros_nmr_coupling_symbol_tl +\tl_set:Nn \l__chemmacros_nmr_coupling_symbol_tl { J } +\tl_new:N \g__chemmacros_nmr_element_coupled_tl +\tl_new:N \g__chemmacros_nmr_element_tl +\tl_new:N \l__chemmacros_nmr_element_default_tl +\tl_set:Nn \l__chemmacros_nmr_element_default_tl { H } +\tl_new:N \l__chemmacros_nmr_format_tl +\tl_new:N \l__chemmacros_nmr_delta_tl +\tl_new:N \l__chemmacros_nmr_coupling_unit_tl +\tl_set:Nn \l__chemmacros_nmr_coupling_unit_tl { \hertz } +\tl_new:N \l__chemmacros_nmr_unit_tl +\tl_set:Nn \l__chemmacros_nmr_unit_tl { \mega\hertz } +\tl_new:N \l__chemmacros_nmr_list_setup_tl +\tl_set:Nn \l__chemmacros_nmr_list_setup_tl + { + \topsep\z@skip \partopsep\z@skip + \itemsep\z@ \parsep\z@ \itemindent\z@ + \leftmargin\z@ + } +\tl_new:N \l__chemmacros_nmr_position_tl +\tl_new:N \l__chemmacros_nmr_element_method_connector_tl +\tl_set:Nn \l__chemmacros_nmr_element_method_connector_tl {-} +\tl_new:N \l__chemmacros_nmr_method_tl +\tl_set:Nn \l__chemmacros_nmr_method_tl {NMR} + +\bool_new:N \l__chemmacros_nmr_coupling_nuclei_sub_bool +\bool_new:N \l__chemmacros_nmr_frequency_bool +\bool_new:N \l__chemmacros_nmr_solvent_bool +\bool_new:N \l__chemmacros_nmr_delimiters_bool +\bool_new:N \l__chemmacros_nmr_comma_bool +\bool_new:N \l__chemmacros_nmr_inner_bool +\bool_new:N \l__chemmacros_nmr_position_side_bool +\bool_new:N \l__chemmacros_nmr_parse_bool +\bool_set_true:N \l__chemmacros_nmr_parse_bool +\bool_new:N \l__chemmacros_nmr_list_bool +\bool_new:N \l__chemmacros_nmr_use_equal_bool +\bool_new:N \l__chemmacros_nmr_custom_command_active_bool +\bool_new:N \l__chemmacros_nmr_custom_command_used_bool + +\cs_new_protected:Npn \__chemmacros_nmr_nucleus:nn #1#2 + { + \tl_gset:Nn \g__chemmacros_nmr_isotope_tl { #1 } + \tl_if_in:nnTF { #2 } { [ } + { \__chemmacros_nmr_element:w #2 \q_stop } + { + \tl_gset:No \g__chemmacros_nmr_element_tl { #2 } + \tl_gclear:N \g__chemmacros_nmr_element_coupled_tl + } + } +\cs_generate_variant:Nn \__chemmacros_nmr_nucleus:nn { VV } + +\cs_new_protected:Npn \__chemmacros_nmr_nucleus:w #1,#2 \q_stop + { + \tl_gset:Nn \g__chemmacros_nmr_isotope_tl { #1 } + \tl_if_in:nnTF { #2 } { [ } + { \__chemmacros_nmr_element:w #2 \q_stop } + { + \tl_gset:No \g__chemmacros_nmr_element_tl { #2 } + \tl_gclear:N \g__chemmacros_nmr_element_coupled_tl + } + } + +\cs_new_protected:Npn \__chemmacros_nmr_element:w #1[#2] \q_stop + { + \tl_gset:Nn \g__chemmacros_nmr_element_tl { #1 } + \tl_gset:Nn \g__chemmacros_nmr_element_coupled_tl { #2 } + } + +\cs_new_protected:Npn \__chemmacros_nmr_default_nucleus:w #1,#2 \q_stop + { + \tl_set:Nn \l__chemmacros_nmr_isotope_default_tl { #1 } + \tl_set:Nn \l__chemmacros_nmr_element_default_tl { #2 } + } + +\cs_new_protected:Npn \__chemmacros_nmr_base:nn #1#2 + { + \tl_if_blank:VF \g__chemmacros_nmr_element_coupled_tl + { + \tl_put_left:Nn \g__chemmacros_nmr_element_coupled_tl { \{ } + \tl_put_right:Nn \g__chemmacros_nmr_element_coupled_tl { \} } + } + \tl_put_left:Nn \g__chemmacros_nmr_element_coupled_tl { #2 } + \iupac { ^ { #1 } } + \bool_if:NTF \l__chemmacros_nmr_parse_bool + { \chemformula_ch:nV {} \g__chemmacros_nmr_element_coupled_tl } + { \chemmacros_atom:V \g__chemmacros_nmr_element_coupled_tl } + \tl_use:N \l__chemmacros_nmr_element_method_connector_tl + \tl_use:N \l__chemmacros_nmr_method_tl + } +\cs_generate_variant:Nn \__chemmacros_nmr_base:nn { VV } + +\cs_new_protected:Npn \__chemmacros_nmr_frequency:n #1 + { + \tl_if_in:nnTF { #1 } { , } + { \__chemmacros_nmr_frequency_aux_i:w #1 \q_stop } + { \__chemmacros_nmr_frequency_aux_ii:n { #1 } } + } + +\cs_new_protected:Npn \__chemmacros_nmr_frequency_aux_i:w #1,#2 \q_stop + { \SI { #1 } { #2 } } + +\cs_new_protected:Npn \__chemmacros_nmr_frequency_aux_ii:n #1 + { \SI { #1 } { \tl_use:N \l__chemmacros_nmr_unit_tl } } + +\cs_new_eq:NN \__chemmacros_nmr_number:n \use:n +\cs_new_eq:NN \__chemmacros_nmr_position:n \use:n + +\keys_define:nn { chemmacros / nmr } + { + unit .tl_set:N = \l__chemmacros_nmr_unit_tl , + unit .default:n = \mega\hertz , + nucleus .code:n = + { \__chemmacros_nmr_default_nucleus:w #1 \q_stop } , + nucleus .default:n = { 1,H } , + format .tl_set:N = \l__chemmacros_nmr_format_tl , + method .tl_set:N = \l__chemmacros_nmr_method_tl , + connector .tl_set:N = \l__chemmacros_nmr_element_method_connector_tl , + pos-number .choice: , + pos-number / sub .code:n = + \tl_set:Nn \l__chemmacros_nmr_position_tl { _ } + \bool_set_false:N \l__chemmacros_nmr_position_side_bool , + pos-number / super .code:n = + \tl_set:Nn \l__chemmacros_nmr_position_tl { ^ } + \bool_set_false:N \l__chemmacros_nmr_position_side_bool , + pos-number / side .code:n = + \tl_set:Nn \l__chemmacros_nmr_position_tl { - } + \bool_set_true:N \l__chemmacros_nmr_position_side_bool , + coupling-unit .tl_set:N = \l__chemmacros_nmr_coupling_unit_tl , + coupling-pos .choice: , + coupling-pos / sub .code:n = + \bool_set_true:N \l__chemmacros_nmr_coupling_nuclei_sub_bool , + coupling-pos / side .code:n = + \bool_set_false:N \l__chemmacros_nmr_coupling_nuclei_sub_bool , + coupling-nuclei-pre .tl_set:N = + \l__chemmacros_nmr_coupling_nuclei_pre_tl , + coupling-nuclei-post .tl_set:N = + \l__chemmacros_nmr_coupling_nuclei_post_tl , + coupling-bonds-pre .tl_set:N = + \l__chemmacros_nmr_coupling_bonds_pre_tl , + coupling-bonds-post .tl_set:N = + \l__chemmacros_nmr_coupling_bonds_post_tl , + coupling-symbol .tl_set:N = + \l__chemmacros_nmr_coupling_symbol_tl , + atom-number-cs .code:n = + \cs_set_eq:NN \__chemmacros_nmr_number:n #1 , + coupling-pos-cs .code:n = + \cs_set_eq:NN \__chemmacros_nmr_position:n #1 , + parse .bool_set:N = \l__chemmacros_nmr_parse_bool , + delta .code:n = + \tl_set:Nn \l__chemmacros_nmr_delta_tl { \, #1 } , + list .bool_set:N = \l__chemmacros_nmr_list_bool , + list .default:n = true , + list-setup .tl_set:N = \l__chemmacros_nmr_list_setup_tl , + use-equal .bool_set:N = \l__chemmacros_nmr_use_equal_bool , + use-equal .default:n = true + } + +\prop_new:N \l__chemmacros_nmr_prop + +\cs_new_protected:Npn \chemmacros_new_nmr:Nn #1#2 + { + \bool_if:nTF + { + \prop_if_in_p:Nn \l__chemmacros_nmr_prop { #1 } + || + \cs_if_exist_p:N #1 + } + { \msg_error:nnn { chemmacros } { new-nmr } { #1 } } + { + \prop_put:Nnn \l__chemmacros_nmr_prop { #1 } { #2 } + \NewDocumentCommand #1 { s } + { \IfBooleanTF {##1} { \NMR*{#2} } { \NMR{#2} } } + } + } + +\cs_new_protected:Npn \chemmacros_define_nmr:Nn #1#2 + { + \prop_put:Nnn \l__chemmacros_nmr_prop { #1 } { #2 } + \cs_if_exist:NTF #1 + { + \RenewDocumentCommand #1 { s } + { \IfBooleanTF {##1} { \NMR*{#2} } { \NMR{#2} } } + } + { + \NewDocumentCommand #1 { s } + { \IfBooleanTF {##1} { \NMR*{#2} } { \NMR{#2} } } + } + } + +\cs_new_protected:Npn \chemmacros_renew_nmr:Nn #1#2 + { + \bool_if:nTF + { + \prop_if_in_p:Nn \l__chemmacros_nmr_prop { #1 } + && + \cs_if_exist_p:N #1 + } + { + \prop_put:Nnn \l__chemmacros_nmr_prop { #1 } { #2 } + \RenewDocumentCommand #1 { s } + { \IfBooleanTF {##1} { \NMR*{#2} } { \NMR{#2} } } + } + { \msg_error:nnn { chemmacros } { renew-nmr } { #1 } } + } + +\NewDocumentCommand \NewChemNMR { mm } + { \chemmacros_new_nmr:Nn #1 { #2 } } + +\NewDocumentCommand \RenewChemNMR { mm } + { \chemmacros_renew_nmr:Nn #1 { #2 } } + +\NewDocumentCommand \DeclareChemNMR { mm } + { \chemmacros_define_nmr:Nn #1 { #2 } } + +\NewDocumentCommand \NMR { s G{} D(){} O{} } + { + \IfBooleanTF { #1 } + { \chemmacros_nmr:nnnn { * } { #2 } { #3 } { #4 } } + { \chemmacros_nmr:nnnn { } { #2 } { #3 } { #4 } } + } + +\AtBeginDocument + { + % \NMR{<num>,<elem>}(<num>,<unit>)[<solvent>] ALL arguments are optional + % \NMR* same but without ": $\delta$" at end + \cs_new_protected:Npn \chemmacros_nmr:nnnn #1#2#3#4 + { + \bool_if:NT \l__chemmacros_nmr_list_bool { \item \scan_stop: } + \group_begin: + \chemmacros_leave_vmode: + \bool_set_false:N \l__chemmacros_nmr_frequency_bool + \bool_set_false:N \l__chemmacros_nmr_solvent_bool + \tl_if_empty:nF { #3 } + { \bool_set_true:N \l__chemmacros_nmr_frequency_bool } + \tl_if_empty:nF { #4 } + { \bool_set_true:N \l__chemmacros_nmr_solvent_bool } + \bool_if:nT + { + \l__chemmacros_nmr_frequency_bool + || + \l__chemmacros_nmr_solvent_bool + } + { \bool_set_true:N \l__chemmacros_nmr_delimiters_bool } + \bool_if:nT + { + \l__chemmacros_nmr_frequency_bool + && + \l__chemmacros_nmr_solvent_bool + } + { \bool_set_true:N \l__chemmacros_nmr_comma_bool } + \tl_if_empty:nTF { #2 } + { + \__chemmacros_nmr_nucleus:VV + \l__chemmacros_nmr_isotope_default_tl + \l__chemmacros_nmr_element_default_tl + } + { \__chemmacros_nmr_nucleus:w #2 \q_stop } + \mode_if_math:TF + { + \text + { + \group_begin: + \tl_use:N \l__chemmacros_nmr_format_tl + \__chemmacros_nmr_base:VV + \g__chemmacros_nmr_isotope_tl + \g__chemmacros_nmr_element_tl + \bool_if:NT \l__chemmacros_nmr_delimiters_bool + { ~ ( } + \bool_if:NT \l__chemmacros_nmr_frequency_bool + { \__chemmacros_nmr_frequency:n { #3 } } + \bool_if:NT \l__chemmacros_nmr_comma_bool + { , ~ } + \bool_if:NT \l__chemmacros_nmr_solvent_bool + { \chemmacros_atom:n { #4 } } + \bool_if:NT \l__chemmacros_nmr_delimiters_bool + { ) } + \tl_if_blank:nT { #1 } { : ~ } + \group_end: + } + \tl_if_blank:nT { #1 } + { + \delta + \text { \l__chemmacros_nmr_delta_tl } + \bool_if:NT \l__chemmacros_nmr_use_equal_bool { = } + } + } + { + \group_begin: + \tl_use:N \l__chemmacros_nmr_format_tl + \__chemmacros_nmr_base:VV + \g__chemmacros_nmr_isotope_tl + \g__chemmacros_nmr_element_tl + \bool_if:NT \l__chemmacros_nmr_delimiters_bool + { ~ ( } + \bool_if:NT \l__chemmacros_nmr_frequency_bool + { \__chemmacros_nmr_frequency:n { #3 } } + \bool_if:NT \l__chemmacros_nmr_comma_bool + { , ~ } + \bool_if:NT \l__chemmacros_nmr_solvent_bool + { + \bool_if:NTF \l__chemmacros_nmr_parse_bool + { \chemformula_ch:nn { } { #4 } } + { #4 } + } + \bool_if:NT \l__chemmacros_nmr_delimiters_bool + { ) } + \tl_if_blank:nT { #1 } { : } + \group_end: + \tl_if_blank:nT { #1 } + { + \tl_use:N \c_space_tl + \c_math_toggle_token + \delta + \c_math_toggle_token + \l__chemmacros_nmr_delta_tl + \bool_if:NT \l__chemmacros_nmr_use_equal_bool { ~ = } + } + \bool_if:NF \l__chemmacros_nmr_comma_bool + { \tl_if_blank:nT { #1 } { \chemmacros_xspace: } } + } + \group_end: + } + } + +\NewDocumentCommand \chemmacros_data:w { smo } + { + \bool_if:NT \l__chemmacros_nmr_list_bool { \item } + { + \tl_use:N \l__chemmacros_nmr_format_tl #2 + \IfNoValueF { #3 } { ~ ( #3 ) } + \IfBooleanT { #1 } { \bool_if:NT \l__chemmacros_nmr_use_equal_bool { : } } + } + \IfBooleanF { #1 } { \bool_if:NT \l__chemmacros_nmr_use_equal_bool { ~ = } } + } + +\cs_new_protected:Npn \chemmacros_val:n #1 + { + \tl_if_in:nnTF { #1 } { -- } + { \chemmacros_val_aux:w #1 \q_nil } + { \num { #1 } } + } + +\cs_new_protected:Npn \chemmacros_val_aux:w #1--#2 \q_nil + { \numrange { #1 } { #2 } } + +\NewDocumentEnvironment { experimental } { o } + { + \group_begin: + \IfNoValueF { #1 } { \keys_set:nn { chemmacros / nmr } { #1 } } + \bool_set_true:N \l__chemmacros_nmr_inner_bool + \cs_set_eq:NN \# \chemmacros_nmr_number:n + \cs_set_eq:NN \pos \chemmacros_nmr_position:n + \cs_set_eq:NN \J \chemmacros_nmr_coupling:w + \cs_set_eq:NN \data \chemmacros_data:w + \cs_set_eq:NN \val \chemmacros_val:n + \bool_if:NT \l__chemmacros_nmr_list_bool + { \list {} { \l__chemmacros_nmr_list_setup_tl } } + } + { + \bool_if:NT \l__chemmacros_nmr_list_bool + { \endlist } + \group_end: + \chemmacros_ignore_spaces: + } + +\cs_new_protected:Npn \chemmacros_nmr_number:n #1 + { + \__chemmacros_nmr_number:n { #1 } \, + \chemmacros_atom:V \g__chemmacros_nmr_element_tl + } + +\cs_new_protected:Npn \chemmacros_nmr_position:n #1 + { + \chemmacros_chemformula:x + { + \exp_not:V \g__chemmacros_nmr_element_tl + \bool_if:NF \l__chemmacros_nmr_position_side_bool + { + \exp_not:V \l__chemmacros_nmr_position_tl + \exp_not:n { {#1} } + } + } + \bool_if:NT \l__chemmacros_nmr_position_side_bool + { + \tl_use:N \l__chemmacros_nmr_position_tl + \__chemmacros_nmr_position:n { #1 } + } + } + +\cs_new_protected:Npn \chemmacros_nmr_coupling:w + { + \tl_clear:N \l__chemmacros_nmr_coupling_nuclei_tl + \tl_clear:N \l__chemmacros_nmr_coupling_bonds_tl + \peek_meaning:NTF ( + { \__chemmacros_nmr_coupling:w } + { \__chemmacros_nmr_coupling_aux_i:w } + } + +\cs_new_protected:Npn \__chemmacros_nmr_coupling:w (#1;#2) + { + \tl_set:Nn \l__chemmacros_nmr_coupling_bonds_tl + { + \l__chemmacros_nmr_coupling_bonds_pre_tl + #1 + \l__chemmacros_nmr_coupling_bonds_post_tl + } + \bool_if:NTF \l__chemmacros_nmr_coupling_nuclei_sub_bool + { + \tl_set:Nn \l__chemmacros_nmr_coupling_nuclei_tl + { + \c_math_subscript_token + { \chemmacros_chemformula:n {#2} } + } + } + { + \tl_set:Nn \l__chemmacros_nmr_coupling_nuclei_tl + { + \l__chemmacros_nmr_coupling_nuclei_pre_tl + \chemmacros_chemformula:n {#2} + \l__chemmacros_nmr_coupling_nuclei_post_tl + } + } + \__chemmacros_nmr_coupling_aux_i:w + } + +\cs_new_protected:Npn \__chemmacros_nmr_coupling_aux_i:w + { + \peek_meaning:NTF [ + { \__chemmacros_nmr_coupling_aux_ii:w } + { \__chemmacros_nmr_coupling_aux_iii:n } + } + +\cs_new_protected:Npn \__chemmacros_nmr_coupling_aux_ii:w [#1]#2 + { + \group_begin: + \sisetup + { + list-final-separator={,~}, + list-pair-separator={,~}, + list-units=single + } + \c_math_toggle_token + ^{ \l__chemmacros_nmr_coupling_bonds_tl } + \l__chemmacros_nmr_coupling_symbol_tl + \l__chemmacros_nmr_coupling_nuclei_tl = \SIlist{#2}{#1} + \c_math_toggle_token + \group_end: + } + +\cs_new_protected:Npn \__chemmacros_nmr_coupling_aux_iii:n #1 + { + \group_begin: + \sisetup + { + list-final-separator={,~}, + list-pair-separator={,~}, + list-units=single + } + \c_math_toggle_token + ^{ \l__chemmacros_nmr_coupling_bonds_tl } + \l__chemmacros_nmr_coupling_symbol_tl + \l__chemmacros_nmr_coupling_nuclei_tl + = \exp_args:Nno \SIlist { #1 } { \l__chemmacros_nmr_coupling_unit_tl } + \c_math_toggle_token + \group_end: + } + +% -------------------------------------------------------------------------- +% deprecated mhName: +\keys_define:nn { chemmacros } + { mhName .code:n = \chemmacros_option_deprecated:n { mhName } } + +% --------------------------------------------------------------------------- % +% - phases +\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 } +\prop_new:N \l__chemmacros_phases_prop +\prop_new:N \l__chemmacros_phases_german_prop + +\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 + } + +\cs_new_protected:Npn \chemmacros_new_phase:Nn #1#2 + { + \tl_set:Nx \l__chemmacros_tmpa_tl + { \chemmacros_remove_backslash:N #1 } + \cs_if_free:NF #1 + { \msg_error:nnn {chemmacros} {new-phase} {#1} } + \exp_args:Nx \@trnslt@declare@translation + { phase-\l__chemmacros_tmpa_tl } {fallback} {#2} + \__chemmacros_define_phase:Nx #1 + { + \exp_not:N \chemmacros_translate:n + { phase-\l__chemmacros_tmpa_tl } + } + } + +\cs_new_protected:Npn \chemmacros_define_phase:Nn #1#2 + { + \tl_set:Nx \l__chemmacros_tmpa_tl + { \chemmacros_remove_backslash:N #1 } + \exp_args:Nx \@trnslt@declare@translation + { phase-\l__chemmacros_tmpa_tl } {fallback} {#2} + \__chemmacros_define_phase:Nx #1 + { + \exp_not:N \chemmacros_translate:n + { phase-\l__chemmacros_tmpa_tl } + } + } + +\cs_new_protected:Npn \chemmacros_renew_phase:Nn #1#2 + { + \tl_set:Nx \l__chemmacros_tmpa_tl + { \chemmacros_remove_backslash:N #1 } + \cs_if_exist:NF #1 + { \msg_error:nnn {chemmacros} {renew-phase} {#1} } + \exp_args:Nx \@trnslt@declare@translation + { phase-\l__chemmacros_tmpa_tl } {fallback} {#2} + \__chemmacros_define_phase:Nx #1 + { + \exp_not:N \chemmacros_translate:n + { phase-\l__chemmacros_tmpa_tl } + } + } + +\NewDocumentCommand \NewChemPhase { mom } + { \chemmacros_new_phase:Nn #1 {#3} } + +\NewDocumentCommand \DeclareChemPhase { mom } + { \chemmacros_define_phase:Nn #1 {#3} } + +\NewDocumentCommand \RenewChemPhase { mom } + { \chemmacros_renew_phase:Nn #1 {#3} } + +\cs_new_protected:Npn \__chemmacros_define_phase:Nn #1#2 + { + \cs_if_exist:NF #1 { \cs_new:Npn #1 {} } + \DeclareDocumentCommand #1 { o } + { + \bool_if:NTF \l__chemmacros_phases_sub_bool + { + \bool_if:NTF \l_chemformula_inside_ch_bool + { \chemformula_subscript:n { ( #2 \IfNoValueF {##1} {,~##1} ) } } + { + \ensuremath + { + \c_math_subscript_token + { \text { ( #2 \IfNoValueF {##1} {,~##1} ) } } + } + } + } + { + \ensuremath + { + \skip_horizontal:N \l__chemmacros_phases_space_dim + \text { ( #2 \IfNoValueF {##1} {,~##1} ) } + } + } + } + } +\cs_generate_variant:Nn \__chemmacros_define_phase:Nn { Nx } + +\NewChemPhase \sld {s} +\NewChemPhase \lqd {l} +\NewChemPhase \gas {g} +\NewChemPhase \aq {aq} + +\cs_new_protected:Npn \chemmacros_phase:n #1 + { + \bool_if:NTF \l__chemmacros_phases_sub_bool + { \ensuremath { \c_math_subscript_token { \text { (#1) } } } } + { + \ensuremath + { + \skip_horizontal:N \l__chemmacros_phases_space_dim + \text { (#1) } + } + } + } + +\NewDocumentCommand \phase { m } + { \chemmacros_phase:n {#1} } + +% -------------------------------------------------------------------------- +% reaction environments +\cs_new_protected:Npn \__chemmacros_record_for_lor:nnnnn #1#2#3#4#5 + { + \tl_if_eq:nnT { #1 } { reaction } + { + \group_begin: + % we need to prevent \Hy@make@anchor from being written to the lor + % file: + \bool_if:NT \l__chemmacros_hyperref_bool + { \cs_set:Npn \Hy@make@anchor {} } + \addcontentsline { lor } { reaction } + { + \tl_use:N \l__chemmacros_reaction_lorname_tl + \tl_use:N \c_space_tl + #2 #3 #4 #5 + \tl_use:N \g__chemmacros_reaction_description_tl + } + \tl_gclear:N \g__chemmacros_reaction_description_tl + \group_end: + } + } + +% redefine mathtools' command \MT_define_tagform:nwnn to ensure we add an +% entry to the list of reactions even if the user redefines the reaction tag +% this should probably be done via patching... +\AfterPackage* { mathtools } + { + \cs_set_protected:Npn \MT_define_tagform:nwnn #1[#2]#3#4 + { + \@namedef{MT_tagform_#1:n}##1 + { + % this is the original part: + \maketag@@@{#3\ignorespaces#2{##1}\unskip\@@italiccorr#4} + % this is added => this disturbs hyperref: + \__chemmacros_record_for_lor:nnnnn + { #1 } { #3 } { #2 } { ##1 } { #4 } + } + } + } + +\tl_new:N \g__chemmacros_reaction_description_tl + +\cs_new_protected:Npn \chemmacros_add_reaction_description:n #1 + { + \tl_if_blank:nF { #1 } + { \tl_gset:Nn \g__chemmacros_reaction_description_tl { : ~ #1 } } + } + +\NewDocumentCommand \AddRxnDesc { m } + { \chemmacros_add_reaction_description:n { #1 } } + +% define \listofreactions +\tl_new:N \l__chemmacros_reaction_lorname_tl +\tl_new:N \reactionlistname +\tl_new:N \l__chemmacros_reaction_heading_tl + +\cs_new:Npn \__chemmacros_reaction_heading:n #1 + { \l__chemmacros_reaction_heading_tl { #1 } } +\cs_generate_variant:Nn \__chemmacros_reaction_heading:n { V } + +\cs_new_protected:Npn \listofreactions + { + \__chemmacros_reaction_heading:V \reactionlistname + \@starttoc { lor } + } + +\cs_new_protected:Npn \l@reaction #1#2 + { \@dottedtocline { 1 } { 1.5em } { 2.3em } { #1 } { #2 } } + +% create tagform +\newtagform { reaction } { \{ } { \} } +\newcounter { chemmacros_save_reaction } +\newcounter { reaction } + +% switch to reaction tags +\cs_new_protected:Npn \__chemmacros_begin_reaction: + { + % create individual names for `hyperref': + \bool_if:NT \l__chemmacros_hyperref_bool + { + \cs_set:Npn \theHequation + { R . \theHsection . \arabic { reaction } } + } + % enable labelformat `reaction': + \bool_if:NT \l__chemmacros_varioref_bool + { \cs_set_eq:NN \p@equation \p@reaction } + \setcounter { chemmacros_save_reaction } { \value { equation } } + \setcounter { equation } { \value { reaction } } + \usetagform { reaction } + } + +% switch back to equation tags +\cs_new_protected:Npn \__chemmacros_end_reaction: + { + \setcounter { reaction } { \value { equation } } + \setcounter { equation } { \value { chemmacros_save_reaction } } + } + +% --------------------------------------------------------------------------- % +\bool_new:N \l__chemmacros_reactions_star_bool +\bool_new:N \l__chemmacros_reactions_args_bool + +\keys_define:nn { chemmacros / reaction } + { + star .bool_set:N = \l__chemmacros_reactions_star_bool , + star .default:n = true , + arg .bool_set:N = \l__chemmacros_reactions_args_bool , + arg .default:n = true , + list-name .tl_set:N = \reactionlistname , + list-entry .code:n = + \tl_set:Nn \l__chemmacros_reaction_lorname_tl { #1 } , + list-heading .tl_set:N = \l__chemmacros_reaction_heading_tl + } + +% \DeclareChemReaction[<keyval>]{<name>}{<type>} +\cs_new_protected:Npn \__chemmacros_define_reaction:Nnnn #1#2#3#4 + { + \bool_set_false:N \l__chemmacros_reactions_star_bool + \bool_set_false:N \l__chemmacros_reactions_args_bool + \keys_set:nn { chemmacros / reaction } { #2 } + \bool_if:NTF \l__chemmacros_reactions_args_bool + { + #1 { #3 } [ 2 ] [] + { + \__chemmacros_begin_reaction: + \AddRxnDesc { ##1 } + \begin { #4 } { ##2 } + \chemmacros_equation_chemformula:V \BODY + \end{ #4 } + \__chemmacros_end_reaction: + } + \bool_if:NT \l__chemmacros_reactions_star_bool + { + #1 { #3* } [ 1 ] + { + \begin { #4* } { ##1 } + \chemmacros_equation_chemformula:V \BODY + \end { #4* } + } + } + } + { + #1 { #3 } [ 1 ] [] + { + \__chemmacros_begin_reaction: + \AddRxnDesc { ##1 } + \begin { #4 } + \chemmacros_equation_chemformula:V \BODY + \end { #4 } + \__chemmacros_end_reaction: + } + \bool_if:NT \l__chemmacros_reactions_star_bool + { + #1 { #3* } + { + \begin { #4* } + \chemmacros_equation_chemformula:V \BODY + \end { #4* } + } + } + } + \ignorespaces + } + +\cs_new_protected:Npn \chemmacros_define_reaction:nnn #1#2#3 + { + \cs_if_exist:cTF { #2 } + { \__chemmacros_define_reaction:Nnnn \RenewEnviron { #1 } { #2 } { #3 } } + { \__chemmacros_define_reaction:Nnnn \NewEnviron { #1 } { #2 } { #3 } } + } + +\cs_new_protected:Npn \chemmacros_new_reaction:nnn #1#2#3 + { + \cs_if_exist:cTF { #2 } + { \msg_error:nnx { chemmacros } { already-defined } { #2 } } + { \__chemmacros_define_reaction:Nnnn \NewEnviron { #1 } { #2 } { #3 } } + } + +\cs_new_protected:Npn \chemmacros_renew_reaction:nnn #1#2#3 + { + \cs_if_exist:cTF { #2 } + { \__chemmacros_define_reaction:Nnnn \RenewEnviron { #1 } { #2 } { #3 } } + { \msg_error:nnx { chemmacros } { not-defined } { #2 } } + } + +\NewDocumentCommand \NewChemReaction { O{} m m } + { \chemmacros_new_reaction:nnn { #1 } { #2 } { #3 } } +\NewDocumentCommand \RenewChemReaction { O{} m m } + { \chemmacros_renew_reaction:nnn { #1 } { #2 } { #3 } } +\NewDocumentCommand \DeclareChemReaction { O{} m m } + { \chemmacros_declare_reaction:nnn { #1 } { #2 } { #3 } } +\DeclareChemDeprecated \newreaction \NewChemReaction + +\cs_new_protected:Npn \chemmacros_equation_chemformula:n #1 + { \chemformula_ch:nn { } { #1 } } +\cs_generate_variant:Nn \chemmacros_equation_chemformula:n { V } + +% predefined: +\NewChemReaction [ star ] { reaction } { equation } +\NewChemReaction [ star ] { reactions } { align } + +% -------------------------------------------------------------------------- +% thermodynamics et.al. +% \standardstate as defined by the chemstyle package. Thanks to Joseph Wright +% the `chemstyle' provides it with \providecommand so it doesn't matter which +% package defines it first +\ProvideDocumentCommand \standardstate {} + { { \ensuremath { \chemmacros_standardstate: } } } + +\cs_new_protected:Npn \chemmacros_standardstate: + { \mathpalette \chemmacros_standardstate_aux: \circ } + +\cs_new_protected:Npn \chemmacros_standardstate_aux: #1#2 + { + \ooalign + { + \tex_hfil:D + \c_math_toggle_token #1- \c_math_toggle_token + \tex_hfil:D + \tex_cr:D + \tex_hfil:D + \c_math_toggle_token #1#2 \c_math_toggle_token + \tex_hfil:D + \tex_cr:D + } + } + +\cs_new_protected:Npn \changestate + { \mathop{} \! \chemDelta } + +% -------------------------------------------------------------------------- +% \State +\tl_new:N \l__chemmacros_State_delta_tl +\tl_set:Nn \l__chemmacros_State_delta_tl { \changestate } +\tl_new:N \l__chemmacros_State_exponent_tl +\tl_set:Nn \l__chemmacros_State_exponent_tl { \standardstate } + +\bool_new:N \l__chemmacros_State_delta_bool +\bool_set_true:N \l__chemmacros_State_delta_bool +\bool_new:N \l__chemmacros_State_subscript_left_bool +\bool_set_true:N \l__chemmacros_State_subscript_left_bool +\bool_new:N \l__chemmacros_State_exponent_bool +\bool_set_true:N \l__chemmacros_State_exponent_bool + +\keys_define:nn { chemmacros / state } + { + delta .code:n = + { + \exp_args:Nf \tl_if_eq:nnTF { #1 } { false } + { \bool_set_false:N \l__chemmacros_State_delta_bool } + { + \bool_set_true:N \l__chemmacros_State_delta_bool + \tl_set:Nn \l__chemmacros_State_delta_tl { #1 } + } + } , + subscript-left .bool_set:N = \l__chemmacros_State_subscript_left_bool , + subscript-left .default:n = true , + exponent .code:n = + { + \exp_args:Nf \tl_if_eq:nnTF { #1 } { false } + { \bool_set_false:N \l__chemmacros_State_exponent_bool } + { + \bool_set_true:N \l__chemmacros_State_exponent_bool + \tl_set:Nn \l__chemmacros_State_exponent_tl { #1 } + } + } , + exponent .default:n = \standardstate + } + +% old syntax (v1.1): +% \State[<exp>,<Delta>,<subscript pos>]{<Symbol>}{<subscript>} +% old syntax (v2.0): +% \State[<keyval>]{<Symbol>}{<subscript>} +% {<subscript>} is an optional argument! +\cs_new_protected:Npn \chemmacros_state:nnn #1#2#3 + { + \group_begin: + \keys_set:nn { chemmacros / state } { #1 } + \ensuremath + { + \bool_if:NT \l__chemmacros_State_delta_bool + { \tl_use:N \l__chemmacros_State_delta_tl } + \bool_if:NT \l__chemmacros_State_subscript_left_bool + { \c_math_subscript_token { \text { #3 } } } + #2 + \bool_if:NF \l__chemmacros_State_subscript_left_bool + { \c_math_subscript_token { \text { #3 } } } + \bool_if:NT \l__chemmacros_State_exponent_bool + { ^ { \tl_use:N \l__chemmacros_State_exponent_tl } } + } + \group_end: + } +\cs_generate_variant:Nn \chemmacros_state:nnn { xnV } + +\NewDocumentCommand \State { s O{} m G{} } + { + \group_begin: + \IfBooleanT { #1 } + { + \keys_set:nn { chemmacros / state } + { subscript-left = false , exponent = } + } + \chemmacros_state:nnn { #2 } { #3 } { #4 } + \group_end: + } + +% -------------------------------------------------------------------------- +\tl_new:N \l__chemmacros_thermod_subscript_left_tl +\tl_new:N \l__chemmacros_thermod_subscript_left_default_tl +\tl_new:N \l__chemmacros_thermod_subscript_tl +\tl_new:N \l__chemmacros_thermod_subscript_default_tl +\tl_new:N \l__chemmacros_thermod_unit_tl +\tl_new:N \l__chemmacros_thermod_exponent_tl +\tl_new:N \l__chemmacros_thermod_exponent_default_tl +\tl_set:Nn \l__chemmacros_thermod_exponent_default_tl { \standardstate } +\tl_new:N \l__chemmacros_thermod_delta_tl +\tl_new:N \l__chemmacros_thermod_delta_default_tl +\tl_set:Nn \l__chemmacros_thermod_delta_default_tl { \changestate } + +\bool_new:N \l__chemmacros_renewstate_bool +\bool_new:N \l__chemmacros_state_overwrite_error_bool + +\keys_define:nn { chemmacros } + { + State / subscript .choice: , + State / subscript / left .code:n = + { \tl_set:Nn \l__chemmacros_thermod_subscript_left_tl { true } } , + State / subscript / right .code:n = + { \tl_set:Nn \l__chemmacros_thermod_subscript_left_tl { false } } , + State / exponent .tl_set:N = + \l__chemmacros_thermod_exponent_tl , + State / delta .tl_set:N = + \l__chemmacros_thermod_delta_tl , + State / unit .tl_set:N = + \l__chemmacros_thermod_unit_tl , + setnewstate / subscript-left .tl_set:N = + \l__chemmacros_thermod_subscript_left_default_tl , + setnewstate / subscript .tl_set:N = + \l__chemmacros_thermod_subscript_default_tl , + setnewstate / exponent .tl_set:N = + \l__chemmacros_thermod_exponent_default_tl , + setnewstate / delta .tl_set:N = + \l__chemmacros_thermod_delta_default_tl + } + +% \NewChemState{<name>}[<keyval>]{<symbol>}{<unit>} +\NewDocumentCommand \NewChemState { omO{}mm } + { + \bool_set_false:N \l__chemmacros_renewstate_bool + \bool_set_true:N \l__chemmacros_state_overwrite_error_bool + \__chemmacros_setnewstate_reset: + \IfNoValueTF { #1 } + { \chemmacros_define_state:nnnn { #3 } { #2 } { #4 } { #5 } } + { + \msg_warning:nn { chemmacros } { state-syntax } + \chemmacros_define_state:nnnn { #1#3 } { #2 } { #4 } { #5 } + } + } +% \DeclareChemState{<name>}[<keyval>]{<symbol>}{<unit>} +\NewDocumentCommand \DeclareChemState { omO{}mm } + { + \bool_set_false:N \l__chemmacros_renewstate_bool + \bool_set_false:N \l__chemmacros_state_overwrite_error_bool + \__chemmacros_setnewstate_reset: + \IfNoValueTF { #1 } + { \chemmacros_define_state:nnnn { #3 } { #2 } { #4 } { #5 } } + { + \msg_warning:nn { chemmacros } { state-syntax } + \chemmacros_define_state:nnnn { #1#3 } { #2 } { #4 } { #5 } + } + } +% \RenewChemState{<name>}[<keyval>]{<symbol>}{<unit>} +\NewDocumentCommand \RenewChemState { omO{}mm } + { + \bool_set_true:N \l__chemmacros_renewstate_bool + \bool_set_true:N \l__chemmacros_state_overwrite_error_bool + \__chemmacros_setnewstate_reset: + \IfNoValueTF { #1 } + { \chemmacros_define_state:nnnn { #3 } { #2 } { #4 } { #5 } } + { + \msg_warning:nn { chemmacros } { state-syntax } + \chemmacros_define_state:nnnn { #1#3 } { #2 } { #4 } { #5 } + } + } +% TODO +\cs_set_protected:Npn \setnewstate + { + \msg_warning:nnnn { chemmacros } { command-deprecated } + { \setnewstate } { \NewChemState } + \NewChemState + } +\cs_set_protected:Npn \renewstate + { + \msg_warning:nnnn { chemmacros } { command-deprecated } + { \renewstate } { \RenewChemState } + \RenewChemState + } + +\cs_new_protected:Npn \__chemmacros_setnewstate_reset: + { + \tl_set:Nn \l__chemmacros_thermod_subscript_left_default_tl { true } + \tl_clear:N \l__chemmacros_thermod_subscript_default_tl + \tl_set:Nn \l__chemmacros_thermod_exponent_default_tl { \standardstate } + \tl_set:Nn \l__chemmacros_thermod_delta_default_tl { \changestate } + } + +\cs_new_protected:Npn \chemmacros_define_state:nnnn #1#2#3#4 + { + \keys_set:nn { chemmacros / setnewstate } { #1 } + \chemmacros_if_is_cs:nTF { #2 } + { \__chemmacros_set_state:xnn { \cs_to_str:N #2 } { #3 } { #4 } } + { + \msg_warning:nn { chemmacros } { state-syntax } + \__chemmacros_set_state:nnn { #2 } { #3 } { #4 } + } + } + +\cs_new_protected:Npn \__chemmacros_set_state:nnn #1#2#3 + { + \bool_if:NT \l__chemmacros_state_overwrite_error_bool + { + \bool_if:NTF \l__chemmacros_renewstate_bool + { + \cs_if_exist:cF { #1 } + { \msg_error:nnx { chemmacros } { nenew-state } { #1 } } + } + { + \cs_if_exist:cT { #1 } + { \msg_error:nnx { chemmacros } { new-state } { #1 } } + } + } + \cs_undefine:c { chemmacros_ #1 _reset: } + \cs_undefine:c { c__chemmacros_ #1 _subscript_tl } + \cs_undefine:c { c__chemmacros_ #1 _exponent_tl } + \cs_undefine:c { c__chemmacros_ #1 _delta_tl } + \cs_undefine:c { c__chemmacros_ #1 _left_tl } + \cs_undefine:c { c__chemmacros_ #1 _unit_tl } + \cs_undefine:c { #1 } + \cs_undefine:c { #1 _aux_i:n } + \cs_undefine:c { #1 _aux_ii:n } + \cs_undefine:c { #1 _aux_iii:n } + \group_begin: + \tl_const:cV + { c__chemmacros_ #1 _subscript_tl } + \l__chemmacros_thermod_subscript_default_tl + \tl_const:cV + { c__chemmacros_ #1 _exponent_tl } + \l__chemmacros_thermod_exponent_default_tl + \tl_const:cV + { c__chemmacros_ #1 _delta_tl } + \l__chemmacros_thermod_delta_default_tl + \tl_const:cV + { c__chemmacros_ #1 _left_tl } + \l__chemmacros_thermod_subscript_left_default_tl + \tl_const:cn + { c__chemmacros_ #1 _unit_tl } + { #3 } + \cs_new_protected:cpn {chemmacros_ #1 _reset: } + { + \tl_set_eq:Nc + \l__chemmacros_thermod_subscript_tl + { c__chemmacros_ #1 _subscript_tl } + \tl_set_eq:Nc + \l__chemmacros_thermod_exponent_tl + { c__chemmacros_ #1 _exponent_tl } + \tl_set_eq:Nc + \l__chemmacros_thermod_delta_tl + { c__chemmacros_ #1 _delta_tl } + \tl_set_eq:Nc + \l__chemmacros_thermod_subscript_left_tl + { c__chemmacros_ #1 _left_tl } + \tl_set_eq:Nc + \l__chemmacros_thermod_unit_tl + { c__chemmacros_ #1 _unit_tl } + } + \cs_new_protected:cpn { #1 } + { + \use:c {chemmacros_ #1 _reset: } + \peek_meaning:NTF [ + { \tl_use:c { #1 _aux_i:n } } + { + \peek_meaning:NTF ( + { \tl_use:c { #1 _aux_ii:n } } + { \tl_use:c { #1 _aux_iii:n } } + } + } + \cs_new_protected:cpn { #1 _aux_i:n } [##1] + { + \keys_set:nn { chemmacros / State } { ##1 } + \peek_meaning:NTF ( + { \tl_use:c { #1 _aux_ii:n } } + { \tl_use:c { #1 _aux_iii:n } } + } + \cs_new_protected:cpn { #1 _aux_ii:n } (##1) + { + \tl_set:Nn \l__chemmacros_thermod_subscript_tl { ##1 } + \tl_use:c { #1 _aux_iii:n } + } + \cs_new_protected:cpn { #1 _aux_iii:n } ##1 + { + \ensuremath + { + \tl_if_eq:VnTF + \l__chemmacros_thermod_subscript_left_tl { true } + { + \chemmacros_state:xnV + { + subscript-left = true , + exponent = + { \exp_not:V \l__chemmacros_thermod_exponent_tl } , + delta = + { \exp_not:V \l__chemmacros_thermod_delta_tl } + } + { #2 } + } + { + \chemmacros_state:xnV + { + subscript-left = false , + exponent = + { \exp_not:V \l__chemmacros_thermod_exponent_tl } , + delta = + { \exp_not:V \l__chemmacros_thermod_delta_tl } + } + { #2 } + } + \l__chemmacros_thermod_subscript_tl + = + \exp_args:NnV \SI { ##1 } \l__chemmacros_thermod_unit_tl + } + } + \group_end: + \ignorespaces + } +\cs_generate_variant:Nn \__chemmacros_set_state:nnn { x } + +% predefined: +\NewChemState \Enthalpy {H} {\kilo\joule\per\mole} +\NewChemState \Entropy [ delta=false, subscript-left=false ] + {S} {\joule\per\kelvin\per\mole} +\NewChemState \Gibbs {G} {\kilo\joule\per\mole} + +% -------------------------------------------------------------------------- +% Newman projections +\fp_new:N \l__chemmacros_newman_rel_angle_fp +\fp_zero:N \l__chemmacros_newman_rel_angle_fp +\fp_new:N \l__chemmacros_newman_tmp_angle_fp +\fp_new:N \l__chemmacros_newman_abs_angle_fp +\fp_zero:N \l__chemmacros_newman_abs_angle_fp +\fp_new:N \l__chemmacros_newman_scale_fp +\fp_set:Nn \l__chemmacros_newman_scale_fp { 1 } +\fp_new:N \l__chemmacros_newman_x_fp +\fp_new:N \l__chemmacros_newman_y_fp + +\tl_new:N \l__chemmacros_newman_tikz_ring_tl +\tl_new:N \l__chemmacros_newman_tikz_front_tl +\tl_new:N \l__chemmacros_newman_tikz_back_tl + +\bool_new:N \l__chemmacros_newman_tikz_back_bool + +\keys_define:nn { chemmacros / newman } + { + ring .tl_set:N = \l__chemmacros_newman_tikz_ring_tl , + atoms .tl_set:N = \l__chemmacros_newman_tikz_front_tl , + back-atoms .code:n = + { + \bool_set_true:N \l__chemmacros_newman_tikz_back_bool + \tl_set:Nn \l__chemmacros_newman_tikz_back_tl { #1 } + } , + scale .fp_set:N = \l__chemmacros_newman_scale_fp , + scale .default:n = 1 , + angle .fp_set:N = \l__chemmacros_newman_abs_angle_fp , + angle .default:n = 0 + } + +% \newman[<keyval>](<angle>){<1>,<2>,<3>,<4>,<5>,<6>} +\NewDocumentCommand \newman { o d() > { \SplitArgument { 5 } { , } } m } + { + \group_begin: + \IfNoValueF { #1 } { \keys_set:nn { chemmacros / newman } { #1 } } + \IfNoValueTF { #2 } + { \chemmacros_newman_atoms:nnnnnnn { } #3 } + { \chemmacros_newman_atoms:nnnnnnn { #2 } #3 } + \group_end: + } + +% place atoms: +% #1: angle +% #2 - #7: atoms +\cs_new_protected:Npn \chemmacros_newman_atoms:nnnnnnn #1#2#3#4#5#6#7 + { + \tl_if_blank:nTF { #1 } + { + \fp_set_eq:NN + \l__chemmacros_newman_rel_angle_fp + \l__chemmacros_newman_abs_angle_fp + } + { \fp_set:Nn \l__chemmacros_newman_rel_angle_fp { #1 } } + \chemmacros_tikz_picture:xn + { + scale = \fp_to_tl:N \l__chemmacros_newman_scale_fp , + chemmacros_newman_atom_front / .style = + { + inner~sep=0pt, + outer~sep=0pt, + \tl_use:N \l__chemmacros_newman_tikz_front_tl + }, + chemmacros_newman_atom_back / .style = + { + inner~sep=0pt, + outer~sep=0pt, + \bool_if:NTF \l__chemmacros_newman_tikz_back_bool + { \tl_use:N \l__chemmacros_newman_tikz_back_tl } + { \tl_use:N \l__chemmacros_newman_tikz_front_tl } + } + } + { + \chemmacros_tikz_draw:f + { \tl_use:N \l__chemmacros_newman_tikz_ring_tl } + (0pt,0pt) circle (\fp_to_dim:N \l__chemmacros_newman_scale_fp * 15) ; + \chemmacros_newman_back_node:nn + { 30 } + { \IfNoValueF { #6 } { #6 } } + \chemmacros_newman_back_node:nf + { 150 } + { \IfNoValueF { #7 } { #7 } } + \chemmacros_newman_back_node:nf + { 270 } + { \IfNoValueF { #5 } { #5 } } + \chemmacros_newman_front_node:nf + { 90 } + { \IfNoValueF { #2 } { #2 } } + \chemmacros_newman_front_node:nf + { 210 } + { \IfNoValueF { #3 } { #3 } } + \chemmacros_newman_front_node:nf + { 330 } + { \IfNoValueF { #4 } { #4 } } + } + } + +% provide cartesian coordiantes from polar coordinates +% #1: fp variable for x +% #2: fp variable for y +% #3: angle +% #4: radius +\cs_new_protected:Npn \chemmacros_polar_to_cartesian:NNnn #1#2#3#4 + { + \fp_set:Nn #1 { #4 * cos( #3 / 180 * pi ) }% x + \fp_set:Nn #2 { #4 * sin( #3 / 180 * pi ) }% y + } + +% place back nodes +\cs_new_protected:Npn \chemmacros_newman_back_node:nn #1#2 + { + \group_begin: + \fp_add:Nn \l__chemmacros_newman_rel_angle_fp { #1 } + \chemmacros_polar_to_cartesian:NNnn + \l__chemmacros_newman_x_fp + \l__chemmacros_newman_y_fp + { \l__chemmacros_newman_rel_angle_fp } + { \l__chemmacros_newman_scale_fp } + \chemmacros_tikz_draw:f + { \tl_use:N \l__chemmacros_newman_tikz_ring_tl } + ( + 15 * \fp_to_dim:N \l__chemmacros_newman_x_fp , + 15 * \fp_to_dim:N \l__chemmacros_newman_y_fp + ) + -- + ( + 30 * \fp_to_dim:N \l__chemmacros_newman_x_fp , + 30 * \fp_to_dim:N \l__chemmacros_newman_y_fp + ) ; + \chemmacros_polar_to_cartesian:NNnn + \l__chemmacros_newman_x_fp + \l__chemmacros_newman_y_fp + { \l__chemmacros_newman_rel_angle_fp } + { \l__chemmacros_newman_scale_fp } + \chemmacros_tikz_node:f + { + chemmacros_newman_atom_back, + anchor = -180 + \fp_to_int:N \l__chemmacros_newman_rel_angle_fp + } + at + ( + 31 * \fp_to_dim:N \l__chemmacros_newman_x_fp , + 31 * \fp_to_dim:N \l__chemmacros_newman_y_fp + ) + { #2 } ; + \group_end: + } +\cs_generate_variant:Nn \chemmacros_newman_back_node:nn { nf } + +% place front nodes: +\cs_new_protected:Npn \chemmacros_newman_front_node:nn #1#2 + { + \chemmacros_polar_to_cartesian:NNnn + \l__chemmacros_newman_x_fp + \l__chemmacros_newman_y_fp + { #1 } + { \l__chemmacros_newman_scale_fp } + \chemmacros_tikz_draw:f + { \tl_use:N \l__chemmacros_newman_tikz_ring_tl } + (0pt,0pt) -- ++ + ( + 30 * \fp_to_dim:N \l__chemmacros_newman_x_fp , + 30 * \fp_to_dim:N \l__chemmacros_newman_y_fp + ) ; + \chemmacros_polar_to_cartesian:NNnn + \l__chemmacros_newman_x_fp + \l__chemmacros_newman_y_fp + { #1 } + { \l__chemmacros_newman_scale_fp } + \chemmacros_tikz_node:f + { chemmacros_newman_atom_front, anchor = -180 + #1 } + at + ( + 31 * \fp_to_dim:N \l__chemmacros_newman_x_fp , + 31 * \fp_to_dim:N \l__chemmacros_newman_y_fp + ) + { #2 } ; + } +\cs_generate_variant:Nn \chemmacros_newman_front_node:nn { nf } + +% -------------------------------------------------------------------------- +% \orbital[<keyval>]{<type>} +% variables: +\bool_new:N \l__chemmacros_orbital_type_s_bool +\bool_new:N \l__chemmacros_orbital_type_p_bool +\bool_new:N \l__chemmacros_orbital_type_sp_bool +\bool_new:N \l__chemmacros_orbital_type_sptwo_bool +\bool_new:N \l__chemmacros_orbital_type_spthree_bool +\bool_new:N \l__chemmacros_orbital_s_phase_bool +\bool_set_true:N \l__chemmacros_orbital_s_phase_bool +\bool_new:N \l__chemmacros_orbital_p_phase_bool +\bool_set_true:N \l__chemmacros_orbital_p_phase_bool +\bool_new:N \l__chemmacros_orbital_sp_phase_bool +\bool_set_true:N \l__chemmacros_orbital_sp_phase_bool +\bool_new:N \l__chemmacros_orbital_sptwo_phase_bool +\bool_set_true:N \l__chemmacros_orbital_sptwo_phase_bool +\bool_new:N \l__chemmacros_orbital_spthree_phase_bool +\bool_set_true:N \l__chemmacros_orbital_spthree_phase_bool +\bool_new:N \l__chemmacros_orbital_p_half_bool +\bool_new:N \l__chemmacros_orbital_overlay_bool +\bool_new:N \l__chemmacros_orbital_opacity_bool + +\tl_new:N \l__chemmacros_orbital_s_color_tl +\tl_set:Nn \l__chemmacros_orbital_s_color_tl { black } +\tl_new:N \l__chemmacros_orbital_s_phase_color_tl +\tl_new:N \l__chemmacros_orbital_p_color_tl +\tl_set:Nn \l__chemmacros_orbital_p_color_tl { black } +\tl_new:N \l__chemmacros_orbital_p_pphase_color_tl +\tl_new:N \l__chemmacros_orbital_p_mphase_color_tl +\tl_new:N \l__chemmacros_orbital_sp_color_tl +\tl_set:Nn \l__chemmacros_orbital_sp_color_tl { black } +\tl_new:N \l__chemmacros_orbital_sp_pphase_color_tl +\tl_new:N \l__chemmacros_orbital_sp_mphase_color_tl +\tl_new:N \l__chemmacros_orbital_sptwo_color_tl +\tl_set:Nn \l__chemmacros_orbital_sptwo_color_tl { black } +\tl_new:N \l__chemmacros_orbital_sptwo_pphase_color_tl +\tl_new:N \l__chemmacros_orbital_sptwo_mphase_color_tl +\tl_new:N \l__chemmacros_orbital_spthree_color_tl +\tl_set:Nn \l__chemmacros_orbital_spthree_color_tl { black } +\tl_new:N \l__chemmacros_orbital_spthree_pphase_color_tl +\tl_new:N \l__chemmacros_orbital_spthree_mphase_color_tl +\tl_new:N \l__chemmacros_orbital_s_scale_tl +\tl_set:Nn \l__chemmacros_orbital_s_scale_tl { 1 } +\tl_new:N \l__chemmacros_orbital_p_scale_tl +\tl_set:Nn \l__chemmacros_orbital_p_scale_tl { 1 } +\tl_new:N \l__chemmacros_orbital_sp_scale_tl +\tl_set:Nn \l__chemmacros_orbital_sp_scale_tl { 1 } +\tl_new:N \l__chemmacros_orbital_sptwo_scale_tl +\tl_set:Nn \l__chemmacros_orbital_sptwo_scale_tl { 1 } +\tl_new:N \l__chemmacros_orbital_spthree_scale_tl +\tl_set:Nn \l__chemmacros_orbital_spthree_scale_tl { 1 } + +\fp_new:N \l__chemmacros_orbital_angle_fp +\fp_set:Nn \l__chemmacros_orbital_angle_fp { 90 } +\fp_new:N \l__chemmacros_orbital_opacity_fp +\fp_set:Nn \l__chemmacros_orbital_opacity_fp { 0.5 } + +\cs_new:Npn \__chemmacros_orbital_options: + { + \__chemmacros_orbital_overlay: , \__chemmacros_orbital_opacity: , + inner~sep=0 , outer~sep=0 , line~width=.2pt , + rotate = { \fp_use:N \l__chemmacros_orbital_angle_fp - 90 } , + baseline , + minimum~size = 0 + } + +\cs_new:Npn \__chemmacros_orbital_overlay: + { \bool_if:NT \l__chemmacros_orbital_overlay_bool { overlay } } + +\cs_new:Npn \__chemmacros_orbital_opacity: + { + \bool_if:NT \l__chemmacros_orbital_opacity_bool + { opacity = { \fp_use:N \l__chemmacros_orbital_opacity_fp } } + } + +% -------------------------------------------------------------------------- +% s-orbitals +\cs_new_protected:Npn \__chemmacros_orbital_type_s: + { + \bool_set_true:N \l__chemmacros_orbital_type_s_bool + \bool_set_false:N \l__chemmacros_orbital_type_p_bool + \bool_set_false:N \l__chemmacros_orbital_type_sp_bool + \bool_set_false:N \l__chemmacros_orbital_type_sptwo_bool + \bool_set_false:N \l__chemmacros_orbital_type_spthree_bool + } + +\keys_define:nn { chemmacros / orbital / s } + { + phase .choice: , + phase / + .code:n = + { \bool_set_true:N \l__chemmacros_orbital_s_phase_bool } , + phase / - .code:n = + { \bool_set_false:N \l__chemmacros_orbital_s_phase_bool } , + scale .tl_set:N = \l__chemmacros_orbital_s_scale_tl , + color .tl_set:N = \l__chemmacros_orbital_s_color_tl + } + +\cs_new_protected:Npn \__chemmacros_orbital_s_draw:n #1 + { + \keys_set:nn { chemmacros / orbital / s } { #1 } + \bool_if:NTF \l__chemmacros_orbital_s_phase_bool + { + \tl_if_in:NnTF \l__chemmacros_orbital_s_color_tl { ! } + { + \tl_set:Nn \l__chemmacros_orbital_s_phase_color_tl + { \tl_use:N \l__chemmacros_orbital_s_color_tl } + } + { + \tl_set:Nn \l__chemmacros_orbital_s_phase_color_tl + { \tl_use:N \l__chemmacros_orbital_s_color_tl ! 90 } + } + } + { + \tl_set:Nn \l__chemmacros_orbital_s_phase_color_tl + { black ! 5 } + } + \chemmacros_tikz_picture:xn{ \__chemmacros_orbital_options: } + { + \chemmacros_tikz_shade:f + { ball~color = \l__chemmacros_orbital_s_phase_color_tl } + (0pt,0pt) circle (\l__chemmacros_orbital_s_scale_tl * .6em) ; + } + } + +% -------------------------------------------------------------------------- +% p-orbitals +\cs_new_protected:Npn \__chemmacros_orbital_type_p: + { + \bool_set_false:N \l__chemmacros_orbital_type_s_bool + \bool_set_true:N \l__chemmacros_orbital_type_p_bool + \bool_set_false:N \l__chemmacros_orbital_type_sp_bool + \bool_set_false:N \l__chemmacros_orbital_type_sptwo_bool + \bool_set_false:N \l__chemmacros_orbital_type_spthree_bool + } + +\keys_define:nn { chemmacros / orbital / p } + { + phase .choice: , + phase / + .code:n = + { \bool_set_true:N \l__chemmacros_orbital_p_phase_bool } , + phase / - .code:n = + { \bool_set_false:N \l__chemmacros_orbital_p_phase_bool } , + scale .tl_set:N = \l__chemmacros_orbital_p_scale_tl , + angle .fp_set:N = \l__chemmacros_orbital_angle_fp , + color .tl_set:N = \l__chemmacros_orbital_p_color_tl , + half .bool_set:N = \l__chemmacros_orbital_p_half_bool , + half .default:n = true + } + +\cs_new_protected:Npn \__chemmacros_orbital_p_draw:n #1 + { + \keys_set:nn { chemmacros / orbital / p } { #1 } + \bool_if:NTF \l__chemmacros_orbital_p_phase_bool + { + \tl_if_in:NnTF \l__chemmacros_orbital_p_color_tl { ! } + { + \tl_set:Nn \l__chemmacros_orbital_p_pphase_color_tl + { \tl_use:N \l__chemmacros_orbital_p_color_tl } + } + { + \tl_set:Nn \l__chemmacros_orbital_p_pphase_color_tl + { \tl_use:N \l__chemmacros_orbital_p_color_tl ! 90 } + } + \tl_set:Nn \l__chemmacros_orbital_p_mphase_color_tl + { black ! 5 } + + } + { + \tl_if_in:NnTF \l__chemmacros_orbital_p_color_tl { ! } + { + \tl_set:Nn \l__chemmacros_orbital_p_mphase_color_tl + { \tl_use:N \l__chemmacros_orbital_p_color_tl } + } + { + \tl_set:Nn \l__chemmacros_orbital_p_mphase_color_tl + { \tl_use:N \l__chemmacros_orbital_p_color_tl ! 90 } + } + \tl_set:Nn \l__chemmacros_orbital_p_pphase_color_tl + { black ! 5 } + } + \chemmacros_tikz_picture:xn { \__chemmacros_orbital_options: } + { + \chemmacros_tikz_shadedraw:f + { + draw = \l__chemmacros_orbital_p_pphase_color_tl , + ball~color = \l__chemmacros_orbital_p_pphase_color_tl + } + (0pt,0pt) .. controls ++ + ( + - \l__chemmacros_orbital_p_scale_tl * 2em , + \l__chemmacros_orbital_p_scale_tl * 2em + ) + and ++ + ( + \l__chemmacros_orbital_p_scale_tl * 2em , + \l__chemmacros_orbital_p_scale_tl * 2em + ) + .. (0pt,0pt); + \bool_if:NF \l__chemmacros_orbital_p_half_bool + { + \chemmacros_tikz_shadedraw:f + { + draw = \l__chemmacros_orbital_p_mphase_color_tl , + ball~color = \l__chemmacros_orbital_p_mphase_color_tl + } + (0pt,0pt) .. controls ++ + ( + - \l__chemmacros_orbital_p_scale_tl * 2em , + - \l__chemmacros_orbital_p_scale_tl * 2em + ) + and ++ + ( + \l__chemmacros_orbital_p_scale_tl * 2em , + - \l__chemmacros_orbital_p_scale_tl * 2em + ) + .. (0pt,0pt); + } + } + } + +% -------------------------------------------------------------------------- +% sp-orbitals +\cs_new_protected:Npn \__chemmacros_orbital_type_sp: + { + \bool_set_false:N \l__chemmacros_orbital_type_s_bool + \bool_set_false:N \l__chemmacros_orbital_type_p_bool + \bool_set_true:N \l__chemmacros_orbital_type_sp_bool + \bool_set_false:N \l__chemmacros_orbital_type_sptwo_bool + \bool_set_false:N \l__chemmacros_orbital_type_spthree_bool + } + +\keys_define:nn { chemmacros / orbital / sp } + { + phase .choice: , + phase / + .code:n = + { \bool_set_true:N \l__chemmacros_orbital_sp_phase_bool } , + phase / - .code:n = + { \bool_set_false:N \l__chemmacros_orbital_sp_phase_bool } , + scale .tl_set:N = \l__chemmacros_orbital_sp_scale_tl , + angle .fp_set:N = \l__chemmacros_orbital_angle_fp , + color .tl_set:N = \l__chemmacros_orbital_sp_color_tl + } + +\cs_new_protected:Npn \__chemmacros_orbital_sp_draw:n #1 + { + \keys_set:nn { chemmacros / orbital / sp } { #1 } + \bool_if:NTF \l__chemmacros_orbital_sp_phase_bool + { + \tl_if_in:NnTF \l__chemmacros_orbital_sp_color_tl { ! } + { + \tl_set:Nn \l__chemmacros_orbital_sp_pphase_color_tl + { \tl_use:N \l__chemmacros_orbital_sp_color_tl } + } + { + \tl_set:Nn \l__chemmacros_orbital_sp_pphase_color_tl + { \tl_use:N \l__chemmacros_orbital_sp_color_tl ! 90 } + } + \tl_set:Nn \l__chemmacros_orbital_sp_mphase_color_tl + { black ! 5 } + + } + { + \tl_if_in:NnTF \l__chemmacros_orbital_sp_color_tl { ! } + { + \tl_set:Nn \l__chemmacros_orbital_sp_mphase_color_tl + { \tl_use:N \l__chemmacros_orbital_sp_color_tl } + } + { + \tl_set:Nn \l__chemmacros_orbital_sp_mphase_color_tl + { \tl_use:N \l__chemmacros_orbital_sp_color_tl ! 90 } + } + \tl_set:Nn \l__chemmacros_orbital_sp_pphase_color_tl + { black ! 5 } + } + \chemmacros_tikz_picture:xn { \__chemmacros_orbital_options: } + { + \chemmacros_tikz_shadedraw:f + { + draw = \l__chemmacros_orbital_sp_pphase_color_tl , + ball~color = \l__chemmacros_orbital_sp_pphase_color_tl + } + (0pt,0pt) .. controls ++ + ( + - \l__chemmacros_orbital_sp_scale_tl * 2em , + \l__chemmacros_orbital_sp_scale_tl * 2em + ) + and ++ + ( + \l__chemmacros_orbital_sp_scale_tl * 2em , + \l__chemmacros_orbital_sp_scale_tl * 2em + ) + .. (0pt,0pt); + \chemmacros_tikz_shadedraw:f + { + draw = \l__chemmacros_orbital_sp_mphase_color_tl , + ball~color = \l__chemmacros_orbital_sp_mphase_color_tl + } + (0pt,0pt) .. controls ++ + ( + - \l__chemmacros_orbital_sp_scale_tl * .6em , + - \l__chemmacros_orbital_sp_scale_tl * .6em + ) + and ++ + ( + \l__chemmacros_orbital_sp_scale_tl * .6em , + - \l__chemmacros_orbital_sp_scale_tl * .6em + ) + .. (0pt,0pt); + } + } + +% -------------------------------------------------------------------------- +% sp2-orbitals +\cs_new_protected:Npn \__chemmacros_orbital_type_sptwo: + { + \bool_set_false:N \l__chemmacros_orbital_type_s_bool + \bool_set_false:N \l__chemmacros_orbital_type_p_bool + \bool_set_false:N \l__chemmacros_orbital_type_sp_bool + \bool_set_true:N \l__chemmacros_orbital_type_sptwo_bool + \bool_set_false:N \l__chemmacros_orbital_type_spthree_bool + } + +\keys_define:nn { chemmacros / orbital / sp2 } + { + phase .choice: , + phase / + .code:n = + { \bool_set_true:N \l__chemmacros_orbital_sptwo_phase_bool } , + phase / - .code:n = + { \bool_set_false:N \l__chemmacros_orbital_sptwo_phase_bool } , + scale .tl_set:N = \l__chemmacros_orbital_sptwo_scale_tl , + angle .fp_set:N = \l__chemmacros_orbital_angle_fp , + color .tl_set:N = \l__chemmacros_orbital_sptwo_color_tl + } + +\cs_new_protected:Npn \__chemmacros_orbital_sptwo_draw:n #1 + { + \keys_set:nn { chemmacros / orbital / sp2 } { #1 } + \bool_if:NTF \l__chemmacros_orbital_sptwo_phase_bool + { + \tl_if_in:NnTF \l__chemmacros_orbital_sptwo_color_tl { ! } + { + \tl_set:Nn \l__chemmacros_orbital_sptwo_pphase_color_tl + { \tl_use:N \l__chemmacros_orbital_sptwo_color_tl } + } + { + \tl_set:Nn \l__chemmacros_orbital_sptwo_pphase_color_tl + { \tl_use:N \l__chemmacros_orbital_sptwo_color_tl ! 90 } + } + \tl_set:Nn \l__chemmacros_orbital_sptwo_mphase_color_tl + { black ! 5 } + + } + { + \tl_if_in:NnTF \l__chemmacros_orbital_sptwo_color_tl { ! } + { + \tl_set:Nn \l__chemmacros_orbital_sptwo_mphase_color_tl + { \tl_use:N \l__chemmacros_orbital_sptwo_color_tl } + } + { + \tl_set:Nn \l__chemmacros_orbital_sptwo_mphase_color_tl + { \tl_use:N \l__chemmacros_orbital_sptwo_color_tl ! 90 } + } + \tl_set:Nn \l__chemmacros_orbital_sptwo_pphase_color_tl + { black ! 5 } + } + \chemmacros_tikz_picture:xn { \__chemmacros_orbital_options: } + { + \chemmacros_tikz_shadedraw:f + { + draw = \l__chemmacros_orbital_sptwo_pphase_color_tl , + ball~color = \l__chemmacros_orbital_sptwo_pphase_color_tl + } + (0pt,0pt) .. controls ++ + ( + - \l__chemmacros_orbital_sptwo_scale_tl * 2em , + \l__chemmacros_orbital_sptwo_scale_tl * 2em + ) + and ++ + ( + \l__chemmacros_orbital_sptwo_scale_tl * 2em , + \l__chemmacros_orbital_sptwo_scale_tl * 2em + ) + .. (0pt,0pt); + \chemmacros_tikz_shadedraw:f + { + draw = \l__chemmacros_orbital_sptwo_mphase_color_tl , + ball~color = \l__chemmacros_orbital_sptwo_mphase_color_tl + } + (0pt,0pt) .. controls ++ + ( + - \l__chemmacros_orbital_sptwo_scale_tl * .8em , + - \l__chemmacros_orbital_sptwo_scale_tl * .8em + ) + and ++ + ( + \l__chemmacros_orbital_sptwo_scale_tl * .8em , + - \l__chemmacros_orbital_sptwo_scale_tl * .8em + ) + .. (0pt,0pt); + } + } + +% -------------------------------------------------------------------------- +% sp3-orbitals +\cs_new_protected:Npn \__chemmacros_orbital_type_spthree: + { + \bool_set_false:N \l__chemmacros_orbital_type_s_bool + \bool_set_false:N \l__chemmacros_orbital_type_p_bool + \bool_set_false:N \l__chemmacros_orbital_type_sp_bool + \bool_set_false:N \l__chemmacros_orbital_type_sptwo_bool + \bool_set_true:N \l__chemmacros_orbital_type_spthree_bool + } + +\keys_define:nn { chemmacros / orbital / sp3 } + { + phase .choice: , + phase / + .code:n = + { \bool_set_true:N \l__chemmacros_orbital_spthree_phase_bool } , + phase / - .code:n = + { \bool_set_false:N \l__chemmacros_orbital_spthree_phase_bool } , + scale .tl_set:N = \l__chemmacros_orbital_spthree_scale_tl , + angle .fp_set:N = \l__chemmacros_orbital_angle_fp , + color .tl_set:N = \l__chemmacros_orbital_spthree_color_tl + } + +\cs_new_protected:Npn \__chemmacros_orbital_spthree_draw:n #1 + { + \keys_set:nn { chemmacros / orbital / sp3 } { #1 } + \bool_if:NTF \l__chemmacros_orbital_spthree_phase_bool + { + \tl_if_in:NnTF \l__chemmacros_orbital_spthree_color_tl { ! } + { + \tl_set:Nn \l__chemmacros_orbital_spthree_pphase_color_tl + { \tl_use:N \l__chemmacros_orbital_spthree_color_tl } + } + { + \tl_set:Nn \l__chemmacros_orbital_spthree_pphase_color_tl + { \tl_use:N \l__chemmacros_orbital_spthree_color_tl ! 90 } + } + \tl_set:Nn \l__chemmacros_orbital_spthree_mphase_color_tl + { black ! 5 } + + } + { + \tl_if_in:NnTF \l__chemmacros_orbital_spthree_color_tl { ! } + { + \tl_set:Nn \l__chemmacros_orbital_spthree_mphase_color_tl + { \tl_use:N \l__chemmacros_orbital_spthree_color_tl } + } + { + \tl_set:Nn \l__chemmacros_orbital_spthree_mphase_color_tl + { \tl_use:N \l__chemmacros_orbital_spthree_color_tl ! 90 } + } + \tl_set:Nn \l__chemmacros_orbital_spthree_pphase_color_tl + { black ! 5 } + } + \chemmacros_tikz_picture:xn { \__chemmacros_orbital_options: } + { + \chemmacros_tikz_shadedraw:f + { + draw = \l__chemmacros_orbital_spthree_pphase_color_tl , + ball~color = \l__chemmacros_orbital_spthree_pphase_color_tl + } + (0pt,0pt) .. controls ++ + ( + - \l__chemmacros_orbital_spthree_scale_tl * 2em , + \l__chemmacros_orbital_spthree_scale_tl * 2em + ) + and ++ + ( + \l__chemmacros_orbital_spthree_scale_tl * 2em , + \l__chemmacros_orbital_spthree_scale_tl * 2em + ) + .. (0pt,0pt); + \chemmacros_tikz_shadedraw:f + { + draw = \l__chemmacros_orbital_spthree_mphase_color_tl , + ball~color = \l__chemmacros_orbital_spthree_mphase_color_tl + } + (0pt,0pt) .. controls ++ + ( + - \l__chemmacros_orbital_spthree_scale_tl * 1em , + - \l__chemmacros_orbital_spthree_scale_tl * 1em + ) + and ++ + ( + \l__chemmacros_orbital_spthree_scale_tl * 1em , + - \l__chemmacros_orbital_spthree_scale_tl * 1em + ) + .. (0pt,0pt); + } + } + +% -------------------------------------------------------------------------- +% main command +\keys_define:nn { chemmacros / orbital } + { + overlay .bool_set:N = \l__chemmacros_orbital_overlay_bool , + overlay .default:n = true , + opacity .code:n = + { + \fp_compare:nTF { #1 = 1 } + { \bool_set_false:N \l__chemmacros_orbital_opacity_bool } + { \bool_set_true:N \l__chemmacros_orbital_opacity_bool } + \fp_set:Nn \l__chemmacros_orbital_opacity_fp { #1 } + } + } + +\keys_define:nn { chemmacros / orbital / type } + { + s .code:n = { \__chemmacros_orbital_type_s: } , + p .code:n = { \__chemmacros_orbital_type_p: } , + sp .code:n = { \__chemmacros_orbital_type_sp: } , + sp2 .code:n = { \__chemmacros_orbital_type_sptwo: } , + sp3 .code:n = { \__chemmacros_orbital_type_spthree: } + } + +\cs_new_protected:Npn \chemmacros_orbital:n #1 + { + \bool_if:NT \l__chemmacros_orbital_type_s_bool + { \__chemmacros_orbital_s_draw:n { #1 } } + \bool_if:NT \l__chemmacros_orbital_type_p_bool + { \__chemmacros_orbital_p_draw:n { #1 } } + \bool_if:NT \l__chemmacros_orbital_type_sp_bool + { \__chemmacros_orbital_sp_draw:n { #1 } } + \bool_if:NT \l__chemmacros_orbital_type_sptwo_bool + { \__chemmacros_orbital_sptwo_draw:n { #1 } } + \bool_if:NT \l__chemmacros_orbital_type_spthree_bool + { \__chemmacros_orbital_spthree_draw:n { #1 } } + } + +\NewDocumentCommand \orbital { o m } + { + \group_begin: + \keys_set:nn { chemmacros / orbital / type } { #2 } + \IfNoValueTF { #1 } + { \chemmacros_orbital:n { } } + { \chemmacros_orbital:n { #1 } } + \group_end: + } + +% -------------------------------------------------------------------------- +% arrow tips for electron movement +\dim_new:N \l__chemmacros_el_length_dim + +% full tip for pairs +\pgfarrowsdeclare { el } { el } + { + \dim_set:Nn \l__chemmacros_el_length_dim + { 2.5pt + 2.5\pgflinewidth } + \pgfarrowsleftextend { -\l__chemmacros_el_length_dim } + \pgfarrowsrightextend { .5\pgflinewidth } + } + { + \dim_set:Nn \l__chemmacros_el_length_dim + { 2.5pt + 2.5\pgflinewidth } + \pgfsetdash {} { 0pt } + \pgfsetroundjoin + \pgfsetroundcap + \pgfpathmoveto { \pgfpoint { 0pt } { 0pt } } + \pgfpathlineto + { + \pgfpoint + { -\l__chemmacros_el_length_dim } + { .3\l__chemmacros_el_length_dim } + } + \pgfpathlineto + { \pgfpoint { -.5\l__chemmacros_el_length_dim } { 0pt } } + \pgfpathlineto + { + \pgfpoint + { -\l__chemmacros_el_length_dim } + { -.3\l__chemmacros_el_length_dim } + } + \pgfpathlineto { \pgfpoint { 0pt } { 0pt } } + \pgfusepathqfillstroke + } + +% half tip on the left +\pgfarrowsdeclare { left~el } { left~el } + { + \dim_set:Nn \l__chemmacros_el_length_dim + { 2.5pt + 2.5\pgflinewidth } + \pgfarrowsleftextend { -\l__chemmacros_el_length_dim } + \pgfarrowsrightextend { .5\pgflinewidth } + } + { + \dim_set:Nn \l__chemmacros_el_length_dim + { 2.5pt + 2.5\pgflinewidth } + \pgfsetdash {} { 0pt } + \pgfsetroundjoin + \pgfsetroundcap + \pgfpathmoveto { \pgfpoint { 0pt } { 0pt } } + \pgfpathlineto + { + \pgfpoint + { -\l__chemmacros_el_length_dim } + { .3\l__chemmacros_el_length_dim } + } + \pgfpathlineto { \pgfpoint { -.5\l__chemmacros_el_length_dim } { 0pt } } + \pgfpathlineto { \pgfpoint { 0pt } { 0pt } } + \pgfusepathqfillstroke + } + +% half tip in the right +\pgfarrowsdeclare { right~el } { right~el } + { + \dim_set:Nn \l__chemmacros_el_length_dim + { 2.5pt + 2.5\pgflinewidth } + \pgfarrowsleftextend { -\l__chemmacros_el_length_dim } + \pgfarrowsrightextend { .5\pgflinewidth } + } + { + \dim_set:Nn \l__chemmacros_el_length_dim + { 2.5pt + 2.5\pgflinewidth } + \pgfsetdash {} { 0pt } + \pgfsetroundjoin + \pgfsetroundcap + \pgfpathmoveto { \pgfpoint { 0pt } { 0pt } } + \pgfpathlineto + { + \pgfpoint + { -\l__chemmacros_el_length_dim } + { -.3\l__chemmacros_el_length_dim } + } + \pgfpathlineto { \pgfpoint { -.5\l__chemmacros_el_length_dim } { 0pt } } + \pgfpathlineto { \pgfpoint { 0pt } { 0pt } } + \pgfusepathqfillstroke + } + +% -------------------------------------------------------------------------- +% setup +\NewDocumentCommand \chemsetup { o m } + { + \IfNoValueTF { #1 } + { \keys_set:nn { chemmacros } { #2 } } + { + \tl_if_eq:nnTF { #1 } { chemformula } + { \setchemformula { #2 } } + { \keys_set:nn { chemmacros / #1 } { #2 } } + } + \ignorespaces + } + + +% -------------------------------------------------------------------------- +% hyperref support +% ?? unsure about adding IUPAC commands +\AfterPackage* { hyperref } + { + \pdfstringdefDisableCommands + { + % \cs_set:Npn \- { - } % maybe not a good idea... + \cs_set:Npn \| { } + \cs_set:Npn \pH { pH } + \cs_set:Npn \pOH { pOH } + \cs_set:Npn \iupac #1 { #1 } + \cs_set:Npn \cip #1 { (#1) } + \cs_set:Npn \cis { cis } + \cs_set:Npn \trans { trans } + \cs_set:Npn \tert { tert } + \cs_set:Npn \ortho { o } + \cs_set:Npn \meta { m } + \cs_set:Npn \para { p } + \cs_set:Npn \syn { syn } + \cs_set:Npn \anti { anti } + } + } + +% -------------------------------------------------------------------------- +% language support -- provided through `translations' +% equilibrium constants: +\DeclareTranslationFallback {K-acid} {\mathrm{a}} +\DeclareTranslation{German} {K-acid} {\mathrm{s}} +\DeclareTranslation{Dutch} {K-acid} {\mathrm{z}} + +\DeclareTranslationFallback {K-base} {\mathrm{b}} + +\DeclareTranslationFallback {K-water} {\mathrm{w}} + +% phases: +\DeclareTranslation{German}{phase-sld}{ f } +\DeclareTranslation{German}{phase-lqd}{ f{}l } +% list of reactions: +\DeclareTranslationFallback {list-of-reactions} { List~ of~ reactions } +\DeclareTranslation{English} {list-of-reactions} { List~ of~ reactions } +\DeclareTranslation{German} {list-of-reactions} { Reaktionsverzeichnis } +\DeclareTranslation{Italian} {list-of-reactions} { Elenco~ delle~ reazioni } +\DeclareTranslation{French} {list-of-reactions} { Table~ des~ r\'eactions } +\DeclareTranslation{Dutch} {list-of-reactions} { Lijst~ van~ reacties } +% +\DeclareTranslationFallback {reaction} { Reaction } +\DeclareTranslation{English} {reaction} { Reaction } +\DeclareTranslation{German} {reaction} { Reaktion } +\DeclareTranslation{Italian} {reaction} { Reazione } +\DeclareTranslation{French} {reaction} { R\'eaction } +\DeclareTranslation{Dutch} {reaction} { Reactie } + +\tl_set:Nn \l__chemmacros_reaction_lorname_tl + { \chemmacros_translate:n {reaction} } +\tl_set:Nn \reactionlistname + { \chemmacros_translate:n {list-of-reactions} } + +\tex_endinput:D diff --git a/macros/latex/contrib/chemmacros/chemmacros-2020-03-07.sty b/macros/latex/contrib/chemmacros/chemmacros-2020-03-07.sty new file mode 100644 index 0000000000..0930f27a2c --- /dev/null +++ b/macros/latex/contrib/chemmacros/chemmacros-2020-03-07.sty @@ -0,0 +1,268 @@ +% -------------------------------------------------------------------------- +% the CHEMMACROS package +% +% comprehensive support for typesetting chemistry documents +% +% -------------------------------------------------------------------------- +% 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--2020 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. +% -------------------------------------------------------------------------- +\RequirePackage{expl3,xparse,l3keys2e} +\ExplSyntaxOn + +% -------------------------------------------------------------------------- +% package information: +\tl_const:Nn \c_chemmacros_date_tl {2020/03/07} +\tl_const:Nn \c_chemmacros_version_major_number_tl {5} +\tl_const:Nn \c_chemmacros_version_minor_number_tl {11} +\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 + } +\tl_const:Nx \c_chemmacros_version_tl + { + \c_chemmacros_version_number_tl + \c_chemmacros_version_subrelease_tl + } +\tl_const:Nn \c_chemmacros_info_tl + {comprehensive~ support~ for~ typesetting~ chemistry~ documents} + +\ProvidesExplPackage + {chemmacros} + {\c_chemmacros_date_tl} + {\c_chemmacros_version_tl} + {\c_chemmacros_info_tl \c_space_tl (CN)} + +% -------------------------------------------------------------------------- +% set compatibility +\tl_new:N \l__chemmacros_compatibility_version_tl +\tl_set_eq:NN \l__chemmacros_compatibility_version_tl \c_chemmacros_version_tl + +\keys_define:nn {chemmacros/compatibility} + { + compatibility .code:n = + \str_case:nnTF {#1} + { + {newest} {} + {latest} {} + } + { + \tl_set_eq:NN + \l__chemmacros_compatibility_version_tl + \c_chemmacros_version_tl + } + { \tl_set:Nn \l__chemmacros_compatibility_version_tl {#1} } , + unknown .code:n = + \PassOptionsToPackage{\CurrentOption}{chemmacros4} + \PassOptionsToPackage{\CurrentOption}{chemmacros5} + } + +\ProcessKeysPackageOptions {chemmacros/compatibility} + +% -------------------------------------------------------------------------- +% compare version numbers +% #1: version +% #2: relation +% #3: version +% #4: true +% #5: false +\prg_new_conditional:Npnn \chemmacros_if_version:nnn #1#2#3 {p,T,F,TF} + { + \fp_compare:nTF + { + ( + \chemmacros_get_major_version:n {#1} * 1e6 + + \chemmacros_get_minor_version:n {#1} * 1e3 + + 0 \chemmacros_get_subrelease:n {#1} + ) + #2 + ( + \chemmacros_get_major_version:n {#3} * 1e6 + + \chemmacros_get_minor_version:n {#3} * 1e3 + + 0 \chemmacros_get_subrelease:n {#3} + ) + } + { \prg_return_true: } + { \prg_return_false: } + } +\cs_generate_variant:Nn \chemmacros_if_version:nnnTF {fnf} + +\cs_new:Npn \__chemmacros_get_minor_version:w #1.#2.#3 \q_stop + { + \tl_if_blank:nTF {#2} {0} { + \tl_map_function:nN {#2} \__chemmacros_get_minor_number:n + } + } + +\cs_new:Npn \chemmacros_get_minor_version:n #1 + { \__chemmacros_get_minor_version:w #1.. \q_stop } + +\cs_new:Npn \__chemmacros_get_minor_number:n #1 + { + \str_case:nn {#1} + { + {0} {0} + {1} {1} + {2} {2} + {3} {3} + {4} {4} + {5} {5} + {6} {6} + {7} {7} + {8} {8} + {9} {9} + } + } + +\cs_new:Npn \__chemmacros_get_major_version:w #1.#2.#3 \q_stop + { \tl_if_blank:nTF {#1} {0} {#1} } + +\cs_new:Npn \chemmacros_get_major_version:n #1 + { \__chemmacros_get_major_version:w #1.. \q_stop } + +\cs_new:Npn \__chemmacros_get_subrelease:w #1.#2.#3 \q_stop + { + \tl_if_blank:nTF {#2} {0} { + \tl_map_function:nN {#2} \__chemmacros_get_subrelease_number:n + } + } + +\cs_new:Npn \chemmacros_get_subrelease:n #1 + { \__chemmacros_get_subrelease:w #1.. \q_stop } + +\cs_new:Npn \__chemmacros_get_subrelease_number:n #1 + { + \str_case:nnF {#1} + { + {0} {} + {1} {} + {2} {} + {3} {} + {4} {} + {5} {} + {6} {} + {7} {} + {8} {} + {9} {} + } + { \int_from_alph:n {#1} } + } + +% check compatibility +% #1: relation +% #2: number +% #3: true +% #4: false +\prg_new_conditional:Npnn \chemmacros_if_compatibility:nn #1#2 {p,T,F,TF} + { + \chemmacros_if_version:fnfTF + { \l__chemmacros_compatibility_version_tl } + {#1} + {#2} + { \prg_return_true: } + { \prg_return_false: } + } +\cs_generate_variant:Nn \chemmacros_if_compatibility:nnT {nV} + +% user checks: +\NewExpandableDocumentCommand \IfChemCompatibilityTF {mm+m+m} + { \chemmacros_if_compatibility:nnTF {#1} {#2} {#3} {#4} } + +\NewExpandableDocumentCommand \IfChemCompatibilityT {mm+m} + { \chemmacros_if_compatibility:nnT {#1} {#2} {#3} } + +\NewExpandableDocumentCommand \IfChemCompatibilityF {mm+m} + { \chemmacros_if_compatibility:nnF {#1} {#2} {#3} } + +% -------------------------------------------------------------------------- +% compatibility coding: +\cs_new_protected:Npn \ChemCompatibility #1#2 \EndChemCompatibility + { \chemmacros_if_compatibility:nnT {=} {#1} {#2} } + +\cs_new_protected:Npn \ChemCompatibilityFrom #1#2 \EndChemCompatibility + { \chemmacros_if_compatibility:nnT {>=} {#1} {#2} } + +\cs_new_protected:Npn \ChemCompatibilityTo #1#2 \EndChemCompatibility + { \chemmacros_if_compatibility:nnT {<} {#1} {#2} } + +\cs_new_protected:Npn \ChemCompatibilityBetween #1#2#3 \EndChemCompatibility + { + \bool_lazy_and:nnT + { \chemmacros_if_compatibility_p:nn {>=} {#1} } + { \chemmacros_if_compatibility_p:nn {<} {#2} } + {#3} + } + +% -------------------------------------------------------------------------- +% messages: +\msg_new:nnn {chemmacros} {too-low-compatibility} + { + Compatibility~ for~ versions~ below~ v4.7~ is~ not~ supported!~ You~ + requested~ version~ v #1.~ Loading~ v4.7~ instead. + } + +\msg_new:nnn {chemmacros} {too-high-compatibility} + { + You~ requested~ compatibility~ mode~ v #1~ while~ the~ current~ version~ + of~ chemmacros~ is~ v \c_chemmacros_version_tl .~ Falling~ back~ + to~ v \c_chemmacros_version_number_tl ! + } + +\msg_new:nnn {chemmacros} {low-compatibility} + { + You~ requested~ compatibility~ mode~ v #1~ while~ the~ current~ version~ + of~ chemmacros~ is~ v \c_chemmacros_version_tl .~ Not~ all~ features~ + or~ fixes~ will~ be~ available! + } + +% -------------------------------------------------------------------------- +% let's see that the max number is the newest (=current) version +\chemmacros_if_compatibility:nnT {>} { \c_chemmacros_version_tl } + { + \tl_set_eq:NN + \l__chemmacros_compatibility_version_tl + \c_chemmacros_version_tl + } + +% -------------------------------------------------------------------------- +% compatibility too low: +\chemmacros_if_compatibility:nnT {<} {4.7} + { + \msg_warning:nnx {chemmacros} {too-low-compatibility} + { \l__chemmacros_compatibility_version_tl } + } + +% not the newest version: +\chemmacros_if_compatibility:nnT {<} { \c_chemmacros_version_tl } + { + \msg_warning:nnx {chemmacros} {low-compatibility} + { \l__chemmacros_compatibility_version_tl } + } + +% -------------------------------------------------------------------------- +\chemmacros_if_compatibility:nnTF {<} {5.0} + { \RequirePackage{chemmacros4} } + { \RequirePackage{chemmacros5} } + +\file_input_stop: diff --git a/macros/latex/contrib/chemmacros/chemmacros-manual.pdf b/macros/latex/contrib/chemmacros/chemmacros-manual.pdf Binary files differindex 8e18c20935..6ecf64a6eb 100644 --- a/macros/latex/contrib/chemmacros/chemmacros-manual.pdf +++ b/macros/latex/contrib/chemmacros/chemmacros-manual.pdf diff --git a/macros/latex/contrib/chemmacros/chemmacros-manual.tex b/macros/latex/contrib/chemmacros/chemmacros-manual.tex index 08954ccb2f..f685451e11 100644 --- a/macros/latex/contrib/chemmacros/chemmacros-manual.tex +++ b/macros/latex/contrib/chemmacros/chemmacros-manual.tex @@ -1,5 +1,5 @@ % -------------------------------------------------------------------------- -% the CHEMMACROS package v6.2 2022/03/05 +% the CHEMMACROS package v6.2a 2022/03/12 % % comprehensive support for typesetting chemistry documents % @@ -212,9 +212,9 @@ groups: Prior to v5.0 \chemmacros\ had quite a number of load-time options. \chemmacros\ v6.0 has only two: \begin{options} - \keybool{minimal}\Default{false} + \keybool{minimal}\Initial{false} Loads \chemmacros\ with the basic preset of modules. - \keyval{modules}{comma separated list of module names}\Default + \keyval{modules}{comma separated list of module names}\Initial When \option{minimal} is used this option allows to load additional modules. \end{options} @@ -229,18 +229,18 @@ command When an option is described then in the left margin the module the option belongs to is denoted. This looks something like this: \begin{options} - \keyval{option}{value}\Module{module}\Default + \keyval{option}{value}\Module{module}\Initial Description of \option{option}. The module is printed in the left margin. The default value to the right is the setting the option has when \chemmacros\ is loaded. This can be an explicit setting but the option can also be empty. - \keychoice{choice-option}{list,of,\default{choices}}\Module{module}\Default{list} + \keychoice{choice-option}{list,of,\default{choices}}\Module{module}\Initial{list} Description of \option{choice-option}. A choice option can only be used with a predefined list of values. If one of the values is underlined it means that the option can be used without value in which case the underlined value is chosen. If no value is underlined then a value \emph{has} to be given by the user. - \keybool{boolean-option}\Module{module}\Default{true} + \keybool{boolean-option}\Module{module}\Initial{true} Description of \option{boolean-option}. A boolean option is a choice option with exactly the two values \code{true} and \code{false}. If the option is called without value then the underlined value is chosen (which @@ -341,15 +341,15 @@ Easy representation of \pH, \pKa \ldots There is one option which changes the style the \p{} is typeset, other options allow to change the subscript of the constants: \begin{options} - \keychoice{p-style}{italics,slanted,upright}\Module{acid-base}\Default{upright} + \keychoice{p-style}{italics,slanted,upright}\Module{acid-base}\Initial{upright} Set the style of the \p{} operator. - \keyval{K-acid}{text}\Module{acid-base}\Default{\cs{ChemTranslate}\Marg{K-acid}} + \keyval{K-acid}{text}\Module{acid-base}\Initial{\cs{ChemTranslate}\Marg{K-acid}} The subscript to \cs{Ka} and \cs{pKa}. - \keyval{K-base}{text}\Module{acid-base}\Default{\cs{ChemTranslate}\Marg{K-base}} + \keyval{K-base}{text}\Module{acid-base}\Initial{\cs{ChemTranslate}\Marg{K-base}} The subscript to \cs{Kb} and \cs{pKb}. - \keyval{K-water}{text}\Module{acid-base}\Default{\cs{ChemTranslate}\Marg{K-water}} + \keyval{K-water}{text}\Module{acid-base}\Initial{\cs{ChemTranslate}\Marg{K-water}} The subscript to \cs{Kw}. - \keyval{eq-constant}{text}\Module{acid-base}\Default{K} + \keyval{eq-constant}{text}\Module{acid-base}\Initial{K} The\sinceversion{5.4} symbol of the constants. \end{options} \begin{example} @@ -421,7 +421,7 @@ The \chemmodule{charges} module loads the module \chemmodule{formula}. \subsection{Ion Charges}\label{sec:ion-charges} Simple displaying of (real) charges. It is worth noting that these commands -really are relicts from a time when \chemmacros\ tried hard to be compliant +really are relics from a time when \chemmacros\ tried hard to be compliant with \pkg{mhchem} and \chemformula\ didn't exist, yet. \textbf{They are still provided for backwards compatibility but \emph{my recommendation is to use} \cs{ch} (see the documentation of the \chemformula\ @@ -465,16 +465,16 @@ section~\vref{sec:redox-module}) or with the \pkg{chemfig} package: \subsection{Charge Options} \begin{options} - \keychoice{circled}{formal,\default{all},none}\Module{charges}\Default{formal} + \keychoice{circled}{formal,\default{all},none}\Module{charges}\Initial{formal} \chemmacros\ uses two different kinds of charges which indicate the usage of real ($+/-$) and formal (\fplus/\fminus) charges. The option \code{formal} distinguishes between them, option \code{none} displays them all without circle, option \code{all} circles all. - \keychoice{circletype}{chem,math}\Module{charges}\Default{chem} + \keychoice{circletype}{chem,math}\Module{charges}\Initial{chem} This option switches between two kinds of circled charge symbols: \cs{fplus} \fplus/\cs{fminus} \fminus\ (\code{chem}) and \verbcode+$\oplus$+ $\oplus$/\verbcode+$\ominus$+ $\ominus$ (\code{math}). - \keyval{partial-format}{\LaTeX\ code}\Module{charges}\Default{\cs*{tiny}} + \keyval{partial-format}{\LaTeX\ code}\Module{charges}\Initial{\cs*{tiny}} Code which formats the macros defined with \cs{NewChemPartialCharge} (see section~\ref{sec:own-charge-macros}). \end{options} @@ -581,18 +581,18 @@ and \cs*{textsuperscript} instead of \sym{\textasciicircum} without Prints\sinceversion{5.3} a prime character in superscript position. It is defined as \verbcode+\ensuremath{{}^{\prime}}+. \command{nonbreakinghyphen} - Prints\sinceversion{5.8c} a hyphen which doesn't allow a linebreak after + Prints\sinceversion{5.8c} a hyphen which doesn't allow a line-break after it. It is defined as \verbcode+\mbox{-}\nobreak\hspace{0pt}+. \end{commands} The spaces inserted by \sym{-} and \sym{\textbar} can be customized. \begin{options} - \keyval{hyphen-pre-space}{dim}\Module{nomenclature}\Default{.01em} + \keyval{hyphen-pre-space}{dim}\Module{nomenclature}\Initial{.01em} Set the space that is inserted before the hyphen set with \sym{-}. - \keyval{hyphen-post-space}{dim}\Module{nomenclature}\Default{-.03em} + \keyval{hyphen-post-space}{dim}\Module{nomenclature}\Initial{-.03em} Set the space that is inserted after the hyphen set with \sym{-}. - \keyval{break-space}{dim}\Module{nomenclature}\Default{.01em} + \keyval{break-space}{dim}\Module{nomenclature}\Initial{.01em} Set the space inserted by \sym{\textbar}. \end{options} @@ -607,7 +607,7 @@ a number of the naming commands have very general names: \cs{meta}, \cs{D}, defines both \cs{D} and \cs{E}, for example). In order to give you control which commands are defined in which way, there is the option \option{iupac}: \begin{options} - \keychoice{iupac}{auto,restricted,strict}\Module{nomenclature}\Default{auto} + \keychoice{iupac}{auto,restricted,strict}\Module{nomenclature}\Initial{auto} Take care of how \ac{iupac} naming commands are defined. \end{options} It has three modes: @@ -734,21 +734,21 @@ Both these commands and the entgegen/zusammen descriptors get a small additional amount of kerning after the closing parenthesis. This amount can be changed through the following option: \begin{options} - \keyval{cip-kern}{dim}\Module{nomenclature}\Default{.075em} + \keyval{cip-kern}{dim}\Module{nomenclature}\Initial{.075em} Set the amount of kerning after the closing parenthesis. \end{options} The entries typeset by and implemented with \cs{cip} can be customized further: \begin{options} - \keyval{cip-outer-format}{format}\Default{\cs*{upshape}} + \keyval{cip-outer-format}{format}\Initial{\cs*{upshape}} \sinceversion{5.8}The format of parentheses and commas typeset by \cs{cip}. - \keyval{cip-inner-format}{format}\Default{\cs*{itshape}} + \keyval{cip-inner-format}{format}\Initial{\cs*{itshape}} \sinceversion{5.8}The format of the entries in \cs{cip}. This format works additive to the outer format. - \keyval{cip-number-format}{format}\Default{\cs*{upshape}} + \keyval{cip-number-format}{format}\Initial{\cs*{upshape}} \changedversion{6.0}The format of numbers in \cs{cip}. This format works - additive to the outer format and is applied to arabic figures only. + additive to the outer format and is applied to Arabic figures only. \end{options} \subsection{Fischer} @@ -813,14 +813,14 @@ Although these commands are provided I like to cite Two options allow customization: \begin{options} - \keychoice{bridge-number}{sub,super}\Module{nomenclature}\Default{sub} + \keychoice{bridge-number}{sub,super}\Module{nomenclature}\Initial{sub} Appends the number as a subscript or superscript, depending on the choice. The \ac{iupac} recommendation is the subscript~\cite{iupac:redbook}. - \keybool{coord-use-hyphen}\Module{nomenclature}\Default{true} + \keybool{coord-use-hyphen}\Module{nomenclature}\Initial{true} Append a hyphen to \cs{hapto}, \cs{dento} and \cs{bridge} or don't. \end{options} -The default behaviour\sinceversion{5.8} of \cs{hapto} and \cs{dento} has +The default behavior\sinceversion{5.8} of \cs{hapto} and \cs{dento} has changed with version~5.8 to follow \ac{iupac} recommendations. \subsection{Examples} @@ -898,7 +898,7 @@ existing ones: \subsection{Latin Phrases} -\chemmacros\ provides a command for typesetting latin phrases: +\chemmacros\ provides a command for typesetting Latin phrases: \begin{commands} \command{latin}[\oarg{options}\marg{phrase}] Typesets \meta{phrase} according to the option \option{format} described @@ -914,22 +914,22 @@ will \emph{not} define its own \cs{latin}. The last three commands mentioned above are defined through \begin{commands} \command{NewChemLatin}[\marg{cs}\marg{phrase}] - Define a new latin phrase. Gives an error if \meta{cs} already exists. + Define a new Latin phrase. Gives an error if \meta{cs} already exists. \command{DeclareChemLatin}[\marg{cs}\marg{phrase}] - Define a new latin phrase. Silently redefined existing macros. + Define a new Latin phrase. Silently redefined existing macros. \command{RenewChemLatin}[\marg{cs}\marg{phrase}] - Redefine an existing latin phrase. Gives an error if \meta{cs} doesn't + Redefine an existing Latin phrase. Gives an error if \meta{cs} doesn't exist. \command{ProvideChemLatin}[\marg{cs}\marg{phrase}] - Define a new latin phrase only if \meta{cs} doesn't exist. + Define a new Latin phrase only if \meta{cs} doesn't exist. \end{commands} \begin{example}[side-by-side] \NewChemLatin\ltn{latin text}\ltn \end{example} You can change the appearance with this option: \begin{options} - \keyval{format}{definition}\Module{nomenclature}\Default{\cs*{emph}} - \changedversion{5.7}Sets the format for the latin phrases. + \keyval{format}{definition}\Module{nomenclature}\Initial{\cs*{emph}} + \changedversion{5.7}Sets the format for the Latin phrases. \end{options} \section{The \chemmodule*{particles} Module}\label{sec:particles-module} @@ -952,10 +952,10 @@ details are explained in section~\vref{sec:defin-own-part}. The macros \cs{Nuc} and \cs{ba} are special: they have an optional argument for the following options: \begin{options} - \keychoice{elpair}{dots,dash,false}\Module{particles}\Default{false} + \keychoice{elpair}{dots,dash,false}\Module{particles}\Initial{false} Determine how the electron pair of the nucleophiles is displayed. The electron pair is drawn using \chemformula's \cs{chlewis} macro. - \keyval{space}{dim}\Module{particles}\Default{.1em} + \keyval{space}{dim}\Module{particles}\Initial{.1em} Sets\sinceversion{5.3} the space that is inserted between the electron pair and the negative charge sign. \end{options} @@ -1034,7 +1034,7 @@ A macro defined this way will have an optional argument for the \section{The \chemmodule*{phases} Module}\label{sec:phases-module} -The \chemmodule{phases} module loads the \chemmodule{formula} modul. +The \chemmodule{phases} module loads the \chemmodule{formula} module. \subsection{Basics} @@ -1059,9 +1059,9 @@ might want to put it as a subscript which is also very common. There are two options to customize the output: \begin{options} - \keychoice{pos}{side,sub}\Module{phases}\Default{side} + \keychoice{pos}{side,sub}\Module{phases}\Initial{side} Switch the position of the phase indicator. - \keyval{space}{dim}\Module{phases}\Default{.1333em} + \keyval{space}{dim}\Module{phases}\Initial{.1333em} Change the default spacing between compound a phase indicator if \keyis{pos}{side}. A \TeX\ dimension. \end{options} @@ -1175,7 +1175,7 @@ they like. this is done with the following general option: \begin{options} - \keyval{formula}{method}\Default{chemformula} + \keyval{formula}{method}\Initial{chemformula} This\sinceversion{5.1} option let's you choose how chemical formulas are typeset. Available methods are \begin{itemize} @@ -1372,10 +1372,10 @@ the \pkg{elements} package. There are options which allow you to determine how the isotope is printed: \begin{options} - \keychoice{format}{super,side}\Module{isotopes}\Default{super} + \keychoice{format}{super,side}\Module{isotopes}\Initial{super} Either print the isotope number as superscript or to the right of the element symbol. - \keyval{side-connect}{input}\Module{isotopes}\Default{-} + \keyval{side-connect}{input}\Module{isotopes}\Initial{-} Determine what is printed between the element symbol and the isotope number if \keyis{format}{side}. \end{options} @@ -1444,15 +1444,15 @@ projections. It loads the \chemmodule{tikz} module. Several options allow customization: \begin{options} - \keyval{angle}{angle}\Module{newman}\Default{0} + \keyval{angle}{angle}\Module{newman}\Initial{0} Default angle. - \keyval{scale}{factor}\Module{newman}\Default{1} + \keyval{scale}{factor}\Module{newman}\Initial{1} Scale the whole projection by factor \meta{factor}. - \keyval{ring}{tikz}\Module{newman}\Default + \keyval{ring}{tikz}\Module{newman}\Initial Customize the ring with \TikZ\ keys. - \keyval{atoms}{tikz}\Module{newman}\Default + \keyval{atoms}{tikz}\Module{newman}\Initial Customize the nodes within which the atoms are set with \TikZ\ keys. - \keyval{back-atoms}{tikz}\Module{newman}\Default + \keyval{back-atoms}{tikz}\Module{newman}\Initial Explicitly customize the nodes of the back atoms with \TikZ\ keys. \end{options} @@ -1498,16 +1498,16 @@ There are the following types available for \meta{type}: Depending on the type you have different options to modify the orbitals: \begin{options} - \keychoice{phase}{+,-}\Module{orbital}\Default{+} + \keychoice{phase}{+,-}\Module{orbital}\Initial{+} changes the phase of the orbital (all types) - \keyval{scale}{factor}\Module{orbital}\Default{1} + \keyval{scale}{factor}\Module{orbital}\Initial{1} changes the size of the orbital (all types) - \keyval{color}{color}\Module{orbital}\Default{black} + \keyval{color}{color}\Module{orbital}\Initial{black} changes the color of the orbital (all types) - \keyval{angle}{angle}\Module{orbital}\Default{0} + \keyval{angle}{angle}\Module{orbital}\Initial{0} rotates the orbitals with a p contribution counter clockwise (all types except \code{s}) - \keybool{half}\Module{orbital}\Default{false} + \keybool{half}\Module{orbital}\Initial{false} displays only half an orbital (only \code{p}) \end{options} @@ -1520,7 +1520,7 @@ Depending on the type you have different options to modify the orbitals: \orbital[angle=135,scale=1.5]{p} \orbital[half]{p} \end{example} -Additionally there are two options, with which the \TikZ\ behaviour can be +Additionally there are two options, with which the \TikZ\ behavior can be changed. \begin{options} \keybool{overlay}\Module{orbital} @@ -1612,14 +1612,14 @@ implements the following macro based on the same idea: node}\marg{closing node}] The value of \meta{depth} is the same as \meta{height} unless it is specified explicitly. \meta{opening node} and \meta{closing node} are the - names of \TikZ' nodes where the delimites are placed. + names of \TikZ' nodes where the delimiters are placed. \end{commands} \begin{options} - \keychoice{delimiters}{\Marg{\meta{left}\meta{right}}}\Module{polymers}\Default{[]} + \keychoice{delimiters}{\Marg{\meta{left}\meta{right}}}\Module{polymers}\Initial{[]} This option demands two tokens as argument, the first being the opening brace, the second the closing brace. A dot (\code{.}) denotes an empty delimiter. - \keyval{subscript}{subscript}\Module{polymers}\Default{\$n\$} + \keyval{subscript}{subscript}\Module{polymers}\Initial{\$n\$} Subscript to the right delimiter. \keyval{superscript}{superscript}\Module{polymers} Superscript to the right delimiter. @@ -1712,11 +1712,11 @@ If you want to change the layout of the counter tags, you can use \end{commands} or use the following options: \begin{options} - \keyval{tag-open}{left delimiter}\Module{reactions}\Default{\{} + \keyval{tag-open}{left delimiter}\Module{reactions}\Initial{\cs*{\{}} \sinceversion{5.6}The left delimiter. - \keyval{tag-close}{right delimiter}\Module{reactions}\Default{\}} + \keyval{tag-close}{right delimiter}\Module{reactions}\Initial{\cs*{\}}} \sinceversion{5.6}The right delimiter. - \keyval{before-tag}{format}\Module{reactions}\Default + \keyval{before-tag}{format}\Module{reactions}\Initial \sinceversion{5.6}Code inserted before the tags. \end{options} @@ -1734,7 +1734,7 @@ or use the following options: You\sinceversion{6.1} can also make reactions share a counter with math equations (by using the \code{equation} counter). \begin{options} - \keybool{own-counter}\Module{reactions}\Default{true} + \keybool{own-counter}\Module{reactions}\Initial{true} If set to false the reaction environments will use the \code{equation} counter instead of the \code{reaction} counter. \end{options} @@ -1755,15 +1755,21 @@ or \pkg{fancyref}~\cite{pkg:fancyref} and have set \keyis{own-counter}{true} the \env{reaction} counter is supported by both packages and already set up by \chemmacros. -For \pkg{fancyref} use the prefix \code{rct} by defining the following: +For \pkg{fancyref} \chemmacros' uses the prefix \code{rct} by defining the +following: \begin{sourcecode} \newcommand*\fancyrefrctlabelprefix{rct} \end{sourcecode} +You can of course redefine \cs{fancyrefrctlabelprefix} into whatever suits you +best. Also \pkg{hyperref}'s \cs*{autoref} is supported. \begin{options} - \keyval{autoref-name}{name}\Module{reactions}\Default{\cs*{ChemTranslate}\Marg{reaction}} - \sinceversion{6.1}Change the name used by \pkg{hyperref}'s \cs*{autoref}. + \keyval{autoref-name}{name}\Module{reactions}\Initial{\cs*{ChemTranslate}\Marg{reaction}} + \sinceversion{6.1}Change the name used by \pkg{hyperref}'s + \cs*{autoref}. + + Alternatively you can just redefine \cs{reactionautorefname}. \end{options} \subsection{Own Reactions} @@ -1792,7 +1798,7 @@ You can create new types of reactions with the command: \NewChemReaction{reactions*}{align*} \end{sourcecode} -Let's suppose, you'd like to have the alignment behaviour of the \env{alignat} +Let's suppose, you'd like to have the alignment behavior of the \env{alignat} environment for \chemformula\ reactions. You could do the following: \begin{sourcecode} @@ -1828,14 +1834,15 @@ the reactions created with the \env{reaction} environment. The output of this list can be modified by two options: \begin{options} \keyval{list-name}{name of the - list}\Module{reactions}\Default{\cs*{ChemTranslate}\Marg{{list-of-reactions}}} + list}\Module{reactions}\Initial{\cs*{ChemTranslate}\Marg{{list-of-reactions}}} Let's you set the name of the list manually. The default name is language - dependent, see section~\vref{sec:lang-module}. + dependent, see section~\vref{sec:lang-module}. Alternatively you can + redefine \cs{reactionlistname}. \keyval{list-entry}{prefix to each - entry}\Module{reactions}\Default{\cs*{ChemTranslate}\Marg{reaction}} + entry}\Module{reactions}\Initial{\cs*{ChemTranslate}\Marg{reaction}} Let's you set a prefix to each list entry. The default name is language dependent, see section~\vref{sec:lang-module}. - \keyval{list-heading-cmd}{code}\Module{reactions}\Default{\cs*{section}\sarg\Marg{\#1}} + \keyval{list-heading-cmd}{code}\Module{reactions}\Initial{\cs*{section}\sarg\Marg{\#1}} The\sinceversion{5.2} macro that is called at the beginning of the list. Inside of \meta{code} \code{\#1} refers to the actual heading of the list. The default setting is not entirely true: if a macro \cs*{chapter} is @@ -1985,7 +1992,7 @@ Typical uses will look like this: \subsection{Options} \begin{options} - \keybool{initiate}\Module{reactants}\Default{false} + \keybool{initiate}\Module{reactants}\Initial{false} The \pkg{chemnum} package that is internally used for numbering the reactants offers two ways of initiating a new label: either when \cs{cmpd} is first used or through \cs{initcmpd}. The \module{reactants} module @@ -1997,7 +2004,7 @@ Typical uses will look like this: Reactants are automatically numbered in the order of their first appearance, while \option{initiate} numbers the compounds in the order in which they were declared in the preamble or in an external document. - \keybool{switch}\Module{reactants}\Default{false} + \keybool{switch}\Module{reactants}\Initial{false} While \cs{reactants} will output name and number of a reactant, its starred variant \cs{reactant}\sarg, will by default result in the name without the corresponding number. Setting \keyis{switch}{true}, globally @@ -2084,19 +2091,19 @@ The options that change the units of the properties can be set with \cs{chemsetup} or in the optional argument of \cs{reactant}. Accepted units are units defined by the \pkg{siunitx} package or by the \module{units} module. \begin{options} - \keyval{mass-unit}{unit}\Module{reactants}\Default{\cs*{gram}} + \keyval{mass-unit}{unit}\Module{reactants}\Initial{\cs*{gram}} Change the unit of the \code{mass} property. - \keyval{volume-unit}{unit}\Module{reactants}\Default{\cs*{milli}\cs*{liter}} + \keyval{volume-unit}{unit}\Module{reactants}\Initial{\cs*{milli}\cs*{liter}} Change the unit of the \code{volume} property. - \keyval{fraction-unit}{unit}\Module{reactants}\Default{\code{w/w \cs*{percent}}} + \keyval{fraction-unit}{unit}\Module{reactants}\Initial{\code{w/w \cs*{percent}}} Change the unit of the \code{fraction} property. - \keyval{amount-unit}{unit}\Module{reactants}\Default{\cs*{milli}\cs*{mole}} + \keyval{amount-unit}{unit}\Module{reactants}\Initial{\cs*{milli}\cs*{mole}} Change the unit of the \code{amount} property. - \keyval{equiv-unit}{unit}\Module{reactants}\Default{\code{eq}} + \keyval{equiv-unit}{unit}\Module{reactants}\Initial{\code{eq}} Change the unit of the \code{equiv} property. - \keyval{concentration-unit}{unit}\Module{reactants}\Default{\cs*{Molar}} + \keyval{concentration-unit}{unit}\Module{reactants}\Initial{\cs*{Molar}} Change the unit of the \code{concentration} property. - \keyval{purity-unit}{unit}\Module{reactants}\Default{\cs*{percent}} + \keyval{purity-unit}{unit}\Module{reactants}\Initial{\cs*{percent}} Change the unit of the \code{purity} property. \end{options} @@ -2115,10 +2122,10 @@ output styles: \begin{options} \keychoice{reactant-output-style}{name-main-other,main-name-other,main-other-name}% \Module{reactants}\\[-\baselineskip] - \Default{name-main-other} + \Initial{name-main-other} Select one of the three predefined styles to determine the output style of the data and their units in the \cs{reactant} command. - \keychoice{solvent-output-style}{main-name,name-main}\Module{reactants}\Default{main-name} + \keychoice{solvent-output-style}{main-name,name-main}\Module{reactants}\Initial{main-name} Select one of the two predefined styles to determine the output style of the data and their units in the \cs{solvent} command. \end{options} @@ -2152,7 +2159,7 @@ contents of the categories are typeset. \end{example} \begin{options} - \keychoice{main}{default,amount,equiv}\Module{reactants}\Default{default} + \keychoice{main}{default,amount,equiv}\Module{reactants}\Initial{default} By default, only \code{mass} and \code{volume} are assigned to the \code{main} category. Using the \option{main} option, \code{equiv} or \code{amount} can be added to the main category. @@ -2169,7 +2176,7 @@ contents of the categories are typeset. \end{example} \begin{options} - \keybool{equivalents}\Module{reactants}\Default{true} + \keybool{equivalents}\Module{reactants}\Initial{true} Can be used to prevent \code{equiv} from being output while still keeping the corresponding information in the input code. If you used the \keyis{main}{equiv} option, the \keyis{equivalents}{false} option will be @@ -2239,7 +2246,7 @@ module also offers the following \code{s} and \code{l} suffixed variants: \end{commands} \begin{options} - \keychoice{acronym-support}{acro,glossaries,none}\Module{reactants}\Default{none} + \keychoice{acronym-support}{acro,glossaries,none}\Module{reactants}\Initial{none} Can be used to select, which of the two packages \pkg{acro} or \pkg{glossaries-extra} is used in the background in order to format and sort acronyms. @@ -2258,7 +2265,7 @@ As mentioned before, \cs{printreactants} can be used to print a list of all used reactants and their numbers. The \module{reactants} module internally uses either \pkg{longtable} or \pkg{xltabular} to typeset this list: \begin{options} - \keychoice{printreactants-style}{xltabular,longtable,none}\Module{reactants}\Default{none} + \keychoice{printreactants-style}{xltabular,longtable,none}\Module{reactants}\Initial{none} Can be used to switch between \pkg{longtable} and \pkg{xltabular} which are responsible for formatting the list of reactants. Be aware that with \code{longtable}, the column widths are hard coded, thus you could @@ -2304,33 +2311,33 @@ There are a number of options that can be used to modify the typeset result: \sinceversion{5.11}Allows to apply arbitrary \meta{code} in front of the typeset oxidation numbers. The last command may expect the oxidation number as an argument. An example might be \cs*{textcolor}\Marg{red}. - \keybool{parse}\Module{redox}\Default{true} + \keybool{parse}\Module{redox}\Initial{true} When \code{false} an arbitrary entry can be used for \code{<number>}. - \keybool{roman}\Module{redox}\Default{false} - Switches from roman to arabic numbers. - \keychoice{pos}{top,super,side}\Module{redox}\Default{super} + \keybool{roman}\Module{redox}\Initial{false} + Switches from Roman to Arabic numbers. + \keychoice{pos}{top,super,side}\Module{redox}\Initial{super} \code{top} places \meta{number} above \meta{atom}, \code{super} to the upper right as superscript and \code{side} to the right and inside brackets. Both \code{super} and \code{side} follow \ac{iupac} recommendation, \code{top} does not! - \keybool{explicit-sign}\Module{redox}\Default{false} - Shows the $+$ for positiv numbers and the $\pm$ for $0$. - \keybool{explizit-zero-sign}\Module{redox}\Default{true} + \keybool{explicit-sign}\Module{redox}\Initial{false} + Shows the $+$ for positive numbers and the $\pm$ for $0$. + \keybool{explizit-zero-sign}\Module{redox}\Initial{true} Only\sinceversion{5.4} if both \option{explicit-sign} and \option{explicit-zero-sign} are set to \code{true} $\pm0$ will be printed. - \keychoice{decimal-marker}{comma,point}\Module{redox}\Default{point} + \keychoice{decimal-marker}{comma,point}\Module{redox}\Initial{point} Choice for the decimal marker for formal oxidation numbers like \ox{1.2,X}. - \keychoice{align}{center,right}\Module{redox}\Default{center} + \keychoice{align}{center,right}\Module{redox}\Initial{center} Center the oxidation number relative to the atom or right-align it. - \keyval{side-connect}{code}\Module{redox}\Default{\cs*{,}} + \keyval{side-connect}{code}\Module{redox}\Initial{\cs*{,}} Code that is inserted between atom and oxidation number if \keyis{pos}{side} is used. - \keyval{text-frac}{cs}\Module{redox}\Default{\cs{chemfrac}\Oarg{text}\Marg{\#1}\Marg{\#2}} + \keyval{text-frac}{cs}\Module{redox}\Initial{\cs{chemfrac}\Oarg{text}\Marg{\#1}\Marg{\#2}} The fraction macro that is used for fractions if \keyis{pos}{side} is used. \meta{cs} must be a macro that takes two mandatory arguments, the first for the numerator and the second for the denominator. - \keyval{super-frac}{cs}\Module{redox}\Default{\cs{chemfrac}\Oarg{superscript}% + \keyval{super-frac}{cs}\Module{redox}\Initial{\cs{chemfrac}\Oarg{superscript}% \Marg{\#1}\Marg{\#2}} The fraction macro that is used for fractions if \keyis{pos}{top} or \keyis{pos}{super} is used. \meta{cs} must be a macro that takes two @@ -2386,7 +2393,7 @@ redox reactions. Both commands are using \TikZ. \command{OX}[\Marg{\meta{name},\meta{atom}}] Label \meta{atom} with the label \meta{name}. \command{redox}[\Darg{\meta{name1},\meta{name2}}\oarg{tikz}\oarg{num}\marg{text}] - Connect two \meta{atom}s previously labelled with \cs{OX}. Only the first + Connect two \meta{atom}s previously labeled with \cs{OX}. Only the first argument \Darg{\meta{name1},\meta{name2}} is required, the others are all optional. \end{commands} @@ -2423,7 +2430,7 @@ the text. The default length of the vertical lines can be customized with the option \begin{options} - \keyval{dist}{dim}\Module{redox}\Default{.6em} + \keyval{dist}{dim}\Module{redox}\Initial{.6em} A \TeX\ dimension. \end{options} @@ -2434,7 +2441,7 @@ The default length of the vertical lines can be customized with the option \end{example} \begin{options} - \keyval{sep}{dim}\Module{redox}\Default{.2em} + \keyval{sep}{dim}\Module{redox}\Initial{.2em} The option can be used to change the distance between the atom and the beginning of the line. \end{options} @@ -2545,10 +2552,13 @@ If\sinceversion{5.6} you are using either \pkg{cleveref}~\cite{pkg:cleveref} or \pkg{fancyref}~\cite{pkg:fancyref} the \env{scheme} counter is supported by both packages and already set up by \chemmacros. -For \pkg{fancyref} use the prefix \code{sch} by defining the following: +For \pkg{fancyref} \chemmacros\ uses the prefix \code{sch} by defining the +following: \begin{sourcecode} \newcommand*\fancyrefschlabelprefix{sch} \end{sourcecode} +You can of course redefine \cs{fancyrefschlabelprefix} into whatever suits you +best. \section{The \chemmodule*{spectroscopy} Module}\label{sec:spectroscopy-module} @@ -2611,16 +2621,16 @@ It is possible to define short cut commands for specific nuclei. \begin{commands} \command{NewChemNMR}[\marg{cs}\Marg{\meta{num},\meta{atom}}] Define a new shortcut macro for typesetting a certain type of magnetic - resonence data. Gives an error if \meta{cs} already exists. + resonance data. Gives an error if \meta{cs} already exists. \command{DeclareChemNMR}[\marg{cs}\Marg{\meta{num},\meta{atom}}] Define a new shortcut macro for typesetting a certain type of magnetic - resonence data. Overwrites an existing macro. + resonance data. Overwrites an existing macro. \command{RenewChemNMR}[\marg{cs}\Marg{\meta{num},\meta{atom}}] Redefine an existing shortcut macro for typesetting a certain type of - magnetic resonence data. Gives an error if \meta{cs} doesn't exist. + magnetic resonance data. Gives an error if \meta{cs} doesn't exist. \command{ProvideChemNMR}[\marg{cs}\Marg{\meta{num},\meta{atom}}] Define a new shortcut macro for typesetting a certain type of magnetic - resonence data. \meta{cs} is only defined if it doesn't exist, yet. + resonance data. \meta{cs} is only defined if it doesn't exist, yet. \end{commands} This defines a command with the same arguments as \cs{NMR} \emph{except} for @@ -2679,54 +2689,54 @@ of experimental data. The output of the environment and of the NMR commands can be customized be a number of options. \begin{options} - \keyval{unit}{unit}\Module{spectroscopy}\Default{\cs*{mega}\cs*{hertz}} + \keyval{unit}{unit}\Module{spectroscopy}\Initial{\cs*{mega}\cs*{hertz}} The used default unit. - \keychoice{nucleus}{\Marg{\meta{num},\meta{atom}}}\Module{spectroscopy}\Default{\Marg{1,H}} + \keychoice{nucleus}{\Marg{\meta{num},\meta{atom}}}\Module{spectroscopy}\Initial{\Marg{1,H}} The used default nucleus. - \keyval{connector}{code}\Module{spectroscopy}\Default{-} + \keyval{connector}{code}\Module{spectroscopy}\Initial{-} Places \meta{code} between the nucleus and the method. - \keyval{method}{code}\Module{spectroscopy}\Default{NMR} + \keyval{method}{code}\Module{spectroscopy}\Initial{NMR} The measuring method. - \keyval{format}{commands}\Module{spectroscopy}\Default + \keyval{format}{commands}\Module{spectroscopy}\Initial For example \cs*{bfseries}. - \keyval{nmr-base-format}{commands}\Module{spectroscopy}\Default + \keyval{nmr-base-format}{commands}\Module{spectroscopy}\Initial \sinceversion{5.8}Formatting instructions for the NMR base. - \keychoice{pos-number}{side,sub,super}\Module{spectroscopy}\Default{side} + \keychoice{pos-number}{side,sub,super}\Module{spectroscopy}\Initial{side} Position of the number next to the atom. - \keyval{coupling-symbol}{code}\Module{spectroscopy}\Default{J} + \keyval{coupling-symbol}{code}\Module{spectroscopy}\Initial{J} The symbol used for the coupling constant. - \keyval{coupling-unit}{unit}\Module{spectroscopy}\Default{\cs*{hertz}} + \keyval{coupling-unit}{unit}\Module{spectroscopy}\Initial{\cs*{hertz}} A \pkg{siunitx} unit. - \keychoice{coupling-pos}{side,sub}\Module{spectroscopy}\Default{side} + \keychoice{coupling-pos}{side,sub}\Module{spectroscopy}\Initial{side} Placement of the coupling nuclei next to the symbol $J$ (or rather the symbol specified with option \option{coupling-symbol}). - \keyval{coupling-nuclei-pre}{code}\Module{spectroscopy}\Default{(} + \keyval{coupling-nuclei-pre}{code}\Module{spectroscopy}\Initial{(} Code inserted before the coupling nuclei when \keyis{coupling-pos}{side}. - \keyval{coupling-nuclei-post}{code}\Module{spectroscopy}\Default{)} + \keyval{coupling-nuclei-post}{code}\Module{spectroscopy}\Initial{)} Code inserted after the coupling nuclei when \keyis{coupling-pos}{side}. - \keyval{coupling-bonds-pre}{code}\Module{spectroscopy}\Default + \keyval{coupling-bonds-pre}{code}\Module{spectroscopy}\Initial Code inserted before the coupling bonds. - \keyval{coupling-bonds-post}{code}\Module{spectroscopy}\Default{\cs*{!}} + \keyval{coupling-bonds-post}{code}\Module{spectroscopy}\Initial{\cs*{!}} Code inserted after the coupling bonds. - \keyval{coupling-pos-cs}{cs}\Module{spectroscopy}\Default{\cs*{@firstofone}} + \keyval{coupling-pos-cs}{cs}\Module{spectroscopy}\Initial{\cs*{@firstofone}} Set the macro that prints the number set with the \cs{pos} macro. This needs to be a command with one mandatory argument. - \keyval{atom-number-cs}{cs}\Module{spectroscopy}\Default{\cs*{@firstofone}} + \keyval{atom-number-cs}{cs}\Module{spectroscopy}\Initial{\cs*{@firstofone}} Set the macro that prints the number set with the \cs{\#} macro. This needs to be a command with one mandatory argument. - \keyval{atom-number-space}{dim}\Module{spectroscopy}\Default{.16667em} + \keyval{atom-number-space}{dim}\Module{spectroscopy}\Initial{.16667em} Horizontal\sinceversion{5.3} space inserted between number and atom (printed by \cs{\#}). - \keybool{parse}\Module{spectroscopy}\Default{true} + \keybool{parse}\Module{spectroscopy}\Initial{true} Treat the solvent as \chemformula\ formula (this depends on the setting of the \option{formula} option, see~\vref{sec:formula-module}) or not. - \keyval{delta}{tokens}\Module{spectroscopy}\Default + \keyval{delta}{tokens}\Module{spectroscopy}\Initial The \meta{tokens} are added after $\delta$. - \keybool{list}\Module{spectroscopy}\Default{false} + \keybool{list}\Module{spectroscopy}\Initial{false} The environment \env{experimental} is formatted as a list \keyval{list-setup}{setup}\Module{spectroscopy} Setup of the list. See below for the default settings. - \keybool{use-equal}\Module{spectroscopy}\Default{false} + \keybool{use-equal}\Module{spectroscopy}\Initial{false} Add equal sign after \cs{NMR} and \cs{data}. \end{options} @@ -2762,7 +2772,7 @@ Of course options can also be chosen with \cs{chemsetup}. \begin{sourcecode} \sisetup{separate-uncertainty,per-mode=symbol,detect-all,range-phrase=--} - \begin{experimental}[<optionen>] + \begin{experimental}[<options>] \data*{yield} \qty{17}{\milli\gram} yellow needles (\qty{0.04}{\milli\mole}, \qty{13}{\percent}). % @@ -2976,19 +2986,19 @@ This macro can be used to write the thermodynamic state variables. These options are available: \begin{options} - \keyval{pre}{text}\Module{thermodynamics}\Default{\cs{changestate}} + \keyval{pre}{text}\Module{thermodynamics}\Initial{\cs{changestate}} Code inserted before the variable. Inserted in text mode. - \keyval{post}{text}\Module{thermodynamics}\Default + \keyval{post}{text}\Module{thermodynamics}\Initial Code inserted after the variable. Inserted in text mode. - \keyval{superscript-left}{text}\Module{thermodynamics}\Default + \keyval{superscript-left}{text}\Module{thermodynamics}\Initial The left superscript. Inserted in text mode. - \keyval{superscript-right}{text}\Module{thermodynamics}\Default{\cs{standardstate}} + \keyval{superscript-right}{text}\Module{thermodynamics}\Initial{\cs{standardstate}} The right superscript. Inserted in text mode. \keyval{superscript}{text}\Module{thermodynamics} An alias of \option{superscript-right}. - \keyval{subscript-left}{text}\Module{thermodynamics}\Default + \keyval{subscript-left}{text}\Module{thermodynamics}\Initial The left subscript. Inserted in text mode. - \keyval{subscript-right}{text}\Module{thermodynamics}\Default + \keyval{subscript-right}{text}\Module{thermodynamics}\Initial The right subscript. Inserted in text mode. \keyval{subscript}{text}\Module{thermodynamics} An alias of \option{subscript-left}. @@ -3028,28 +3038,28 @@ number and unit: \end{example} \begin{options} - \keyval{pre}{text}\Module{thermodynamics}\Default{\cs{changestate}} + \keyval{pre}{text}\Module{thermodynamics}\Initial{\cs{changestate}} Code inserted before the variable. Inserted in text mode. - \keyval{post}{text}\Module{thermodynamics}\Default + \keyval{post}{text}\Module{thermodynamics}\Initial Code inserted after the variable. Inserted in text mode. - \keyval{superscript-left}{text}\Module{thermodynamics}\Default + \keyval{superscript-left}{text}\Module{thermodynamics}\Initial The left superscript. Inserted in text mode. - \keyval{superscript-right}{text}\Module{thermodynamics}\Default{\cs{standardstate}} + \keyval{superscript-right}{text}\Module{thermodynamics}\Initial{\cs{standardstate}} The right superscript. Inserted in text mode. \keyval{superscript}{text}\Module{thermodynamics} An alias of \option{superscript-right}. - \keyval{subscript-left}{text}\Module{thermodynamics}\Default + \keyval{subscript-left}{text}\Module{thermodynamics}\Initial The left subscript. Inserted in text mode. - \keyval{subscript-right}{text}\Module{thermodynamics}\Default + \keyval{subscript-right}{text}\Module{thermodynamics}\Initial The right subscript. Inserted in text mode. \keyval{subscript}{text}\Module{thermodynamics} An alias of \option{subscript-left}. - \keychoice{subscript-pos}{left,right}\Module{thermodynamics}\Default{left} - Determines wether the subscript given in \darg{subscript} is placed to the + \keychoice{subscript-pos}{left,right}\Module{thermodynamics}\Initial{left} + Determines whether the subscript given in \darg{subscript} is placed to the left or the right of the variable. - \keyval{symbol}{symbol}\Module{thermodynamics}\Default + \keyval{symbol}{symbol}\Module{thermodynamics}\Initial The symbol of the variable. Inserted in math mode. - \keyval{unit}{unit}\Module{thermodynamics}\Default + \keyval{unit}{unit}\Module{thermodynamics}\Initial A valid \pkg{siunitx} unit. \end{options} @@ -3088,28 +3098,28 @@ its settings: \end{commands} The argument \meta{options} is a comma separated list of key/value options: \begin{options} - \keyval{pre}{text}\Module{thermodynamics}\Default{\cs{changestate}} + \keyval{pre}{text}\Module{thermodynamics}\Initial{\cs{changestate}} Code inserted before the variable. Inserted in text mode. - \keyval{post}{text}\Module{thermodynamics}\Default + \keyval{post}{text}\Module{thermodynamics}\Initial Code inserted after the variable. Inserted in text mode. - \keyval{superscript-left}{text}\Module{thermodynamics}\Default + \keyval{superscript-left}{text}\Module{thermodynamics}\Initial The left superscript. Inserted in text mode. - \keyval{superscript-right}{text}\Module{thermodynamics}\Default{\cs{standardstate}} + \keyval{superscript-right}{text}\Module{thermodynamics}\Initial{\cs{standardstate}} The right superscript. \keyval{superscript}{text}\Module{thermodynamics} An alias of \option{superscript-right}. - \keyval{subscript-left}{text}\Module{thermodynamics}\Default + \keyval{subscript-left}{text}\Module{thermodynamics}\Initial The left subscript. Inserted in text mode. - \keyval{subscript-right}{text}\Module{thermodynamics}\Default + \keyval{subscript-right}{text}\Module{thermodynamics}\Initial The right subscript. Inserted in text mode. \keyval{subscript}{text}\Module{thermodynamics} An alias of \option{subscript-left}. - \keychoice{subscript-pos}{left,right}\Module{thermodynamics}\Default{left} - Determines wether the subscript given in \darg{subscript} is placed to the + \keychoice{subscript-pos}{left,right}\Module{thermodynamics}\Initial{left} + Determines whether the subscript given in \darg{subscript} is placed to the left or the right of the variable. - \keyval{symbol}{symbol}\Module{thermodynamics}\Default + \keyval{symbol}{symbol}\Module{thermodynamics}\Initial The symbol of the variable. - \keyval{unit}{unit}\Module{thermodynamics}\Default + \keyval{unit}{unit}\Module{thermodynamics}\Initial A valid \pkg{siunitx} unit. \end{options} @@ -3319,7 +3329,7 @@ loads the package \pkg{translations}~\cite{pkg:translations}. This module defines the following option: \begin{options} - \keychoice{language}{auto,\meta{language}}\Default{auto} + \keychoice{language}{auto,\meta{language}}\Initial{auto} If set to \code{auto} \chemmacros\ will detect the language used by \pkg{babel}~\cite{pkg:babel} or \pkg{polyglossia}~\cite{pkg:polyglossia} automatically, the fallback translation is English and will be used if no @@ -3365,7 +3375,7 @@ preamble: \sinceversion{6.2}Basically the same as \cs{DeclareChemTranslation} but with focus on the language instead of the key and thus has a different argument order. This command can only be used in the preamble. - \command{AddChemTranslations}[\marg{languagen}\Marg{\meta{key} = \meta{translation}}] + \command{AddChemTranslations}[\marg{language}\Marg{\meta{key} = \meta{translation}}] \sinceversion{6.2}Basically the same as \cs{DeclareChemTranslations} but with focus on the language instead of the key. It lets you define the translations of several keys for one language in one go. This command can diff --git a/macros/latex/contrib/chemmacros/chemmacros.sty b/macros/latex/contrib/chemmacros/chemmacros.sty index f9b0bf50cd..64f237e629 100644 --- a/macros/latex/contrib/chemmacros/chemmacros.sty +++ b/macros/latex/contrib/chemmacros/chemmacros.sty @@ -1,5 +1,5 @@ % -------------------------------------------------------------------------- -% the CHEMMACROS package v6.2 2022/03/05 +% the CHEMMACROS package v6.2a 2022/03/12 % % comprehensive support for typesetting chemistry documents % @@ -34,10 +34,10 @@ % -------------------------------------------------------------------------- % package information: -\tl_const:Nn \c_chemmacros_date_tl {2022/03/05} +\tl_const:Nn \c_chemmacros_date_tl {2022/03/11} \tl_const:Nn \c_chemmacros_version_major_number_tl {6} \tl_const:Nn \c_chemmacros_version_minor_number_tl {2} -\tl_const:Nn \c_chemmacros_version_subrelease_tl {} +\tl_const:Nn \c_chemmacros_version_subrelease_tl {a} \tl_const:Nx \c_chemmacros_version_number_tl { \c_chemmacros_version_major_number_tl . @@ -1708,9 +1708,9 @@ { { \ensuremath { \chemmacros_standardstate: } } } \cs_new_protected:Npn \chemmacros_standardstate: - { \mathpalette \chemmacros_standardstate_aux: \circ } + { \mathpalette \__chemmacros_standardstate: \circ } -\cs_new_protected:Npn \chemmacros_standardstate_aux: #1#2 +\cs_new_protected:Npn \__chemmacros_standardstate: #1#2 { \ooalign { @@ -3959,9 +3959,10 @@ % -------------------------------------------------------------------------- \ChemModuleEnd -\ChemModule{reactions}{2022/02/05 reaction environments} +\ChemModule{reactions}{2022/03/11 reaction environments} \newcounter {reaction} + \hook_gput_code:nnn {package/hyperref/after} {chemmacros} { \cs_if_exist:NTF \chapter @@ -4118,10 +4119,11 @@ { \bool_if:NT \l__chemmacros_reactions_counter_bool { + \chemmacros_patch_cmd:Nnn \thereaction {reaction} {equation} \cs_set_eq:NN \r@equation \r@reaction \cs_set_eq:NN \p@equation \p@reaction \cs_set_eq:NN \c@equation \c@reaction - \chemmacros_patch_cmd:Nnn \thereaction {reaction} {equation} + \cs_set_eq:NN \theequation \thereaction \chemmacros_if_package_loaded:nT {cleveref} { \crefalias {equation} {reaction} } % this only works if nobody steps counters inside reactions: diff --git a/macros/latex/contrib/easybook/README.md b/macros/latex/contrib/easybook/README.md index 0a22e71b49..6534037fd7 100644 --- a/macros/latex/contrib/easybook/README.md +++ b/macros/latex/contrib/easybook/README.md @@ -1,4 +1,4 @@ -# Easybook document class +# easybook document class `easybook` is a pure academic template created based on the `ctexbook` book document class. It also has the functions of `book` and `article` document class. Combined with the general framework design of the dissertation of many universities in China, providing multiple commands and interfaces allows users to easily customize the thesis template. Its basic macro package `easybase` can also be used with `ctex` and standard document classes. diff --git a/macros/latex/contrib/easybook/easybook.dtx b/macros/latex/contrib/easybook/easybook.dtx index 15185e97b7..698244b85f 100644 --- a/macros/latex/contrib/easybook/easybook.dtx +++ b/macros/latex/contrib/easybook/easybook.dtx @@ -15,7 +15,7 @@ %<*class> \NeedsTeXFormat{LaTeX2e}[2020/10/01] \RequirePackage{l3keys2e} -\ProvidesExplClass{easybook}{2022/03/11}{1.645} +\ProvidesExplClass{easybook}{2022/03/12}{1.646} {Easily typesetting Chinese theses or books} \bool_set_false:N \l__eb_compile_draft_bool @@ -303,7 +303,7 @@ %<*package> \NeedsTeXFormat{LaTeX2e}[2020/10/01] \RequirePackage{l3keys2e,etoolbox} -\ProvidesExplPackage{easybase}{2022/03/11}{1.645} +\ProvidesExplPackage{easybase}{2022/03/12}{1.646} {Easily typesetting Chinese theses or books} \cs_generate_variant:Nn \dim_set:Nn { NV } @@ -430,7 +430,6 @@ } \PassOptionsToPackage{list = off}{bicaption} -\PassOptionsToPackage{nonewpage}{imakeidx} \PassOptionsToPackage{upint}{newtxmath} \PassOptionsToPackage{svgnames}{xcolor} \PassOptionsToPackage{many}{tcolorbox} @@ -474,6 +473,7 @@ \newcounter{chapter} \providebool{@mainmatter} \bool_set_false:N \l__eb_class_mode_book_bool + \ctex_define:n { chapter .meta:nn = { ctex/chapter } {#1} } \ctex_define:n { chapter/tocline .code:n = { } } } \bool_if:NF \l__eb_class_mode_book_bool @@ -633,8 +633,6 @@ { \use:c { eb@mark@#1@label@layout }{##1} } } } -\cs_gset_eq:NN \easyhead \fancyhead -\cs_gset_eq:NN \easyfoot \fancyfoot \NewDocumentCommand{\markrule} {O{\textwidth}D(){ctex@frame}m>{\SplitArgument{1}{|}}O{}} {\eb_draw_markrule:nnnnn {#1} {#2} {#3} #4} @@ -888,6 +886,7 @@ { plain,hang,bottom,para,flush } { \eb_footnote_value_handle:n {#1} }, footnotetype .value_required:n = true, + footnotetype/default .meta:n = footnotetype/plain, footnotetype .initial:n = hang, fnmark-vmove .code:n = \eb_fnmate_move_set:nnn {#1} { mark } { v }, fnmark-hmove .code:n = \eb_fnmate_move_set:nnn {#1} { mark } { h }, @@ -1222,13 +1221,13 @@ \NewDocumentCommand{\counteruse}{sO{arabic}D(){.}mod()} { \IfBooleanF{#1}{\stepcounter{#4}} - \tl_set:cn { theeb@#4 } + \tl_set:cn { theeb-#4 } { \IfValueT{#5}{\use:c { the#5 }#3} \use:c {#2}{#4} } - \tl_use:c { theeb@#4 } - \eb_current_label:n { eb@#4 } + \tl_use:c { theeb-#4 } + \eb_current_label:n { eb-#4 } } \cs_new:Npn \eb_section_counter_prefix:n #1 { @@ -2323,7 +2322,7 @@ } %</package> %<*tcolorbox> -\ProvidesExplFile{eb-tcolorbox.cfg}{2022/03/11}{1.645} +\ProvidesExplFile{eb-tcolorbox.cfg}{2022/03/12}{1.646} {Customization of tcolorbox for easybook} \cs_set_protected:Npn \addtotcbstyle #1#2 @@ -2332,7 +2331,6 @@ { \tcbset{#1/.style = {#2}} } \cs_new_protected:Npn \tcbappstyle { \@ifstar{\deftcbstyle}{\addtotcbstyle} } -\cs_set_eq:NN \newtcbstyle \deftcbstyle \deftcbstyle{tc-easybox} { diff --git a/macros/latex/contrib/easybook/easybook.pdf b/macros/latex/contrib/easybook/easybook.pdf Binary files differindex 0ef1b36ef4..b8185638a7 100644 --- a/macros/latex/contrib/easybook/easybook.pdf +++ b/macros/latex/contrib/easybook/easybook.pdf diff --git a/macros/latex/contrib/easybook/easybook.tex b/macros/latex/contrib/easybook/easybook.tex index b1eb6b71b7..6935a62b41 100644 --- a/macros/latex/contrib/easybook/easybook.tex +++ b/macros/latex/contrib/easybook/easybook.tex @@ -21,8 +21,8 @@ name = easybook, color-scheme = blue, title = EASYBOOK使用手册, - version = v1.645, - date = 2022/03/11, + version = v1.646, + date = 2022/03/12, authors = 瞿毅, info = 简便地排版中文学位论文或书籍, email = q1jx@foxmail.com, @@ -168,7 +168,7 @@ 您在使用 \cls*{easybook} 文档类编写文档前可能需要具备以下的条件: \begin{itemize} \item 使用 \hologo{XeLaTeX}(推荐)或 \hologo{LuaLaTeX} 两种编译方式。 - \item 由于文档类用到了一些 \LaTeX 和依赖宏包较新的功能,需要版本至少在2020/10/01以后的 \LaTeX 内核支持,建议您安装最新的 \TeX 发行版。 + \item 由于文档类用到了一些 \LaTeX 和依赖宏包较新的功能,需要版本至少在\textbf{2020/10/01}以后的 \LaTeX 内核支持。建议您安装最新的 \TeX 发行版。 \item 虽然手册对基本用法做了介绍,但这并不是入门教程,所涉及到宏包的用法与命令也需要有了解。您应当具有一定的 \LaTeX 使用基础,可以在 \TeX 综合网站 \href{https://www.ctan.org/}{CTAN} 查看相关资源。 \end{itemize} @@ -566,7 +566,7 @@ \keyval{caption-every}{数值}\Default{1.2} 同时设置图片、表格和代码题注的行距因子。 \keyval{footnote}{数值}\Default{1.2} - 脚注内容整体的行距因子,可以使用 \option{fnpara-form} 的代码覆盖每个脚注单独的行距,从而与不同脚注的段落间距不同\footnote{若在正文区中更改脚注行距,脚注横线下方的间距不会随当前行距改变。}。 + 脚注内容整体的行距因子。可以使用 \option{fnpara-form} 的代码覆盖每个脚注单独的行距,从而与不同脚注的段落间距不同\footnote{若在正文区中更改脚注行距,脚注横线下方的间距不会随当前行距改变。}。 \begin{ctexexam} \ebspread{footnote = 1.3} \ebhdrset{fnpara-form = \linespread{1.2}\selectfont} @@ -632,10 +632,10 @@ 使用由 \cs*{defbibfilter} 定义的 \option*{filter} 来过滤条目。 \end{options} - 可能在一些情况下您希望更加灵活地设置参考文献或有更多需求,下面举一个在导言区手动配置 \pkg*{biblatex} 宏包并使一个条目\textbf{同时输出}双语文献的例子: + 可能在一些情况下您希望更加灵活地设置参考文献或有更多需求,下面举一个在导言区手动配置 \pkg*{biblatex} 宏包并使一个条目输出双语对照文献的例子: \begin{ctexexam} - \usepackage[style = numeric]{biblatex} - \addbibresource{myrefs.bib} + \usepackage[style = gb7714-2015]{biblatex} + \addbibresource{reference.bib} \defbibheading{bibliography}[参考文献] % 定义参考文献标题 {\chapter*{#1}\markboth{#1}{#1}} \defbibentryset{Zhang2022}{张三2022,ZhangSan2022} @@ -1098,8 +1098,8 @@ boxrule = 5pt,boxsep = 5pt, borderline = {2pt}{2pt}{white} } - \newtcolorbox{mytcbox}[1][]{enhanced,mytcb,title = #1} - \begin{tcolorbox}[mytcb,enhanced] + \newtcolorbox{mytcbox}[1][]{enhanced,fancy,title = #1} + \begin{tcolorbox}[fancy,enhanced] 盒子内容 \end{tcolorbox} \begin{mytcbox}[盒子标题] @@ -1156,7 +1156,7 @@ 除了以普通公式的方式,化学式还可用 \pkg*{chemformula} 实现。无机化学式使用 \cs{ch} 命令书写。化合物表达式中的原子数不需要加下标符号,化学计量数与表达式间隔一个空格。 \begin{ctexexam} \ch{[Cu(NH3)4]^2+} - \ch{Cu2S + 2 O2 - 2 e^- == 2 Cu^2+ + SO^{2-}_4} + \ch{Cu2S + 2 O2 - 2 e^- == 2 Cu^2+ + SO4^2-} \end{ctexexam} \end{commands} @@ -1166,9 +1166,9 @@ \command{counteruse}[\sarg\oarg{编号}\darg{分隔符}\marg{计数器}\oarg{父计数器}] 命令 \cs{newcounter} 是 \LaTeX 自带的创建计数器命令,计数器值输出命令 \cs{counteruse} 将会以 \cs*{the}\meta{父计数器}\meta{分隔符}\cs*{the}\meta{计数器} 形式输出这种计数器的值。命令 \cs{counteruse} 仅具有\textbf{输出功能},并不会改变计数器原有的绑定关系。默认每使用一次命令 \meta{计数器} 的值增加1,带有星号参数的命令使 \meta{计数器} 的值保持不变。计数器的 \meta{编号} 为 \code{arabic} 或 \code{alph} 等计数形式。 - 在一定的场合下可能用到 \cs{counteruse} 命令,比如通过新建快捷命令在一些位置使用定理环境的计数器,使用 \cs{labelformat} 设置计数器的标签引用需添加 \code{eb@}: + 在一定的场合下可能用到 \cs{counteruse} 命令,比如通过新建快捷命令在一些位置使用定理环境的计数器。使用 \cs{labelformat} 设置计数器的标签引用时需添加 \code{eb-} 前缀: \begin{ctexexam} - \labelformat{eb@theorem}{定理#1} + \labelformat{eb-theorem}{定理#1} \newcommand{\theoremhead}[1]{定理\counteruse{theorem}[chapter]\hspace{1em}#1} \theoremhead{定理内容}\label{thm:theorem} \end{ctexexam} @@ -1212,12 +1212,12 @@ \begin{commands} \command{indexsetup}[\marg{键值列表}] \pkg*{imakeidx} 宏包增强了索引的功能。这是它的的接口命令,用于设置索引表的整体格式。 - \command*{index}[\oarg{索引名}\marg{标签}] - 索引标签命令 \cs*{index} 的 \meta{索引名} 与索引输出命令 \cs{printindex} 一致,可以存在多个索引表。 - \command*{makeindex}[\oarg{键值列表}] - 使用 \cs*{makeindex} 命令开启索引收集。这个命令可以重复使用打印多个索引表,以不同的 \meta{索引名} 作为区分,如果仅打印一个索引表就没必要再使用。 + \command{index}[\oarg{索引名}\marg{标签}] + 索引标签命令的可选参数可以用不同的 \meta{索引名} 给多个索引表设置标签。 + \command{makeindex}[\oarg{键值列表}] + 用于导言区开启索引收集的命令。这个命令可以重复使用收集多个索引表,以不同的 \meta{索引名} 作为区分,如果仅打印一个索引表没必要重复使用。 \command{printindex}[\sarg\oarg{键值列表}] - 现在索引表生成命令 \cs{printindex} 被重新定义。\meta{键值列表} 中的选项与\ref{sec:document command} 其它目录命令相同,但是原本接口命令 \cs{indexsetup} 的部分选项失效。 + 打印不同索引表的命令。这个命令被重新定义,\meta{键值列表} 中的选项与\ref{sec:document command} 其它目录命令相同,但是接口命令 \cs{indexsetup} 的部分选项失效。 \begin{options} \keyval{name}{索引名} 指定输出名为 \meta{索引名} 的索引表,如果只使用一个索引表则默认为项目文件名不需要指定。 diff --git a/macros/latex/contrib/profcollege/doc/ProfCollege-doc.pdf b/macros/latex/contrib/profcollege/doc/ProfCollege-doc.pdf Binary files differindex d5bd2b6749..77976e2bf7 100644 --- a/macros/latex/contrib/profcollege/doc/ProfCollege-doc.pdf +++ b/macros/latex/contrib/profcollege/doc/ProfCollege-doc.pdf diff --git a/macros/latex/contrib/profcollege/latex/ProfCollege.sty b/macros/latex/contrib/profcollege/latex/ProfCollege.sty index 8497e8d9d3..5e1c717793 100644 --- a/macros/latex/contrib/profcollege/latex/ProfCollege.sty +++ b/macros/latex/contrib/profcollege/latex/ProfCollege.sty @@ -3,7 +3,7 @@ % or later, see http://www.latex-project.org/lppl.txtf \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{ProfCollege}[2022/02/17 v0.99-l Aide pour l'utilisation de LaTeX au collège] +\ProvidesPackage{ProfCollege}[2022/03/10 v0.99-m Aide pour l'utilisation de LaTeX au collège] \RequirePackage{verbatim} @@ -14,11 +14,13 @@ \RequirePackage{siunitx} \sisetup{% locale=FR,% - detect-all,% + mode = match, propagate-math-font = true,% + reset-math-version = false, reset-text-family = false,% + reset-text-series = false, reset-text-shape = false,% + text-family-to-math = true, text-series-to-math = true,% output-decimal-marker={,},% group-minimum-digits=4% }% - \DeclareSIUnit{\kmh}{\km\per\hour} \newcommand\speed[1]{\SI{#1}{\kmh}} \newcommand\Speed[1]{\SI[per-mode=symbol]{#1}{\kmh}} @@ -1690,7 +1692,7 @@ transform canvas={xshift=0em,yshift=0em}},rectangle,rounded corners,ultra thick, }{% \TableMultiplicationSeule{#2}% }% - }{ + }{% \ifboolKV[Tables]{Addition}{% \TableAdditionComplete% }{% @@ -2526,6 +2528,64 @@ transform canvas={xshift=0em,yshift=0em}},rectangle,rounded corners,ultra thick, }% %%% +% Mots croisés +%%% +\setKVdefault[ClesCroises]{Lignes=6,Colonnes=8,Solution=false,Croises=false,Couleur=gray,Largeur=1em} + +\newcounter{PfCLettreHorizontal} + +\newcommand\MotsCroises[2][]{% + \useKVdefault[ClesCroises]% + \setKV[ClesCroises]{#1}% + \setcounter{PfCLettreHorizontal}{0}% + \setsepchar[*]{§*,*/}% + \readlist*\ListeCasesCroises{#2}% + \begin{NiceTabular}{*{\fpeval{\useKV[ClesCroises]{Colonnes}}}{p{\useKV[ClesCroises]{Largeur}}}}[first-row,first-col]% + \xintFor* ##1 in {\xintSeq{1}{\fpeval{\useKV[ClesCroises]{Colonnes}}}}\do{% + &\ifboolKV[ClesCroises]{Croises}{\stepcounter{PfCLettreHorizontal}\footnotesize\Alph{PfCLettreHorizontal}}{} + }\\ + \xintFor* ##1 in {\xintSeq{1}{\fpeval{\useKV[ClesCroises]{Lignes}}}}\do{% + \ifboolKV[ClesCroises]{Croises}{\footnotesize##1}{}\xintFor* ##2 in {\xintSeq{1}{\fpeval{\useKV[ClesCroises]{Colonnes}}}}\do{% + &\IfStrEq{\ListeCasesCroises[##1,##2,1]}{!}{% + }{% + \IfStrEq{\ListeCasesCroises[##1,##2,1]}{*}{% + \Block[draw,fill=black]{}{\PfCTBstrut}}{% + \IfStrEq{\ListeCasesCroises[##1,##2,1]}{+}{% + \Block[draw,fill=\useKV[ClesCroises]{Couleur}]{}{% + \PfCTBstrut\ifboolKV[ClesCroises]{Solution}{% + \ListeCasesCroises[##1,##2,2]% + }{}% + } + }{% + \Block[draw]{}{\PfCTBstrut\ifboolKV[ClesCroises]{Solution}{% + \ListeCasesCroises[##1,##2,2]}{}% + }% + }% + }% + }% + }\\ + }% + \CodeAfter + \xintFor* ##1 in {\xintSeq{1}{\fpeval{\useKV[ClesCroises]{Lignes}}}}\do{% + \xintFor* ##2 in {\xintSeq{1}{\fpeval{\useKV[ClesCroises]{Colonnes}}}}\do{% + \IfStrEq{\ListeCasesCroises[##1,##2,1]}{!}{% + }{% + \IfStrEq{\ListeCasesCroises[##1,##2,1]}{*}{% + }{% + \IfStrEq{\ListeCasesCroises[##1,##2,1]}{+}{% + }{% + \xintifboolexpr{\fpeval{\ListeCasesCroises[##1,##2,1]}>0}{\tikz\node[transform canvas={xshift=1mm,yshift=-1mm}] at (\fpeval{##1}-|\fpeval{##2}){\tiny\ListeCasesCroises[##1,##2,1]};}{}% + }% + }% + }% + }% + }% + \end{NiceTabular}% + \setsepchar{,}% +}% + + +%%% % Mots empilés %%% \setKVdefault[ClesMotEmpile]{Colonne=4,Solution=false,Couleur=black} @@ -7163,9 +7223,10 @@ couleur indiquée, le nombre de cases donné par le résultat du calcul. %%% % Nombre Premier %%% -\setKVdefault[ClesNombrePremier]{Tableau=false,TableauVertical=false,TableauVerticalVide=false,Exposant=false,Longue=false,All=false,Arbre=false,ArbreVide=false,ArbreComplet=false,Diviseurs=false,DiviseursT=false,Dot=\dotfill,Impose=false,ImposeAll=false,Potence=false} -\defKV[ClesNombrePremier]{Nombre=\setKV[ClesNombrePremier]{Impose}} -\defKV[ClesNombrePremier]{AllNombre=\setKV[ClesNombrePremier]{ImposeAll}} +\setKVdefault[ClesNombrePremier]{Tableau=false,TableauVertical=false,TableauVerticalVide=false,Exposant=false,Longue=false,All=false,Arbre=false,ArbreVide=false,ArbreComplet=false,ArbreDessine=false,ArbreDessineVide=false,Entoure=false,Entourefin=false,Diviseurs=false,DiviseursT=false,Dot=\dotfill,Impose=false,ImposeAll=false,Potence=false,Decalage=10,Vide=false,CouleurFeuillage=ForestGreen,CouleurTronc=BurlyWood,CouleurFruits=Red,CouleurTexte=white}% +\defKV[ClesNombrePremier]{Nombre=\ifboolKV[ClesNombrePremier]{ArbreDessine}{}{\ifboolKV[ClesNombrePremier]{ArbreDessineVide}{}{\setKV[ClesNombrePremier]{Impose}}}}% +\defKV[ClesNombrePremier]{AllNombre=\setKV[ClesNombrePremier]{ImposeAll}}% +\defKV[ClesNombrePremier]{Impression=\setKV[ClesNombrePremier]{CouleurFeuillage=white,CouleurTronc=white,CouleurFruits=gris,CouleurTexte=black}} \newcommand\Decomposition[2][]{% \useKVdefault[ClesNombrePremier]% @@ -7181,414 +7242,333 @@ couleur indiquée, le nombre de cases donné par le résultat du calcul. \ifboolKV[ClesNombrePremier]{All}{\NombrePremierExposant{#2}}{}% \ifboolKV[ClesNombrePremier]{Arbre}{\MPArbre{#2}}{}% \ifboolKV[ClesNombrePremier]{ArbreComplet}{\MPArbreComplet{#2}}{}% + \ifboolKV[ClesNombrePremier]{ArbreVide}{\MPArbreVide{#2}}{}% + \ifboolKV[ClesNombrePremier]{ArbreDessine}{\MPArbreDessine{#2}{\useKV[ClesNombrePremier]{Nombre}}}{}% + \ifboolKV[ClesNombrePremier]{ArbreDessineVide}{\setKV[ClesNombrePremier]{Vide=true}\MPArbreDessine{#2}{\useKV[ClesNombrePremier]{Nombre}}}{}% \ifboolKV[ClesNombrePremier]{Diviseurs}{\ListeDiviseur{#2}}{}% \ifboolKV[ClesNombrePremier]{DiviseursT}{\ListeDiviseurT{#2}}{}% - \ifboolKV[ClesNombrePremier]{ArbreVide}{\MPArbreVide{#2}}{}% }% \def\MPArbre#1{% \ifluatex - \mplibforcehmode + \mplibforcehmode \begin{mplibcode} + input PfCArithmetique; numeric depart; pair Ancre[]; numeric decalage; - decalage=10mm; + decalage=\useKV[ClesNombrePremier]{Decalage}*1mm; - vardef PremierSimple(expr NB)= - b:=2; - depart:=NB; - if Estcepremier(depart)=false: + k:=0; + Ancre0:=(0,0); + racine:=#1; + + label(btex \num{#1} etex,(0,0)); forever: - if (depart mod b)=0: - Ancre[k+1]-Ancre[k]=(-decalage*0.5,-decalage); - Ancre[k+2]-Ancre[k+1]=(decalage,0); - depart:=depart div b; - label(TEX("\num{"&decimal(b)&"}"),Ancre[k+1]); - label(TEX("\num{"&decimal(depart)&"}"),Ancre[k+2]); - draw 1/5[Ancre[k],Ancre[k+1]]--4/5[Ancre[k],Ancre[k+1]]; - draw 1/5[Ancre[k],Ancre[k+2]]--4/5[Ancre[k],Ancre[k+2]]; - k:=k+2; - racine:=depart; - depart:=1; - else: - b:=b+1; - fi; - exitif depart=1; + PremierSimple(racine); + exitif racine=1; endfor; - else: - racine:=1; - fi; -enddef; - -vardef Estcepremier(expr NBa)= - boolean $; - c:=2; - departa:=NBa; - test:=1; - $=true; - if departa=1: - $:=false; - else: - forever: - if (departa mod c)=0: - departa:=departa div c; - test:=test+1; - else: - c:=c+1; - fi; - exitif departa=1; + + if \useKV[ClesNombrePremier]{Entoure}: + for l=1 upto k: + if Estcepremier(retenirnb[l]): + draw cercles(Ancre[l],0.25*decalage); + fi; endfor; - fi; - if test=2: - $:=true - else: - $:=false; - fi; - $ - enddef; - k:=0; - Ancre0:=(0,0); - racine:=#1; - - label(btex \num{#1} etex,(0,0)); - forever: - PremierSimple(racine); - exitif racine=1; - endfor; + fi; \end{mplibcode} \else - \begin{mpost} + \begin{mpost}[mpsettings={numeric decalage;decalage=\useKV[ClesNombrePremier]{Decalage}*1mm; boolean Entoure; Entoure=\useKV[ClesNombrePremier]{Entoure};}] + input PfCArithmetique; numeric depart; pair Ancre[]; - numeric decalage; - decalage=10mm; - vardef PremierSimple(expr NB)= - b:=2; - depart:=NB; - if Estcepremier(depart)=false: + k:=0; + Ancre0:=(0,0); + racine:=#1; + label(LATEX("\num{"&decimal(racine)&"}"),(0,0)); forever: - if (depart mod b)=0: - Ancre[k+1]-Ancre[k]=(-decalage*0.5,-decalage); - Ancre[k+2]-Ancre[k+1]=(decalage,0); - depart:=depart div b; - label(LATEX("\num{"&decimal(b)&"}"),Ancre[k+1]); - label(LATEX("\num{"&decimal(depart)&"}"),Ancre[k+2]); - draw 1/5[Ancre[k],Ancre[k+1]]--4/5[Ancre[k],Ancre[k+1]]; - draw 1/5[Ancre[k],Ancre[k+2]]--4/5[Ancre[k],Ancre[k+2]]; - k:=k+2; - racine:=depart; - depart:=1; - else: - b:=b+1; - fi; - exitif depart=1; - endfor; - else: - racine:=1; - fi; -enddef; - -vardef Estcepremier(expr NBa)= - boolean $; - c:=2; - departa:=NBa; - test:=1; - $=true; - if departa=1: - $:=false; - else: - forever: - if (departa mod c)=0: - departa:=departa div c; - test:=test+1; - else: - c:=c+1; - fi; - exitif departa=1; + PremierSimplePdf(racine); + exitif racine=1; endfor; - fi; - if test=2: - $:=true - else: - $:=false; - fi; - $ - enddef; - k:=0; - Ancre0:=(0,0); - racine:=#1; - label(LATEX("\num{"&decimal(racine)&"}"),(0,0)); - forever: - PremierSimple(racine); - exitif racine=1; - endfor; + if \useKV[ClesNombrePremier]{Entoure}: + for l=1 upto k: + if Estcepremier(retenirnb[l]): + draw cercles(Ancre[l],0.25*decalage); + fi; + endfor; + fi; \end{mpost} \fi } \def\MPArbreComplet#1{% \ifluatex - \mplibforcehmode + \mplibforcehmode \begin{mplibcode} - beginfig(1); + input PfCArithmetique; numeric depart; pair Ancre[]; numeric decalage; - decalage=7.5mm; + decalage=\useKV[ClesNombrePremier]{Decalage}*1mm; -vardef NbEtape(expr nb)= - b:=2; - depart:=nb; - etape:=0; - Stock[0][0]=depart; - forever: - if (depart mod b)=0: - etape:=etape+1; - if etape=1: - Stock[etape][0]=b; - Stock[etape][etape]:=depart div b; - else: - for k=0 upto etape-2: - Stock[etape][k]:=Stock[etape-1][k]; - endfor; - Stock[etape][etape-1]:=b; - Stock[etape][etape]:=depart div b; - fi; - depart:=depart div b; - else: - b:=b+1; - fi; - exitif depart=1; - endfor; - etape -enddef; - -dx:=1cm; -dy:=1cm; - -pair N[][]; - -vardef Positions(expr Step)= - for k=0 upto (Step-1): - for l=0 upto k: - N[k][l]=(-k*dx+(l+k*.5)*dx,-k*dy); - label(TEX("\num{"&decimal(Stock[k][l])&"}"),N[k][l]); - endfor; - for l=0 upto k-1: - label(btex $\times$ etex,1/2[N[k][l],N[k][l+1]]); - endfor; - endfor; - for k=0 upto (Step-1): - for l=0 upto (k-1): - draw 1/5[N[k][l],N[k-1][l]]--4/5[N[k][l],N[k-1][l]]; - endfor; - if k>0: - draw 1/5[N[k][k],N[k-1][k-1]]--4/5[N[k][k],N[k-1][k-1]]; - fi; - endfor; - enddef; - - Positions(NbEtape(#1)); + dx:=1cm; + dy:=1cm; + + pair N[][]; + nbe:=NbEtape(#1); + Positions(nbe); + if \useKV[ClesNombrePremier]{Entoure}: + draw polygone(N[nbe-1][0]+(-0.25*dx,0.25*decalage),N[nbe-1][nbe-1]+(0.25*dx,0.25*decalage),N[nbe-1][nbe-1]+(0.25*dx,-0.25*decalage),N[nbe-1][0]+(-0.25*dx,-0.25*decalage)) dashed evenly; + fi; \end{mplibcode} \else - \begin{mpost} + \begin{mpost}[mpsettings={numeric decalage;decalage=\useKV[ClesNombrePremier]{Decalage}*1mm;}] + input PfCArithmetique; numeric depart; -pair Ancre[]; -numeric decalage; -decalage=7.5mm; - -vardef NbEtape(expr nb)= - b:=2; - depart:=nb; - etape:=0; - Stock[0][0]=depart; - forever: - if (depart mod b)=0: - etape:=etape+1; - if etape=1: - Stock[etape][0]=b; - Stock[etape][etape]:=depart div b; - else: - for k=0 upto etape-2: - Stock[etape][k]:=Stock[etape-1][k]; - endfor; - Stock[etape][etape-1]:=b; - Stock[etape][etape]:=depart div b; - fi; - depart:=depart div b; - else: - b:=b+1; - fi; - exitif depart=1; - endfor; - etape -enddef; - -dx:=1cm; -dy:=1cm; + pair Ancre[]; -pair N[][]; + dx:=1cm; + dy:=1cm; -vardef Positions(expr Step)= - for k=0 upto (Step-1): - for l=0 upto k: - N[k][l]=(-k*dx+(l+k*.5)*dx,-k*dy); - label(LATEX("\num{"&decimal(Stock[k][l])&"}"),N[k][l]); - endfor; - for l=0 upto k-1: - label(btex $\times$ etex,1/2[N[k][l],N[k][l+1]]); - endfor; - endfor; - for k=0 upto (Step-1): - for l=0 upto (k-1): - draw 1/5[N[k][l],N[k-1][l]]--4/5[N[k][l],N[k-1][l]]; - endfor; - if k>0: - draw 1/5[N[k][k],N[k-1][k-1]]--4/5[N[k][k],N[k-1][k-1]]; - fi; - endfor; - enddef; + pair N[][]; - Positions(NbEtape(#1)); + PositionsPdf(NbEtape(#1)); \end{mpost} \fi } \def\MPArbreVide#1{% \ifluatex - \mplibforcehmode + \mplibforcehmode \begin{mplibcode} + input PfCArithmetique; numeric depart; pair Ancre[]; numeric decalage; - decalage=7.5mm; - -vardef NbEtape(expr nb)= - b:=2; - depart:=nb; - etape:=0; - Stock[0][0]=depart; - forever: - if (depart mod b)=0: - etape:=etape+1; - if etape=1: - Stock[etape][0]=b; - Stock[etape][etape]:=depart div b; - else: - for k=0 upto etape-2: - Stock[etape][k]:=Stock[etape-1][k]; - endfor; - Stock[etape][etape-1]:=b; - Stock[etape][etape]:=depart div b; - fi; - depart:=depart div b; - else: - b:=b+1; - fi; - exitif depart=1; - endfor; - etape -enddef; - -dx:=1cm; -dy:=1cm; + decalage=\useKV[ClesNombrePremier]{Decalage}*1mm; + + dx:=1cm; + dy:=1cm; + + pair N[][]; + + PositionsVide(NbEtape(#1)); + \end{mplibcode} + \else + \begin{mpost}[mpsettings={numeric decalage; decalage=\useKV[ClesNombrePremier]{Decalage}*1mm;}] + input PfCArithmetique; + numeric depart; + pair Ancre[]; + + dx:=1cm; + dy:=1cm; -pair N[][]; + pair N[][]; -vardef Positions(expr Step)= + PositionsVidePdf(NbEtape(#1)); + \end{mpost} + \fi +} - for k=0 upto (Step-1): - for l=0 upto k: - N[k][l]=(-k*dx+(l+k*.5)*dx,-k*dy); +\def\MPArbreDessine#1#2{% + \ifluatex% + \mplibforcehmode% + \begin{mplibcode} + input PfCArithmetique; + numeric depart; + pair Ancre[]; + numeric decalage; + decalage=\useKV[ClesNombrePremier]{Decalage}*1mm; + rayonfruits:=3mm; + + color CouleurTronc,CouleurFeuillage,CouleurFruits,CouleurTexte; + CouleurTronc=\useKV[ClesNombrePremier]{CouleurTronc}; + CouleurFeuillage=\useKV[ClesNombrePremier]{CouleurFeuillage}; + CouleurFruits=\useKV[ClesNombrePremier]{CouleurFruits}; + CouleurTexte=\useKV[ClesNombrePremier]{CouleurTexte}; + + k:=0; + Ancre0:=(0,0); + racine:=#1; + k:=1; + Ancre1:=(-decalage,-decalage); + draw Branche(Ancre0,Ancre1); + retenirnb[1]:=#2; + racine:=#2; + forever: + PremierSimpleArbre(racine); + exitif racine=1; endfor; - for l=0 upto k-1: - label(btex $\times$ etex,1/2[N[k][l],N[k][l+1]]); + k:=k+1; + Ancre[k]:=(decalage,-decalage); + draw Branche(Ancre0,Ancre[k]); + retenirnb[k]:=#1 div #2; + racine:=retenirnb[k]; + forever: + PremierSimpleArbre(racine); + exitif racine=1; endfor; - endfor; - for k=0 upto (Step-1): - for l=0 upto (k-1): - draw 1/5[N[k][l],N[k-1][l]]--4/5[N[k][l],N[k-1][l]]; + + fill cercles(Ancre[0],rayonfruits) withcolor white; + label(btex \num{#1} etex,(0,0)); + for l=1 upto k: + if \useKV[ClesNombrePremier]{Vide}: + fill cercles(Ancre[l],rayonfruits) withcolor white; + else: + if Estcepremier(retenirnb[l]): + fill cercles(Ancre[l],rayonfruits) withcolor CouleurFruits; + drawoptions(withcolor CouleurTexte); + label(TEX("\num{"&decimal(retenirnb[l])&"}"),Ancre[l]); + drawoptions(); + else: + fill cercles(Ancre[l],rayonfruits) withcolor white; + label(TEX("\num{"&decimal(retenirnb[l])&"}"),Ancre[l]); + fi; + fi; endfor; - if k>0: - draw 1/5[N[k][k],N[k-1][k-1]]--4/5[N[k][k],N[k-1][k-1]]; + for l=0 upto k: + draw cercles(Ancre[l],rayonfruits); + endfor; + picture Bilan; + Bilan=currentpicture; + currentpicture:=nullpicture; + % Habillage + % On récupère le min des ordonnées des Ancre pour le feuillage + minord=1000; + nbancrearetenir=0; + for l=0 upto k: + if ypart(Ancre[l])<minord: + minord:=ypart(Ancre[l]); + nbancrearetenir:=l; fi; endfor; - label(TEX("\num{"&decimal(Stock[0][0])&"}"),N[0][0]); - enddef; - - Positions(NbEtape(#1)); + pair D[]; + D0=0.5[Ancre0,(0,ypart(Ancre[nbancrearetenir]))]; + dotlabel("",D0); + % Herbe du sol + pair A[]; + A0=(xpart(Ancre0)-1cm,ypart(Ancre[nbancrearetenir])-2cm); + A10=(xpart(Ancre0)+1cm,ypart(Ancre[nbancrearetenir])-2cm); + for l=1 upto 9: + A[l]=(l/10)[A0,A10]+uniformdeviate(5)*(unitvector(A10-A0) rotated 90); + endfor; + %Pour le tronc + pair B[]; + B1=D0+(10+uniformdeviate(10))*(unitvector(D0-A0) rotated 90); + B2=symetrie(B1,Ancre0,1/2[A0,A10]);%=(-2mm,0); + B3=1/2[Ancre0,(xpart(1/2[A0,A10]),ypart(Ancre[k]))]; + path tronc; + tronc=A0{dir angle(A1-A0)}..{dir90}B1--B2{dir-90}..{dir angle(A10-A9)}A10--reverse(A0 for l=1 upto 10:--A[l] endfor)--cycle;% + fill tronc withcolor CouleurTronc; + trace tronc; + % Pour le feuillage + path feuillage; + feuillage=cercles((0,0),abs(Ancre[nbancrearetenir]-D0));% + pair C[]; + for l=0 upto 7: + C[l]=(pointarc(feuillage,l*45+(-5+uniformdeviate(10))) xscaled 1.25 yscaled 1) shifted D0; + endfor; + feuillage:=C[0] for l=1 upto 7:..(C[l] if (l mod 2)=0:+(0,2mm) else: +(0,-2mm) fi) endfor ..cycle; + fill feuillage withcolor CouleurFeuillage; + trace feuillage; + draw Bilan; \end{mplibcode} \else - \begin{mpost} + \begin{mpost}[mpsettings={numeric decalage;decalage=\useKV[ClesNombrePremier]{Decalage}*1mm;color CouleurTronc,CouleurFeuillage,CouleurFruits,CouleurTexte;CouleurTronc=\useKV[ClesNombrePremier]{CouleurTronc};CouleurFeuillage=\useKV[ClesNombrePremier]{CouleurFeuillage};CouleurFruits=\useKV[ClesNombrePremier]{CouleurFruits}; CouleurTexte=\useKV[ClesNombrePremier]{CouleurTexte}; boolean Vide; Vide=\useKV[ClesNombrePremier]{Vide};}] + input PfCArithmetique; numeric depart; pair Ancre[]; -numeric decalage; -decalage=7.5mm; - -vardef NbEtape(expr nb)= - b:=2; - depart:=nb; - etape:=0; - Stock[0][0]=depart; - forever: - if (depart mod b)=0: - etape:=etape+1; - if etape=1: - Stock[etape][0]=b; - Stock[etape][etape]:=depart div b; - else: - for k=0 upto etape-2: - Stock[etape][k]:=Stock[etape-1][k]; - endfor; - Stock[etape][etape-1]:=b; - Stock[etape][etape]:=depart div b; - fi; - depart:=depart div b; + rayonfruits:=3mm; + + k:=0; + Ancre0:=(0,0); + racine:=#1; + k:=1; + Ancre1:=(-decalage,-decalage); + draw Branche(Ancre0,Ancre1); + retenirnb[1]:=#2; + racine:=#2; + forever: + PremierSimpleArbre(racine); + exitif racine=1; + endfor; + k:=k+1; + Ancre[k]:=(decalage,-decalage); + draw Branche(Ancre0,Ancre[k]); + retenirnb[k]:=#1 div #2; + racine:=retenirnb[k]; + forever: + PremierSimpleArbre(racine); + exitif racine=1; + endfor; + + fill cercles(Ancre[0],rayonfruits) withcolor white; + label(btex \num{#1} etex,(0,0)); + for l=1 upto k: + if Vide: + fill cercles(Ancre[l],rayonfruits) withcolor white; else: - b:=b+1; + if Estcepremier(retenirnb[l]): + fill cercles(Ancre[l],rayonfruits) withcolor CouleurFruits; + drawoptions(withcolor CouleurTexte); + label(LATEX("\num{"&decimal(retenirnb[l])&"}"),Ancre[l]); + drawoptions(); + else: + fill cercles(Ancre[l],rayonfruits) withcolor white; + label(LATEX("\num{"&decimal(retenirnb[l])&"}"),Ancre[l]); + fi; fi; - exitif depart=1; - endfor; - etape -enddef; - -dx:=1cm; -dy:=1cm; - -pair N[][]; - -vardef Positions(expr Step)= - - for k=0 upto (Step-1): - for l=0 upto k: - N[k][l]=(-k*dx+(l+k*.5)*dx,-k*dy); - endfor; - for l=0 upto k-1: - label(btex $\times$ etex,1/2[N[k][l],N[k][l+1]]); endfor; - endfor; - for k=0 upto (Step-1): - for l=0 upto (k-1): - draw 1/5[N[k][l],N[k-1][l]]--4/5[N[k][l],N[k-1][l]]; + for l=0 upto k: + draw cercles(Ancre[l],rayonfruits); endfor; - if k>0: - draw 1/5[N[k][k],N[k-1][k-1]]--4/5[N[k][k],N[k-1][k-1]]; + picture Bilan; + Bilan=currentpicture; + currentpicture:=nullpicture; + % Habillage + minord=1000; + nbancrearetenir=0; + for l=0 upto k: + if ypart(Ancre[l])<minord: + minord:=ypart(Ancre[l]); + nbancrearetenir:=l; fi; endfor; - label(LATEX("\num{"&decimal(Stock[0][0])&"}"),N[0][0]); - enddef; - - Positions(NbEtape(#1)); + pair D[]; + D0=0.5[Ancre0,(0,ypart(Ancre[nbancrearetenir]))]; + pair A[]; + A0=(xpart(Ancre0)-1cm,ypart(Ancre[nbancrearetenir])-2cm); + A10=(xpart(Ancre0)+1cm,ypart(Ancre[nbancrearetenir])-2cm); + for l=1 upto 9: + A[l]=(l/10)[A0,A10]+uniformdeviate(5)*(unitvector(A10-A0) rotated 90); + endfor; + pair B[]; + B1=D0+(10+uniformdeviate(10))*(unitvector(D0-A0) rotated 90); + B2=symetrie(B1,Ancre0,1/2[A0,A10]);% + B3=1/2[Ancre0,(xpart(1/2[A0,A10]),ypart(Ancre[k]))]; + path tronc; + tronc=A0{dir angle(A1-A0)}..{dir90}B1--B2{dir-90}..{dir angle(A10-A9)}A10--reverse(A0 for l=1 upto 10:--A[l] endfor)--cycle;% + fill tronc withcolor CouleurTronc; + trace tronc; + path feuillage; + feuillage=cercles((0,0),abs(Ancre[nbancrearetenir]-D0));% + pair C[]; + for l=0 upto 7: + C[l]=(pointarc(feuillage,l*45+(-5+uniformdeviate(10))) xscaled 1.25 yscaled 1) shifted D0; + endfor; + feuillage:=C[0] for l=1 upto 7:..(C[l] if (l mod 2)=0:+(0,2mm) else: +(0,-2mm) fi) endfor ..cycle; + fill feuillage withcolor CouleurFeuillage; + trace feuillage; + draw Bilan; \end{mpost} - \fi +\fi } -\newcount\premier +\newcount\premier% -\newcommand{\NombrePremier}[1]{%\'ecrire la d\'ecomposition compl\`ete +\newcommand\NombrePremier[1]{%\'ecrire la d\'ecomposition compl\`ete % #1 le nombre premier \`a tester \newcount\anp\newcount\bnp\newcount\cnp%\newcount\e\newcount\f% \anp=#1\relax @@ -7810,7 +7790,7 @@ vardef Positions(expr Step)= \fi% } -\newcommand{\PremierDiviseurVide}[2]{% +\newcommand\PremierDiviseurVide[2]{% %#1 : le nombre entier \`a tester %#2 : le nombre d'\'etapes \`a effectuer \newcount\anpvv\newcount\bnpvv\newcount\cnpvv\newcount\dnpvv% @@ -7835,7 +7815,7 @@ vardef Positions(expr Step)= } } -\newcommand{\PremierMultipleVide}[2]{% +\newcommand\PremierMultipleVide[2]{% %#1 : le nombre entier \`a tester %#2 : le nombre d'\'etapes \`a effectuer \newcount\anpmv\newcount\bnpmv\newcount\cnpmv\newcount\dnpmv% @@ -7860,9 +7840,9 @@ vardef Positions(expr Step)= } } -\newcommand{\NombrePremierVerticalVide}[1]{%\'ecrire la d\'ecomposition compl\`ete +\newcommand\NombrePremierVerticalVide[1]{%\'ecrire la d\'ecomposition compl\`ete % #1 le nombre premier \`a tester - \newcount\anpv\newcount\bnpv\newcount\cnpv%\newcount\e\newcount\f% + \newcount\anpv\newcount\bnpv\newcount\cnpv% \anpv=#1\relax \bnpv=2\relax \premier=-1\relax @@ -7878,7 +7858,7 @@ vardef Positions(expr Step)= \fi% } \ifnum\premier=0 - Le nombre \num{#1} est un nombre premier. + Le nombre \num{#1} est un nombre premier.% \else \renewcommand{\arraystretch}{1.5} \begin{tabular}{c|c} @@ -7892,9 +7872,9 @@ vardef Positions(expr Step)= \fi } -\newcommand{\NombrePremierExposant}[1]{%\'ecrire la d\'ecomposition +\newcommand\NombrePremierExposant[1]{%\'ecrire la d\'ecomposition % compl\`ete - \newcount\anp\newcount\bnp\newcount\cnp%\newcount\e\newcount\f% + \newcount\anp\newcount\bnp\newcount\cnp% % #1 le nombre premier \`a tester \anp=#1\relax% \bnp=2\relax% @@ -7920,7 +7900,7 @@ vardef Positions(expr Step)= \fi% }% -\newcommand{\PremierEtape}[2]{% +\newcommand\PremierEtape[2]{% %#1 : le nombre entier \`a tester %#2 : le nombre d'\'etapes \`a effectuer \newcount\anp\newcount\bnp\newcount\cnp\newcount\dnp% @@ -7946,7 +7926,7 @@ vardef Positions(expr Step)= } } -\newcommand{\PremierExposant}[1]{% +\newcommand\PremierExposant[1]{% %#1 : le nombre entier \`a tester \ensuremath{% \newcount\anp\newcount\bnp\newcount\cnp% @@ -7976,7 +7956,7 @@ vardef Positions(expr Step)= }% }% -\newcommand{\PremierLong}[1]{% +\newcommand\PremierLong[1]{% %#1 : le nombre entier \`a tester \ensuremath{% \newcount\anpl\newcount\bnpl\newcount\cnpl% @@ -7998,7 +7978,7 @@ vardef Positions(expr Step)= } } -\newcommand{\ListeDiviseur}[1]{%#1 : le nombre entier \`a tester +\newcommand\ListeDiviseur[1]{%#1 : le nombre entier \`a tester \newcount\anp\newcount\bnp% \anp=#1% \bnp=2\relax% @@ -8023,26 +8003,26 @@ vardef Positions(expr Step)= \whiledo{\bnpT<\anpT}{% \modulo{\the\anpT}{\the\bnpT}{}% \ifnum\remainder=0% - \cnpT=\numexpr\cnpT+1 + \cnpT=\numexpr\cnpT+1% \fi% \bnpT=\numexpr\bnpT+1% }% - \ifodd\cnpT - \begin{tabular}{c|c} + \ifodd\cnpT% + \begin{tabular}{c|c}% 1&\num{#1}\\ \xintFor* ##1 in {\xintSeq {1}{\fpeval{(\cnpT+1)/2}}}\do{% \DiviseurNumero{#1}{##1}\num{\fpeval{\dnpT}}\uppercase{&}\DiviseurNumero{#1}{##1}\xintifboolexpr{\dnpT=\fpeval{#1/\dnpT}}{}{\num{\fpeval{#1/\dnpT}}}\\ } - \end{tabular} - \else + \end{tabular}% + \else% \begin{tabular}{c|c} 1&\num{#1}\\ \xintFor* ##1 in {\xintSeq {1}{\fpeval{\cnpT/2}}}\do{% \DiviseurNumero{#1}{##1}\num{\fpeval{\dnpT}}\uppercase{&}\DiviseurNumero{#1}{##1}\num{\fpeval{#1/\dnpT}}\\ } - \end{tabular} - \fi -} + \end{tabular}% + \fi% +}% \newcommand\DiviseurNumero[2]{% % #1 nb entier \`a tester @@ -10175,7 +10155,7 @@ vardef Positions(expr Step)= FreqVide=false,AngVide=false,ECCVide=false,TotalVide=false,Sondage=false,% Tableau=false,Stretch=1,Frequence=false,EffectifTotal=false,% Etendue=false,Moyenne=false,SET=false,Mediane=false,QuartileUn=false,QuartileTrois=false,Total=false,Concret=false,% -Unite={},Largeur=1cm,Precision=2,Donnee=Valeurs,Effectif=Effectif,Grille=false,Origine=0,Angle=false,SemiAngle=false,Qualitatif=false,TableauVide=false,Graphique=false,Batons=true,Pasx=1,Pasy=1,Unitex=0.5,Unitey=0.5,Rayon=3cm,AffichageAngle=false,Liste=false,ECC=false,Coupure=10,CouleurTab=gray!15,ListeCouleurs={white},Hachures=false,Inverse=false,AbscisseRotation=false,Representation=false} +Unite={},Largeur=1cm,Precision=2,Donnee=Valeurs,Effectif=Effectif,Grille=false,Origine=0,Angle=false,SemiAngle=false,Qualitatif=false,TableauVide=false,Graphique=false,Batons=true,Pasx=1,Pasy=1,Unitex=0.5,Unitey=0.5,Rayon=3cm,AffichageAngle=false,Liste=false,ECC=false,Coupure=10,CouleurTab=gray!15,ListeCouleurs={white},Hachures=false,Inverse=false,AbscisseRotation=false,Representation=false,EcartHachures=0.25,EpaisseurHachures=1,Longueur=10cm,Hauteur=5mm,Barre=false} % La construction du tableau \def\addtotok#1#2{#1\expandafter{\the#1#2}} @@ -10265,22 +10245,48 @@ Unite={},Largeur=1cm,Precision=2,Donnee=Valeurs,Effectif=Effectif,Grille=false,O \]% }% +% Pour construire le diagramme en barres horizontales +\def\UpdatetoksHor#1/#2/#3\nil{\addtotok\toklistenomhor{"#1",}\addtotok\toklistedonhor{#3,}\addtotok\toklisteaffhor{"#2",}}% + +\newcommand\buildgraphbarhor{% + \newtoks\toklistenomhor% + \newtoks\toklistedonhor% + \newtoks\toklisteaffhor% + \newtoks\toklistecouleur% + \xdef\PfCfooStat{}% + \xintFor* ##1 in {\xintSeq {1}{\ListeCompletelen}}\do{% + \xdef\PfCfooStat{\PfCfooStat \ListeComplete[##1,2],}% + }% + \xdef\DivMax{\fpeval{max(\PfCfooStat)}}% + \xdef\DivMax{\fpeval{round(ln(\DivMax)/ln(10))}}% + \xdef\DivMax{\fpeval{10**\DivMax}}% + \xdef\PfCfooStat{}% + \xintFor* ##1 in {\xintSeq {1}{\ListeCompletelen}}\do{% + \xdef\PfCfooStat{\PfCfooStat \ListeComplete[##1,1]/\ListeComplete[##1,2]/\fpeval{\ListeComplete[##1,2]/\DivMax},}% + }% + \readlist*\ListeCompleteDiagHor{\PfCfooStat}% + \foreachitem\compteur\in\ListeCompleteDiagHor{\expandafter\UpdatetoksHor\compteur\nil}% + \xdef\ListeAvantCouleurs{\useKV[ClesStat]{ListeCouleurs}}% + \readlist*\ListeCouleur{\ListeAvantCouleurs}% + \foreachitem\couleur\in\ListeCouleur{\expandafter\UpdateCoul\couleur\nil}% + \[\MPDiagBarreHor{\the\toklistenomhor}{\the\toklistedonhor}{\the\toklisteaffhor}{\the\toklistecouleur}\]% +}% + % Pour construire le diagramme en bâtons -\def\Updatetoks#1/#2\nil{\addtotok\toklistepoint{(#1,#2),}} +\def\Updatetoks#1/#2\nil{\addtotok\toklistepoint{(#1,#2),}}% \newcommand\buildgraph[1][]{% - \newtoks\toklistepoint + \newtoks\toklistepoint% \foreachitem\compteur\in\ListeComplete{\expandafter\Updatetoks\compteur\nil}% - \[\MPStat[#1]{\useKV[ClesStat]{Unitex}}{\useKV[ClesStat]{Unitey}}{\the\toklistepoint}{\useKV[ClesStat]{Donnee}}{\useKV[ClesStat]{Effectif}}{\useKV[ClesStat]{Origine}}{\useKV[ClesStat]{AbscisseRotation}}\]% + \[\MPStat[#1]{\useKV[ClesStat]{Unitex}}{\useKV[ClesStat]{Unitey}}{\the\toklistepoint}{\useKV[ClesStat]{Donnee}}{\useKV[ClesStat]{Effectif}}{\useKV[ClesStat]{Origine}}{\useKV[ClesStat]{AbscisseRotation}}\]% }% % Pour construire le diagramme en bâtons qualitatif -\def\Updatetoksq#1/#2\nil{\addtotok\toklistepointq{"#1",#2,}} +\def\Updatetoksq#1/#2\nil{\addtotok\toklistepointq{"#1",#2,}}% \newcommand\buildgraphq[1][]{% - \newtoks\toklistepointq - \foreachitem\compteur\in\ListeComplete{\expandafter\Updatetoksq\compteur\nil} - \[\MPStatQ[#1]{2*\useKV[ClesStat]{Unitex}}{0.5*\useKV[ClesStat]{Unitey}}{\the\toklistepointq}{\useKV[ClesStat]{Donnee}}{\useKV[ClesStat]{Effectif}}{\useKV[ClesStat]{Origine}}{\useKV[ClesStat]{AbscisseRotation}}\] -} - + \newtoks\toklistepointq% + \foreachitem\compteur\in\ListeComplete{\expandafter\Updatetoksq\compteur\nil}% + \[\MPStatQ[#1]{2*\useKV[ClesStat]{Unitex}}{0.5*\useKV[ClesStat]{Unitey}}{\the\toklistepointq}{\useKV[ClesStat]{Donnee}}{\useKV[ClesStat]{Effectif}}{\useKV[ClesStat]{Origine}}{\useKV[ClesStat]{AbscisseRotation}}\]% +}% \def\UpdateCoul#1\nil{\addtotok\toklistecouleur{#1,}}% @@ -10354,6 +10360,149 @@ Unite={},Largeur=1cm,Precision=2,Donnee=Valeurs,Effectif=Effectif,Grille=false,O \num{\TotalECC}% } +% Construction d'un diagramme en barres horizontal +\newcommand\MPDiagBarreHor[4]{% + % #1 Liste des noms + % #2 Liste des valeurs associées + % #3 Liste des valeurs à afficher (si pb calcul MP) + \ifluatex + \mplibforcehmode% + \begin{mplibcode}% + Longueur:=\useKV[ClesStat]{Longueur}; + Hauteur:=\useKV[ClesStat]{Hauteur}; + ecarthachures=\useKV[ClesStat]{EcartHachures}; + epaisseurhachures=\useKV[ClesStat]{EpaisseurHachures}; + boolean Hachures; + Hachures=\useKV[ClesStat]{Hachures}; + vardef CalculNombreDonneesEtDonneeMax(text t)= + nbdon:=0;%nombre de données + DonneeMax:=0;%donnée DonneeMaximale + for p_=t: + nbdon:=nbdon+1; + if p_>DonneeMax: + DonneeMax:=p_; + fi; + endfor; + enddef; + vardef ListeDonnees(text t)= + n:=0; + for p_=t: + n:=n+1; + Donnees[n]:=p_; + endfor; + enddef; + vardef RecuperationCouleurs(text t)= + color Col[]; + n:=0; + for p_=t: + n:=n+1; + Col[n]=p_; + endfor; + enddef; + vardef TraceDiag= + for k=0 upto nbdon-1: + path RectangleDonnee; + RectangleDonnee=(unitsquare xscaled ((Donnees[k+1]/DonneeMax)*Longueur) yscaled Hauteur) shifted(0,-k*Hauteur); + if Hachures: + trace Hachurage(RectangleDonnee,60 if + (k mod 2)=0: +90 fi,ecarthachures,if (k mod 2)=0 : 0 else: 1 fi) + withpen pencircle scaled epaisseurhachures; + else: + remplis RectangleDonnee withcolor if unknown Col[k+1]: white else:Col[k+1] fi; + fi; + trace RectangleDonnee; + endfor; + enddef; + vardef AffichageNom(text t)= + k:=0; + for p_=t: + label.lft(TEX(p_),0.5[(0,0),(0,Hauteur)] shifted (0,-k*Hauteur)); + k:=k+1; + endfor; + enddef; + vardef AffichageDonnees(text t)= + k:=0; + for p_=t: + label.rt(TEX("\num{"&p_&"}"),0.5[(0,0),(0,Hauteur)] shifted (((Donnees[k+1]/DonneeMax)*Longueur),-k*Hauteur)); + k:=k+1; + endfor; + enddef; + CalculNombreDonneesEtDonneeMax(#2); + ListeDonnees(#2); + RecuperationCouleurs(#4); + TraceDiag; + AffichageNom(#1); + AffichageDonnees(#3); + \end{mplibcode} + \else + \mpxcommands{% + \xdef\Nom{\expand#1} + } + \begin{mpost}[mpsettings={Longueur:=\useKV[ClesStat]{Longueur};Hauteur:=\useKV[ClesStat]{Hauteur};ecarthachures=\useKV[ClesStat]{EcartHachures};epaisseurhachures=\useKV[ClesStat]{EpaisseurHachures};boolean Hachures;Hachures=\useKV[ClesStat]{Hachures};}] + % Pb avec les noms accentués : pas de solution (27/02/2022) + vardef CalculNombreDonneesEtDonneeMax(text t)= + nbdon:=0;%nombre de données + DonneeMax:=0;%donnée DonneeMaximale + for p_=t: + nbdon:=nbdon+1; + if p_>DonneeMax: + DonneeMax:=p_; + fi; + endfor; + enddef; + vardef ListeDonnees(text t)= + n:=0; + for p_=t: + n:=n+1; + Donnees[n]:=p_; + endfor; + enddef; + vardef RecuperationCouleurs(text t)= + color Col[]; + n:=0; + for p_=t: + n:=n+1; + Col[n]=p_; + endfor; + enddef; + vardef TraceDiag= + for k=0 upto nbdon-1: + path RectangleDonnee; + RectangleDonnee=(unitsquare xscaled ((Donnees[k+1]/DonneeMax)*Longueur) yscaled Hauteur) shifted(0,-k*Hauteur); + if Hachures: + trace Hachurage(RectangleDonnee,60 if + (k mod 2)=0: +90 fi,ecarthachures,if (k mod 2)=0 : 0 else: 1 fi) + withpen pencircle scaled epaisseurhachures; + else: + remplis RectangleDonnee withcolor if unknown Col[k+1]: white else:Col[k+1] fi; + fi; + trace RectangleDonnee; + endfor; + enddef; + vardef AffichageNom(text t)= + k:=0; + for p_=t: + label.lft(LATEX(p_),0.5[(0,0),(0,Hauteur)] shifted (0,-k*Hauteur)); + k:=k+1; + endfor; + enddef; + vardef AffichageDonnees(text t)= + k:=0; + for p_=t: + label.rt(LATEX("\num{"&p_&"}"),0.5[(0,0),(0,Hauteur)] shifted (((Donnees[k+1]/DonneeMax)*Longueur),-k*Hauteur)); + k:=k+1; + endfor; + enddef; + CalculNombreDonneesEtDonneeMax(#2); + ListeDonnees(#2); + RecuperationCouleurs(#4); + TraceDiag; + AffichageNom(#1); + AffichageDonnees(#3); + \end{mpost} + \fi +}% + % la construction du graphique en bâtons pour quantitatif \newcommand\MPStat[8][]{% \ifluatex @@ -10577,8 +10726,10 @@ Unite={},Largeur=1cm,Precision=2,Donnee=Valeurs,Effectif=Effectif,Grille=false,O % la construction du graphique qualitatif \def\MPStatCirculaireQ#1#2#3#4#5#6#7{% \ifluatex - \mplibforcehmode + \mplibforcehmode \begin{mplibcode} + ecarthachures=\useKV[ClesStat]{EcartHachures}; + epaisseurhachures=\useKV[ClesStat]{EpaisseurHachures}; pair A[],O,B[],C[],D[]; O=(0,0); n:=0; @@ -10626,10 +10777,10 @@ Unite={},Largeur=1cm,Precision=2,Donnee=Valeurs,Effectif=Effectif,Grille=false,O arccercle(A[n],A[n-1],O) fi--cycle) withcolor if unknown Col[n]: white else:Col[n] fi; else: draw - hachurage((O--if #7=0:arccercle(A[n-1],A[n],O) + Hachurage((O--if #7=0:arccercle(A[n-1],A[n],O) else:arccercle(A[n],A[n-1],O) fi--cycle),p_*(#3/total[N]) if - (n mod 2)=0: +90 else: -90 fi,0.25,if (n mod 2)=0 : 0 else: 1 fi) - if #4=1: withcolor 0.5white fi; + (n mod 2)=0: +90 else: -90 fi,ecarthachures,if (n mod 2)=0 : 0 else: 1 fi) + withpen pencircle scaled epaisseurhachures if #4=1: withcolor 0.5white fi; fi; draw A[n-1]--O--A[n] if #6=1: withpen pencircle scaled2 fi; % Affichage des angles associ\'es @@ -10703,7 +10854,7 @@ Unite={},Largeur=1cm,Precision=2,Donnee=Valeurs,Effectif=Effectif,Grille=false,O toto(#2); \end{mplibcode} \else - \begin{mpost}%[mpsettings={input PfCGeometrie;}] + \begin{mpost}[mpsettings={ecarthachures=\useKV[ClesStat]{EcartHachures};epaisseurhachures=\useKV[ClesStat]{EpaisseurHachures};}] pair A[],O,B[],C[],D[]; O=(0,0); n:=0; @@ -10751,10 +10902,10 @@ Unite={},Largeur=1cm,Precision=2,Donnee=Valeurs,Effectif=Effectif,Grille=false,O arccercle(A[n],A[n-1],O) fi--cycle) withcolor if unknown Col[n]: white else:Col[n] fi; else: draw - hachurage((O--if #7=0:arccercle(A[n-1],A[n],O) + Hachurage((O--if #7=0:arccercle(A[n-1],A[n],O) else:arccercle(A[n],A[n-1],O) fi--cycle),p_*(#3/total[N]) if - (n mod 2)=0: +90 else: -90 fi,0.25,if (n mod 2)=0 : 0 else: 1 fi) - if #4=1: withcolor 0.5white fi; + (n mod 2)=0: +90 else: -90 fi,ecarthachures,if (n mod 2)=0 : 0 else: 1 fi) + withpen pencircle epaisseurhachures if #4=1: withcolor 0.5white fi; fi; draw A[n-1]--O--A[n] if #6=1: withpen pencircle scaled2 fi; % Affichage des angles associ\'es @@ -11130,7 +11281,9 @@ Unite={},Largeur=1cm,Precision=2,Donnee=Valeurs,Effectif=Effectif,Grille=false,O % Construction du graphique \ifboolKV[ClesStat]{Graphique}{% \ifboolKV[ClesStat]{Liste}{Pas de graphique possible avec la cl\'e Liste.\\Utilisez plut\^ot la cl\'e Sondage si vous voulez un graphique avec cette liste.}{% - \ifboolKV[ClesStat]{Angle}{\buildgraphcq{360}}{\ifboolKV[ClesStat]{SemiAngle}{\buildgraphcq{180}}{\buildgraphq[#1]}}% + \ifboolKV[ClesStat]{Barre}{% + \buildgraphbarhor% + }{\ifboolKV[ClesStat]{Angle}{\buildgraphcq{360}}{\ifboolKV[ClesStat]{SemiAngle}{\buildgraphcq{180}}{\buildgraphq[#1]}}}% }}{}% }{%%%%%%%%%%%%%%%%%%%%%D\'ebut quantitatif % % on effectue les calculs @@ -17573,13 +17726,32 @@ Unite={},Largeur=1cm,Precision=2,Donnee=Valeurs,Effectif=Effectif,Grille=false,O %%% % Tableaux d'unit\'es %%% -\setKVdefault[ClesTableaux]{Virgule=true,Incline=false,Entiers=false,Decimaux=false,Milliards=false,Millions=false,Micro=false,Nano=false,Partie=false,CouleurG=gray!15,CouleurM=gray!15,Couleurm=gray!15,Couleuru=gray!15,Couleurd=gray!15,Classes=false,Nombres=false,Puissances=false,NbLignes=2,Metre=false,Are=false,Capacite=false,Carre=false,Cube=false,Litre=false,Gramme=false,Fleches=false,FlechesB=false,FlechesH=false,Colonnes=false,Prefixes=false} +\setKVdefault[ClesTableaux]{Virgule=true,Incline=false,Entiers=false,Decimaux=false,Milliards=false,Millions=false,Micro=false,Nano=false,Partie=false,CouleurG=gray!15,CouleurM=gray!15,Couleurm=gray!15,Couleuru=gray!15,Couleurd=gray!15,Classes=false,Nombres=false,Puissances=false,NbLignes=2,Metre=false,Are=false,Capacite=false,Carre=false,Cube=false,Litre=false,Gramme=false,Fleches=false,FlechesB=false,FlechesH=false,Colonnes=false,Prefixes=false,Escalier=false} \newcommand\PfCTBstrut{\rule[-1.2ex]{0pt}{3.8ex}} % Top and Bottom strut \newcommand\Tableau[2][]{% \useKVdefault[ClesTableaux]% \setKV[ClesTableaux]{#1}% + \ifboolKV[ClesTableaux]{Escalier}{% + \ifboolKV[ClesTableaux]{Metre}{% + \xdef\PfCTableauUnite{\meter}% + \xdef\PfCCoefConversion{10}% + }{}% + \ifboolKV[ClesTableaux]{Carre}{% + \xdef\PfCTableauUnite{\square\meter}% + \xdef\PfCCoefConversion{100}% + }{}% + \ifboolKV[ClesTableaux]{Cube}{% + \xdef\PfCTableauUnite{\cubic\meter}% + \xdef\PfCCoefConversion{1000}% + }{}% + \ifboolKV[ClesTableaux]{Gramme}{% + \xdef\PfCTableauUnite{\gram}% + \xdef\PfCCoefConversion{10}% + }{}% + \PfCTableauIncline% + }{% % %%% Cl\'e Prefixes % @@ -18599,6 +18771,7 @@ Unite={},Largeur=1cm,Precision=2,Donnee=Valeurs,Effectif=Effectif,Grille=false,O \]% \Conversion{10}% }{}% + } }% \newcommand\Conversion[1]{% @@ -18622,44 +18795,78 @@ Unite={},Largeur=1cm,Precision=2,Donnee=Valeurs,Effectif=Effectif,Grille=false,O }{}% }% +\newcommand\PfCTableauIncline{% +\begin{NiceTabular}{p{1.5em}p{1.5em}p{1.5em}p{1.5em}p{1.5em}p{1.5em}p{1.5em}} + &&&&&&\\ + \Block[borders={bottom}]{}{\si{\kilo\PfCTableauUnite}}&\\ + &\Block[borders={left}]{}{}&\\ + &\Block[borders={left,bottom}]{}{\si{\hecto\PfCTableauUnite}}&\\ + &&\Block[borders={left}]{}{}&\\ + &&\Block[borders={left,bottom}]{}{\si{\deca\PfCTableauUnite}}&\\ + &&&\Block[borders={left}]{}{}&\\ + &&&\Block[borders={left,bottom}]{}{\si{\PfCTableauUnite}}&\\ + &&&&\Block[borders={left}]{}{}&\\ + &&&&\Block[borders={left,bottom}]{}{\si{\deci\PfCTableauUnite}}&\\ + &&&&&\Block[borders={left}]{}{}&\\ + &&&&&\Block[borders={left,bottom}]{}{\si{\centi\PfCTableauUnite}}&\\ + &&&&&&\Block[borders={left}]{}{}\\ + &&&&&&\Block[borders={left,bottom}]{}{\si{\milli\PfCTableauUnite}}\\ + &&&&&& + \CodeAfter + \tikz\draw[out=35,in=90,-stealth,gray] (2-|1.5) to node[midway,right]{\footnotesize$\times\num{\PfCCoefConversion}$}(4-|2.5); + \tikz\draw[out=35,in=90,-stealth,gray] (4-|2.5) to node[midway,right]{\footnotesize$\times\num{\PfCCoefConversion}$}(6-|3.5); + \tikz\draw[out=35,in=90,-stealth,gray] (6-|3.5) to node[midway,right]{\footnotesize$\times\num{\PfCCoefConversion}$}(8-|4.5); + \tikz\draw[out=35,in=90,-stealth,gray] (8-|4.5) to node[midway,right]{\footnotesize$\times\num{\PfCCoefConversion}$}(10-|5.5); + \tikz\draw[out=35,in=90,-stealth,gray] (10-|5.5) to node[midway,right]{\footnotesize$\times\num{\PfCCoefConversion}$}(12-|6.5); + \tikz\draw[out=35,in=90,-stealth,gray] (12-|6.5) to node[midway,right]{\footnotesize$\times\num{\PfCCoefConversion}$}(14-|7.5); + % bas + \tikz\draw[out=215,in=-90,-stealth,gray,transform canvas={yshift=-2mm}] (15-|7.5) to node[midway,left]{\footnotesize$\div{\PfCCoefConversion}$}(13-|6.5); + \tikz\draw[out=215,in=-90,-stealth,gray,transform canvas={yshift=-2mm}] (13-|6.5) to node[midway,left]{\footnotesize$\div{\PfCCoefConversion}$}(11-|5.5); + \tikz\draw[out=215,in=-90,-stealth,gray,transform canvas={yshift=-2mm}] (11-|5.5) to node[midway,left]{\footnotesize$\div{\PfCCoefConversion}$}(9-|4.5); + \tikz\draw[out=215,in=-90,-stealth,gray,transform canvas={yshift=-2mm}] (9-|4.5) to node[midway,left]{\footnotesize$\div{\PfCCoefConversion}$}(7-|3.5); + \tikz\draw[out=215,in=-90,-stealth,gray,transform canvas={yshift=-2mm}] (7-|3.5) to node[midway,left]{\footnotesize$\div{\PfCCoefConversion}$}(5-|2.5); + \tikz\draw[out=215,in=-90,-stealth,gray,transform canvas={yshift=-2mm}] (5-|2.5) to node[midway,left]{\footnotesize$\div{\PfCCoefConversion}$}(3-|1.5); +\end{NiceTabular} +} + %%% % Cards %%% \newtcolorbox{Mybox}[3]{% - enhanced, - nobeforeafter, - left=0pt,right=0pt,top=0pt, - text fill, - width=\largeurcarte, - height=\hauteurcarte, - arc=5pt, + enhanced,% + nobeforeafter,% + left=0pt,right=0pt,top=0pt,% + text fill,% + width=\largeurcarte,% + height=\hauteurcarte,% + arc=5pt,% overlay unbroken and first={% - \coordinate[yshift=-0.5\hauteurtitre] (A1) at (frame.north west); - \coordinate[yshift=-0.5\hauteurtitre] (B1) at (frame.north east); - \coordinate[yshift=-\hauteurtitre] (A) at (frame.north west); - \coordinate[yshift=-\hauteurtitre] (B) at (frame.north east); - \coordinate[xshift=1.5pt,yshift=8mm] (S1) at (frame.south west); - \coordinate[xshift=-1.5pt,yshift=8mm] (S2) at (frame.south east); - \coordinate[xshift=3mm+(\largeurtitre/2)] (A2) at (A1); - \coordinate[xshift=-3mm-(\largeurtitre/2)] (B2) at (B1); - \node[rounded corners, draw=black, rectangle,minimum height=1cm,text width=\largeurtitre,fill=TrameCouleur] (T1) at (A2){}; - \node[TexteCouleur] (T1a) at (T1){\Large #1}; - \node[yshift=-0.65cm] (T1b) at (T1){\tiny r\'eponse pr\'ec\'edente}; - \node[inner sep=0pt,rounded corners, rectangle, draw=black,minimum height=1cm,text width=\largeurtitre,fill=TrameCouleur] (T2) at (B2){}; - \node[inner sep=0pt,TexteCouleur] (T2a) at (T2){ - \begin{minipage}{\largeurtitre} - \begin{center} - #2 - \end{center} - \end{minipage} - }; - \node[yshift=-0.65cm] (T2b) at (T2){}; - \ifboolKV[Cards]{Titre}{\node[] at (T2b) {\tiny\useKV[Cards]{NomTitre}};}{}, - \node[rectangle,xshift=5pt,yshift=4.25mm,minimum width=2em,rounded corners,fill=TrameCouleur,draw=black,anchor=west] (R) at (frame.south west) {\color{black}\Large\bfseries #3}; - \draw[dashed] (S1) -- (S2); - }, - colback=white, - colbacktitle=TrameCouleur, + \coordinate[yshift=-0.5\hauteurtitre] (A1) at (frame.north west);% + \coordinate[yshift=-0.5\hauteurtitre] (B1) at (frame.north east);% + \coordinate[yshift=-\hauteurtitre] (A) at (frame.north west);% + \coordinate[yshift=-\hauteurtitre] (B) at (frame.north east);% + \coordinate[xshift=1.5pt,yshift=8mm] (S1) at (frame.south west);% + \coordinate[xshift=-1.5pt,yshift=8mm] (S2) at (frame.south east);% + \coordinate[xshift=3mm+(\largeurtitre/2)] (A2) at (A1);% + \coordinate[xshift=-3mm-(\largeurtitre/2)] (B2) at (B1);% + \node[rounded corners, draw=black, rectangle,minimum height=1cm,text width=\largeurtitre,fill=TrameCouleur] (T1) at (A2){};% + \node[TexteCouleur] (T1a) at (T1){\Large #1};% + \node[yshift=-0.65cm] (T1b) at (T1){\tiny r\'eponse pr\'ec\'edente};% + \node[inner sep=0pt,rounded corners, rectangle, draw=black,minimum height=1cm,text width=\largeurtitre,fill=TrameCouleur] (T2) at (B2){};% + \node[inner sep=0pt,TexteCouleur] (T2a) at (T2){% + \begin{minipage}{\largeurtitre}% + \begin{center}% + #2% + \end{center}% + \end{minipage}% + };% + \node[yshift=-0.65cm] (T2b) at (T2){};% + \ifboolKV[Cards]{Titre}{\node[] at (T2b) {\tiny\useKV[Cards]{NomTitre}};}{}% + \node[rectangle,xshift=5pt,yshift=4.25mm,minimum width=2em,rounded corners,fill=TrameCouleur,draw=black,anchor=west] (R) at (frame.south west) {\color{black}\Large\bfseries #3};% + \draw[dashed] (S1) -- (S2);% + },% + colback=white,% + colbacktitle=TrameCouleur,% } \newtcolorbox{MyboxJQ}[2]{% @@ -18741,15 +18948,15 @@ Unite={},Largeur=1cm,Precision=2,Donnee=Valeurs,Effectif=Effectif,Grille=false,O colback=white,% underlay={% \ifboolKV[Cards]{BackgroundAr}{% - \begin{tcbclipinterior} - \node[anchor=center,opacity=1] - at (interior.center) {% - \includegraphics[% - height=\tcb@height, - width=\tcb@width, - ]{\useKV[Cards]{ImageAr}}}; - \end{tcbclipinterior},% - }{} + \begin{tcbclipinterior} + \node[anchor=center,opacity=1] + at (interior.center) {% + \includegraphics[% + height=\tcb@height, + width=\tcb@width, + ]{\useKV[Cards]{ImageAr}}}; + \end{tcbclipinterior}%,% + }{}% },% overlay unbroken and first={% \coordinate[yshift=-0.5\hauteurtitre] (A) at (frame.north);% @@ -18758,8 +18965,6 @@ Unite={},Largeur=1cm,Precision=2,Donnee=Valeurs,Effectif=Effectif,Grille=false,O #1% \end{center}% \end{minipage}};% - % \node[yshift=-1em] (B) at (A){}; - % \ifboolKV[Cards]{Titre}{\node[fill=white] at (B) {\useKV[Cards]{NomTitre}};}{}, }% }% \makeatother @@ -18945,7 +19150,7 @@ Unite={},Largeur=1cm,Precision=2,Donnee=Valeurs,Effectif=Effectif,Grille=false,O \end{center} #2 -} +}% %%% % Tableur diff --git a/macros/latex/contrib/profcollege/metapost/PfCArithmetique.mp b/macros/latex/contrib/profcollege/metapost/PfCArithmetique.mp new file mode 100644 index 0000000000..870049c011 --- /dev/null +++ b/macros/latex/contrib/profcollege/metapost/PfCArithmetique.mp @@ -0,0 +1,237 @@ +% Fichier regroupant les macros pour les schémas des nombres premiers + +numeric retenirnb[]; + +vardef Estcepremier(expr NBa)= + boolean $; + c:=2; + departa:=NBa; + test:=1; + $=true; + if departa=1: + $:=false; + else: + forever: + if (departa mod c)=0: + departa:=departa div c; + test:=test+1; + else: + c:=c+1; + fi; + exitif departa=1; + endfor; + fi; + if test=2: + $:=true + else: + $:=false; + fi; + $ +enddef; + +vardef PremierSimple(expr NB)= + b:=2; + depart:=NB; + if Estcepremier(depart)=false: + forever: + if (depart mod b)=0: + Ancre[k+1]-Ancre[k]=(-decalage*0.5,-decalage); + Ancre[k+2]-Ancre[k+1]=(decalage,0); + depart:=depart div b; + retenirnb[k+1]=b; + retenirnb[k+2]=depart; + label(TEX("\num{"&decimal(b)&"}"),Ancre[k+1]); + label(TEX("\num{"&decimal(depart)&"}"),Ancre[k+2]); + draw 1/5[Ancre[k],Ancre[k+1]]--4/5[Ancre[k],Ancre[k+1]]; + draw 1/5[Ancre[k],Ancre[k+2]]--4/5[Ancre[k],Ancre[k+2]]; + k:=k+2; + racine:=depart; + depart:=1; + else: + b:=b+1; + fi; + exitif depart=1; + endfor; + else: + racine:=1; + fi; +enddef; + +vardef PremierSimplePdf(expr NB)= + b:=2; + depart:=NB; + if Estcepremier(depart)=false: + forever: + if (depart mod b)=0: + Ancre[k+1]-Ancre[k]=(-decalage*0.5,-decalage); + Ancre[k+2]-Ancre[k+1]=(decalage,0); + depart:=depart div b; + retenirnb[k+1]=b; + retenirnb[k+2]=depart; + label(LATEX("\num{"&decimal(b)&"}"),Ancre[k+1]); + label(LATEX("\num{"&decimal(depart)&"}"),Ancre[k+2]); + draw 1/5[Ancre[k],Ancre[k+1]]--4/5[Ancre[k],Ancre[k+1]]; + draw 1/5[Ancre[k],Ancre[k+2]]--4/5[Ancre[k],Ancre[k+2]]; + k:=k+2; + racine:=depart; + depart:=1; + else: + b:=b+1; + fi; + exitif depart=1; + endfor; + else: + racine:=1; + fi; +enddef; + +vardef PremierSimpleArbre(expr NB)= + b:=2; + depart:=NB; + if Estcepremier(depart)=false: + forever: + if (depart mod b)=0: + Ancre[k+1]-Ancre[k]=(-decalage*0.5,-decalage); + Ancre[k+2]-Ancre[k+1]=(decalage,0); + depart:=depart div b; + retenirnb[k+1]=b; + retenirnb[k+2]=depart; + draw Branche(Ancre[k],Ancre[k+1]); + draw Branche(Ancre[k],Ancre[k+2]); + k:=k+2; + racine:=depart; + depart:=1; + else: + b:=b+1; + fi; + exitif depart=1; + endfor; + else: + racine:=1; + fi; +enddef; + +vardef NbEtape(expr nb)= + b:=2; + depart:=nb; + etape:=0; + Stock[0][0]=depart; + forever: + if (depart mod b)=0: + etape:=etape+1; + if etape=1: + Stock[etape][0]=b; + Stock[etape][etape]:=depart div b; + else: + for k=0 upto etape-2: + Stock[etape][k]:=Stock[etape-1][k]; + endfor; + Stock[etape][etape-1]:=b; + Stock[etape][etape]:=depart div b; + fi; + depart:=depart div b; + else: + b:=b+1; + fi; + exitif depart=1; + endfor; + etape +enddef; + +vardef Positions(expr Step)= + for k=0 upto (Step-1): + for l=0 upto k: + N[k][l]=(-k*dx+(l+k*.5)*dx,-k*dy); + label(TEX("\num{"&decimal(Stock[k][l])&"}"),N[k][l]); + endfor; + for l=0 upto k-1: + label(btex $\times$ etex,1/2[N[k][l],N[k][l+1]]); + endfor; + endfor; + for k=0 upto (Step-1): + for l=0 upto (k-1): + draw 1/5[N[k][l],N[k-1][l]]--4/5[N[k][l],N[k-1][l]]; + endfor; + if k>0: + draw 1/5[N[k][k],N[k-1][k-1]]--4/5[N[k][k],N[k-1][k-1]]; + fi; + endfor; +enddef; + +vardef PositionsPdf(expr Step)= + for k=0 upto (Step-1): + for l=0 upto k: + N[k][l]=(-k*dx+(l+k*.5)*dx,-k*dy); + label(LATEX("\num{"&decimal(Stock[k][l])&"}"),N[k][l]); + endfor; + for l=0 upto k-1: + label(btex $\times$ etex,1/2[N[k][l],N[k][l+1]]); + endfor; + endfor; + for k=0 upto (Step-1): + for l=0 upto (k-1): + draw 1/5[N[k][l],N[k-1][l]]--4/5[N[k][l],N[k-1][l]]; + endfor; + if k>0: + draw 1/5[N[k][k],N[k-1][k-1]]--4/5[N[k][k],N[k-1][k-1]]; + fi; + endfor; +enddef; + +vardef PositionsVide(expr Step)= + for k=0 upto (Step-1): + for l=0 upto k: + N[k][l]=(-k*dx+(l+k*.5)*dx,-k*dy); + endfor; + for l=0 upto k-1: + label(btex $\times$ etex,1/2[N[k][l],N[k][l+1]]); + endfor; + endfor; + for k=0 upto (Step-1): + for l=0 upto (k-1): + draw 1/5[N[k][l],N[k-1][l]]--4/5[N[k][l],N[k-1][l]]; + endfor; + if k>0: + draw 1/5[N[k][k],N[k-1][k-1]]--4/5[N[k][k],N[k-1][k-1]]; + fi; + endfor; + label(TEX("\num{"&decimal(Stock[0][0])&"}"),N[0][0]); +enddef; + +vardef PositionsVidePdf(expr Step)= + for k=0 upto (Step-1): + for l=0 upto k: + N[k][l]=(-k*dx+(l+k*.5)*dx,-k*dy); + endfor; + for l=0 upto k-1: + label(btex $\times$ etex,1/2[N[k][l],N[k][l+1]]); + endfor; + endfor; + for k=0 upto (Step-1): + for l=0 upto (k-1): + draw 1/5[N[k][l],N[k-1][l]]--4/5[N[k][l],N[k-1][l]]; + endfor; + if k>0: + draw 1/5[N[k][k],N[k-1][k-1]]--4/5[N[k][k],N[k-1][k-1]]; + fi; + endfor; + label(LATEX("\num{"&decimal(Stock[0][0])&"}"),N[0][0]); +enddef; + +vardef Branche(expr nbd,nba)= + save $; + picture $; + pair UnitVector; + numeric AngleVector; + UnitVector=unitvector(nba-nbd) rotated 90; + AngleVector=angle(nba-nbd)+(-10+uniformdeviate(20)); + path branche; + branche=(nbd+UnitVector){dir AngleVector}..(nba+UnitVector)--reverse((nbd-UnitVector){dir AngleVector}..(nba-UnitVector))--cycle; + $=image( + fill branche withcolor gris; + draw branche; + ); + $ +enddef; + +endinput; diff --git a/macros/latex/contrib/profcollege/metapost/PfCScratchpdf.mp b/macros/latex/contrib/profcollege/metapost/PfCScratchpdf.mp index b9edf3873f..94a37beccc 100644 --- a/macros/latex/contrib/profcollege/metapost/PfCScratchpdf.mp +++ b/macros/latex/contrib/profcollege/metapost/PfCScratchpdf.mp @@ -319,7 +319,7 @@ vardef OvalMenuCap(expr art)=OvalCapMenu(art) enddef; vardef OvalCapMenu(expr ar)= save $; picture $; string TTm; - TTm=if print:ar&"\hbox to1em{\barre}\blacktriangledown" else: "\color{white}"&ar&"\hbox to1em{\barre}\blacktriangledown"; + TTm=if print:ar&"\hbox to1em{\barre}$\blacktriangledown$" else: "\color{white}"&ar&"\hbox to1em{\barre}$\blacktriangledown$"; fi; path TAMC; TAMC=OvalBox(TTm); @@ -349,8 +349,8 @@ enddef; vardef OvalMouvMenu(expr ar)= save $; picture $; path ta; string TTm; - TTm=if print:ar&"\hbox to1em{\barre}\blacktriangledown" else: - "\color{white}"&ar&"\hbox to1em{\barre}\color{black}\blacktriangledown" + TTm=if print:ar&"\hbox to1em{\barre}$\blacktriangledown$" else: + "\color{white}"&ar&"\hbox to1em{\barre}\color{black}$\blacktriangledown$" fi; ta=OvalBox(TTm); $=image( @@ -364,7 +364,7 @@ enddef; vardef OvalAppMenu(expr ar)= save $; picture $; path ta; string TTm; - TTm=if print:ar&"\hbox to1em{\barre}\blacktriangledown" else: "\color{white}"&ar&"\hbox to1em{\barre}\blacktriangledown"; + TTm=if print:ar&"\hbox to1em{\barre}$\blacktriangledown$" else: "\color{white}"&ar&"\hbox to1em{\barre}$\blacktriangledown$"; fi; ta=OvalBox(TTm); $=image( @@ -381,7 +381,7 @@ vardef OvalMenuSon(expr ar)= save $; save TA; picture $; string TTm; - TTm=if print:ar&"\hbox to1em{\barre}\blacktriangledown" else: "\color{white}"&ar&"\hbox to1em{\barre}\blacktriangledown"; + TTm=if print:ar&"\hbox to1em{\barre}$\blacktriangledown$" else: "\color{white}"&ar&"\hbox to1em{\barre}$\blacktriangledown$"; fi; path TA; TA=OvalBox(TTm); @@ -397,7 +397,7 @@ vardef OvalMenuControle(expr ar)= save $; save TA; picture $; string TTm; - TTm=if print:ar&"\hbox to1em{\barre}\blacktriangledown" else: "\color{white}"&ar&"\hbox to1em{\barre}\blacktriangledown"; + TTm=if print:ar&"\hbox to1em{\barre}$\blacktriangledown$" else: "\color{white}"&ar&"\hbox to1em{\barre}$\blacktriangledown$"; fi; path TA; TA=OvalBox(TTm); @@ -415,11 +415,11 @@ vardef OvalStylo(expr ar)= string TT,TTI; if string ar: if print: - TT=ar&"\hbox to1em{\barre}\blacktriangledown" + TT=ar&"\hbox to1em{\barre}$\blacktriangledown$" else: - TT=ar&"\hbox to1em{\barre}\color{white}\blacktriangledown" + TT=ar&"\hbox to1em{\barre}\color{white}$\blacktriangledown$" fi; - TTI=ar&"\hbox to1em{\barre}\phantom{\blacktriangledown}"; + TTI=ar&"\hbox to1em{\barre}\phantom{$\blacktriangledown$}"; path TA; TA=OvalBox(TT); $=image( @@ -452,7 +452,7 @@ vardef OvalMenuEvenement(expr ar)= save $; save TA; picture $; string TTm; - TTm=if print:ar&"\hbox to1em{\barre}\blacktriangledown" else: "\color{white}"&ar&"\hbox to1em{\barre}\blacktriangledown"; + TTm=if print:ar&"\hbox to1em{\barre}$\blacktriangledown$" else: "\color{white}"&ar&"\hbox to1em{\barre}$\blacktriangledown$"; fi; path TA; TA=OvalBox(TTm); @@ -468,7 +468,7 @@ enddef; vardef RecMouvMenu(expr ar)= save $; picture $; path ta; string TTm; - TTm=if print:ar&"\hbox to1em{\barre}\blacktriangledown" else: "\color{white}"&ar&"\hbox to1em{\barre}\blacktriangledown" + TTm=if print:ar&"\hbox to1em{\barre}$\blacktriangledown$" else: "\color{white}"&ar&"\hbox to1em{\barre}$\blacktriangledown$" fi; ta=RecBox(TTm); $=image( @@ -482,7 +482,7 @@ enddef; vardef RecMenuApp(expr ar)= save $; picture $; save ta; path ta; string TTm; - TTm=if print:ar&"\hbox to1em{\barre}\blacktriangledown" else: "\color{white}"&ar&"\hbox to1em{\barre}\blacktriangledown"; + TTm=if print:ar&"\hbox to1em{\barre}$\blacktriangledown$" else: "\color{white}"&ar&"\hbox to1em{\barre}$\blacktriangledown$"; fi; ta=RecBox(TTm); $=image( @@ -496,7 +496,7 @@ enddef; vardef RecMenuOp(expr ar)= save $; save TA; picture $; string TTm; - TTm=if print:ar&"\hbox to1em{\barre}\blacktriangledown" else: "\color{white}"&ar&"\hbox to1em{\barre}\blacktriangledown"; + TTm=if print:ar&"\hbox to1em{\barre}$\blacktriangledown$" else: "\color{white}"&ar&"\hbox to1em{\barre}$\blacktriangledown$"; fi; path TA; TA=RecBox(TTm); @@ -511,7 +511,7 @@ enddef; vardef RecMenuSon(expr ar)= save $; save TA; picture $; string TTm; - TTm=if print:ar&"\hbox to1em{\barre}\blacktriangledown" else: "\color{white}"&ar&"\hbox to1em{\barre}\blacktriangledown" fi; + TTm=if print:ar&"\hbox to1em{\barre}$\blacktriangledown$" else: "\color{white}"&ar&"\hbox to1em{\barre}$\blacktriangledown$" fi; path TA; TA=RecBox(TTm); $=image( @@ -525,7 +525,7 @@ enddef; vardef RecEvenementMenu(expr ar)= save $; picture $; path ta; string TTm; - TTm=if print:ar&"\hbox to1em{\barre}\blacktriangledown" else: "\color{white}"&ar&"\hbox to1em{\barre}\blacktriangledown"; + TTm=if print:ar&"\hbox to1em{\barre}$\blacktriangledown$" else: "\color{white}"&ar&"\hbox to1em{\barre}$\blacktriangledown$"; fi; ta=RecBox(TTm); $=image( @@ -539,7 +539,7 @@ enddef; vardef RecMenuCap(expr ar)= save $; picture $; path ta; string TTm; - TTm=if print:ar&"\hbox to1em{\barre}\blacktriangledown" else: "\color{white}"&ar&"\hbox to1em{\barre}\blacktriangledown"; + TTm=if print:ar&"\hbox to1em{\barre}$\blacktriangledown$" else: "\color{white}"&ar&"\hbox to1em{\barre}$\blacktriangledown$"; fi; ta=RecBox(TTm); $=image( @@ -553,7 +553,7 @@ enddef; vardef RecMenuVar(expr ar)= save $; save TA; picture $; string TTm; - TTm=if print:ar&"\hbox to1em{\barre}\blacktriangledown" else: "\color{white}"&ar&"\hbox to1em{\barre}\blacktriangledown"; + TTm=if print:ar&"\hbox to1em{\barre}$\blacktriangledown$" else: "\color{white}"&ar&"\hbox to1em{\barre}$\blacktriangledown$"; fi; path TA; TA=RecBox(TTm); @@ -568,7 +568,7 @@ enddef; vardef RecMenuList(expr ar)= save $; save TA; picture $; string TTm; - TTm=if print:ar&"\hbox to1em{\barre}\blacktriangledown" else: "\color{white}"&ar&"\hbox to1em{\barre}\blacktriangledown"; + TTm=if print:ar&"\hbox to1em{\barre}$\blacktriangledown$" else: "\color{white}"&ar&"\hbox to1em{\barre}$\blacktriangledown$"; fi; path TA; TA=RecBox(TTm); @@ -2005,7 +2005,7 @@ vardef Stop(expr nbpas)= save $; picture $,texto; string TTm;%Pour sauvegarder le nbpas car en l'utilisant dans les if, il ne permet pas la concaténation... - TTm=if print:nbpas&"\hbox to1em{\barre}\blacktriangledown" else:"\color{white}"&nbpas&"\hbox to1em{\barre}\blacktriangledown"; + TTm=if print:nbpas&"\hbox to1em{\barre}$\blacktriangledown$" else:"\color{white}"&nbpas&"\hbox to1em{\barre}$\blacktriangledown$"; fi; texto=image( path ti; |