Debian Codegraph @

texmf-dist/doc/latex/chemformula/chemformula-manual.cls

raw
1 % --------------------------------------------------------------------------
2 % the CHEMFORMULA package
3 %
4 % typeset chemical compounds and reactions
5 %
6 % --------------------------------------------------------------------------
7 % Clemens Niederberger
8 % --------------------------------------------------------------------------
9 % https://github.com/cgnieder/chemformula/
10 % [email protected]
11 % --------------------------------------------------------------------------
12 % If you have any ideas, questions, suggestions or bugs to report, please
13 % feel free to contact me.
14 % --------------------------------------------------------------------------
15 % Copyright 2011--2022 Clemens Niederberger
16 %
17 % This work may be distributed and/or modified under the
18 % conditions of the LaTeX Project Public License, either version 1.3
19 % of this license or (at your option) any later version.
20 % The latest version of this license is in
21 % http://www.latex-project.org/lppl.txt
22 % and version 1.3 or later is part of all distributions of LaTeX
23 % version 2005/12/01 or later.
24 %
25 % This work has the LPPL maintenance status `maintained'.
26 %
27 % The Current Maintainer of this work is Clemens Niederberger.
28 % --------------------------------------------------------------------------
29 \ProvidesClass{chemformula-manual}[2022/01/23]
30
31 \LoadClass[load-preamble,add-index]{cnltx-doc}
32 \RequirePackage{imakeidx}
33 \RequirePackage[utf8]{inputenc}
34
35 \RequirePackage{chemformula}
36 \RequirePackage{chemmacros}
37
38 \setcnltx{
39 package = {chemformula},
40 info = {typeset chemical compounds and reactions} ,
41 url = http://www.mychemistry.eu/forums/forum/chemformula/ ,
42 authors = Clemens Niederberger ,
43 email = [email protected] ,
44 abstract = {%
45 \centering
46 \includegraphics{chemmacros-logo.pdf}
47 \par
48 } ,
49 add-cmds = {
50 bond,
51 ce, ch, charrow, chcpd, chemformula@bondlength, chemsetup, chlewis,
52 chname,
53 DeclareChemAdditionSymbol, DeclareChemArrow, DeclareChemBond,
54 DeclareChemBondAlias, DeclareChemCompoundProperty, DeclareChemSymbol,
55 mch,
56 NewChemAdditionSymbol, NewChemArrow, NewChemBond, NewChemBondAlias,
57 NewChemCompoundProperty, NewChemSymbol,
58 ox, OX,
59 pch,
60 redox, RemoveChemCompoundProperty, RenewChemAdditionSymbol,
61 RenewChemArrow, RenewChemBond, RenewChemCompoundProperty,
62 RenewChemSymbol,
63 setchemformula, ShowChemArrow, ShowChemBond
64 } ,
65 add-silent-cmds = {
66 addplot,
67 chemfig,
68 DeclareInstance, draw,
69 sample, setchemfig, sfrac,
70 usetikzlibrary
71 } ,
72 index-setup = { othercode=\footnotesize, level=\section } ,
73 makeindex-setup = { columns=3, columnsep=1em }
74 }
75
76 \RequirePackage{chemfig,booktabs,cancel,varioref}
77 \RequirePackage[version=4]{mhchem}
78
79 \def\libertine@figurestyle{LF}
80 \RequirePackage{amsmath}
81 \undef\lvert \undef\lVert
82 \undef\rvert \undef\rVert
83 \RequirePackage[libertine]{newtxmath}
84 \def\libertine@figurestyle{OsF}
85
86 \RequirePackage{fontawesome}
87 \RequirePackage{datetime2}
88 \DTMsetup{useregional=numeric,datesep=/}
89 \newrobustcmd*\chemformula@add@version[2]{%
90 \csdef{chemformula@ver@#2}{%
91 \DTMdate{#1}%
92 \csgdef{chemformula@ver@#2used}{}%
93 \csdef{chemformula@ver@#2}{\DTMdate{#1}}%
94 }%
95 }
96
97 \newrobustcmd*\chemformula@date[1]{%
98 \ifcsdef{chemformula@ver@#1used}{}{ (\csuse{chemformula@ver@#1})}}
99 \newrobustcmd*\chemformula@ifnew[1]{\ifcsstring{c_chemformula_version_tl}{#1}}
100 \newrobustcmd*\chemformula@NEW{\faStarO\ New}
101
102 \renewrobustcmd*\sinceversion[1]{%
103 \chemformula@ifnew{#1}%
104 {\cnltx@version@note{\textcolor{red}{\chemformula@NEW}}}%
105 {\cnltx@version@note{\GetTranslation{cnltx-introduced}~#1\chemformula@date{#1}}}%
106 }
107 \renewrobustcmd*\changedversion[1]{%
108 \cnltx@version@note{\GetTranslation{cnltx-changed}~#1\chemformula@date{#1}}%
109 }
110
111 \newnote*\sincechanged[2]{%
112 \GetTranslation{cnltx-introduced}~#1\chemformula@date{#1},
113 changed with version~#2\chemformula@date{#2}\chemformula@ifnew{#2}{ \chemformula@NEW}{}%
114 }
115
116 \RenewDocumentEnvironment{commands}{}
117 {%
118 \cnltx@set@catcode_{12}%
119 \let\command\cnltx@command
120 \cnltxlist
121 }
122 {\endcnltxlist}
123
124 \RequirePackage{tcolorbox,xsimverb}
125 \tcbuselibrary{skins,breakable}
126 \tcbset{enhanced,enhanced jigsaw}
127
128 \newtcolorbox{bewareofthedog}{
129 colback = white ,
130 colframe = red ,
131 underlay={%
132 \path[draw=none]
133 (interior.south west)
134 rectangle node[red]{\Huge\bfseries !}
135 ([xshift=-4mm]interior.north west);
136 }%
137 }
138
139 \newtcolorbox{cnltxcode}[1][]{
140 boxrule = 1pt ,
141 colback = cnltxbg ,
142 colframe = cnltx ,
143 arc = 5pt ,
144 beforeafter skip = .5\baselineskip ,%
145 #1%
146 }
147
148 \newcommand*\chemformula@readoptions[1]{%
149 \catcode`\^^M=13
150 \chemformula@read@options{#1}%
151 }
152
153 \begingroup
154 \catcode`\^^M=13
155 \gdef\chemformula@read@options#1#2^^M{%
156 \ifblank{#2}{}{\chemformula@read@options@#2}%
157 #1%
158 \XSIMfilewritestart*{\jobname.tmp}%
159 }%
160 \endgroup
161
162 \def\chemformula@read@options@[#1]{\pgfqkeys{/cnltx}{#1}}
163
164 \RenewDocumentEnvironment{sourcecode}{}
165 {%
166 \chemformula@readoptions{%
167 \setlength\cnltx@sidebysidewidth
168 {\dimexpr .45\columnwidth -\lst@xleftmargin -\lst@xrightmargin\relax}%
169 \expanded{%
170 \noexpand\lstset{
171 style=cnltx,
172 \ifboolexpe{ bool {cnltx@sidebyside} and not bool {cnltx@codeonly} }
173 {linewidth=\cnltx@sidebysidewidth,}{}%
174 \expandonce\cnltx@local@listings@options
175 }%
176 }%
177 \XSIMgobblechars{2}%
178 }%
179 }
180 {%
181 \XSIMfilewritestop
182 \cnltxcode[breakable]%
183 \lstinputlisting[style=cnltx]{\jobname.tmp}%
184 \endcnltxcode
185 }
186
187 \RenewDocumentEnvironment{example}{}
188 {%
189 \chemformula@readoptions{%
190 \setlength\cnltx@sidebysidewidth
191 {\dimexpr .45\columnwidth -\lst@xleftmargin -\lst@xrightmargin\relax}%
192 \expanded{%
193 \noexpand\lstset{
194 style=cnltx,
195 \ifboolexpe{ bool {cnltx@sidebyside} and not bool {cnltx@codeonly} }
196 {linewidth=\cnltx@sidebysidewidth,}{}%
197 \expandonce\cnltx@local@listings@options
198 }%
199 }%
200 \XSIMgobblechars{2}%
201 }%
202 }
203 {%
204 \XSIMfilewritestop
205 \catcode`\^^M=5
206 \ifbool{cnltx@sidebyside}
207 {%
208 \cnltxcode
209 \noindent
210 \minipage[c]{\cnltx@sidebysidewidth}%
211 \cnltx@pre@source@hook
212 \lstinputlisting[style=cnltx] {\jobname.tmp}%
213 \cnltx@after@source@hook
214 \endminipage\hfill
215 \minipage[c]{\cnltx@sidebysidewidth}%
216 \cnltx@pre@example@hook
217 \input {\jobname.tmp}%
218 \cnltx@after@example@hook
219 \endminipage
220 }
221 {%
222 \cnltxcode[breakable]%
223 \cnltx@pre@source@hook
224 \lstinputlisting{\jobname.tmp}%
225 \cnltx@after@source@hook
226 \tcblower
227 \cnltx@pre@example@hook
228 \input {\jobname.tmp}%
229 \cnltx@after@example@hook
230 }%
231 \endcnltxcode
232 }
233
234 \RequirePackage[
235 backend=biber,
236 style=cnltx,
237 sortlocale=en_US,
238 indexing=cite]{biblatex}
239 \RequirePackage{csquotes,varioref}
240 \defbibheading{bibliography}{\section{References}}
241
242 \newpackagename\chemmacros{chemmacros}
243
244 \newidxcmd\manual{\textsf{#1}}[\ (manual)]
245 \newidxcmd\arrowtype{\code{#1}}[\ (arrow type)]
246
247 \newcommand*\cf@arrow{%
248 \@ifstar
249 {\cf@arrow@star}
250 {\cf@arrow@nostar}%
251 }
252 \newrobustcmd*\cf@arrow@star[1]{%
253 \@ifnextchar[
254 {\cf@arrow@star@opt{#1}}
255 {\cf@arrow@star@opt{#1}[]}%
256 }
257 \newrobustcmd*\cf@arrow@nostar[1]{%
258 \@ifnextchar[
259 {\cf@arrow@nostar@opt{#1}}
260 {\cf@arrow@nostar@opt{#1}[]}%
261 }
262 \def\cf@arrow@star@opt#1[#2]{%
263 \ifblank{#2}
264 {\item\arrowtype*{#1}}
265 {\item\arrowtype*{#1}#2}%
266 \cnltx@checkdefault{\hfill\newline}%
267 }
268 \def\cf@arrow@nostar@opt#1[#2]{%
269 \ifblank{#2}
270 {\item\arrowtype{#1}}
271 {\item\arrowtype{#1}#2}%
272 \cnltx@checkdefault{\hfill\newline}%
273 }
274
275 \newenvironment{codedesc}
276 {%
277 \def\Code##1{\item\code{##1}\hfill\newline}%
278 \cnltxlist
279 }
280 {\endcnltxlist}
281
282 \newenvironment{arrows}
283 {%
284 \let\arrow\cf@arrow
285 \cnltxlist
286 }
287 {\endcnltxlist}
288
289 \renewcommand*\AmS{\hologo{AmS}}
290
291 \newcommand*\TikZ{Ti\textit{k}Z}
292
293 \newname\hensel{Martin Hensel}
294
295 \RequirePackage[biblatex]{embrac}[2012/06/29]
296 \ChangeEmph{[}[,.02em]{]}[.055em,-.08em]
297 \ChangeEmph{(}[-.01em,.04em]{)}[.04em,-.05em]
298
299 \newenvironment{changes}[1]{%
300 \subsection*{Version #1 (\csuse{chemformula@ver@#1})}
301 \itemize\let\change\item
302 }{\enditemize}
303
304 \chemsetup{
305 greek = newtx ,
306 formula = chemformula ,
307 chemformula/format = \libertineLF
308 }
309
310 \usepackage{acro}
311 \acsetup{
312 format/long = \scshape ,
313 format/short = \scshape
314 }
315 \DeclareAcronym{iupac}{
316 short = iupac ,
317 long = International Union of Pure and Applied Chemistry ,
318 pdfstring = IUPAC ,
319 short-acc = IUPAC
320 }
321
322 \sisetup{
323 detect-mode=false,
324 mode=text,
325 text-font-command=\libertineLF
326 }
327
328 \chemformula@add@version{2012-01-28}{3.0}
329 \chemformula@add@version{2012-01-30}{3.0a}
330 \chemformula@add@version{2012-02-03}{3.0b}
331 \chemformula@add@version{2012-02-05}{3.0c}
332 \chemformula@add@version{2012-02-10}{3.0d}
333 \chemformula@add@version{2012-02-19}{3.1}
334 \chemformula@add@version{2012-02-26}{3.1a}
335 \chemformula@add@version{2012-03-03}{3.1b}
336 \chemformula@add@version{2012-03-14}{3.1c}
337 \chemformula@add@version{2012-03-20}{3.2}
338 \chemformula@add@version{2012-05-07}{3.3}
339 \chemformula@add@version{2012-05-13}{3.3a}
340 \chemformula@add@version{2012-05-18}{3.3b}
341 \chemformula@add@version{2012-05-18}{3.3c}
342 \chemformula@add@version{2012-07-24}{3.3d}
343 \chemformula@add@version{2012-08-21}{3.3e}
344 \chemformula@add@version{2012-09-11}{3.4}
345 \chemformula@add@version{2012-10-03}{3.4a}
346 \chemformula@add@version{2013-01-04}{3.4b}
347 \chemformula@add@version{2013-01-28}{3.5}
348 \chemformula@add@version{2013-02-19}{3.5a}
349 \chemformula@add@version{2013-02-26}{3.6}
350 \chemformula@add@version{2013-02-27}{3.6a}
351 \chemformula@add@version{2013-04-19}{3.6b}
352 \chemformula@add@version{2013-07-06}{4.0}
353 \chemformula@add@version{2013-07-26}{4.0a}
354 \chemformula@add@version{2013-08-24}{4.1}
355 \chemformula@add@version{2013-10-24}{4.2}
356 \chemformula@add@version{2013-11-04}{4.2a}
357 \chemformula@add@version{2014-01-24}{4.3}
358 \chemformula@add@version{2014-01-29}{4.4}
359 \chemformula@add@version{2014-04-07}{4.5}
360 \chemformula@add@version{2014-06-30}{4.6}
361 \chemformula@add@version{2014-08-04}{4.7}
362 \chemformula@add@version{2014-08-08}{4.8}
363 \chemformula@add@version{2014-10-07}{4.9}
364 \chemformula@add@version{2015-03-16}{4.10}
365 \chemformula@add@version{2015-04-03}{4.10a}
366 \chemformula@add@version{2015-06-30}{4.11}
367 \chemformula@add@version{2015-08-12}{4.12}
368 \chemformula@add@version{2015-08-29}{4.12a}
369 \chemformula@add@version{2015-09-08}{4.12b}
370 \chemformula@add@version{2015-01-01}{4.13}
371 \chemformula@add@version{2015-10-21}{4.14}
372 \chemformula@add@version{2016-01-07}{4.14a}
373 \chemformula@add@version{2016-05-03}{4.14b}
374 \chemformula@add@version{2016-05-11}{4.15}
375 \chemformula@add@version{2016-06-08}{4.15a}
376 \chemformula@add@version{2016-06-08}{4.15b}
377 \chemformula@add@version{2016-08-21}{4.15c}
378 \chemformula@add@version{2017-02-02}{4.15d}
379 \chemformula@add@version{2017-03-23}{4.15e}
380 \chemformula@add@version{2019-09-23}{4.15f}
381 \chemformula@add@version{2019-09-27}{4.15g}
382 \chemformula@add@version{2019-10-13}{4.15h}
383 \chemformula@add@version{2020-02-01}{4.15i}
384 \chemformula@add@version{2020-03-07}{4.15j}
385 \chemformula@add@version{2020-03-15}{4.15k}
386 \chemformula@add@version{2020-12-22}{4.16}
387 \chemformula@add@version{2022-01-23}{4.17}
388
389 \endinput