From 4446262d21bd355820d10bf638ff0f38c94d77a2 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Thu, 12 Jan 2006 23:52:28 +0000 Subject: bpchem git-svn-id: svn://tug.org/texlive/trunk@724 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/tex/latex/bpchem/bpchem.sty | 229 ++++++++++++++++++++++++++ 1 file changed, 229 insertions(+) create mode 100644 Master/texmf-dist/tex/latex/bpchem/bpchem.sty (limited to 'Master/texmf-dist/tex/latex/bpchem') diff --git a/Master/texmf-dist/tex/latex/bpchem/bpchem.sty b/Master/texmf-dist/tex/latex/bpchem/bpchem.sty new file mode 100644 index 00000000000..766ee6e91e7 --- /dev/null +++ b/Master/texmf-dist/tex/latex/bpchem/bpchem.sty @@ -0,0 +1,229 @@ +%% +%% This is file `bpchem.sty', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% bpchem.dtx (with options: `bpchem') +%% +%% IMPORTANT NOTICE: +%% +%% For the copyright see the source file. +%% +%% Any modified versions of this file must be renamed +%% with new filenames distinct from bpchem.sty. +%% +%% For distribution of the original source see the terms +%% for copying and modification in the file bpchem.dtx. +%% +%% This generated file may be distributed as long as the +%% 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 +%% Bjoern Pedersen +%% This file may be distributed and used freely under +%% the Latex Project Public License +%% +%% +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{bpchem}[2004/11/06 v1.05 Chemical input helper] +\RequirePackage{xspace} + %\IUPAC{Tetra\|cyclo[2.2.2.1\^{1,4}]\- + + + + + +\newif\ifusecbgreek% +\usecbgreekfalse% +\DeclareOption{cbgreek}{\PackageInfo{bpchem}{cbgreek selected}\usecbgreektrue} +\ProcessOptions\relax +%% Define a textsubscript corresponing to textsuperscript. +%% This is now also available as the package textsubscript by +%% D.Arsenau or as part of KOMA-Script2 by M. Kohm. +%% +%% +\providecommand*\textsubscript[1]{% + \@textsubscript{\selectfont#1}} +\def\@textsubscript#1{% + {\m@th\ensuremath{_{\mbox{\fontsize\sf@size\z@#1}}}}} +%% 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} + +%% 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 + }% +%% 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 + }% +%% 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% + }% +%% 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% + }% +%% see if next token is BPCsuper, + \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% + }% +%% backspace BPClen and make superscript +%% eats the old \verb|\^| + \DeclareRobustCommand{\BPCsuperbs}[1]{\kern-\BPClensub\BPCsuper}% +%% backspace and make subscript +%% eats the old \_ + \DeclareRobustCommand{\BPCsubbs}[1]{\kern-\BPClensuper\BPCsub}% +%% needed to get catcodes right + \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 +%% setup for chemical formula +\DeclareRobustCommand\BPChem{% + \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} +\let\MB=\MultiBreak \let\BH=\BreakHyph +\DeclareRobustCommand{\DoIUPAC}[1]{% +#1\endgroup} +\def\Prep{% +\let\-=\BreakHyph% +\let\|=\MultiBreak% +\DoIUPAC% +} +\DeclareRobustCommand*{\IUPAC}{% + \begingroup\BPCSetup\ignorespaces% + \Prep}% + +%% Trick by David Kastrup to make +%% non-fragile. Otherwise \verb+\|+ would become \verb+\delimiter"026B30D+ in +%% e.g. the toc +\expandafter\DeclareRobustCommand\expandafter\|\expandafter{\|} +\expandafter\DeclareRobustCommand\expandafter\-\expandafter{\-} +%%%%%%%%%%%%%%%% +%% 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}% +} + +%% reference a CNlabel/sublabel +\DeclareRobustCommand*{\CNrefsub}[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}% +} + +%% +\DeclareRobustCommand*{\CNlabelnoref}[1]{% +\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}% +} +\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}% +%% \newchems@b{#1}{#2}% +%% \write\@auxout{\string\newchems@b{#1}{#2}}% + \fi% +} +%% more helper mcors +\DeclareRobustCommand{\HNMR}{\IUPAC{\^{1}H-NMR}: $\delta$\xspace} +\DeclareRobustCommand{\CNMR}{\IUPAC{\^{13}C-NMR}: $\delta$\xspace} +\DeclareRobustCommand{\cis}{\textit{cis}\xspace} +\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}} +\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 +\let\talpha\bpalpha +\let\tbeta\bpbeta +%%%%%% +\DeclareRobustCommand*{\dreh}[1]% +{$\lbrack \alpha \rbrack _{\mathrm D}^{#1}$} +\endinput +%% +%% End of file `bpchem.sty'. -- cgit v1.2.3