Newer
Older
LaTeX / lectures / lecturecommon.sty
Nigel Stanger on 12 Sep 2016 6 KB Merge commit '01b673a' as 'lectures'
\def\filedate{1 July 2016}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Common definitions shared across the various lecture document classes.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Version History
% v1.0   Initial version.
% v1.0.1 Fixed incorrect provided package name.
% v1.0.2 Increased number of tab stops in codesyntaxblock environment.
% v1.1   Added Unicode/XeLaTeX support.
%        Added exercise environment.
% v1.2   Switched to "class" instead of "chapter".
% v1.2.1 Fixed fontspec option clash and made font handling consistent with XML framework.
% v1.2.2 Fixed incorrect Roman font in math mode.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\NeedsTeXFormat{LaTeX2e}[2001/06/01]
\ProvidesPackage{lecturecommon}[2016/07/01 INFO standard lecture setup v1.2.2]


% Standard packages common to ALL lecture documents.

\RequirePackage{amsmath} % needs to be loaded before mathspec

\RequirePackage{ifxetex}

\ifxetex

\RequirePackage[no-math]{fontspec}
\RequirePackage{mathspec}
\RequirePackage{xunicode}
\RequirePackage{xltxtra}

\defaultfontfeatures{Mapping=tex-text}
% The following line is equivalent to:
%   \setmainfont{TeX Gyre Pagella}
%   \setmathsfont(Latin,Digits){TeX Gyre Pagella}
%   \setmathrm{TeX Gyre Pagella}
\setprimaryfont{TeX Gyre Pagella}
\setsansfont[Scale=MatchUppercase,BoldFont={Gill Sans}]{Gill Sans Light}
\setmonofont[Scale=MatchLowercase]{Letter Gothic 12 Pitch}

% Hack to prevent digits in hyperlinks from being set in the main font instead of the mono font.
% From http://tex.stackexchange.com/questions/99770/problem-with-digits-in-urls-when-using-mathspec-and-hyperref
% Note: doesn't matter if this is executed multiple times.
\makeatletter
     \DeclareMathSymbol{0}{\mathalpha}{\eu@DigitsArabic@symfont}{`0}
     \DeclareMathSymbol{1}{\mathalpha}{\eu@DigitsArabic@symfont}{`1}
     \DeclareMathSymbol{2}{\mathalpha}{\eu@DigitsArabic@symfont}{`2}
     \DeclareMathSymbol{3}{\mathalpha}{\eu@DigitsArabic@symfont}{`3}
     \DeclareMathSymbol{4}{\mathalpha}{\eu@DigitsArabic@symfont}{`4}
     \DeclareMathSymbol{5}{\mathalpha}{\eu@DigitsArabic@symfont}{`5}
     \DeclareMathSymbol{6}{\mathalpha}{\eu@DigitsArabic@symfont}{`6}
     \DeclareMathSymbol{7}{\mathalpha}{\eu@DigitsArabic@symfont}{`7}
     \DeclareMathSymbol{8}{\mathalpha}{\eu@DigitsArabic@symfont}{`8}
     \DeclareMathSymbol{9}{\mathalpha}{\eu@DigitsArabic@symfont}{`9}
\makeatother

\else % assume PDFLaTeX otherwise

\RequirePackage[T1]{fontenc}
\RequirePackage{textcomp}
\RequirePackage{lmodern}
\RequirePackage{mathpazo}

% Gill Sans to come...
% \renewcommand{\sfdefault}{}
\renewcommand{\ttdefault}{blg}

\fi

\RequirePackage{boxedminipage}
\RequirePackage{graphicx}
\RequirePackage{hyperref}

\hypersetup{pdfpagemode=UseNone}

% NJS 2011-07-28: Weirdness with XeLaTeX and Hyperref: URLs formatted with
% \url{} that have numbers in them use monospaced font for the letters and
% serif font for the numbers?!?!


% Standard macros and package configuration common to ALL lecture notes
% documents.

% graphicx setup.
\graphicspath{{images/}}

