%%
%% LaTeX package `boldtensors'
%%
%% This program can be redistributed and/or modified under the
%% terms of the GNU Public License, version 2.
%%
%% Copyright 1995 by Werner Fink und Juergen Bachteler
%% Copyright 2007 by Werner Fink
%%
%% 1995/01/10
%% Authors : Werner Fink und Juergen Bachteler
%%           Institut fuer Theoretische und Angewandte Physik,
%%           Universitaet Stuttgart
%%           Pfaffenwaldring 57/vi, 7000 Stuttgart 80 
%%
%% 2007/06/29
%% Author: Werner Fink <werner@suse.de>
%%
\NeedsTeXFormat{LaTeX2e}[1994/12/01]
\ProvidesPackage{boldtensors}[1995/01/10 boldtensors]
\@ifundefined{@bt@math}{\relax}%
    {\message{-- boldtensors already loaded --}\endinput}
\message{Document Style Option `boldtensors' }
\newif\ifbt@nabla\bt@nablafalse
\newif\ifbt@diffop\bt@diffopfalse
\DeclareOption{nabla}{\bt@nablatrue}
\DeclareOption{differential}{\bt@diffoptrue}
\ProcessOptions
%
% Define a font family and some font shapes for both
% bold latin and greek symbols in \mathversion{normal}
% For all fonts we use \skewchar'177 then we can also
% use accents even on the nabla operator.
%
\DeclareFontFamily{U}{cmten}{\skewchar\font='177}
%
% Bold italic standard version
%
\DeclareFontShape{U}{cmten}{b}{it}{%
    <5> sfixed * [5.48] cmmib5
    <6> sfixed * [6.57] cmmib6
    <7> sfixed * [7.67] cmmib7
    <8> sfixed * [8.76] cmmib8
    <9> sfixed * [9.86] cmmib9
    <10> sfixed * [10] cmmib10
    <11> sfixed * [10.95] cmmib10
    <12> sfixed * [12] cmmib10
    <14> sfixed * [14.4] cmmib10
    <17> sfixed * [17.28] cmmib10
    <20> sfixed * [20.74] cmmib10
    <25> sfixed * [24.88] cmmib10}{}
%
% Bold \mathrm numbers for null and one tensor
% Some changes are done for upper greek symbols
%
\DeclareFontShape{U}{cmten}{bx}{n}{%
    <5> sfixed * [5.48] cmbx5
    <6> sfixed * [6.57] cmbx6
    <7> sfixed * [7.67] cmbx7
    <8> sfixed * [8.76] cmbx8
    <9> sfixed * [9.86] cmbx9
    <10> sfixed * [10] cmbx10
    <11> sfixed * [10.95] cmbx10
    <12> sfixed * [12] cmbx12
    <14> sfixed * [14.4] cmbx12
    <17> sfixed * [17.28] cmbx12
    <20> sfixed * [20.74] cmbx12
    <25> sfixed * [24.88] cmbx12}{}
%
% Some bold symbols useful for e.g. nabla operator
% cmbsy5 upto cmbsy9 are found within the AMS fonts
%
\DeclareFontShape{U}{cmten}{b}{n}{%
    <5> sfixed * [5.48] cmbsy5
    <6> sfixed * [6.57] cmbsy6
    <7> sfixed * [7.67] cmbsy7
    <8> sfixed * [8.76] cmbsy8
    <9> sfixed * [9.86] cmbsy9
    <10> sfixed * [10] cmbsy10
    <11> sfixed * [10.95] cmbsy10
    <12> sfixed * [12] cmbsy10
    <14> sfixed * [14.4] cmbsy10
    <17> sfixed * [17.28] cmbsy10
    <20> sfixed * [20.74] cmbsy10
    <25> sfixed * [24.88] cmbsy10}{}
%
% The blackboards bolds from Jeffrey's
%
\DeclareFontShape{U}{cmten}{m}{n}{%
    <5> sfixed * [5] bbold5
    <6> sfixed * [6] bbold6
    <7> sfixed * [7] bbold7
    <8> sfixed * [8] bbold8
    <9> sfixed * [9] bbold9
    <10> sfixed * [10] bbold10
    <11> sfixed * [10.95] bbold10
    <12> sfixed * [12] bbold12
    <14> sfixed * [14.4] bbold12
    <17> sfixed * [17.28] bbold17
    <20> sfixed * [20.74] bbold17
    <25> sfixed * [24.88] bbold17}{}
%
% Now declare the symbol fonts
%
\DeclareSymbolFont{cmtensor}  {U}{cmten}{b} {it}
\DeclareSymbolFont{cmoperator}{U}{cmten}{bx}{n}
\DeclareSymbolFont{cmsymbols} {U}{cmten}{b} {n}
\DeclareSymbolFont{cmbboard}  {U}{cmten}{m} {n}
%
% Set up fonts
%
\DeclareSymbolFontAlphabet{\btensor}  {cmtensor}
\DeclareSymbolFontAlphabet{\boperator}{cmoperator}
\DeclareSymbolFontAlphabet{\bsymbols} {cmsymbols}
\DeclareSymbolFontAlphabet{\bboard}   {cmbboard}
%
% This macro helps us some none \mathalpha
% symbols in a bold version
%
\let\@wait\expandafter
\let\@null\relax
\def\def@DeclareMathSymbol#1#2#3#4#5{\@wait%
  \DeclareMathSymbol\csname#1@\string#2\endcsname{#3}{#4}{#5}}
%
% For both bold and blackboard bold symbols
%
\def\btens@DeclareMathSymbol{\def@DeclareMathSymbol{bt}}
\def\bbold@DeclareMathSymbol{\def@DeclareMathSymbol{bb}}
%
% The bold tensor none \mathalpha symbols
%
\btens@DeclareMathSymbol{\alpha}{\mathord}{cmtensor}{"0B}
\btens@DeclareMathSymbol{\beta}{\mathord}{cmtensor}{"0C}
\btens@DeclareMathSymbol{\gamma}{\mathord}{cmtensor}{"0D}
\btens@DeclareMathSymbol{\delta}{\mathord}{cmtensor}{"0E}
\btens@DeclareMathSymbol{\epsilon}{\mathord}{cmtensor}{"0F}
\btens@DeclareMathSymbol{\zeta}{\mathord}{cmtensor}{"10}
\btens@DeclareMathSymbol{\eta}{\mathord}{cmtensor}{"11}
\btens@DeclareMathSymbol{\theta}{\mathord}{cmtensor}{"12}
\btens@DeclareMathSymbol{\iota}{\mathord}{cmtensor}{"13}
\btens@DeclareMathSymbol{\kappa}{\mathord}{cmtensor}{"14}
\btens@DeclareMathSymbol{\lambda}{\mathord}{cmtensor}{"15}
\btens@DeclareMathSymbol{\mu}{\mathord}{cmtensor}{"16}
\btens@DeclareMathSymbol{\nu}{\mathord}{cmtensor}{"17}
\btens@DeclareMathSymbol{\xi}{\mathord}{cmtensor}{"18}
\btens@DeclareMathSymbol{\pi}{\mathord}{cmtensor}{"19}
\btens@DeclareMathSymbol{\rho}{\mathord}{cmtensor}{"1A}
\btens@DeclareMathSymbol{\sigma}{\mathord}{cmtensor}{"1B}
\btens@DeclareMathSymbol{\tau}{\mathord}{cmtensor}{"1C}
\btens@DeclareMathSymbol{\upsilon}{\mathord}{cmtensor}{"1D}
\btens@DeclareMathSymbol{\phi}{\mathord}{cmtensor}{"1E}
\btens@DeclareMathSymbol{\chi}{\mathord}{cmtensor}{"1F}
\btens@DeclareMathSymbol{\psi}{\mathord}{cmtensor}{"20}
\btens@DeclareMathSymbol{\omega}{\mathord}{cmtensor}{"21}
\btens@DeclareMathSymbol{\varepsilon}{\mathord}{cmtensor}{"22}
\btens@DeclareMathSymbol{\vartheta}{\mathord}{cmtensor}{"23}
\btens@DeclareMathSymbol{\varpi}{\mathord}{cmtensor}{"24}
\btens@DeclareMathSymbol{\varrho}{\mathord}{cmtensor}{"25}
\btens@DeclareMathSymbol{\varsigma}{\mathord}{cmtensor}{"26}
\btens@DeclareMathSymbol{\varphi}{\mathord}{cmtensor}{"27}
\btens@DeclareMathSymbol{\imath}{\mathord}{cmtensor}{"7B}
\btens@DeclareMathSymbol{\jmath}{\mathord}{cmtensor}{"7C}
%
% Some bold integers and roman symbols
%
\btens@DeclareMathSymbol{1}{\mathord}{cmoperator}{"31}
\btens@DeclareMathSymbol{0}{\mathord}{cmoperator}{"30}
\btens@DeclareMathSymbol{\Gamma}{\mathord}{cmoperator}{"00}
\btens@DeclareMathSymbol{\Delta}{\mathord}{cmoperator}{"01}
\btens@DeclareMathSymbol{\Theta}{\mathord}{cmoperator}{"02}
\btens@DeclareMathSymbol{\Lambda}{\mathord}{cmoperator}{"03}
\btens@DeclareMathSymbol{\Xi}{\mathord}{cmoperator}{"04}
\btens@DeclareMathSymbol{\Pi}{\mathord}{cmoperator}{"05}
\btens@DeclareMathSymbol{\Sigma}{\mathord}{cmoperator}{"06}
\btens@DeclareMathSymbol{\Upsilon}{\mathord}{cmoperator}{"07}
\btens@DeclareMathSymbol{\Phi}{\mathord}{cmoperator}{"08}
\btens@DeclareMathSymbol{\Psi}{\mathord}{cmoperator}{"09}
\btens@DeclareMathSymbol{\Omega}{\mathord}{cmoperator}{"0A}
%
% The bold nabla operator
%
\ifbt@nabla
\btens@DeclareMathSymbol{\nabla}{\mathord}{cmsymbols}{"72}\fi
%
% The blackboard bold greek characters
%
\bbold@DeclareMathSymbol{\alpha}{\mathord}{cmbboard}{"0B}
\bbold@DeclareMathSymbol{\beta}{\mathord}{cmbboard}{"0C}
\bbold@DeclareMathSymbol{\gamma}{\mathord}{cmbboard}{"0D}
\bbold@DeclareMathSymbol{\delta}{\mathord}{cmbboard}{"0E}
\bbold@DeclareMathSymbol{\epsilon}{\mathord}{cmbboard}{"0F}
\bbold@DeclareMathSymbol{\zeta}{\mathord}{cmbboard}{"10}
\bbold@DeclareMathSymbol{\eta}{\mathord}{cmbboard}{"11}
\bbold@DeclareMathSymbol{\theta}{\mathord}{cmbboard}{"12}
\bbold@DeclareMathSymbol{\iota}{\mathord}{cmbboard}{"13}
\bbold@DeclareMathSymbol{\kappa}{\mathord}{cmbboard}{"14}
\bbold@DeclareMathSymbol{\lambda}{\mathord}{cmbboard}{"15}
\bbold@DeclareMathSymbol{\mu}{\mathord}{cmbboard}{"16}
\bbold@DeclareMathSymbol{\nu}{\mathord}{cmbboard}{"17}
\bbold@DeclareMathSymbol{\xi}{\mathord}{cmbboard}{"18}
\bbold@DeclareMathSymbol{\pi}{\mathord}{cmbboard}{"19}
\bbold@DeclareMathSymbol{\rho}{\mathord}{cmbboard}{"1A}
\bbold@DeclareMathSymbol{\sigma}{\mathord}{cmbboard}{"1B}
\bbold@DeclareMathSymbol{\tau}{\mathord}{cmbboard}{"1C}
\bbold@DeclareMathSymbol{\upsilon}{\mathord}{cmbboard}{"1D}
\bbold@DeclareMathSymbol{\phi}{\mathord}{cmbboard}{"1E}
\bbold@DeclareMathSymbol{\chi}{\mathord}{cmbboard}{"1F}
\bbold@DeclareMathSymbol{\psi}{\mathord}{cmbboard}{"20}
\bbold@DeclareMathSymbol{\omega}{\mathord}{cmbboard}{"21}
\bbold@DeclareMathSymbol{\varepsilon}{\mathord}{cmbboard}{"22}
\bbold@DeclareMathSymbol{\vartheta}{\mathord}{cmbboard}{"23}
\bbold@DeclareMathSymbol{\varpi}{\mathord}{cmbboard}{"24}
\bbold@DeclareMathSymbol{\varrho}{\mathord}{cmbboard}{"25}
\bbold@DeclareMathSymbol{\varsigma}{\mathord}{cmbboard}{"26}
\bbold@DeclareMathSymbol{\varphi}{\mathord}{cmbboard}{"27}
\bbold@DeclareMathSymbol{\imath}{\mathord}{cmbboard}{"7B}
\bbold@DeclareMathSymbol{\jmath}{\mathord}{cmbboard}{"7C}
%
% Redeclare the small `d' to have differential operator in roman
%
\ifbt@diffop
\DeclareMathSymbol{d}{\mathord}{operators}{`d}\fi
%
% For known symbols use them otherwise use font
%
\def\btens@#1{%
   \@wait\ifx\csname bt@\string#1\endcsname\@null%
     \mathord{\btensor#1}%
   \else%
     \csname bt@\string#1\endcsname%
   \fi}
\def\bbold@#1{%
   \@wait\ifx\csname bb@\string#1\endcsname\@null%
     \mathord{\bboard#1}%
   \else%
     \csname bb@\string#1\endcsname%
   \fi}
%
% Do this only in math mode
%
\def\@bt@math{\ifmmode\@wait\btens@\else\@wait\bt@text\fi}
\def\@bb@math{\ifmmode\@wait\bbold@\else\@wait\bb@text\fi}
%
% Avoid that macros will be broken
%
\def\bt@math{\protect\@bt@math}
\def\bb@math{\protect\@bb@math}
%
% Switch cat code back for ~ and "
%
\def\outer@boldtensor{%
  \catcode`\"=13\@null%
  \catcode`\~=13\@null}
%
% Switch cat code to math for ~ and "
%
\def\inner@boldtensor{%
  \mathcode`\"="8000\@null%
  \mathcode`\~="8000\@null}
%
% Set up the hook for begin{document}
%
\begingroup
  \outer@boldtensor\@null%
  \gdef\boldtensor{%
     \let\bt@text=~\@null%
     \let\bb@text="\@null%
     \let~=\bt@math\@null%
     \let"=\bb@math\@null%
     \let\boldtensor=\@null%
     \inner@boldtensor\@null}
  \AtBeginDocument{\boldtensor}
\endgroup
%
% Just the end
%
\endinput
