%    Title:  Physics Notes
%     File:  physicsnotes.sty
%   Author:  David N. Williams
% Compiler:  Tex Live 2013
%            http://www.tug.org/texlive/
%  License:  LPPL
%  Started:  January 22, 2008 (as localBW.sty)
%  Revised:  March 6,7,9-12, 2008
%            December 28, 2008 (notes.sty start)
%            February 2, 2009
%            December 24, 2011
%            January 23, 2012
%            June 7, 2012
%            June 9, 2012 (renamed as dnwnotes.sty
%            June 14, 2012
%            August 7, 2012 (renamed as physicsnotes.sty)
%            January 22, 2013
%            February 2, 2013
%            June 11, 2014
%
% Copyright 2008, 2009, 2011-14 David N. Williams
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version
% 1.3 of this license or (at your option) any later version. The
% latest version of this license is (probably) in
%
%   http://www.latex-project.org/lppl.txt
%
% and version 1.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% This work has the LPPL maintenance status `maintained'.
% 
% The Current Maintainer of this work is David N. Williams.
%
% The work consists of this file.  It is based on the file
% dnwphysics.sty, with extra, document-specific macros.

% All references to The LaTeX Companion are from the 1994 second
% printing.

\ProvidesPackage{physicsnotes}[2013/02/02 DNW's physics note macros]

\@ifclassloaded{memoir}{}{%
 \PackageError{physicsnotes}
   {memoir class not loaded}
   {Missing \protect\documentclass[<options>]{memoir}.}
}
\@ifpackageloaded{amsmath}{}{%
  \PackageError{physicsnotes}
    {amsmath package needed}
    {Insert \textbackslash usepackage[<options>]\{amsmath\}}
}
\@ifpackageloaded{xspace}{}{%
  \PackageError{physicsnotes}
    {xspace package needed}
    {Insert \textbackslash usepackage[<options>]\{xspace\}}
}
\@ifpackageloaded{amsthm}{}{%
  \PackageError{physicsnotes}
    {amsthm package needed}
    {Insert \textbackslash usepackage[<options>]\{amsthm\}}
}
% for the user, not used explicitly here
\@ifpackageloaded{empheq}{}{%
  \PackageError{physicsnotes}
    {empheq package needed}
    {Insert \textbackslash usepackage[<options>]\{empheq\}}
}

%%% Front and main matter setup

% Title and table of contents not on separate pages.
%
\renewcommand{\frontmatter}{%
  \renewcommand{\thefootnote}{\fnsymbol{footnote}}
}
%
\renewcommand{\mainmatter}{%
  \setcounter{footnote}{0}
  \renewcommand{\thefootnote}{\arabic{footnote}}
}

%%% Title page setup

\pretitle{\begin{center}\LARGE\bfseries}
\predate{\begin{center}\normalsize}

% No title page, toc not separate; \maketitle mods found by
% trial and error:
%
\setlength{\droptitle}{-\headheight}
\addtolength{\droptitle}{-\headsep}
\renewcommand{\maketitlehooka}{\vspace*{-2em}} % undo hard wire

% Based on \published in The Memoir Class, Titles and Abstracts
% chapter:
%
\newcommand{\institution}[1]{\gdef\inS{#1}}
\newcommand{\inS}{}
\renewcommand{\maketitlehookc}{\centering{\normalsize\itshape\inS}}
%\renewcommand{\maketitlehookc}{\centering{\normalsize\inS}}

% To make default, paragraph style indentation by
% \thanksmarkwidth minus the mark size:
%
%\setlength{\thanksmarkwidth}{1.8em}
%\setlength{\thanksmarksep}{-\thanksmarkwidth}

% To make default, paragraph style indentation by \thanksmarkwidth
%  minus the mark size, do nothing, which uses the defaults:
%
%\setlength{\thanksmarkwidth}{1.8em}
% This makes subsequent footnote lines flush left:
%\setlength{\thanksmarksep}{-\thanksmarkwidth}

% To make \thanksmarkwidth from the left margin the same as a
% one-digit \footmarkwidth, and hang indent after the thanks
% mark:
%
%\setlength{\thanksmarksep}{0pt}
%\settowidth{\thanksmarkwidth}{\footnotesize 2}
%
\newcommand{\UMzip}{48109\,--1040}

\renewcommand{\abstractnamefont}{\normalsize\bfseries}

%%% Table of Contents setup (same as physicspaper.sty)

\renewcommand{\aftertoctitle}{\thispagestyle{plain}\afterchaptertitle}

\settocdepth{subsection}
%
\renewcommand{\cftsectionfont}{\normalfont\normalsize\bfseries}
\renewcommand{\cftsubsectionfont}{\normalfont\normalsize}
%
\newlength{\cftsecnumafterwidth}
\newlength{\cftsubsecnumafterwidth}
\newlength{\cftsubsubsecnumafterwidth}
%
\cftsectionfont
\setlength{\cftsecnumafterwidth}{0.5em}
%
\setlength{\cftsectionindent}{0em}
\settowidth{\cftsectionnumwidth}{2} % width of "2"
\addtolength{\cftsectionnumwidth}{\cftsecnumafterwidth}
\renewcommand{\cftsectionpresnum}{\hfill}
\renewcommand{\cftsectionaftersnum}{\hspace\cftsecnumafterwidth}
%
\setlength{\cftsubsectionindent}{\cftsectionnumwidth}
%
\cftsubsectionfont
\setlength{\cftsubsecnumafterwidth}{0.5em}
%
\settowidth{\cftsubsectionnumwidth}{2.b} % width of "2.b"
\addtolength{\cftsubsectionnumwidth}{\cftsubsecnumafterwidth}
\renewcommand{\cftsubsectionpresnum}{\hfill}
\renewcommand{\cftsubsectionaftersnum}%
  {\hfill\hspace\cftsubsecnumafterwidth} % flush left to align on "."
%
\setlength{\cftsubsubsectionindent}{\cftsubsectionindent}
\addtolength{\cftsubsubsectionindent}{\cftsubsectionnumwidth}
%
\cftsubsubsectionfont
\setlength{\cftsubsubsecnumafterwidth}{0.5em}
%
\settowidth{\cftsubsubsectionnumwidth}{2.b.b} % width of "2.b.b"
\addtolength{\cftsubsubsectionnumwidth}{\cftsubsubsecnumafterwidth}
\renewcommand{\cftsubsubsectionpresnum}{\hfill}
\renewcommand{\cftsubsubsectionaftersnum}%
  {\hfill\hspace\cftsubsubsecnumafterwidth} % flush left to align on "."
%
% restore standard font context
\normalfont\normalsize

%%% Body setup

% To make default, paragraph style indentation by \footmarkwidth
%  minus the mark size, do nothing, which uses the defaults:
%
% \setlength{\footmarkwidth}{1.8em}
% This makes subsequent footnote lines flush left:
% \setlength{\footmarksep}{-\footmarkwidth}
% This seems to be ignored:
% \setlength{\footparindent}{1em}

% To make \footmarkwidth from the left margin the same as a
% one-digit \footmarkwidth, and hang indent after the foot
% mark:
%
%\settowidth{\footmarkwidth}{\footnotesize 2}
%\setlength{\footmarksep}{0pt}

\pagestyle{plain}

\setsecnumdepth{subsection}
\renewcommand{\thesection}{\arabic{section}}

% Adapted from Rowland McDonnell's secsty package v2.0.2,
% documentation p. 16.  The memoir word \setsecnumformat is used
% to redefine the standard Latex \@seccntformat instead of the
% \def\@seccntformat used by McDonnell.
%
\setsecnumformat{\@ifundefined{#1@cntformat}%
{\csname the#1\endcsname\quad}% default
{\csname #1@cntformat\endcsname}% individual control
}
\newcommand{\section@cntformat}{\thesection\hspace{0.5em}}
\newcommand{\subsection@cntformat}{\thesubsection\hspace{0.5em}}
\newcommand{\subsubsection@cntformat}{\thesubsubsection\hspace{0.5em}}

\renewcommand{\theenumi}{(\roman{enumi})}
\renewcommand{\labelenumi}{\theenumi}

% This is based on the Notes environment, LaTeX Companion,
% p. 65.  It assumes only digits 0-9 (monospaced) for the label.
% See stappsthm.
\newcounter{step}
\newenvironment{steps}{%
  \begin{list}{\arabic{step}. }{%
    \usecounter{step}%
    \setlength{\labelsep}{0pt}\setlength{\leftmargin}{0pt}%
    \setlength{\labelwidth}{0pt}%
    \setlength{\listparindent}{\parindent}%
  }}%
{\end{list}}

%%% Math and theorem setup

\numberwithin{equation}{section}

\renewcommand{\theequation}{\arabic{equation}}

\newcommand{\eqnum}[1]{(\ref{#1})\xspace}
\newcommand{\eqp}[1]{Eq.~(\ref{#1})\xspace}
\newcommand{\eqsp}[1]{Eqs.~(\ref{#1})\xspace}

\theoremstyle{definition}
\newtheorem{lem}{Lemma}
\newtheorem*{lem*}{Lemma}
\newtheorem{cor}{Corollary}
\newtheorem*{cor*}{Corollary}
\newtheorem{thm}{Theorem}
\newtheorem*{thm*}{Theorem}
\newtheorem{dfn}{Definition}
\newtheorem*{dfn*}{Definition}
\newtheorem{cdn}{Condition}

% Use the analog of one of these in the document's local
% definitions section to change the numbering style:
%\renewcommand{\thelem}{\alph{lem}}
%\renewcommand{\thethm}{\Alph{thm}}
%\renewcommand{\thecdn}{\Roman{cdn}}

\renewcommand{\qedsymbol}{}
\newcommand{\qqed}{\ensuremath{\quad\blacksquare}}

\newcommand{\Thm}[1]{Theorem~\ref{#1}\xspace}
\newcommand{\Lem}[1]{Lemma~\ref{#1}\xspace}
\newcommand{\Cor}[1]{Corrollary~\ref{#1}\xspace}
\newcommand{\Dfn}[1]{Definition~\ref{#1}\xspace}
\newcommand{\Cdn}[1]{Condition~\ref{#1}\xspace}

%%% Bibliography setup

\renewcommand{\bibname}{References}

% Simple biblabel (see diracalg, stappsthm):
\setbiblabel{\hfill[#1]}

% Use this to do the bibname in the toc in the same font as
% sections (see tomometric, elastensor, eufermi):
%
\renewcommand{\bibsection}{%
\section*{\bibname}
\addcontentsline{toc}{section}{\numberline {}\bibname}
\prebibhook}

%%% Text definitions

%\newcommand{\Cf}{{\em Cf.}~}
%\newcommand{\cf}{{\em cf.}~}

% Based on LaTeX Companion, p. 50:
\newcommand{\Cf}{Cf.\@\xspace}
\newcommand{\cf}{cf.\@\xspace}
\newcommand{\Eg}{E.g.,\xspace}
\newcommand{\eg}{e.g.,\xspace}
\newcommand{\Ie}{I.e.,\xspace}
\newcommand{\ie}{i.e.,\xspace}
\newcommand{\resp}{resp.\@\xspace}

\newcommand{\rcite}[1]{Ref.~\cite{#1}\xspace}
\newcommand{\rscite}[1]{Refs.~\cite{#1}\xspace}
\newcommand{\sect}[1]{Section~\ref{#1}\xspace}
\newcommand{\chap}[1]{Chapter~\ref{#1}\xspace}
\newcommand{\fig}[1]{Fig.~\ref{#1}\xspace}
\newcommand{\figs}[1]{Figs.~\ref{#1}\xspace}

\newcommand{\pquad}{\hspace*{1.4em}}
