%
% The Youth Hostel errata
%
% Reuben Thomas(notes)
% Requires PDFLaTeX (TODO: use LuaTeX when it supports kerning with microtype; then get OpenType Adobe Caslon Pro working (currently has problems with kerning and expert ligatures)
%

% To print: (TODO) Currently cannot persuade this to print n-up, so manually n-up it by converting to EPS (pdf2ps; ps2eps) then importing into LibreOffice Draw (see errata-print.odg); remember to print 1-sided!

\documentclass[10pt]{book}
% Control draft vs non-draft mode
%\usepackage[draft]{graphicx}
\usepackage{graphicx}
\usepackage[papersize={4.25in,4.25in},twoside,showcrop,driver=none]{geometry}% printing 4-up on A4
% Note: page size is given in bp (= PostScript points) so that ps2pdf’s rounding of dimensions to nearest point doesn’t change anything
\usepackage[LGR,T1]{fontenc}
\usepackage[greek,british]{babel}
\languageattribute{greek}{polutoniko}
\usepackage[utf8]{inputenc}
\usepackage[shortcuts]{extdash}
\usepackage[hidelinks]{hyperref}
\usepackage{ifthen,calc,siunitx,mfirstuc,xparse,lettrine,booktabs,array,fwlw,relsize,gitinfo2}
\usepackage{hevea}

\makeatletter % Allow internals to be redefined

% Microtype
\usepackage[activate={true,nocompatibility},letterspace=250,kerning=true]{microtype}
% Kerning rules for C18th punctuation
\SetExtraKerning
   [ name     = englishC18-default,
     context  = englishC18,
     unit     = space   ]
   { encoding = {OT1,T1,LY1} }
   {
     :  = {500, }, % ~ \thinspace
     ;  = {500, },
     !  = {500, },
     ?  = {500, },
     — = {500, 500},
   }

% Try to avoid excessive hyphens
\doublehyphendemerits=30000
\finalhyphendemerits=30000
\adjdemerits=10000
\brokenpenalty10000\relax

% Avoid widows and orphans
% https://mailman.ntg.nl/pipermail/ntg-context/2013/074250.html
\widowpenalty 10000
\clubpenalty 10000

% Disable vertical justification
\raggedbottom

% Long S characters with eighteenth-century rules
\usepackage[c18th,extraligs]{adobecaslon}[2014/04/01] % v2.0
\usepackage{textcomp} % Get punctuation such as footnote marks from Caslon
\renewcommand{\sfdefault}{bgs} % Bitstream Humanist (= Gill Sans); used in Colophon for LaTeX package names
%HEVEA\begin{latexonly}
\newenvironment{modern}{%
\renewcommand{\name}[1]{\mbox{##1}}%
\begin{microtypecontext}{kerning=}%
\adobecaslonexpert%
}{%
\end{microtypecontext}%
}
%HEVEA\end{latexonly}
% Workaround bug in adobecaslon where small caps ligatures are used, preventing letterspacing
\newcommand{\smallcaps}[1]{{\adobecaslonexpert\textsc{#1}}}

% Set up Greek to use Theano
\usepackage{teubner} % TODO: currently needed to make Theano work!
\newcommand{\greek}[1]{{\fontencoding{LGR}\fontfamily{TheanoOldStyle}\selectfont #1}}

% Page headings
\usepackage{fancyhdr}
\renewcommand{\headrulewidth}{0pt}
\setlength{\headheight}{14pt}
\fancyhf{} % clear all header and footer fields
\fancyfoot[RO]{\usebox\NextWordBox}
\fancypagestyle{plain}{% Change page style for chapters’ first pages
  \fancyhead[LE,RO]{}
  \fancyhead[C]{\large(\hspace{1ex}\thepage\hspace{1ex})} % centred page number in parentheses
}
\fancyhead[LE,RO]{\large\thepage}
\fancyhead[C]{\large\leftmark}
\newcommand{\markbothls}[1]{\markboth{\lssc{#1}.}{}}

% Chapter headings
%\begin{latexonly}
\usepackage[explicit]{titlesec}
\titlespacing{\chapter}{0pt}{-3ex}{2ex}
% TODO: the following is rather nasty. Create an alternative \chapter command that uses a different format?
\titleformat{\chapter}[display]%
  {\normalfont\normalsize\filcenter}%
  {\chaptertitlename}%
  {0pt}%
  {%
    \titlerule[\heavyrulewidth]%
    \vspace{1ex}%
    \titlerule[\heavyrulewidth]%
    \vspace{3ex}%
    \gdef\titletext{%
      \protect%
        \IfEndWith{\detokenize{#1}}{.}{%
          \protect\StrGobbleRight{\detokenize{#1}}{1}}{#1}%
    }%
    \textls*{\MakeUppercase{\titletext}}%
    \protect\IfEndWith{\detokenize{#1}}{.}{.}{}%
    \markbothls{\titletext}
  }
%\end{latexonly}

% Print a numeric range, eliding common prefix
\newcommand{\commonprefixrange}[2]{%
  \StrCompare{#1}{#2}[\commonprefixlenplusone]%
  #1–\StrGobbleLeft{#2}{\numexpr\commonprefixlenplusone-1}}

% Page border & full-page rules
% After http://tex.stackexchange.com/questions/129088/create-a-frame-for-a-title-page
\usepackage{tikz}
\usetikzlibrary{calc}
% TODO: \hspace arg and adjustment to \textwidth give an equal gap, but not sure why.
\newcommand{\HRule}{\hspace*{0.01in}\tikz \draw[line width = \heavyrulewidth] (0.0pt, 0pt) --(\textwidth + 0.01in, 0pt);}

% Miscellaneous commands
\def\UrlFont{\adobecaslonexpert}
\renewcommand*{\thefootnote}{\fnsymbol{footnote}}
\newcommand{\tab}{\hspace*{2ex}} % tab for overlong lines which wrap
\newcommand{\lssc}[1]{\textls[100]{\smallcaps{#1}}} % Set in letter spaced small caps
\newcommand{\name}[1]{\mbox{\lssc{#1}}} % Name: unbreakable, in \lssc TODO: this is really a separate command, only/mostly for use in verse; \versename?
\newcommand{\notename}[1]{\textit{#1}} % Names in footnotes are in italics
\newcommand{\capsls}[1]{\MakeUppercase{\textls[100]{#1}}} % Make a name in caps, letter spaced
\newcommand{\poempagebreak}{\pend\clearpage\pstart} % Line and page break (N.B. no \\ needed before it)
\microtypecontext{kerning=englishC18}
\newcommand{\verseref}[1]{V.~\lineref{#1}}
\newcommand{\versesref}[2]{VV.~\commonprefixrange{\lineref{#1}}{\lineref{#2}}}
\newcommand{\bibleref}[3]{#1~Ch.~#2\ V.~#3}
\newcommand{\biblerefs}[4]{#1~Ch.~#2\ VV.~\commonprefixrange{#3}{#4}}
\newcommand{\etc}{\&c.}
% The negative kern doesn’t seem to be needed for printing, but helps on screen
\newcommand{\longdash}{\,{\microtypecontext{kerning=}—\kern-0.1pt—}\,}

\makeatother % Prevent access to internals

\begin{document}

\chapter*{Errata.}

\thispagestyle{empty}
\begin{modern}
\begin{rawhtml}
<style>
main {
    font-family: serif;
}
h1 {
    font-variant: small-caps;
}
p.drop-para:first-letter {
    font-size: 300%;
    float: left;
    line-height: 100%;
}
.title-caps {
    letter-spacing: 2px;
    text-transform: uppercase;
}
</style>
\end{rawhtml}
%\begin{latexonly}
\lettrine[loversize=0.1]{I\,}{\textls{n}}
%\end{latexonly}
%HEVEAIn
editions up to and including
b17df7d (the first and second printings), for the remark on
p.~15 headed \emph{\adobecasloneighteenth To those who so bravely bore \etc}, for the first \notename{Jonathan Campbell} read \notename{Alexander Choat}. Many thanks to Iestyn Davies for spotting the error, and to Robert Grove of St John’s College School for finding the right name. Apologies to Mr~Choat.

In edition b01deff \emph{only} (the second printing), the Colophon gives the source of the paper incorrectly; it should say that it was “made and cut by John Purcell Paper, Brixton”.

In editions up to, but excluding a6e1c9b (the first and second printings), the lemma of the imitation note to VV.~270–1 contains a comma; it should be a semi-colon.

There are other \emph{differences} between the published editions, but no other known \emph{errors}. Should you spot any, please let Reuben Thomas know, for example by writing to \url{rrt@sc3d.org}.
\end{modern}

\end{document}
