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/source/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/source/latex/bpchem')
-rw-r--r-- | Master/texmf-dist/source/latex/bpchem/bpchem.dtx | 268 |
1 files changed, 128 insertions, 140 deletions
diff --git a/Master/texmf-dist/source/latex/bpchem/bpchem.dtx b/Master/texmf-dist/source/latex/bpchem/bpchem.dtx index 9639c0ce27f..8aa7533d8de 100644 --- a/Master/texmf-dist/source/latex/bpchem/bpchem.dtx +++ b/Master/texmf-dist/source/latex/bpchem/bpchem.dtx @@ -1,16 +1,16 @@ % \iffalse -%% 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 %% %% % %<*dtx> - \ProvidesFile{bpchem.dtx}[2004/11/25 v1.06 Chemical input helper] + \ProvidesFile{bpchem.dtx}[2017/08/23 v1.1 Chemical input helper] %</dtx> %<bpchem>\NeedsTeXFormat{LaTeX2e} -%<bpchem>\ProvidesPackage{bpchem}[2004/11/25 v1.06 Chemical input helper] +%<bpchem>\ProvidesPackage{bpchem}[2004/08/21 v1.1 Chemical input helper] %<bpchem>\RequirePackage{xspace} %<driver>\ProvidesFile{bpchem.drv} % \fi @@ -26,6 +26,11 @@ \end{document} %</driver> %\fi +% \changes{v1.1}{2017/08/23}{ +% Resolved conflict with recent \LaTeX{} releases (thanks to Ulrike Fischer +% and Martin Sievers) +% } +% % \changes{v1.05}{2004/11/06}{ % changed email % } @@ -40,20 +45,20 @@ % \date{\filedate} % \maketitle % \section{Introduction} -%This package has been written to alleviate the task of writing -%publications containing lots of chemistry. It provides methods for -%typesetting chemical names, sum formulae and isotopes. It provides the -%possibility to break very long names even over several lines. +% This package has been written to alleviate the task of writing +% publications containing lots of chemistry. It provides methods for +% typesetting chemical names, sum formulae and isotopes. It provides the +% possibility to break very long names even over several lines. % -%This package also provides a way to automatically enumerate your -%chemical compounds, allowing for one-level subgrouping. +% This package also provides a way to automatically enumerate your +% chemical compounds, allowing for one-level subgrouping. % -%What this package does not provide: Methods to draw chemical -%compounds. Although there exist some packages,which where designed for -%this purpose (e.g. xymtex, PPChTex) they are quite limited once you -%get to complex organic, or metal organic compounds. I recommend using -%an external drawing program, possibly in conjunction with psfrag, in -%these cases. +% What this package does not provide: Methods to draw chemical +% compounds. Although there exist some packages,which where designed for +% this purpose (e.g. xymtex, PPChTex) they are quite limited once you +% get to complex organic, or metal organic compounds. I recommend using +% an external drawing program, possibly in conjunction with psfrag, in +% these cases. % %\section{Package options} % Currently this package supports only one option: @@ -120,10 +125,6 @@ %Alkohol \CNlabel{al} is converted to aldehyd \CNlabel{ad}. \CNref{al} %can also be used otherwise, while \CNref{ad} cannot. %\end{minipage} - - - - % % %\subsection{Using sub-labels for classes of compounds: CNlabelsub\{<label>\}\{<sublabel>\}, @@ -138,7 +139,7 @@ %To change, use something like \begin{verbatim} %\renewcommand{\theBPCnoa}{\textbf{\arabic{BPCno}\alph{BPCnoa}}} %\end{verbatim} - +% %\begin{verbatim} %To demonstrate the use of sublabels, methanol \CNlabelsub{alk}{a} and %ethanol \CNlabelsub{alk}{b} are both natural products. The acohols \CNref{alk} @@ -151,7 +152,7 @@ %can synthezied bio-chemically. \CNrefsub{alk}{a} is toxic, while %\CNrefsub{alk}{b} is only mildly toxic. %\end{minipage} - +% %\subsection{Shortcuts for common idioms in chemical literature} % % @@ -160,7 +161,6 @@ %\item[\CNMR] \verb|\CNMR| %\item[\cis] \verb|\cis| %\item[\trans] \verb|\trans| - %\item[\bpalpha] \verb|\bpalpha| %\item[\bpbeta] \verb|\bpbeta| %\item[\bpDelta] \verb|\bpdelta| @@ -232,215 +232,204 @@ %% two registers needed to get back to correct %% working position if one is longer than the other. % \begin{macrocode} - \newlength{\BPClensub} - \newlength{\BPClensuper} - \newlength{\BPCdelta} -% +\newlength{\BPClensub} +\newlength{\BPClensuper} +\newlength{\BPCdelta} % \end{macrocode} - %% we are in subscript and maybe the superscript was longer % \begin{macrocode} - \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 +}% % \end{macrocode} %% we are in superscript and maybe the subscript was longer % \begin{macrocode} - \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 +}% % \end{macrocode} -% %% make a subscript and remember length in BPClen % \begin{macrocode} - \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% +}% % \end{macrocode} -% %% make a superscript and remember length in BPClen %% raise by 0.15 em, else e.g. + collides with subscript % \begin{macrocode} - \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% +}% % \end{macrocode} -% -% %% see if next token is BPCsuper, % \begin{macrocode} - \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% +}% % \end{macrocode} -% %% see if next token is BPCsub % \begin{macrocode} - \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% +}% % \end{macrocode} %% backspace BPClen and make superscript %% eats the old \verb|\^| % \begin{macrocode} - \DeclareRobustCommand{\BPCsuperbs}[1]{\kern-\BPClensub\BPCsuper}% -% +\DeclareRobustCommand{\BPCsuperbs}[1]{\kern-\BPClensub\BPCsuper}% % \end{macrocode} %% backspace and make subscript -%% eats the old \_ +%% eats the old \_ % \begin{macrocode} - \DeclareRobustCommand{\BPCsubbs}[1]{\kern-\BPClensuper\BPCsub}% -% +\DeclareRobustCommand{\BPCsubbs}[1]{\kern-\BPClensuper\BPCsub}% % \end{macrocode} -% %% needed to get catcodes right % \begin{macrocode} - \DeclareRobustCommand{\DoBPChem}{}% - \def\DoBPChem#1{% - #1\endgroup% - }% +\DeclareRobustCommand{\DoBPChem}{}% +\def\DoBPChem#1{% + #1\endgroup% +}% \DeclareRobustCommand{\BPCSetupCat}{} \def\BPCSetupCat{% %\catcode`^=\active% %\catcode`\_=\active% \BPCSetup% }% -% \DeclareRobustCommand{\BPCSetup}{} \def\BPCSetup{% -% \let\_=\BPCsub% \let\^=\BPCsuper% }%end BPCSetup % \end{macrocode} -% %% setup for chemical formula % \begin{macrocode} \DeclareRobustCommand\BPChem{% \begingroup% endgroup in DoBPChem \BPCSetupCat% \DoBPChem% - } +} % \end{macrocode} -% -% - %% 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 % \changes{v1.05}{2004/11/06}{ -% fixed whitespace bug in DoIUPAC +% fixed whitespace bug in \cs{DoIUPAC} % } % \begin{macrocode} \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}% % \end{macrocode} - -% \changes{v1.03}{2002/11/01}{ -% fixed bug in \textbackslash IUPAC, \textbackslash | is not getting translated -% to \textbackslash delimitier during \textbackslash write anymore +% \changes{v1.03}{2002/11/01}{% +% fixed bug in \cs{IUPAC}, \texttt{\textbackslash$\vert$} is not getting +% translated to \cs{delimiter} during \cs{write} anymore % } -% \changes{v1.04}{2002/12/14}{also \textbackslash - was affected, fixed} -%% 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 % \begin{macrocode} \expandafter\DeclareRobustCommand\expandafter\|\expandafter{\|} -\expandafter\DeclareRobustCommand\expandafter\-\expandafter{\-} % \end{macrocode} -%%%%%%%%%%%%%%%% +% \changes{v1.04}{2002/12/14}{also \cs{-} was affected, fixed} +%% 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 +% \changes{v1.1}{2017/08/23}{% +% Recent \LaTeX{} releases make \cs{-} robust as +% well. This results in an infinite loop. +% } +%% 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. +% \begin{macrocode} +\DeclareRobustCommand{\-}{% + \discretionary{% + \char \ifnum\hyphenchar\font<\z@% + \defaulthyphenchar% + \else% + \hyphenchar\font% + \fi% + }{}{}% +}% \end{macrocode} %% counters for numbering of chemical substances % \begin{macrocode} \newcounter{BPCno} \renewcommand{\theBPCno}{\textbf{\arabic{BPCno}}} - +% \newcounter{BPCnoa}[BPCno] \renewcommand{\theBPCnoa}{\textbf{\arabic{BPCno}\alph{BPCnoa}}} % \end{macrocode} - %% helper functions to mark first definition % \begin{macrocode} \newcommand{\newchems@b}[2]{ \expandafter\gdef\csname cna@#1#2\endcsname{#2}% } % \end{macrocode} - %% reference a CNlabel (useful for section titles, captions etc.) % \begin{macrocode} \DeclareRobustCommand*{\CNref}[1]{% -\ref{cn:#1}% + \ref{cn:#1}% } % \end{macrocode} - %% reference a CNlabel/sublabel % \begin{macrocode} \DeclareRobustCommand*{\CNrefsub}[2]{% -\ref{cn:#1#2} + \ref{cn:#1#2} %%\textbf{\csname cna@#1#2\endcsname}% } % \end{macrocode} - - %% label a substance and insert the number % \changes{v1.06}{2004/11/25}{ % fixed whitespace bug in CNlabel % } % \begin{macrocode} \DeclareRobustCommand*{\CNlabel}[1]{% -\CNlabelnoref{#1}% -\CNref{#1}% + \CNlabelnoref{#1}% + \CNref{#1}% } % \end{macrocode} - -%% % \begin{macrocode} \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% } % \end{macrocode} % \begin{macrocode} \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% @@ -458,32 +447,31 @@ %\DeclareRobustCommand{\R}{\textit{R}} %\DeclareRobustCommand{\S}{\textit{S}} %%%%%%%%%%%%%%%%%%%%% -% \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}}% + \PackageInfo{bpchem}{using upright greek fonts from cbgreek} + \input{lgrenc.def} + \DeclareRobustCommand{\rm@greekletter}[1]{{\fontencoding{LGR}\selectfont% + \def\encodingdefault{LGR}#1}}% % some examples -\DeclareRobustCommand{\bpalpha}{\rm@greekletter{a}} -\DeclareRobustCommand{\bpbeta}{\rm@greekletter{b}} -\DeclareRobustCommand{\bpDelta}{\rm@greekletter{D}} -\DeclareRobustCommand{\hapto}[1]{\rm@greekletter{h}\^{#1}} + \DeclareRobustCommand{\bpalpha}{\rm@greekletter{a}} + \DeclareRobustCommand{\bpbeta}{\rm@greekletter{b}} + \DeclareRobustCommand{\bpDelta}{\rm@greekletter{D}} + \DeclareRobustCommand{\hapto}[1]{\rm@greekletter{h}\^{#1}} \else % code with standard math greek -\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}$} % \end{macrocode} %</bpchem> % \PrintChanges -% \CheckSum{365} +% \CheckSum{372} % \Finale |