Debian Codegraph @

texmf-dist/doc/latex/chemgreek/chemgreek_en.tex

raw
1 % arara: pdflatex: { shell: on , interaction: nonstopmode }
2 % !arara: biber
3 % !arara: pdflatex
4 % !arara: pdflatex
5 % --------------------------------------------------------------------------
6 % the CHEMGREEK package
7 %
8 % interface for upright greek letters for use in chemistry
9 %
10 % --------------------------------------------------------------------------
11 % Clemens Niederberger
12 % --------------------------------------------------------------------------
13 % https://github.com/cgnieder/chemgreek/
14 % [email protected]
15 % --------------------------------------------------------------------------
16 % If you have any ideas, questions, suggestions or bugs to report, please
17 % feel free to contact me.
18 % --------------------------------------------------------------------------
19 % Copyright 2015--2020 Clemens Niederberger
20 %
21 % This work may be distributed and/or modified under the
22 % conditions of the LaTeX Project Public License, either version 1.3
23 % of this license or (at your option) any later version.
24 % The latest version of this license is in
25 % http://www.latex-project.org/lppl.txt
26 % and version 1.3 or later is part of all distributions of LaTeX
27 % version 2005/12/01 or later.
28 %
29 % This work has the LPPL maintenance status `maintained'.
30 %
31 % The Current Maintainer of this work is Clemens Niederberger.
32 % --------------------------------------------------------------------------
33 \documentclass[load-preamble+]{cnltx-doc}
34 \KOMAoption{listof}{totoc}
35 \usepackage[utf8]{inputenc}
36 \usepackage{chemgreek}
37 \setcnltx{
38 package = {chemgreek},
39 info = {interface for upright greek letters for use in chemistry},
40 url = http://www.mychemistry.eu/forums/forum/chemgreek/ ,
41 authors = Clemens Niederberger ,
42 email = [email protected] ,
43 abstract = {%
44 \centering
45 \includegraphics{chemmacros-logo.pdf}
46 \par
47 } ,
48 add-cmds = {
49 activatechemgreekmapping,
50 changechemgreeksymbol, chemalpha, chembeta, chemgamma, chemdelta,
51 chemDelta, chemomega, chemphi, chemPhi,
52 chemgreekmappingsymbol,
53 declarechemgreekmapping,
54 newchemgreekmapping,
55 printchemgreekalphabet,
56 renewchemgreekmapping,
57 selectchemgreekmapping
58 } ,
59 index-setup = { level = \section , headers={\indexname}{\indexname} , noclearpage }
60 }
61
62 \usepackage{array,booktabs}
63
64 \expandafter\def\csname libertine@figurestyle\endcsname{LF}
65 \usepackage[libertine]{newtxmath}
66 \expandafter\def\csname libertine@figurestyle\endcsname{OsF}
67
68 \usepackage{chemmacros}
69 \selectchemgreekmapping{newtx}
70
71 \usepackage[biblatex]{embrac}
72 \ChangeEmph{[}[,.02em]{]}[.055em,-.08em]
73 \ChangeEmph{(}[-.01em,.04em]{)}[.04em,-.05em]
74
75 \usepackage[accsupp]{acro}
76 \acsetup{
77 long-format = \scshape ,
78 short-format = \scshape
79 }
80 \DeclareAcronym{iupac}{
81 short = iupac ,
82 long = International Union of Pure and Applied Chemistry ,
83 pdfstring = IUPAC ,
84 accsupp = IUPAC
85 }
86 \DeclareAcronym{pdf}{
87 short = pdf ,
88 long = portable document file ,
89 pdfstring = PDF ,
90 accsupp = PDF
91 }
92
93 \defbibheading{bibliography}{\section{References}}
94
95 \newcommand*\tablehead[1]{\textrm{\bfseries#1}}
96
97 % \BeforeBeginEnvironment{example}{\vspace{\baselineskip}}
98 % \AfterEndEnvironment{example}{\vspace{\baselineskip}}
99 % \BeforeBeginEnvironment{sourcecode}{\vspace{\baselineskip}}
100 % \AfterEndEnvironment{sourcecode}{\vspace{\baselineskip}}
101
102 \begin{document}
103 \selectchemgreekmapping{newtx}
104
105 \listoftables
106
107 \section{Introduction}
108 The \chemgreek{} package is an auxiliary package for other chemistry packages
109 such as \pkg{chemmacros}. In chemistry there is often the need for upright
110 greek letters. The \chemgreek{} package provides an interface to various
111 other packages that provide upright greek letters. One could mention
112 \pkg{textgreek}, \pkg{upgreek}, \pkg{newtx} or \pkg{kpfonts}. All of these
113 packages provide upright greek letters, some a whole alphabet some only the
114 upright variants of the standard italic symbols for which macros are defined
115 in base \LaTeX.
116
117 \chemgreek{} offers a possibility to map those different interfaces to a
118 unified set of macros for usage in a chemistry package. This is useful as
119 then for example names like \iupac{\b-\D-gluco|pyranose} can be typeset
120 with a semantic interface and still have matching greek letters while the user
121 is not limited to a certain package or font. Consequently this package is
122 used by the \pkg{chemmacros} package~\cite{pkg:chemmacros} and its \acs{iupac}
123 naming commands, for example, and by the \pkg{chemnum}
124 package~\cite{pkg:chemnum}.
125
126 \section{Licence and Requirements}
127 \license
128
129 \chemgreek{} loads the following packages:
130 \pkg{expl3}\footnote{\CTANurl{l3kernel}}~\cite{bnd:l3kernel},
131 \pkg{xparse}\footnote{\CTANurl{l3packages}}~\cite{bnd:l3packages} and
132 \pkg{amstext}\footnote{\url{http://ctan.org/tex-archive/macros/latex/required/amslatex/math}}%
133 ~\cite{pkg:amstext}.
134
135 \section{News}
136 \subsection{Version~0.2}
137 \begin{itemize}
138 \item The mapping ``mathdesign'' has been added. In order to use it you
139 need the \pkg{mathdesign} package~\cite{pkg:mathdesign} loaded and use one
140 of its options.
141 \item The mapping ``fourier'' has been added. In order to use it you
142 need the \pkg{fourier} package~\cite{pkg:fourier} loaded.
143 \end{itemize}
144
145 \subsection{Version~0.3}
146 \begin{itemize}
147 \item The provided macros have been renamed from \cs*{Chem\meta{\ldots}}
148 into \cs*{chem\meta{\ldots}}. The uppercase version still are provided
149 for backwards compatibility but issue a warning message and will be
150 removed some time in the future.
151 \item The commands for defining mappings have gotten an optional argument
152 which allows to specify the name of the package a mapping needs. The
153 command \cs{selectchemgreekmapping} now checks for this package and gives
154 a warning if it doesn't find it loaded.
155 \item The mapping ``textalpha'' has been added. In order to use it you
156 need the \pkg{textalpha} package (part of
157 \bnd{greek-fontenc}~\cite{bnd:greek-fontenc}) loaded.
158 \item If the package \pkg{hyperref}~\cite{pkg:hyperref} is loaded with the
159 \code{unicode} option \emph{and} the \pkg{textalpha} package has been
160 loaded at begin document all the \cs*{chem\meta{\ldots}} commands are let
161 to \pkg{textalpha}'s \cs*{text\meta{\ldots}} commands for the \acs{pdf}
162 bookmarks. This allows Greek letters in the bookmarks without worrying
163 about \cs*{texorpdfstring}.
164 \end{itemize}
165
166 \subsection{Version~0.4}
167 \begin{itemize}
168 \item The mapping ``fontspec'' has been added. In order to use it you
169 need the \pkg{fontspec} package~\cite{pkg:fontspec} loaded. This means it
170 can only be used with \LuaLaTeX\ or \XeLaTeX.
171 \item New command \cs{printchemgreekalphabet}.
172 \end{itemize}
173
174 \subsection{Version~0.5}
175 \begin{itemize}
176 \item The package is now distributed independently from the \pkg{chemmacros}
177 package.
178 \end{itemize}
179
180 \subsection{Version~0.5}
181 \begin{itemize}
182 \item The deprecated macros \cs*{Chem\meta{\ldots}} have been dropped and
183 will now cause an error if used.
184 \end{itemize}
185
186 \subsection{Version~1.0}
187 \begin{itemize}
188 \item If a mapping is activated that needs a package and the package is
189 missing \chemgreek\ falls back to the `default' mapping now.
190 \item If exactly one package for one of the mappings has been loaded the
191 corresponding mapping is activated at begin document, see also
192 section~\ref{sec:pred-mapp-select}.
193 \item expl3 versions of the letter macros (\verbcode+\chemgreek_alpha:+,
194 \verbcode+\chemgreek_Alpha:+, \ldots)
195 \item New macros \cs{chemgreekmappingsymbol} (see
196 section~\ref{sec:additional-macros}), \cs{newchemgreekmappingalias},
197 \cs{renewchemgreekmappingalias} and \cs{declarechemgreekmappingalias} (see
198 section~\ref{sec:define-mappings}).
199 \end{itemize}
200
201 \section{Define Mappings}\label{sec:define-mappings}
202 \selectchemgreekmapping{default}
203
204 \chemgreek's main commands are:
205 \begin{commands}
206 \command{newchemgreekmapping}[\oarg{package}\marg{name}\marg{mapping list}]
207 \changedversion{0.3}Add a new mapping to \chemgreek. Issues an error if a
208 mapping with the same name already exists. With the optional argument the
209 package that is needed for this mapping can (and should) be specified.
210 \command{renewchemgreekmapping}[\oarg{package}\marg{name}\marg{mapping list}]
211 \changedversion{0.3}Renew a \chemgreek{} mapping. Issues an error if the
212 mapping doesn't exist yet. With the optional argument the package that is
213 needed for this mapping can (and should) be specified.
214 \command{declarechemgreekmapping}[\oarg{package}\marg{name}\marg{mapping list}]
215 \changedversion{0.3}Declare a new mapping to \chemgreek. If the mapping
216 already exists it will be overwritten. With the optional argument the
217 package that is needed for this mapping can (and should) be specified.
218 \command{newchemgreekmappingalias}[\marg{new mapping name}\marg{existing mapping name}]
219 \sinceversion{1.0}Define an alias mapping. Issues an error if \meta{new
220 mapping name} already exists.
221 \command{renewchemgreekmappingalias}[\marg{new mapping name}\marg{existing mapping name}]
222 \sinceversion{1.0}Redefine a mapping to an alias of an existing mapping.
223 Issues an error if \meta{new mapping name} doesn't exist, yet.
224 \command{declarechemgreekmappingalias}[\marg{new mapping name}\marg{existing mapping name}]
225 \sinceversion{1.0}Define an alias mapping. Doesn't check, if \marg{new
226 mapping name} exists or not.
227 \end{commands}
228
229 The command \cs{newchemgreekmapping} needs to get a comma separated list of
230 24 pairs divided by a slash. The first entry is the lowercase version und the
231 second the uppercase version for the corresponding greek letter at the current
232 position. This will become clearer if you look at how the \code{default}
233 mapping is defined:
234
235 \begin{sourcecode}
236 \newchemgreekmapping{default}
237 {
238 \ensuremath{\alpha} / \ensuremath{\mathrm{A}} , % 1: alpha
239 \ensuremath{\beta} / \ensuremath{\mathrm{B}} , % 2: beta
240 \ensuremath{\gamma} / \ensuremath{\Gamma} , % 3: gamma
241 \ensuremath{\delta} / \ensuremath{\Delta} , % 4: delta
242 \ensuremath{\epsilon} / \ensuremath{\mathrm{E}} , % 5: epsilon
243 \ensuremath{\zeta} / \ensuremath{\mathrm{Z}} , % 6: zeta
244 \ensuremath{\eta} / \ensuremath{\mathrm{H}} , % 7: eta
245 \ensuremath{\theta} / \ensuremath{\Theta} , % 8: theta
246 \ensuremath{\iota} / \ensuremath{\mathrm{I}} , % 9: iota
247 \ensuremath{\kappa} / \ensuremath{\mathrm{K}} , % 10: kappa
248 \ensuremath{\lambda} / \ensuremath{\Lambda} , % 11: lambda
249 \ensuremath{\mu} / \ensuremath{\mathrm{M}} , % 12: mu
250 \ensuremath{\nu} / \ensuremath{\mathrm{N}} , % 13: nu
251 \ensuremath{\xi} / \ensuremath{\Xi} , % 14: xi
252 \ensuremath{o} / \ensuremath{\mathrm{O}} , % 15: omikron
253 \ensuremath{\pi} / \ensuremath{\Pi} , % 16: pi
254 \ensuremath{\rho} / \ensuremath{\mathrm{P}} , % 17: rho
255 \ensuremath{\sigma} / \ensuremath{\Sigma} , % 18: sigma
256 \ensuremath{\tau} / \ensuremath{\mathrm{T}} , % 19: tau
257 \ensuremath{\upsilon} / \ensuremath{\Upsilon} , % 20: upsilon
258 \ensuremath{\phi} / \ensuremath{\Phi} , % 21: phi
259 \ensuremath{\psi} / \ensuremath{\Psi} , % 22: psi
260 \ensuremath{\chi} / \ensuremath{\mathrm{X}} , % 23: chi
261 \ensuremath{\omega} / \ensuremath{\Omega} % 24: omega
262 }
263 \end{sourcecode}
264
265 There \emph{must} be 24 pairs of entries, \ie, a complete mapping! Those
266 entries are the ones that will be used by the interface macros. For each
267 letter a pair \cs{chemalpha}/\cs{chemAlpha} is defined that uses the entries
268 of the currently active mapping. That means there are 48 (robust) macros
269 defined each beginning with \cs*{chem...} followed by the lowercase or
270 uppercase name of the Greek letter.
271
272 The default mapping is -- as you can probably see -- \emph{not an upright
273 one}. This is because \chemgreek{} will not make any choice for a specific
274 package but lets the user (or another package) choose. \chemgreek\ however
275 recognizes if \emph{an unambiguous choice} for one of the upright mappings is
276 possible and if it is will select the appropriate mapping at begin document.
277
278 \begin{example}
279 Default mapping: \chemphi\ and \chemPhi, $\phi$ and $\Phi$
280 \end{example}
281
282 \begin{commands}
283 \expandable\command{l\_chemgreek\_active\_mapping\_tl}
284 The currently active mapping is always available in the token list variable.
285 \end{commands}
286
287 \section{Predefined Mappings and Selection of a Mapping}\label{sec:pred-mapp-select}
288 \chemgreek\ predefines some mappings. Some of the mappings require additional
289 packages to be loaded. The mapping names and the required packages are listed
290 in table~\ref{tab:mappings}. The mapping \code{fontspec} is a bit different
291 here: if you use this mapping then the fact is used that \pkg{fontspec} also
292 defines commands like \cs*{textalpha}. However, they only work if you also
293 use a font that has the Greek glyphs.
294
295 \begin{table}
296 \centering
297 \begin{tabular}{>{\ttfamily}ll}
298 \toprule
299 \tablehead{mapping} & \tablehead{package} \\
300 \midrule
301 default & --- \\
302 var-default & --- \\
303 textgreek & \pkg{textgreek} \cite{pkg:textgreek} \\
304 upgreek & \pkg{upgreek} \cite{pkg:upgreek} \\
305 newtx & \pkg*{newtxmath} \cite{pkg:newtx} \\
306 kpfonts & \pkg{kpfonts} \cite{pkg:kpfonts} \\
307 pxgreeks & \pkg{pxgreeks} \cite{pkg:pxgreeks} \\
308 mathdesign & \pkg{mathdesign} \cite{pkg:mathdesign} \\
309 fourier & \pkg{fourier} \cite{pkg:fourier} \\
310 textalpha & \pkg{textalpha} \cite{bnd:greek-fontenc} \\
311 fontspec & \pkg{fontspec} \cite{pkg:fontspec} \\
312 \bottomrule
313 \end{tabular}
314 \caption{Predefined mappings.}
315 \label{tab:mappings}
316 \end{table}
317
318 If exactly \emph{one} of the packages required by one of the mappings has been
319 loaded such that an unambiguous choice is possible then \chemgreek\ will
320 choose and activate the corresponding mapping at begin document. If an
321 umbiguous choice isn't possible then \chemgreek\ will select the `default'
322 mapping at begin document. If a user has selected a mapping manually in the
323 preamble (with one of the commands explained in a bit) then \chemgreek\ will
324 do nothing on its own.
325
326 A mapping is selected and activated manually with one of the following
327 commands:
328 \begin{commands}
329 \command{activatechemgreekmapping}[\sarg\marg{name}]
330 \changedversion{1.0}This commands selects and activates the mapping
331 \meta{name}. If the star variant is used also the package of mapping
332 \meta{name} (as defined with \cs{newchemgreekmapping} is loaded.
333 Otherwise a required package has to be loaded additionally the usual
334 way via \cs*{usepackage} or \cs*{RequirePackage}. If the package hasn't
335 been loaded a warning will be written to the log and the `default' mapping
336 will be activated instead. \emph{The command can only be used in the
337 document preamble}.
338 \command{selectchemgreekmapping}[\marg{name}]
339 \changedversion{1.0}This commands selects and activates the mapping
340 \meta{name}. A required package has to be loaded additionally the usual
341 way via \cs*{usepackage} or \cs*{RequirePackage}. If the package hasn't
342 been loaded a warning will be written to the log and the `default' mapping
343 will be activated instead. \emph{The command can be used throughout the
344 document}.
345 \end{commands}
346
347 \begin{example}
348 % requires the `newtxmath' package to be loaded:
349 \chemphi\ and \chemPhi, $\phi$ and $\Phi$\par
350 \selectchemgreekmapping{newtx}
351 \chemphi\ and \chemPhi, $\upphi$ and $\upPhi$
352 \end{example}
353
354 Since the \code{fontspec} mapping is a little bit different than the others
355 I'd like to show a little example for it. The difference is subtle: you need
356 to choose a font containing the needed glyphs.
357
358 \begin{example}[compile,program=xelatex,runs=1,add-frame=false]
359 \documentclass[margin=3pt]{standalone}
360 \usepackage{fontspec}
361 \setmainfont{LinLibertine_R.otf}% need a font that has the glyphs!
362 \usepackage{chemgreek}
363 \selectchemgreekmapping{fontspec}
364 \begin{document}
365 \printchemgreekalphabet
366 \end{document}
367 \end{example}
368
369 \section{Changing a Specific Symbol in an Existing Mapping}\label{sec:chang-spec-symb}
370 If you should want to change a specific entry of a specific mapping it would
371 be rather tedious to redefine the whole mapping. That is why \chemgreek\
372 provides a command for that purpose:
373 \begin{commands}
374 \command{changechemgreeksymbol}[\marg{mapping
375 name}\Marg{upper|lower}\marg{entry name}\marg{entry}]
376 Changes the \code{upper}- or \code{lower}case entry \meta{entry name} in
377 the mapping \meta{mapping name}.
378 \end{commands}
379
380 In order to activate the change you need the (re-) activate the affected
381 mapping afterwards:
382 \begin{example}
383 \chemalpha
384 \changechemgreeksymbol{default}{lower}{alpha}{xxx}%
385 \selectchemgreekmapping{default}
386 \chemalpha
387 \end{example}
388
389 \section{Inspecting a Mapping}\label{sec:inspecting-mapping}
390 \selectchemgreekmapping{newtx}
391 If you want to check if a mapping has been correctly set you can use the
392 following commands:
393 \begin{commands}
394 \command{printchemgreekmapping}[\marg{mapping}]
395 \sinceversion{0.3}This will typeset a table (using a simple \code{tabular}
396 environment) with all~48 characters like the one shown in
397 table~\ref{tab:showmapping}.
398 \command{printchemgreekalphabet}
399 \sinceversion{0.4}This will print the twentyfour pairs of lower- and
400 uppercase letters of the currently active mapping: \printchemgreekalphabet.
401 \command{showchemgreekmapping}[\marg{mapping}]
402 \changedversion{0.3}This command will write information about the
403 definition of all 48~macros for a mapping to the log file.
404 \end{commands}
405
406 \begin{table}
407 \centering
408 \printchemgreekmapping{newtx}
409 \caption{A demonstration of the \cs*{printchemgreekmapping} command.}
410 \label{tab:showmapping}
411 \end{table}
412
413 \section{Additional Macros}\label{sec:additional-macros}
414
415 \begin{commands}
416 \command{chemgreekmappingsymbol}[\marg{mapping name}\marg{symbol name}]
417 A command which prints a specific symbol of a specific mapping. The mapping
418 \meta{mapping name} doesn't need to be active but package dependencies
419 must be taken care of, \emph{i.e.}, if \meta{mapping name} needs a certain
420 package to be loaded you should make sure that it is.
421 \end{commands}
422
423 \appendix
424
425 \section{Overviews Over the Mappings}\label{sec:overv-over-mapp}
426
427 \newcommand*\demonstratemapping[2][]{%
428 \ifblank{#1}
429 {
430 \subsection{Mapping `\texttt{#2}'}
431 \includegraphics{chemgreek-#2.pdf}
432 }
433 {
434 \subsection{Mapping `\texttt{#2}' with package option \option*{#1}}
435 \includegraphics{chemgreek-#2-#1.pdf}
436 }
437 }
438
439 \demonstratemapping{default}
440 \demonstratemapping{var-default}
441 \demonstratemapping{textgreek}
442 \demonstratemapping{upgreek}
443 \demonstratemapping{newtx}
444 \demonstratemapping{kpfonts}
445 \demonstratemapping{pxgreeks}
446 \demonstratemapping[utopia]{mathdesign}
447 \demonstratemapping[charter]{mathdesign}
448 \demonstratemapping{fourier}
449 \demonstratemapping{textalpha}
450
451 \subsection{Mapping `\texttt{fontspec}' with Font `Linux Libertine'}
452 \includegraphics{chemgreek-fontspec.pdf}
453
454 \end{document}