% SPDX-License-Identifier: CC-BY-4.0
% Copyright Contributors to the Open Shading Language Project.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Style developed by Larry Gritz for various books and technical
% manuals.  Please distribute freely, there's nothing special here.
% It's a modifiction of LaTeX's "book.cls" that changes the
% \chapter, \section, etc., commands to have the formatting I want.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\renewcommand\part{%
  \if@openright
    \cleardoublepage
  \else
    \clearpage
  \fi
  \thispagestyle{plain}%
  \if@twocolumn
    \onecolumn
    \@tempswatrue
  \else
    \@tempswafalse
  \fi
  \null\vfil
  \secdef\@part\@spart}

\def\@part[#1]#2{%
    \ifnum \c@secnumdepth >-2\relax
      \refstepcounter{part}%
      \addcontentsline{toc}{part}{\thepart\hspace{1em}#1}%
    \else
      \addcontentsline{toc}{part}{#1}%
    \fi
    \markboth{}{}%
    {\centering
     \interlinepenalty \@M
     \normalfont
     \ifnum \c@secnumdepth >-2\relax
%lg       \huge\bfseries \partname~\thepart
       \huge\sffamily\bfseries \partname~\thepart     %lg
       \par
       \vskip 20\p@
     \fi
     \Huge \bfseries #2\par}%
    \@endpart}
\def\@spart#1{%
    {\centering
     \interlinepenalty \@M
     \normalfont
%lg     \Huge \bfseries #1\par}%
     \Huge \sffamily\bfseries #1\par}%   %lg
    \@endpart}
\def\@endpart{\vfil\newpage
              \if@twoside
                \null
                \thispagestyle{empty}%
                \newpage
              \fi
              \if@tempswa
                \twocolumn
              \fi}

\renewcommand\chapter{\if@openright\cleardoublepage\else\clearpage\fi
                    \thispagestyle{plain}%
                    \global\@topnum\z@
                    \@afterindentfalse
                    \secdef\@chapter\@schapter}
\def\@chapter[#1]#2{\ifnum \c@secnumdepth >\m@ne
                       \if@mainmatter
                         \refstepcounter{chapter}%
                         \typeout{\@chapapp\space\thechapter.}%
                         \addcontentsline{toc}{chapter}%
                                   {\protect\numberline{\thechapter}#1}%
                       \else
                         \addcontentsline{toc}{chapter}{#1}%
                       \fi
                    \else
                      \addcontentsline{toc}{chapter}{#1}%
                    \fi
                    \chaptermark{#1}%
                    \addtocontents{lof}{\protect\addvspace{10\p@}}%
                    \addtocontents{lot}{\protect\addvspace{10\p@}}%
                    \if@twocolumn
                      \@topnewpage[\@makechapterhead{#2}]%
                    \else
                      \@makechapterhead{#2}%
                      \@afterheading
                    \fi}
\def\@makechapterhead#1{%
  \vspace*{50\p@}%
  {\parindent \z@ \raggedright \normalfont
    \ifnum \c@secnumdepth >\m@ne
      \if@mainmatter
%lg        \huge\bfseries \@chapapp\space \thechapter
        \Huge \sffamily \bfseries \thechapter \hspace{1em} %lg
%lg        \par\nobreak
%lg        \vskip 20\p@
      \fi
    \fi
    \interlinepenalty\@M
%lg    \Huge \bfseries #1\par\nobreak
    \Huge \sffamily\bfseries #1\par\nobreak     %lg
    \vskip 40\p@
  }}
\def\@schapter#1{\if@twocolumn
                   \@topnewpage[\@makeschapterhead{#1}]%
                 \else
                   \@makeschapterhead{#1}%
                   \@afterheading
                 \fi}
\def\@makeschapterhead#1{%   %%% lg this is for chapter*
  \vspace*{50\p@}%
  {\parindent \z@ \raggedright
    \normalfont
    \interlinepenalty\@M
%lg    \Huge \bfseries  #1\par\nobreak
    \Huge \sffamily \bfseries  #1\par\nobreak %lg
    \vskip 40\p@
  }}
\renewcommand\section{\@startsection {section}{1}{\z@}%
                                   {-3.5ex \@plus -1ex \@minus -.2ex}%
                                   {2.3ex \@plus.2ex}%
%lg                                   {\normalfont\Large\bfseries}}
                                   {\normalfont\Large\sffamily\bfseries}} %lg
\renewcommand\subsection{\@startsection{subsection}{2}{\z@}%
                                     {-3.25ex\@plus -1ex \@minus -.2ex}%
                                     {1.5ex \@plus .2ex}%
%lg                                     {\normalfont\large\bfseries}}
                                     {\normalfont\large\sffamily\bfseries}} %lg
\renewcommand\subsubsection{\@startsection{subsubsection}{3}{\z@}%
                                     {-3.25ex\@plus -1ex \@minus -.2ex}%
                                     {1.5ex \@plus .2ex}%
%lg                                     {\normalfont\normalsize\bfseries}}
                                     {\normalfont\normalsize\sffamily\bfseries}} %lg
\renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}%
                                    {3.25ex \@plus1ex \@minus.2ex}%
                                    {-1em}%
                                    {\normalfont\normalsize\bfseries}}
\renewcommand\subparagraph{\@startsection{subparagraph}{5}{\parindent}%
                                       {3.25ex \@plus1ex \@minus .2ex}%
                                       {-1em}%
                                      {\normalfont\normalsize\bfseries}}




%%%%
% lg - added new environment for descriptions specifically for the glossary
%
\newenvironment{glossarydescription}
               {\list{}{\small \setlength{\leftmargin}{0pt}
			\setlength{\itemsep}{0pt}
			\labelwidth\z@ \itemindent-\leftmargin
                        \let\makelabel\glossarydescriptionlabel}}
               {\endlist}
\newcommand*\glossarydescriptionlabel[1]{\hspace\labelsep
                                \normalfont\bfseries #1}
%
%%%%



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Modify the bibliography citation style
% I borrowed this from apastyle, then modified it -- lg
%%%%%%%%

\def\@cite#1#2{(#1\if@tempswa , #2\fi)}
\def\@biblabel#1{}

\newlength{\bibhang}
\setlength{\bibhang}{0em}

\@ifundefined{chapter}{\def\thebibliography#1{\section*{\refname\@mkboth
  {\sl\uppercase{\refname}}{\sl\uppercase{\refname}}}\list
  {\relax}{
  \setlength{\labelsep}{0em}  %lg
  \setlength{\itemindent}{-\bibhang}
  \setlength{\leftmargin}{\bibhang}}
    \def\newblock{\hskip .11em plus .33em minus .07em}
    \sloppy\clubpenalty4000\widowpenalty4000
    \sfcode`\.=1000\relax}}%
{\def\thebibliography#1{\chapter*{\bibname\@mkboth
  {\sl\uppercase{\bibname}}{\sl\uppercase{\bibname}}}\list
  {\relax}{\setlength{\labelsep}{0em}
  \small \setlength{\itemsep}{0pt}  %lg
  \setlength{\itemindent}{-\bibhang}
  \setlength{\leftmargin}{\bibhang}}
    \def\newblock{\hskip .11em plus .33em minus .07em}
    \sloppy\clubpenalty4000\widowpenalty4000
    \sfcode`\.=1000\relax}}

\def\@citex[#1]#2{\if@filesw\immediate\write\@auxout{\string\citation{#2}}\fi
  \def\@citea{}\@cite{\@for\@citeb:=#2\do
    {\@citea\def\@citea{; }\@ifundefined
       {b@\@citeb}{{\bf ?}\@warning
       {Citation `\@citeb' on page \thepage \space undefined}}%
{\csname b@\@citeb\endcsname}}}{#1}}

