diff options
author | Karl Berry <karl@freefriends.org> | 2017-08-24 22:03:11 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2017-08-24 22:03:11 +0000 |
commit | 71d2397f0528e7f9137f494d48b1e7c2b4ef0ae2 (patch) | |
tree | f0e5438afd7c9d5dec59203672ec9725fbf2c968 /Master/texmf-dist/tex/latex/bpchem | |
parent | 3950fff7eb716a577a59f23a0c1ef4859f26cf13 (diff) |
bpchem (24aug17)
git-svn-id: svn://tug.org/texlive/trunk@45120 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/bpchem')
-rw-r--r-- | Master/texmf-dist/tex/latex/bpchem/bpchem.sty | 193 |
1 files changed, 95 insertions, 98 deletions
diff --git a/Master/texmf-dist/tex/latex/bpchem/bpchem.sty b/Master/texmf-dist/tex/latex/bpchem/bpchem.sty index ccaf5a30805..cb06644f293 100644 --- a/Master/texmf-dist/tex/latex/bpchem/bpchem.sty +++ b/Master/texmf-dist/tex/latex/bpchem/bpchem.sty @@ -20,21 +20,17 @@ %% original source files, as listed above, are part of the %% same distribution. (The sources need not necessarily be %% in the same archive or directory.) -%% File: bpchem.dtx Copyright (C) 2001 +%% File: bpchem.dtx Copyright (C) 2001-2017 %% Bjoern Pedersen <Bjoern.Pedersen@ch.tum.de> %% This file may be distributed and used freely under -%% the Latex Project Public License +%% the LaTeX Project Public License %% %% \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{bpchem}[2004/11/25 v1.06 Chemical input helper] +\ProvidesPackage{bpchem}[2004/08/21 v1.1 Chemical input helper] \RequirePackage{xspace} %\IUPAC{Tetra\|cyclo[2.2.2.1\^{1,4}]\- - - - - \newif\ifusecbgreek% \usecbgreekfalse% \DeclareOption{cbgreek}{\PackageInfo{bpchem}{cbgreek selected}\usecbgreektrue} @@ -51,59 +47,58 @@ %% a register to save the length to backspace %% two registers needed to get back to correct %% working position if one is longer than the other. - \newlength{\BPClensub} - \newlength{\BPClensuper} - \newlength{\BPCdelta} - +\newlength{\BPClensub} +\newlength{\BPClensuper} +\newlength{\BPCdelta} %% we are in subscript and maybe the superscript was longer - \DeclareRobustCommand{\BPCadjustsub}{% - \setlength\BPCdelta{\BPClensuper}\addtolength\BPCdelta{-\BPClensub}% - \ifdim\BPCdelta>0pt{\kern\BPCdelta}\else\relax\fi% - \setlength{\BPClensub}{0pt}% reset - \setlength{\BPClensuper}{0pt}% reset - }% +\DeclareRobustCommand{\BPCadjustsub}{% + \setlength\BPCdelta{\BPClensuper}\addtolength\BPCdelta{-\BPClensub}% + \ifdim\BPCdelta>0pt{\kern\BPCdelta}\else\relax\fi% + \setlength{\BPClensub}{0pt}% reset + \setlength{\BPClensuper}{0pt}% reset +}% %% we are in superscript and maybe the subscript was longer - \DeclareRobustCommand{\BPCadjustsuper}{% - \setlength\BPCdelta{\BPClensub}\addtolength\BPCdelta{-\BPClensuper}% - \ifdim\BPCdelta>0pt{\kern\BPCdelta}\else\relax\fi% - \setlength{\BPClensub}{0pt}% reset - \setlength{\BPClensuper}{0pt}% reset - }% +\DeclareRobustCommand{\BPCadjustsuper}{% + \setlength\BPCdelta{\BPClensub}\addtolength\BPCdelta{-\BPClensuper}% + \ifdim\BPCdelta>0pt{\kern\BPCdelta}\else\relax\fi% + \setlength{\BPClensub}{0pt}% reset + \setlength{\BPClensuper}{0pt}% reset +}% %% make a subscript and remember length in BPClen - \DeclareRobustCommand{\BPCsub}[1]{% - \ifmmode_{#1}\settowidth\BPClensub{_{#1}}% - \else\textsubscript{#1}\settowidth\BPClensub{\textsubscript{#1}}\fi% - \futurelet\next\lookforsuper% - }% +\DeclareRobustCommand{\BPCsub}[1]{% + \ifmmode_{#1}\settowidth\BPClensub{_{#1}}% + \else\textsubscript{#1}\settowidth\BPClensub{\textsubscript{#1}}\fi% + \futurelet\next\lookforsuper% +}% %% make a superscript and remember length in BPClen %% raise by 0.15 em, else e.g. + collides with subscript - \DeclareRobustCommand{\BPCsuper}[1]{% - \ifmmode^{#1}\settowidth\BPClensuper{^{#1}}% - \else\raisebox{0.15em}{\textsuperscript{#1}}% - \settowidth\BPClensuper{\textsuperscript{#1}}\fi% - \futurelet\next\lookforsub% - }% +\DeclareRobustCommand{\BPCsuper}[1]{% + \ifmmode^{#1}\settowidth\BPClensuper{^{#1}}% + \else\raisebox{0.15em}{\textsuperscript{#1}}% + \settowidth\BPClensuper{\textsuperscript{#1}}\fi% + \futurelet\next\lookforsub% +}% %% see if next token is BPCsuper, - \DeclareRobustCommand\lookforsuper{% - \ifx\next\BPCsuper\let\next=\BPCsuperbs% - \else\let\next=\BPCadjustsub\fi\next% - }% +\DeclareRobustCommand\lookforsuper{% + \ifx\next\BPCsuper\let\next=\BPCsuperbs% + \else\let\next=\BPCadjustsub\fi\next% +}% %% see if next token is BPCsub - \DeclareRobustCommand\lookforsub{% - \ifx\next\BPCsub\let\next=\BPCsubbs% - \else\let\next=\BPCadjustsuper\fi\next% - }% +\DeclareRobustCommand\lookforsub{% + \ifx\next\BPCsub\let\next=\BPCsubbs% + \else\let\next=\BPCadjustsuper\fi\next% +}% %% backspace BPClen and make superscript %% eats the old \verb|\^| - \DeclareRobustCommand{\BPCsuperbs}[1]{\kern-\BPClensub\BPCsuper}% +\DeclareRobustCommand{\BPCsuperbs}[1]{\kern-\BPClensub\BPCsuper}% %% backspace and make subscript -%% eats the old \_ - \DeclareRobustCommand{\BPCsubbs}[1]{\kern-\BPClensuper\BPCsub}% +%% eats the old \_ +\DeclareRobustCommand{\BPCsubbs}[1]{\kern-\BPClensuper\BPCsub}% %% needed to get catcodes right - \DeclareRobustCommand{\DoBPChem}{}% - \def\DoBPChem#1{% - #1\endgroup% - }% +\DeclareRobustCommand{\DoBPChem}{}% +\def\DoBPChem#1{% + #1\endgroup% +}% \DeclareRobustCommand{\BPCSetupCat}{} \def\BPCSetupCat{% %\catcode`^=\active% @@ -120,79 +115,81 @@ \begingroup% endgroup in DoBPChem \BPCSetupCat% \DoBPChem% - } - +} %% these are taken from german.sty and allow more than one break %% or breaks and hyphens in a word. Very useful for chemical names, %% as they tend to grow rather long. Two short versions are also defined \DeclareRobustCommand{\allowhyphens}{\penalty\@M \hskip\z@skip} \DeclareRobustCommand{\BreakHyph}{\penalty\@M -\allowhyphens} \DeclareRobustCommand{\MultiBreak}% - {\penalty\@M\discretionary{-}{}{\kern.03em}% - \allowhyphens} + {\penalty\@M\discretionary{-}{}{\kern.03em}% + \allowhyphens} \let\MB=\MultiBreak \let\BH=\BreakHyph \DeclareRobustCommand{\DoIUPAC}[1]{% -#1\endgroup} + #1\endgroup} \def\Prep{% -\let\-=\BreakHyph% -\let\|=\MultiBreak% -\DoIUPAC% + \let\-=\BreakHyph% + \let\|=\MultiBreak% + \DoIUPAC% } \DeclareRobustCommand*{\IUPAC}{% \begingroup\BPCSetup\ignorespaces% \Prep}% - -%% Trick by David Kastrup <David.Kastrup@t-online.de> to make +\expandafter\DeclareRobustCommand\expandafter\|\expandafter{\|} +%% Trick by David Kastrup <David.Kastrup@t-online.de> to make %% non-fragile. Otherwise \verb+\|+ would become \verb+\delimiter"026B30D+ in %% e.g. the toc -\expandafter\DeclareRobustCommand\expandafter\|\expandafter{\|} -\expandafter\DeclareRobustCommand\expandafter\-\expandafter{\-} -%%%%%%%%%%%%%%%% +%% Recent \LaTeX{} releases (starting with <2017-04-15>) define \cs{-} robust. +%% This resulted in a infinite loop with older version of bpchem. We could use +%% \cs{IncludeInRelease}, but it might be easier to just use the definition +%% from the latest \LaTeX{} releases. +\DeclareRobustCommand{\-}{% + \discretionary{% + \char \ifnum\hyphenchar\font<\z@% + \defaulthyphenchar% + \else% + \hyphenchar\font% + \fi% + }{}{}% +}% \end{macrocode} %% counters for numbering of chemical substances \newcounter{BPCno} \renewcommand{\theBPCno}{\textbf{\arabic{BPCno}}} - \newcounter{BPCnoa}[BPCno] \renewcommand{\theBPCnoa}{\textbf{\arabic{BPCno}\alph{BPCnoa}}} - %% helper functions to mark first definition \newcommand{\newchems@b}[2]{ \expandafter\gdef\csname cna@#1#2\endcsname{#2}% } - %% reference a CNlabel (useful for section titles, captions etc.) \DeclareRobustCommand*{\CNref}[1]{% -\ref{cn:#1}% + \ref{cn:#1}% } - %% reference a CNlabel/sublabel \DeclareRobustCommand*{\CNrefsub}[2]{% -\ref{cn:#1#2} + \ref{cn:#1#2} %%\textbf{\csname cna@#1#2\endcsname}% } - %% label a substance and insert the number \DeclareRobustCommand*{\CNlabel}[1]{% -\CNlabelnoref{#1}% -\CNref{#1}% + \CNlabelnoref{#1}% + \CNref{#1}% } - -%% \DeclareRobustCommand*{\CNlabelnoref}[1]{% -\expandafter\ifx\csname cnd@#1\endcsname\relax% -{\refstepcounter{BPCno}\label{cn:#1}}% -\expandafter\gdef\csname cnd@#1\endcsname{x}% -\fi% + \expandafter\ifx\csname cnd@#1\endcsname\relax% + {\refstepcounter{BPCno}\label{cn:#1}}% + \expandafter\gdef\csname cnd@#1\endcsname{x}% + \fi% } \DeclareRobustCommand*{\CNlabelsub}[2]{% -\CNlabelsubnoref{#1}{#2}% -\CNrefsub{#1}{#2}% + \CNlabelsubnoref{#1}{#2}% + \CNrefsub{#1}{#2}% } \DeclareRobustCommand*{\CNlabelsubnoref}[2]{% -\CNlabelnoref{#1}% -\expandafter\ifx\csname cna@#1#2\endcsname\relax% -{\refstepcounter{BPCnoa}\label{cn:#1#2}}% -\expandafter\gdef\csname cna@#1#2\endcsname{x}% + \CNlabelnoref{#1}% + \expandafter\ifx\csname cna@#1#2\endcsname\relax% + {\refstepcounter{BPCnoa}\label{cn:#1#2}}% + \expandafter\gdef\csname cna@#1#2\endcsname{x}% %% \newchems@b{#1}{#2}% %% \write\@auxout{\string\newchems@b{#1}{#2}}% \fi% @@ -204,26 +201,26 @@ \DeclareRobustCommand{\trans}{\textit{trans}\xspace} %%%%%%%%%%%%%%%%%%%%% \ifusecbgreek% code with roman greek -\PackageInfo{bpchem}{using upright greek fonts from cbgreek} -\input{lgrenc.def} -\DeclareRobustCommand{\rm@greekletter}[1]{{\fontencoding{LGR}\selectfont% - \def\encodingdefault{LGR}#1}}% -\DeclareRobustCommand{\bpalpha}{\rm@greekletter{a}} -\DeclareRobustCommand{\bpbeta}{\rm@greekletter{b}} -\DeclareRobustCommand{\bpDelta}{\rm@greekletter{D}} -\DeclareRobustCommand{\hapto}[1]{\rm@greekletter{h}\^{#1}} + \PackageInfo{bpchem}{using upright greek fonts from cbgreek} + \input{lgrenc.def} + \DeclareRobustCommand{\rm@greekletter}[1]{{\fontencoding{LGR}\selectfont% + \def\encodingdefault{LGR}#1}}% + \DeclareRobustCommand{\bpalpha}{\rm@greekletter{a}} + \DeclareRobustCommand{\bpbeta}{\rm@greekletter{b}} + \DeclareRobustCommand{\bpDelta}{\rm@greekletter{D}} + \DeclareRobustCommand{\hapto}[1]{\rm@greekletter{h}\^{#1}} \else -\PackageInfo{bpchem}{using default math greek fonts} -\DeclareRobustCommand{\bpalpha}{\ensuremath{\alpha}\xspace} -\DeclareRobustCommand{\bpbeta}{\ensuremath{\beta}\xspace} -\DeclareRobustCommand{\bpDelta}{\ensuremath{\Delta}\xspace} -\DeclareRobustCommand{\hapto}[1]{\ensuremath{\eta^{#1}}} -\fi + \PackageInfo{bpchem}{using default math greek fonts} + \DeclareRobustCommand{\bpalpha}{\ensuremath{\alpha}\xspace} + \DeclareRobustCommand{\bpbeta}{\ensuremath{\beta}\xspace} + \DeclareRobustCommand{\bpDelta}{\ensuremath{\Delta}\xspace} + \DeclareRobustCommand{\hapto}[1]{\ensuremath{\eta^{#1}}} +\fi% \let\talpha\bpalpha \let\tbeta\bpbeta %%%%%% \DeclareRobustCommand*{\dreh}[1]% -{$\lbrack \alpha \rbrack _{\mathrm D}^{#1}$} + {$\lbrack \alpha \rbrack _{\mathrm D}^{#1}$} \endinput %% %% End of file `bpchem.sty'. |