% UCSC biobibliography class
%
% Author: Ethan L. Miller (elm@cs.ucsc.edu)
%
% Use this class in the following way:
%
% \documentclass[11pt]{biobib}
%
% Options are:
%
% outside
%   If this option is set, formats the biobib for outside consumption,
%   affecting primarily class lists.  Also sets the boolean outside
%   to false (default is true).
%
% hyperref
%   Under this option, you can insert a hyperreference (link) to an online
%   version of a paper with \available{url}{PDF}.  Use the \baseurl command
%   to set the base URL for all links.  \available{url}{PDF} produces text
%   that looks like:
%     Available as PDF.
%   with the ``PDF'' linked to the passed URL.  If the hyperref option is not
%   specfified in \documentclass, the \available commands produce no text.
%
% noavailable
%  Only works with the hyperref option.  If this option is specified, the
%  \available command is set to a null, so nothing is printed.
%
% studentpubs
%   With this option enabled, \student{J. Student} will produce a footnoted
%   mark after the student.  With the option not enabled, \student will
%   simply produce the plain text name.  \studentexplanation will produce
%   a one-sentence explanation of the footnote mark if \student is enabled,
%   and nothing otherwise.  The \studentmark command can be redefined
%   to change the mark used to indicate student authors.
%
% acceptrate
%   With this option enabled, \accept{30} will produce a sentence like this:
%     (Acceptance rate: 30%)
%   With it disabled, the command will produce no output.
%
% newclass
%   With this option enabled, \newclass will produce a footnote mark and
%   \newclassexplanation will produce:
%     \emph{NOTE:} \newclass\ denotes a new course in the curriculum.  
%   With this option disabled, \newclass and \newclassexplanation will
%   produce no output.  The \newclassmark command can be redefined to
%   change the mark used to indicate new classes.
%
% Basically, the options can be turned on or off to include various
% information in the final form of the biobib.  The advantage is that you can
% record, say, acceptance information, without including it in your biobib
% if you don't want it.
%
%========================================
%
% Useful environments:
%
% \begin{yearlist}
%    \item[2003]        Something I did in 2003.
%    \item[2000--2001]  The thing I did in 2000--2001.
% \end{yearlist}
%    The yearlist environment is used for lists of things with the year in
%    the left margin, such as positions held, service, etc.  The label is
%    optional, but is wide enough to include ranges like 2000--2001.
%
%
% \begin{teaching}{2002--2003}
% \class{quarter}{CMPS}{111}{course title}{number of students}
%       {% of evals returned}{team taught?}
%  \end{teaching}
%    These commands are used to list classes you've taught.
%
%
% \begin{publist}[J]{Journals}
% \item First journal paper
% \item Second journal paper
% \end{publist}
%
% The publist environment is used for lists of publications.  The required
% argument is the title of the subsection containing the list, such as
% {Journals}, {Refereed Conference Proceedings}, {Technical Reports}, and so
% on.  The optional argument is a string that precedes the number for each
% publication in the list.  This allows, you to number journal papers J1,
% J2, etc. and refereed conference proceedings R1, R2, etc.  The default is
% that numbers are followed by a dot (.), but this character can be changed
% or eliminated with the \publistdot{} command.  For example, \publistdot{-}
% would produce numbers that looked like `J1-'.  This command can be used
% at any time outside the publist environment, allowing you to change it
% between publication lists.
%
% There is also a revpublist environment that works just like publist, except
% that the numbers are in order from highest to lowest.  This is helpful if
% you want your publication numbers to remain the same after you've added
% newer ones, assuming you list newer publications first.  Note that this
% requires the revnum package, which may not be in every latex distribution.
%
%========================================
%
% Useful commands:
%
% \num{20} will produce the ordinal form of the number (20th in this case),
% with the ``th'' part of the number displayed as a superscript.
%
%========================================
%========================================
% Log entries:
% 
% $Log: biobib.cls,v $
% Revision 1.10  2006/09/07 07:15:20  elm
%
% Switched to mathptmx (no longer mathptm).
%
% Revision 1.9  2005/12/20 18:23:11  elm
% Added documentation on revpublist.
%
% Revision 1.8  2005/12/20 18:15:53  elm
% *** empty log message ***
%
% Revision 1.7  2005/05/10 22:40:13  elm
% Added a few minor tweaks.
%
% Revision 1.6  2005/03/02 22:53:07  elm
% More cleanup on the biobib class.  Added options to generate a normal
% CV in addition to the biobib.
%
% Revision 1.5  2003/09/19 22:53:36  elm
% Minor changes to the biobib template.
%
% Revision 1.4  2003/08/27 22:57:40  elm
% Revised \linkto to \available.  Added more instructions to the class file.
%
% Revision 1.3  2003/08/25 23:10:30  elm
% Added documentation to the class, and changed the publistdot default to
% be a dot.
%
% Revision 1.2  2003/07/30 21:44:33  elm
% Added publist environment to biobib.  This environment can print
% letters in front of publication numbers, and automatically generates
% subsection headers from its argument.
%
% Revision 1.1  2003/07/25 20:31:41  elm
%
% Added a class for doing biobibs.
%

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{biobib}

\LoadClass{article}

\RequirePackage{fullpage,mathptmx}
\RequirePackage{verbatim,fancyhdr,xspace}
\RequirePackage{engord}
\RequirePackage{ifthen}
\RequirePackage{revnum}
\RequirePackage{verbatim}
\RequirePackage{relsize}
\RequirePackage{comment}

\newboolean{bb@hyperref}
\setboolean{bb@hyperref}{false}
\newboolean{bb@available}
\setboolean{bb@available}{true}
\newboolean{bb@studentpubs}
\setboolean{bb@studentpubs}{false}
\newboolean{bb@acceptrate}
\setboolean{bb@acceptrate}{false}
\newboolean{bb@newclass}
\setboolean{bb@newclass}{false}
\newboolean{internal}
\setboolean{internal}{true}
\newboolean{bb@evals}
\setboolean{bb@evals}{false}

\DeclareOption{hyperref}{\setboolean{bb@hyperref}{true}}
\DeclareOption{studentpubs}{\setboolean{bb@studentpubs}{true}}
\DeclareOption{acceptrate}{\setboolean{bb@acceptrate}{true}}
\DeclareOption{newclass}{\setboolean{bb@newclass}{true}}
\DeclareOption{available}{\setboolean{bb@available}{true}}
\DeclareOption{noavailable}{\setboolean{bb@available}{false}}
\DeclareOption{outside}{\setboolean{internal}{false}}
\DeclareOption{cv}{\setboolean{internal}{false}}
\DeclareOption{evals}{\setboolean{bb@evals}{true}}

\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}
\ProcessOptions

\setlength{\textheight}{9.0in}
\setlength{\topmargin}{-0.5in}
\setlength{\headsep}{0.25in}
\setlength{\headheight}{0.5in}
\setlength{\footskip}{0.25in}
\setlength{\textwidth}{6.5in}
\setlength{\oddsidemargin}{0in}
\setlength{\evensidemargin}{\oddsidemargin}

\widowpenalty=10000
\clubpenalty=10000

\ifthenelse{\boolean{internal}}{
  \includecomment{internal}
  \excludecomment{external}
}{
  \includecomment{external}
  \excludecomment{internal}
}

\newcommand{\inex}[2]{\ifthenelse{\boolean{internal}}{#1}{#2}}

\newcommand{\bb@author}{}
\renewcommand{\author}[1]{\renewcommand{\bb@author}{#1}}
\newcommand{\bb@date}{}
\renewcommand{\date}[1]{\renewcommand{\bb@date}{#1}}
\newcommand{\bb@title}{Bio-Bibliography}
\renewcommand{\title}[1]{\renewcommand{\bb@title}{#1}}


\date{\today}

\renewcommand{\maketitle}{
  \begin{center}
    {\LARGE \bb@title} \\
    \vspace*{12pt}
    {\Large \bb@author} \\
    \vspace*{12pt}
    {\large \bb@date} \\
    \par\noindent
  \end{center}
}

% advising environment is used for listing students that you've advised.
%
\newlength{\bb@yearwidth}
\settowidth{\bb@yearwidth}{2008}
\newlength{\bb@longname}
\settowidth{\bb@longname}{Vivekand Krishnamoorthi}
\newenvironment{advising}{
  \setlength{\tabcolsep}{3pt}
  \begin{tabular}{p{\bb@yearwidth}p{\bb@longname}p{4.2in}}
}{
  \end{tabular}
}

% teaching environment is used for teaching for a given academic year
% \begin{teaching}{2000--2001}
% \class{...}
% \end{teaching}
%
% Arguments to \class:
%    1. Fall/Winter/Spring/Summer 2. CMPS/CMPE 3. Course number
%    4. Course name               5. Enrolled  6. %Evals
%    7. Shared
\newlength{\bb@colQtr}
\settowidth{\bb@colQtr}{Summer}
\newlength{\bb@courseid}
\settowidth{\bb@courseid}{CMPM~000-00}
\newlength{\bb@coursetitle}
\settowidth{\bb@coursetitle}{CMPM~000-00MIntroduction to Operating SystemsMM}

\newcommand{\bb@quarter}{}
\newcommand*{\quarter}[1][]{\renewcommand{\bb@quarter}{#1}}
\newboolean{bb@noevals}

\newenvironment{teaching}[1]{
  \vspace{0.35in}
  \noindent
  \begin{minipage}{\textwidth}
  \setlength{\tabcolsep}{1pt}
  \par\noindent\inex{\centerline{\relsize{1}\textbf{TEACHING #1}}}{\textbf{#1}}
  \vspace*{0.5ex}
  \par\noindent
  \ifthenelse{\boolean{internal}}{
    \ifthenelse{\boolean{bb@evals}}{
      \begin{tabular}{p{\bb@colQtr}p{\bb@coursetitle}r|r|rr|rr|}
      & & & \multicolumn{1}{c|}{\%Evals} &
      \multicolumn{2}{c|}{Teaching Eff.} & \multicolumn{2}{c|}{Overall} \\
      \multicolumn{1}{c}{Quarter} & \multicolumn{1}{c}{Course} &
      \multicolumn{1}{c}{Enrolled} & \multicolumn{1}{|c|}{Retd} &
      \multicolumn{1}{c}{Avg} & \multicolumn{1}{c|}{\%VG/E} &
      \multicolumn{1}{c}{Avg} & \multicolumn{1}{c|}{\%VG/E} \\
      \hline\hline \\
    }{
      \begin{tabular}{p{\bb@colQtr}p{\bb@coursetitle}rrr}
      & & Enrolled & \%Evals Returned \\
    }
  }
  {
    \begin{tabular}{p{\bb@colQtr}p{\bb@coursetitle}rrr}
  }
}
{\end{tabular} \end{minipage}}


\newcommand{\class}[5][]{
  \bb@quarter\quarter &
  \makebox[\bb@courseid][l]{#2} #3\ifthenelse{\equal{#1}{T}}{$^{\mathbf{T}}$}{} &
  \ifthenelse{\boolean{internal}}{#4\hspace*{1em}}{} &
  #5 \\
}

\newcommand{\evals}[5]{
  \ifthenelse{\boolean{internal}}
  {
    #1\hspace*{0.5em} &
    \ifthenelse{\boolean{bb@evals}}{#2 & #3\hspace*{0.5em} & #4 & #5\hspace*{0.5em}}{}
  }
  {}
}

\newcommand{\noevals}{
  \ifthenelse{\boolean{bb@evals}}
  {
    n/a\hspace*{0.5em} &    &                   &    &
  }
  {n/a}
}

% The yearlist environment is used for things that are listed by year,
% such as education, employment, consulting, service, etc.  Each item
% should be specified as:
% \item[2000--2001]
% If only one year is relevant, use
% \item[2000]
%
\newenvironment{yearlist}{
  \begin{list}{}{%
      \setlength{\labelsep}{0.1in}
      \settowidth{\labelwidth}{2000--2000X}
      \setlength{\leftmargin}{\labelwidth}
      \addtolength{\leftmargin}{\labelsep}
      \setlength{\parsep}{0ex}
      \setlength{\itemsep}{0.2ex plus 0.5ex}
      \setlength{\itemindent}{0in}
      \renewcommand{\makelabel}[1]{##1\hfill}
    }
}
{\end{list}}

%
% Commands for the publication list
%

% The argument to \accept is the acceptance rate (without the % sign).
% By doing it this way, it's trivial to change the biobib to leave off
% acceptance rate entirely by simply having the command ignore its
% argument and print nothing.
\ifthenelse{\boolean{bb@acceptrate}}{
  \newcommand{\accept}[1]{ {\small [Acceptance rate:~#1\%]} }
}{
  \newcommand{\accept}[1]{}
}

\newcommand{\ifacceptrate}[1]{
  \ifthenelse{\boolean{bb@acceptrate}}{#1}{}
}


% \student{Joe Student} is used in author lists to identify student
% authors.  Again, this provides a central location that may be changed
% if identification of student authors is to change.
%
\renewcommand{\thefootnote}{\fnsymbol{footnote}}
\newcommand{\studentmark}{\footnotemark[1]}
\newcommand{\mystudentmark}{\footnotemark[3]}
\ifthenelse{\boolean{bb@studentpubs}}{
  \newcommand{\student}[1]{#1\studentmark}
  \newcommand{\mystudent}[1]{#1\mystudentmark}
  \newcommand{\studentexplanation}{\vspace{1ex}\par\noindent\textit{NOTE:}\
    (\studentmark) denotes a student co-author, and (\mystudentmark)
    denotes a student co-author who was one of my advisees.\vspace{1ex}}
}{
  \newcommand{\student}[1]{#1}
  \newcommand{\mystudent}[1]{#1}
  \newcommand{\studentexplanation}{}
}

% The \newclass command places a footnote mark at the point where it's used
% if the newclass option is passed to biobib.  Otherwise, it does nothing.
% \newclassexplanation either prints an explanation about the new class
% or does nothing.
%
\newcommand{\newclassmark}{\footnotemark[2]}
\ifthenelse{\boolean{bb@newclass}}{
  \newcommand{\newclass}{\newclassmark}
  \newcommand{\newclassexplanation}{\par\noindent\emph{NOTE:} \newclass\ 
    denotes a new or significantly revised course.}
}{
  \newcommand{\newclass}{}
  \newcommand{\newclassexplanation}{}
}

%
% It looks nicer to use superscript-like ordinal numbers.  This macro is
% used like this:
% Proceedings of the \num{20} Conference on Irrelevant Objects
%
% This will produce the correct ordinal number.  It relies upon the engord
% (English ordinal) package, which is part of the standard LaTeX distribution,
% at least on my system.
\newcommand{\num}[1]{\engordnumber{#1}}

%----------------------------------------------------------------------
%
% This sets up a nice header for the biobib.
%
\lhead{\fancyplain{}{\bb@title}}
\chead{\fancyplain{}{\bb@author}}
\rhead{\fancyplain{}{\bb@date}}
\lfoot{}
\cfoot{\fancyplain{}{\thepage}}
\rfoot{}

% This is the command that draws the line at the head of the page.  Change
% the rule width to 0pt to eliminate it.
\renewcommand{\headrulewidth}{0.3pt}
\pagestyle{fancyplain}

\newcommand{\bb@baseurl}{http://www.cs.ucsc.edu/}
\newcommand{\baseurl}[1]{\renewcommand{\bb@baseurl}{#1}}

\newcommand{\available}[2]{}
\ifthenelse{\boolean{bb@hyperref}}{
  \RequirePackage[pdfpagemode=UseNone, pdfkeywords={curriculum vitae,
      bio-bibliography}, colorlinks=true, citecolor=blue,
    linkcolor=red, urlcolor=blue, filecolor=blue, pdfstartview=Fit,
    pdffitwindow, pdftitle={Bio-bibliography}]{hyperref}
  %----------------------------------------------------------------------
  %
  % hyperref customizations.  These are helpful to provide automagic
  % links in PDF to your papers.  As with other macros, the \available
  % macro can be ``disabled'' by simply making it an empty command.
  %
  \ifthenelse{\boolean{bb@available}}{
    \renewcommand{\available}[2]{{\small Available in~\href{\bb@baseurl#1}{#2}.}}
  }{
  }
}
{}

\renewcommand{\section}{\@startsection{section}{1}{0pt}%
  {-2ex plus -1ex minus 0ex}%
  {1ex plus 0.5ex minus 0ex}%
  {\normalfont\large\bfseries\MakeUppercase}}

\renewcommand{\subsection}{\@startsection{subsection}{2}{0pt}%
  {-1ex plus -1ex minus -0.5ex}%
  {0.5ex plus 0.5ex minus 0ex}%
  {\normalfont\large\bfseries}}

\newcommand{\bb@publistdot}{.}
\newcommand{\publistdot}[1]{\renewcommand{\bb@publistdot}{#1}}

\newcommand{\bb@curyear}{1900}
\newcommand{\bb@lastbibyear}{\year}
\newcommand{\curyear}[1]{\renewcommand{\bb@curyear}{#1}}
\newcommand{\lastbibyear}[1]{\renewcommand{\bb@lastbibyear}{#1}}
\inex{
  \newcommand{\newsym}{\ifthenelse{\bb@curyear > \bb@lastbibyear}{\ensuremath{\bigstar}~}{}}
}{
  \newcommand{\newsym}{}
}

\newenvironment{revpublist}[2][]{%
  \subsection*{#2}
  \setlength{\labelwidth}{0.4in}
  \setlength{\labelsep}{0.1in}
  \setlength{\leftmargini}{0.5in}
  \renewcommand{\labelenumi}{\newsym#1\theenumi\bb@publistdot\hfill}
  \begin{revnumerate}
    \setlength{\itemsep}{0.2ex plus 0.5ex}
    \setlength{\parskip}{0pt}
}{
  \end{revnumerate}
}


\newenvironment{publist}[2][]{%
  \subsection*{#2}
  \setlength{\itemsep}{0pt}
  \setlength{\parskip}{0pt}
  \setlength{\labelwidth}{0.4in}
  \setlength{\labelsep}{0.1in}
  \setlength{\leftmargini}{0.5in}
  \renewcommand{\labelenumi}{\newsym#1\theenumi\bb@publistdot\hfill}
  \begin{enumerate}
}{
  \end{enumerate}
}