% Simple code listing setup.
\newcommand{\keyword}[1]{\texttt{\uppercase{#1}}}
\newcommand{\nonterminal}[1]{\textit{\texttt{#1}}}
% Note: maximum 13 tab stops in a tabbing environment. (Bah.)
\newenvironment{codesyntaxblock}[1][\normalsize]%
    {\begingroup\ttfamily#1\begin{tabbing}mm\=mm\=mm\=mm\=mm\=mm\=mm\=mm\=mm\=mm\=mm\=mm\=mm\=\kill}%
    {\end{tabbing}\endgroup}


% Environment for boxed exercises.
\newcounter{exercise}
\setcounter{exercise}{0}
% Arguments: #1 width of box to set the exercise text in (defaults to \columnwidth).
\newenvironment{exercise}[1][\columnwidth]%
    {\noindent\refstepcounter{exercise}\begin{boxedminipage}{#1}\textbf{Exercise \theexercise: }}%
    {\end{boxedminipage}}
% Starred form produces an unnumbered exercise.
\newenvironment{exercise*}[1][\columnwidth]%
    {\noindent\begin{boxedminipage}{#1}\textbf{Exercise: }}%
    {\end{boxedminipage}}


% Standard variables for various things, and macros for initialising them.
% These can be used (or not) as necessary.


% Paper variables: subject code.
\newcommand{\SubjectCode}{UNDEFINED}
\newcommand{\SetSubjectCode}[1]{\renewcommand{\SubjectCode}{#1}}


% Paper number.
\newcommand{\PaperNumber}{UNDEFINED}
\newcommand{\SetPaperNumber}[1]{\renewcommand{\PaperNumber}{#1}}


% Convenience macro for printing out the full paper code.
\newcommand{\PaperCode}{\SubjectCode~\PaperNumber}


% Paper title.
\newcommand{\PaperTitle}{UNDEFINED}
\newcommand{\SetPaperTitle}[1]{\renewcommand{\PaperTitle}{#1}}


% Department name.
\newcommand{\DepartmentName}{UNDEFINED}
\newcommand{\SetDepartmentName}[1]{\renewcommand{\DepartmentName}{#1}}


% Teaching period.
\newcommand{\TeachingPeriod}{UNDEFINED}
\newcommand{\SetTeachingPeriod}[1]{\renewcommand{\TeachingPeriod}{#1}}


% Year offered.
\newcommand{\YearOffered}{UNDEFINED}
\newcommand{\SetYearOffered}[1]{\renewcommand{\YearOffered}{#1}}


% Oracle version.
\newcommand{\Oracle}{UNDEFINED}
\newcommand{\SetOracleVersion}[1]{\renewcommand{\Oracle}{#1}}


% Class number.
\newcommand{\ClassNumber}{\thechapter}
\newcommand{\ClassNumberPlusOne}{%
    \addtocounter{chapter}{1}%
    \thechapter%
    \addtocounter{chapter}{-1}%
}
\newcommand{\SetClassNumber}[1]{\setcounter{chapter}{#1}}

% Backwards compatibility with the old syntax
\newcommand{\ChapterNumber}{\ClassNumber}
\newcommand{\ChapterNumberPlusOne}{\ClassNumberPlusOne}
\newcommand{\SetChapterNumber}[1]{\SetClassNumber{#1}}


% Class title.
\newcommand{\ClassTitle}{UNDEFINED}
\newcommand{\SetClassTitle}[1]{\renewcommand{\ClassTitle}{#1}}

\newcommand{\ShortClassTitle}{UNDEFINED}
\newcommand{\SetShortClassTitle}[1]{\renewcommand{\ShortClassTitle}{#1}}

% Backwards compatibility with the old syntax
\newcommand{\ChapterTitle}{\ClassTitle}
\newcommand{\SetChapterTitle}[1]{\SetClassTitle{#1}}
\newcommand{\ShortChapterTitle}{\ShortClassTitle}
\newcommand{\SetShortChapterTitle}[1]{\SetShortClassTitle{#1}}


% Class type.
\newcommand{\ClassType}{Lecture}
\newcommand{\SetClassType}[1]{\renewcommand{\ClassType}{#1}}


\endinput