diff options
author | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
commit | e0c6872cf40896c7be36b11dcc744620f10adf1d (patch) | |
tree | 60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/latex/contrib/cite |
Initial commit
Diffstat (limited to 'macros/latex/contrib/cite')
-rw-r--r-- | macros/latex/contrib/cite/README | 23 | ||||
-rw-r--r-- | macros/latex/contrib/cite/chapterbib.ltx | 243 | ||||
-rw-r--r-- | macros/latex/contrib/cite/chapterbib.pdf | bin | 0 -> 147894 bytes | |||
-rw-r--r-- | macros/latex/contrib/cite/chapterbib.sty | 557 | ||||
-rw-r--r-- | macros/latex/contrib/cite/cite.ltx | 220 | ||||
-rw-r--r-- | macros/latex/contrib/cite/cite.pdf | bin | 0 -> 84426 bytes | |||
-rw-r--r-- | macros/latex/contrib/cite/cite.sty | 665 | ||||
-rw-r--r-- | macros/latex/contrib/cite/drftcite.sty | 264 | ||||
-rw-r--r-- | macros/latex/contrib/cite/overcite.sty | 21 |
9 files changed, 1993 insertions, 0 deletions
diff --git a/macros/latex/contrib/cite/README b/macros/latex/contrib/cite/README new file mode 100644 index 0000000000..83b82d135e --- /dev/null +++ b/macros/latex/contrib/cite/README @@ -0,0 +1,23 @@ +This directory contains four .sty files that are mutually compatible, +but (mostly) independent: + +cite.sty Compressed, sorted lists of numerical citations: [8,11-16] + with many options for controlling the formatting. + +overcite.sty like \usepackage[superscript]{cite} + +drftcite.sty Print the tags instead of the numbers for \cite and \bibitem. + +chapterbib.sty Do multiple bibliographies--one for each \include file. + +The user manuals for cite and chapterbib are LaTeX files cite.ltx +and chapterbib.ltx, and already typeset pdf versions. + +They are all released under a very simple permissive license in +the MIT/BSD style: They may be freely used, transmitted, reproduced, +or modified provided that the copyright and permission notice is +left intact. + + + +Donald Arseneau asnd@triumf.ca diff --git a/macros/latex/contrib/cite/chapterbib.ltx b/macros/latex/contrib/cite/chapterbib.ltx new file mode 100644 index 0000000000..b134ac1b17 --- /dev/null +++ b/macros/latex/contrib/cite/chapterbib.ltx @@ -0,0 +1,243 @@ +% +% chapterbib.ltx Manual for chapterbib.sty +% +% +% Copyright (c) 1993-2010 by Donald Arseneau +% +% Version 1.16 (5-Sep-2010) +% +\documentclass[12pt,a4paper]{ltxdoc} + +\setcounter{secnumdepth}{4} +\renewcommand\theparagraph{\arabic{paragraph}} +\newcommand\snugger{\vspace{-7pt}} + +\MakeShortVerb{\"} +\hyphenpenalty=500 +\sloppy + +\setlength\parskip{2pt} +\raggedbottom + +\title{chapterbib\\ multiple bibliographies in \LaTeX} +\author{Donald Arseneau\\ asnd@triumf.ca} +\date{2010/09/05} +\begin{document} +\maketitle + +\begin{footnotesize} +\noindent Chapterbib is copyright \copyright\ 1989--2010 by +Niel Kempson and Donald Arseneau.\\ +The package (chapterbib.sty) and this documentation (chapterbib.ltx, +chapterbib.pdf) may be freely transmitted, reproduced, or modified +for any purpose provided that the copyright notice is left intact. +(Small excerpts may of course be taken and used without any restriction.) +\par +\end{footnotesize} + +\section*{Introduction} + + The chapterbib package facilitates multiple bibliographies in a + \LaTeX\ document, including items \cs{cite}d (cited) in more than + one bibliography. Despite the name `chapterbib', + the \emph{bibliographies are for each included file}, not necessarily + for each chapter, although a bibliography per chapter is the usual + application. The main point is to allow you to use \BibTeX: Each + included file should have its own \cs{bibliographystyle} and + \cs{bibliography} commands, and you should run bibtex on each included + file separately rather than on the main or root file. + + Chapterbib also provides the environment |cbunit|, and the command + \cs{cbinput} to allow multiple bibliographies without using \cs{include} + (see item~\ref{cbinput}). + There are two added hooks, \cs{citeform} and \cs{citepunct}, which you can + redefine to customize the formatting of each entry in a citation list, + and the declaration \cs{CitationPrefix} to use in preference to \cs{citeform} + for numbering-by-chapter. + + Alternative packages: bibunits, biblatex. + +\clearpage + +\section*{Usage, Restrictions, and Options} + +\paragraph{Normal use: } \leavevmode \label{normaluse}% 1. +Put \cs{bibliographystyle} and \cs{bibliography} commands in + each \cs{include}d file. Run \LaTeX; run \BibTeX\ on each included file; + run \LaTeX; run \LaTeX. + +\snugger\paragraph{Whole bibliography: } \label{whole} % 2. + With chapterbib, the \cs{bibliography} and |\bibliography|\-|style| + commands are not normally used in the root file, only in files that + have been \cs{include}d. To have a whole-document bibliography, see + items \ref{separate}--\ref{duplicate}, depending on which style of + whole-document bib. + +\snugger\paragraph{Without \textbackslash include: } \label{cbinput} % 3. + If you can't use \cs{include} because a new section must start below the + preceding bibliography on the same page (odd format!), then you can + use |\begin{cbunit}|\dots|\end{cbunit}| (for everything in one file) + or \cs{cbinput}, with a |thebibliography| environment in each unit + or input file. + + To use \BibTeX, input separate files using \cs{cbinput}; at first use + the package or global option |[draft]|, run \LaTeX\ on the document, + then \BibTeX\ on each file that was \cs{cbinput}; finally, remove + the |[draft]| option and run \LaTeX\ again (maybe twice to get page + references right). The |[draft]| option only affects the treatment + of \cs{cbinput}, not \cs{include} or |\begin{cbunit}|. + +\snugger\paragraph{Package compatability: }\label{compatability} % 4. + Your preferred citation style (call it xxx.sty) may not work with + chapterbib at first, but it is easy to make it compatible: + In `xxx.sty' change every `|@\@citeb|' to `|@\@citeb\@extra@b@citeb|', + and insert the line\\[3pt] + \indent + |\@ifundefined{@extra@b@citeb}{\def\@extra@b@citeb{}}{}|\\[3pt] + somewhere (but not as a comment or as part of another definition!). + + If the package also redefines \cs{bibcite} then you should change that + definition, replacing `|@#1|' with `|@#1\@extra@binfo|', and insert + \\[3pt]\indent + |\gdef\@extra@binfo{}|\\[3pt] + somewhere in the file. If the package defines a command that acts + similarly to \cs{bibcite} (being written to the aux file, and then + executed as the aux file is processed), then it should + have `|\@extra@binfo|' inserted in the same way. + + Some citation packages deviate quite far from \LaTeX's own method + of organizing cite tags using `|b@\@citeb|'. The instructions above + catch such extensions as `|Y@\@citeb|', but not more radical differences. + In such cases, try contacting the author of the citation package. + + If a citation style does not (re)define \cs{nocite}, then that command + would not be converted when you make the patches at `|@\@citeb|'. + Chapterbib will try to detect the presence of \cs{@extra@b@citeb} + in \cs{nocite} and insert it, but if that fails you may need to + redefine \cs{nocite} changing any `|@\@citeb|' to + `|@\@citeb\@extra@b@citeb|' in that sty file. + +\snugger\paragraph{Sectionbib: }\label{sectionbib} % 5. + The report and book document classes usually treat the bibliography as + an unnumbered chapter (|\chapter*|), which is not so good for + bibliographies \emph{in} a chapter. You can specify\\[3pt] + \indent + |\usepackage[sectionbib]{chapterbib}| \\[3pt] + to convert your bibliographies from |\chapter*| to |\section*|, with an + entry in the table of contents and the page-header. A bibliography in + the root file remains as a |\chapter*|. The |[sectionbib]| option modifies + the existing |thebibliography| environment (or the \cs{bibsection} + command, if present already), so the other formatting in the bibliography + should remain unchanged. On the other hand, if you already have a + non-standard bibliography defined, or if you want them numbered, it + may be easier to redefine \cs{thebibliography} directly, without any + tricky modification of existing commands. + + Alternatively, you can use the \cs{sectionbib} command directly in the + document preamble. It takes two parameters: the sectioning command, and + the name of the sectioning level. For instance, the |[sectionbib]| option + executes |\sectionbib{\section*}{section}|. Again, for the most control, + it is better to redefine \cs{thebibliography} entirely. + + +\snugger\paragraph{Overall separate bibliography: } \label{separate} %6. + If you want a completely unrelated bibliography in the root file, perhaps + for a general reading list, you can provide your own bibliography there + using the |thebibliography| environment. I don't suppose this will appeal + to \BibTeX\ users! + +\snugger\paragraph{Overall bibliography: }\label{overall}% 7. + To have a cohesive bibliography for the whole document, plus individual + bibs in the chapters, put \cs{bibliography} commands in the included + chapters plus in the root file. Make sure the \cs{bibliographystyle} + for the overall bibliography appears \emph{first}, before any chapters + are included. Run \LaTeX; run \BibTeX\ on the root file; run \BibTeX\ on + each included file; run \LaTeX; run \LaTeX. + This produces an independent `overall' bibliography which only + makes sense for various `named' bibliography styles; a numbered style, or + one with any type of automatic enumeration (like Me2007a, Me2007b) will + give unrelated numbers in each bibliography and lead to confusion. + + \BibTeX\ will complain about multiple \cs{bibdata} commands when it makes + the whole bibliography, but it should obey the first. If you don't + want to see any error messages from bibtex, or if you don't want to put + the main \cs{bibliographystyle} command first in the document, then use + |\usepackage[rootbib]{chapterbib}| when you run \LaTeX\ first; run + \BibTeX\ on the root file; change to |\usepackage{chapterbib}|; run + \LaTeX; run \BibTeX\ on each included file; run \LaTeX; run \LaTeX. + +\snugger\paragraph{Chapter bibs gathered to end: }\label{gather} % 8. + To have a bibliography-by-chapter at the end instead of separate + bibs in the chapters, use |\usepackage[gather]{chapterbib}|, put + \cs{bibliography} commands in each file, and at the end of the main + file. Run \LaTeX\ as in item~\ref{normaluse}. You can control the + titling of the final bibliographies by defining \cs{FinalBibTitles}, + such as\\[3pt] + \indent|\newcommand\FinalBibTitles|\\ + \indent \indent |{References for Chapter \thechapter}|\\[3pt] + A similar effect may be achieved by re-defining \cs{FinalBibPrefix} as + \\[3pt] \indent + |\renewcommand\FinalBibPrefix{References for }|\\[3pt] + Even more control is achieved by redefining \cs{StartFinalBibs}. + The default definition is (like) +\begin{verbatim} + \newcommand{\StartFinalBibs}{% + \renewcommand{\bibname}{Bibliography for chapter n}} +\end{verbatim} + normally, but when using the [sectionbib] option it becomes +\begin{verbatim} + \newcommand{\StartFinalBibs}{\chapter*{\bibname}% + \addcontentsline{toc}{chapter}{\bibname}% + \@mkboth{\bibname}{\bibname}% + \renewcommand{\bibname}{Chapter n}} +\end{verbatim} + where the \cs{bibname} text is now provided by \cs{@auto@bibname}, + which relies on bookkeeping and \cs{FinalBibPrefix}. + + If your document class has neither section nor chapter, then you must + define \cs{StartFinalBibs} and also indicate the sectioning: for example, + if the main sectioning command in your document class is \cs{motif}: + \\[3pt]\indent + |\newcommand\CBMainSectioning{motif}| + +\snugger\paragraph{Duplicate bibliographies at end: } \label{duplicate}% 9 + To have bibliographies in each chapter \emph{plus} a + bibliography-by-chapter at the end, follow item~\ref{gather}, + but declare\\[3pt] + \indent |\usepackage[duplicate]{chapterbib}|\\ + \indent (or |\usepackage[duplicate,sectionbib]{chapterbib}|). + +\snugger\paragraph{Babel: } % 10 + If you use Babel, load chapterbib before babel. + +\section*{Formatting extensions} +\snugger\paragraph*{\textbackslash citeform} + Normally, the citations are formatted as given, but you can define + \cs{citeform} (with one parameter) to reformat every citation. + Some possibilities:\\[3pt] + \quad |\renewcommand\citeform[1]{\romannumeral 0#1}| \hfill [iv,x]\\ + \quad |\renewcommand\citeform[1]{(#1)} | \hfill [(3),(4),(7)]\\[3pt] + If you change \cs{citeform}, you should really define \cs{@biblabel} to match. + + A not-so-good way to provide a chapter-number prefix is\\[3pt] + \indent |\renewcommand\citeform[1]{\thechapter.#1}| \\[3pt] + This partially works, but has only limited applicability: it does not + work with cites in the front-matter (TOC, LOF) or with hyperref. + +\snugger\paragraph*{\textbackslash CitationPrefix} + Instead, there is a \cs{CitationPrefix} command to apply a prefix to the + citation numbers (or names) in the bibliographies and \cs{cite} commands + for the included files. Use it by declaring something like\\[3pt] + \indent |\CitationPrefix{\thechapter.}| \\[3pt] + in the preamble. The prefix will be applied to all the chapter-bibs + but will not be used in an overall (root) bibliography, if you have one. + This not only affects the formatting but the actual citation, therefore + it immediately applies to \cs{bibitem} (no need to change \cs{@biblabel}) + and works with hyperref. (The \cs{CitationPrefix} mechanism may be + prone to conflicts with other packages.) + +\snugger\paragraph*{\textbackslash citepunct} + The \cs{citepunct} command gives the punctuation (comma-penalty-space) + between items in the \cs{cite} list, and you can redefine it. + +\end{document} diff --git a/macros/latex/contrib/cite/chapterbib.pdf b/macros/latex/contrib/cite/chapterbib.pdf Binary files differnew file mode 100644 index 0000000000..9cdeb1d6f0 --- /dev/null +++ b/macros/latex/contrib/cite/chapterbib.pdf diff --git a/macros/latex/contrib/cite/chapterbib.sty b/macros/latex/contrib/cite/chapterbib.sty new file mode 100644 index 0000000000..4004095ab3 --- /dev/null +++ b/macros/latex/contrib/cite/chapterbib.sty @@ -0,0 +1,557 @@ +% chapterbib.sty Version 1.17 (18-Sep-2010) Donald Arseneau +% +% Allow multiple bibliographies in a LaTeX document, including items +% \cite'd in more than one bibliography. +% +% Copyright (C) 1989-2010 by Donald Arseneau and Niel Kempson +% These macros may be freely transmitted, reproduced, or modified +% provided that this notice is left intact. +% +% Instructions are below, after \endinput. +% +%====================== BEGIN MACROS =========================== + +\newenvironment{cbunit}% +{\global\advance\c@inputfile\@ne \xdef\the@ipfilectr{@-\the\c@inputfile}% + \@namedef{b@*\@extra@b@citeb}{}% + \@CB@writeContext}% +{\gdef\the@ipfilectr{}\@CB@writeContext} + +\def\@CB@writeContext{\if@filesw\begingroup + \edef\@tempa{\string\gdef\string\@extra@binfo{\@extra@b@citeb}}% + \immediate\write\@auxout{\@tempa\@CB@wtoc{toc}\@CB@wtoc{lof}\@CB@wtoc{lot}}% + \endgroup\fi} +\def\@CB@wtoc#1{\string\@writefile{#1}{\gdef + \string\the@ipfilectr{\@extra@b@citeb}}}% + +\let\cb@include\include +\def\include#1{\clearpage \cbunit \xdef\@currentipfile{#1}% + \cb@include{#1}\global\let\@currentipfile\@savedjobname\endcbunit} + +\newcommand\cb@input[1]{\cbunit \xdef\@currentipfile{#1}% + \input{#1}\global\let\@currentipfile\@savedjobname\endcbunit} +\let\cbinput\cb@input + +\@ifundefined{@extra@binfo}{% if not defined by compatible package +% \@ifundefined{@safe@activestrue}{}{% babel is loaded + \@ifundefined{org@bibcite}{% + \let\bibcite@iii\bibcite + \def\bibcite#1{\bibcite@iii{#1\@extra@binfo}}% + }{% and will clobber us + \let\bibcite@iii\org@bibcite + \def\org@bibcite#1{\bibcite@iii{#1\@extra@binfo}}% + }%} + }{}% + +\@ifundefined{@extra@b@citeb}{% if not defined by compatible package + \def\@citex[#1]#2{% Add \@extra@b@citeb to \cite + \leavevmode \let\@citea\@empty + \@cite{\@for\@citeb:=#2\do + {\@citea\let\@citea\citepunct + \edef\@citeb{\expandafter\@firstofone\@citeb\@empty}% + \if@filesw\immediate\write\@auxout{\string\citation{\@citeb}}\fi + \@ifundefined{b@\@citeb \@extra@b@citeb}{\hbox{\reset@font\bfseries ?}% + \G@refundefinedtrue + \@latex@warning{Citation `\@citeb' in file `\@currentipfile' + on page \thepage \space undefined}}% + {\@cite@ofmt{\citeform{\csname b@\@citeb + \@extra@b@citeb\endcsname}}}}}{#1}} +}{}% + +% Test if \@extra@b@citeb hook needs to be added to \nocite +\setbox\@tempboxa\hbox{\let\@onlypreamble\document% + \def\@extra@b@citeb{\global\let\@gtempa\relax}\@extra@b@citeb + \def\@ifundefined#1#2#3{\global\let\@gtempa\@empty #1}% + \@fileswfalse \nocite{x}} + +\ifx\@gtempa\@empty % define \nocite with hook +\def\nocite#1{\@bsphack % Add \@extra@b@citeb to \nocite + \ifx\@onlypreamble\document + \@for\@citeb:=#1\do{% + \edef\@citeb{\expandafter\@firstofone\@citeb\@empty}% + \if@filesw\immediate\write\@auxout{\string\citation{\@citeb}}\fi + \@ifundefined{b@\@citeb\@extra@b@citeb}{\G@refundefinedtrue\@latex@warning + {Citation `\@citeb' in file `\@currentipfile' undefined}}% + {}}% + \else + \@latex@error{Cannot be used in preamble}\@eha + \fi + \@esphack} +\fi + +\@ifundefined{@cite@ofmt}{\let\@cite@ofmt\hbox}{} +\@ifundefined{citeform}{\let\citeform\@empty}{} +\@ifundefined{citepunct}{\def\citepunct{,\penalty\@m\ }}{} + +\xdef\@savedjobname{\jobname}% save root file name as a macro +\let\@currentipfile\@savedjobname +\gdef\the@ipfilectr{} +\def\@extra@b@citeb{\the@ipfilectr} +\newcount\c@inputfile \global\c@inputfile=0 + +\gdef\@extra@binfo{} % in case .aux files are left from old run. + +\let\cb@bibliographystyle\bibliographystyle +\def\bibliographystyle#1{\if\cb@roottest\cb@bibliographystyle{#1}\fi} +\def\cb@roottest{11}% for [rootbib]: {2\ifx\the@ipfilectr\@empty 1\else2\fi} + +\def\bibliography#1{\if\cb@roottest + \if@filesw\immediate\write\@auxout{\string\bibdata{#1}}\fi + \fi + \begingroup % localize hooks into \@bibitem + \ifx\@CitationPrefix\@empty\else \ifx\the@ipfilectr\@empty\else + \@cb@insertprefix + \fi\fi + \cb@dobiblio{\@currentipfile.bbl}% + \endgroup} + +\let\cb@dobiblio\@input@ + +\def\FinalBibPrefix{\bibname\space for\space}% +\def\@auto@bibname{Bibliography} + +\def\sectionbib#1#2{% Macro to convert \thebibliography command + \@ifundefined{bibsection}{% Regular -- patch \thebibliography + \long\def\@tempa##1##{% to parse beginning of old def -> \@tempc + \long\def\@tempa####1\endthebibliography{}\def\@tempc{##1}\@tempa}% + \expandafter\@tempa\thebibliography{}{}\endthebibliography + \def\@tempa{\chapter*}% + \begingroup + \toks@{#1}%\showthe\toks@\show\@tempa\show\@tempc + \ifx\@tempa\@tempc\expandafter\PackageInfo\else \expandafter\PackageWarning\fi + {chapterbib}{The sectionbib option changes \string"\expandafter + \strip@prefix\meaning\@tempc\string" to \string"\the\toks@\string" % + in \string\thebibliography}% + \endgroup + \let\cb@thebibliography\thebibliography + \def\thebibliography{\let\@currentlabel\@empty + \ifx\the@ipfilectr\@empty \else + \expandafter\expandafter\expandafter\cb@sectionbib\fi + \cb@thebibliography}% + \expandafter\def\expandafter\cb@sectionbib\@tempc##1{#1{\bibname}% + \ifx\@currentlabel\@empty \begingroup \c@secnumdepth\m@ne + \addcontentsline{toc}{#2}{\bibname}% local: * -> no num + \csname#2mark\endcsname{\bibname}\endgroup\fi + \@ifnextchar\@mkboth{\@gobblethree}{}}% + }{% Some package or class has \bibsection -- patch that. + \long\def\@tempa##1##{% to parse beginning of old def + \long\def\@tempa####1\endthebibliography{}\def\@tempc{##1}\@tempa}% + \expandafter\@tempa\bibsection{}{}\endthebibliography + \def\@tempa{\chapter*}% + \begingroup + \toks@{#1}% + \ifx\@tempa\@tempc\expandafter\PackageInfo\else \expandafter\PackageWarning\fi + {chapterbib}{The sectionbib option changes \string"\expandafter + \strip@prefix\meaning\@tempc\string" to \string"\the\toks@\string" % + in \string\thebibliography}% + \endgroup + \let\cb@bibsection\bibsection + \def\bibsection{\let\@currentlabel\@empty + \ifx\the@ipfilectr\@empty \else + \expandafter\expandafter\expandafter\cb@sectionbib\fi + \cb@bibsection}% + \expandafter\def\expandafter\cb@sectionbib\@tempc{#1}% +}} + +\long\def\@gobblethree#1#2#3{}% +\@ifundefined{bibname}{\def\bibname{Bibliography}}{} + +% The following very messy hacking is to apply a prefix to each +% cite value, shown in the cites and the bibitems, and active +% with hyperref. The user should declare something like: +% \CitationPrefix{\thechapter.} +% Because this hooking-in is so tricky and specific, it is best +% to regard this feature as perpetually "experimental". +% +\let\@cb@use@prefix\@empty +\let\@CitationPrefix\@empty +% +\newcommand\CitationPrefix[1]{% + \def\@CitationPrefix{#1}% + \@ifundefined{cb@emptytoks}{\newtoks\cb@emptytoks}{}\cb@emptytoks={}% + \def\@cb@use@prefix{% Performed at the first \bibitem of each (sub-)bibliography + \let\value\@cb@valuehack + \def\@itemlabel{\@biblabel {\the\value\@listctr}}% + \let\@cb@use@prefix\@empty}% + \def\@cb@valuehack##1{% hook into "\the\value\@listctr" + \ifx\@listctr##1% only affect "\value\@listctr" + \cb@emptytoks % use up the preceding \the + \@CitationPrefix % insert the prefix text + \the % restore \the + \fi + \csname c@\@listctr\endcsname}% regular \value +} + +% redefine \@lbibitem to use prefixed number; set hook (through \value) +% to use prefix in \@bibitem also. This \@cb@insertprefix is executed +% by \bibliography. +\def\@cb@insertprefix{% + \let\@cborg@lbibitem\@lbibitem \let\@cborg@bibitem\@bibitem + \def\@bibitem{\@cb@use@prefix\@cborg@bibitem}% + \def\@lbibitem[##1]{\@cb@use@prefix\@cborg@lbibitem[\@CitationPrefix##1]}% + \let\@cb@insertprefix\@empty % ensure no recursive use +} + +\ProvidesPackage{chapterbib}[2010/09/18 \space v 1.17] +\DeclareOption{sectionbib}{\AtBeginDocument{\sectionbib{\section*}{section}}% + \let\FinalBibPrefix\@empty + \providecommand\StartFinalBibs{\chapter*{\bibname}% + \begingroup \c@secnumdepth\m@ne + \addcontentsline{toc}{chapter}{\bibname}% + \chaptermark{\bibname}\endgroup + \def\bibname{\@auto@bibname}}}% +\DeclareOption{draft}{\let\cbinput=\include} +\DeclareOption{rootbib}{\def\cb@roottest{2\ifx\the@ipfilectr\@empty2\else1\fi}} +\DeclareOption{duplicate}{\gdef\cb@biblist{}\let\cb@sub@input\@input@} +\DeclareOption{gather}{\gdef\cb@biblist{}\let\cb@sub@input\@gobble} +\ProcessOptions + +\@ifundefined{chapter}% +{\@ifundefined{section}% + {\providecommand\CBMainSectioning{page}}% silly default to prevent errors + {\providecommand\CBMainSectioning{section}}% +}{\providecommand\CBMainSectioning{chapter}}% + + +\ifx\cb@sub@input\@input@ % For [duplicate] + \def\cb@dofinalbibs{\if@filesw + \toks@{\let\cb@bc\bibcite\let\bibcite\@gobbletwo}% + \immediate\write\@auxout{\the\toks@}\fi + \let\cb@elt\cb@dogatherbib \cb@biblist + \if@filesw\immediate\write\@auxout{\let\string\bibcite\string\cb@bc}\fi}% +\fi + +\ifx\cb@sub@input\@gobble % For [gather] + \def\cb@dofinalbibs{\let\cb@elt\cb@dogatherbib \cb@biblist}% +\fi + +\ifx\cb@biblist\@empty % duplicate or gather declared + \providecommand\StartFinalBibs{\def\bibname{\@auto@bibname}}% + \def\cb@dobiblio#1{% defined to save local context for later "dofinalbibs" + \begingroup\makeatletter + \ifx\the@ipfilectr\@empty % in root + \StartFinalBibs \cb@dofinalbibs + \else % in chapter, or section; append to \cb@biblist + \let\cb@elt\relax % list \cb@elt{title}{input#}{file}{citeprefix} + \let\@ifchapapp\@secondoftwo % provide a *possible* title + \expandafter\ifx\csname the\CBMainSectioning\endcsname\thechapter + \@ifundefined{@chapapp}{}{\let\@ifchapapp\@firstoftwo}\fi + \@ifundefined{FinalBibTitles}{\def\FinalBibTitles % locally + {\FinalBibPrefix + \@ifchapapp{\@chapapp}{\csname the\CBMainSectioning\endcsname}\space + \csname the\CBMainSectioning\endcsname}}{}% + \protected@xdef\cb@biblist{\cb@biblist\cb@elt + {\FinalBibTitles}{\the\c@inputfile}{\@currentipfile}{\@CitationPrefix}}% + \cb@sub@input{#1}% + \fi\endgroup}% end \cb@dobiblio + \def\cb@dogatherbib#1#2#3#4{% Title, count, fname, prefix + \begingroup + \protected@edef\@auto@bibname{#1}% + \def\@CitationPrefix{#4}% + \ifx\@CitationPrefix\@empty\else \@cb@insertprefix \fi + \global\c@inputfile#2\global\advance\c@inputfile\m@ne + \IfFileExists{#3.bbl}{\cb@input{#3.bbl}}{}% + \endgroup} +\fi + +\AtBeginDocument{\let\sectionbib\undefined} + +\endinput + +%====================== BEGIN INSTRUCTIONS =========================== + + + chapterbib.sty Version + ~~~~~~~~~~~~~~ 1.17 (18-SEP-2010) DA Fix errors introduced in prev + 1.16 (05-SEP-2010) DA \CitationPrefix with [gather], drop 2.09 + 1.15 (30-JUL-2009) DA (typo \CitationPrefix) + 1.14 (31-MAR-2009) DA (\nocite*, \CitationPrefix, etc) + 1.13 (11-DEC-2007) DA (new final-bib titling) + 1.12 (21-MAR-2004) DA + 1.11 (29-FEB-2004) DA (allow \nocite check) + 1.10 (23-JUN-2003) DA (\bibsection \CBMainSectioning) + 1.9 (19-SEP-2001) DA (sectionbib change; babel) + 1.8 (29-APR-1999) DA (gather, duplicate, toc) + 1.7 (21-JUL-1997) DA (sectionbib, \nocite) + 1.6 (08-FEB-1997) Donald Arseneau (more sectionbib) + 1.5 (09-OCT-1995) Donald Arseneau (rootbib) + 1.4 (11-MAR-1995) Donald Arseneau (sectionbib) + 1.3 (04-JUL-1994) Donald Arseneau (2e, cbunit) + 1.2 (21-MAY-1993) Donald Arseneau (bug fix) + 1.1 (24-MAR-1993) Donald Arseneau + 1.0 (23-NOV-1988) Niel Kempson + + Allow multiple bibliographies in a LaTeX document, including items + \cite'd in more than one bibliography. Despite the name "chapterbib", + the BIBLIOGRAPHIES ARE FOR EACH INCLUDED FILE, not necessarily for each + chapter. The main point is to allow you to use BibTeX: Each included + file should have its own \bibliographystyle and \bibliography commands, + and you should run BibTeX on each included file separately rather than + on the root file. + + There are also the commands \begin{cbunit}, \end{cbunit}, and \cbinput + to allow multiple bibliographies without using \include (see item 4). + There are two added hooks, \citeform and \citepunct, which you can + redefine to customise the formatting of each entry in a citation list, + and the declaration \CitationPrefix to use in preference to \citeform + for numbering-by-chapter. + + Usage, Restrictions, and Options + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + 1. Normal use: Put \bibliographystyle and \bibliography commands in + each \include'd file. Run LaTeX; run BibTeX on each included file; + run LaTeX; run LaTeX. + + 2. The \bibliography and \bibliographystyle commands are not normally used + in the root file, only in files that have been \include'd. To have a + whole-document bibliography, see items 6-9, depending on which style of + whole-document bib. + + 3. If you can't use \include because a new section must start below the + preceding bibliography on the same page (odd format!), then you can + use \begin{cbunit}...\end{cbunit} or \cbinput, with a {thebibliography} + environment in each unit or input file. To use BibTeX: input separate + files using \cbinput; at first use the package or global option [draft], + run LaTeX on the document, then BibTeX on each file that was \cbinput; + finally, remove the [draft] option and run LaTeX again (maybe twice to + get page references right). The [draft] option only affects the treatment + of \cbinput, not \include or \begin{cbunit}. + With old LaTeX, do the preliminary run using \include commands, and + change these to \cbinput for the final run(s). + + 4. Your preferred citation style (xxx.sty) may not work with chapterbib at + first, but it is easy to make it compatible: In `xxx.sty' change every + "@\@citeb" to "@\@citeb\@extra@b@citeb", and insert the line + \@ifundefined{@extra@b@citeb}{\def\@extra@b@citeb{}}{} + somewhere (but not as a comment or as part of another definition!). + + If the package also redefines \bibcite then you should change that + definition, replacing "@#1" with "@#1\@extra@binfo", and insert + \gdef\@extra@binfo{} + somewhere in the file. If the package defines a command that acts + similarly to \bibcite (being written to the aux file), then it should + have "\@extra@binfo" inserted the same way. + Some citation packages deviate quite far from LaTeX's own method + of organizing cite tags using "b@\@citeb". The instructions above + catch such extensions as "Y@\@citeb", but not more radical differences. + In such cases, try contacting the author of the citation package. + If a citation style does not define "\nocite", then that command + would not be converted when you make the patches to "@\@citeb". + Chapterbib will try to detect the hook in "\nocite", but if this fails + you may need to redefine "\nocite" (with any "@\@citeb" changed to + "@\@citeb\@extra@b@citeb") in that sty file. + + 5. The report and book document classes usually treat the bibliography as + an unnumbered chapter (\chapter*), which is not so good for bibliographies + IN a chapter. You can specify + \usepackage[sectionbib]{chapterbib} + to convert your bibliographies from \chapter* to \section*, with an + entry in the table of contents and the page-header. A bibliography in + the root file remains as a \chapter*. The [sectionbib] option modifies + the existing thebibliography environment (or the \bibsection command, if + present already), so the other formatting in the bibliography should + remain unchanged. On the other hand, if you already have a non-standard + bibliography defined, or if you want them numbered, it may be easier to + redefine \thebibliography directly, without any trickery. + Alternatively, you can use the \sectionbib command directly in the + document preamble. It takes two parameters: the sectioning command, and + the name of the sectioning level. For instance, the [sectionbib] option + does \sectionbib{\section*}{section}. Again, for the most control, it is + better to redefine \thebibliography entirely. + + 6. If you want a completely unrelated bibliography in the root file, perhaps + for a general reading list, you can provide your own bibliography there + using the thebibliography environment. I don't suppose this will appeal + to BibTeX users! + + 7. To have a cohesive bibliography for the whole document, plus individual + bibs in the chapters, put \bibliography commands in the included chapters + plus in the root file. Make sure the \bibliographystyle for the overall + bibliography appears FIRST, before any chapters are included. Run LaTeX; + run BibTeX on the root file; run BibTeX on each included file; run LaTeX; + run LaTeX. This produces an independent `overall' bibliography which only + makes sense for various `named' bibliography styles; a numbered style, or + one with any type of automatic enumeration (like Me2007a, Me2007b) will + give unrelated numbers in each bibliography and lead to confusion. + Bibtex will complain about multiple \bibdata commands when it makes + the whole bibliography, but it should obey the first. If you don't + want to see any error messages from bibtex, or if you don't want to put + the main \bibliographystyle command first in the document, then use + \usepackage[rootbib]{chapterbib} when you run LaTeX first; run BibTeX + on the root file; change to \usepackage{chapterbib}; run LaTeX; run + BibTeX on each included file; run LaTeX; run LaTeX. + + 8. To have a bibliography-by-chapter at the end instead of separate bibs + in the chapters, use \usepackage[gather]{chapterbib}, put \bibliography + commands in each file, and at the end of the main file. Run LaTeX as + in item 1. You can control the titling of the final bibliographies by + defining \FinalBibTitles, such as + + \newcommand\FinalBibTitles{References for Chapter \thechapter} + + A similar effect may be achived by RE-defining \FinalBibPrefix as + + \renewcommand\FinalBibPrefix{References for } + + Even more control is achieved by redefining \StartFinalBibs. + The default definition is (like) + + \newcommand{\StartFinalBibs}{% + \renewcommand{\bibname}{Bibliography for chapter n}} + + normally, but when using the [sectionbib] option it becomes + + \newcommand{\StartFinalBibs}{\chapter*{\bibname}% + \addcontentsline{toc}{chapter}{\bibname}\@mkboth{\bibname}{\bibname}% + \renewcommand{\bibname}{Chapter n}} + + where the \bibname text is now provided by \@auto@bibname, which + relies on bookkeeping and \FinalBibPrefix. + + If your document class has neither section nor chapter, then you must + define \StartFinalBibs and also indicate the sectioning: for example, + if the main sectioning command in your document class is \motif: + \newcommand\CBMainSectioning{motif} + + 9. To have bibliographies in each chapter PLUS a bibliography-by-chapter at + the end, follow item 8, but declare \usepackage[duplicate]{chapterbib} + (or \usepackage[duplicate,sectionbib]{chapterbib}). + +10. If you use Babel, load chapterbib before babel. + + \citeform, \citepunct and \CitationPrefix: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + Normally, the citations are formatted as given, but you can define \citeform + (with one parameter) to reformat every citation. Some possibilities: + \renewcommand\citeform[1]{\romannumeral 0#1}% roman numerals: [iv,x] + \renewcommand\citeform[1]{(#1)} % parentheses: [(3),(4),(7)] + If you change \citeform, you should probably define \@biblabel to match. + + Another not-so-good example to provide a chapter-number prefix is + \renewcommand\citeform[1]{\thechapter.#1} % number by chapter. + This partially works, but has only limited applicability: it does not + work with cites in the front-matter (TOC, LOF) or with hyperref. + Instead, there is a \CitationPrefix command to apply a prefix to the + citation numbers (or names) in the bibliographies and \cite commands + for the included files. Use it by declaring something like + \CitationPrefix{\thechapter.} + in the preamble. The prefix will be applied to all the chapter-bibs + but will not be used in an overall (root) bibliography, if you have one. + (The \CitationPrefix mechanism is likely to break often if it conflicts + with other packages.) + + \citepunct gives the punctuation (comma-penalty-space) between items + in the \cite list. + +%====================== END INSTRUCTIONS =========================== +% +% -----------------Implementation notes--------------- +% +% LaTeX normally uses command names in the form \b@TAG to associate a mnemonic +% TAG with the citation name or number. Chapterbib changes this to a command +% like \b@TAG@-nn where nn is a number identifying which included file is in +% effect. +% +% Tags indicating the citations and/or the input files: +% ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +% \c@inputfile = counter counting included files +% \the@ipfilectr = (empty) when typesetting from the root file, +% = @-\the\c@inputfile when typesetting from an included file +% \@extra@b@citeb = \the@ipfilectr (just an alias) +% \@extra@binfo = the value of \@extra@b@citeb as saved in .aux files +% +% \b@FOO: +% ~~~~~~~ +% In the root file, the citation number (or name) is given by \b@FOO +% just like regular LaTeX, but in an \include'd file it is given by +% \b@FOO@-number. Any definition of \cite (\@citex) should refer +% to this using \csname b@\@citeb\@extra@b@citeb \endcsname. +% +% \include \cbinput and \cbunit: +% ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +% Redefine the \include macro so that when a file is \include'd... +% Increment the file number, (globally) update \the@ipfilectr to be +% @-number, and write \gdef\@extra@binfo{@-number} in the (main) .aux +% file, and do regular \include. When the \include'd file is finished, +% write \gdef\@extra@binfo{} in the (main) .aux file. Globally reset +% \the@ipfilectr to {}. Provide similar \cbunit and \cbinput. +% +% \cite: +% ~~~~~~ +% Redefine \cite (\@citex actually) and \bibcite to use the file number +% tag along with the specified tag. \@citex also uses \citeform as a hook +% to reformat each individual citation. +% Only do the redefinitions if no citation style that supports chapterbib +% has been loaded--as indicated by existence of filename tags. +% +% \nocite: +% ~~~~~~~~ +% A while ago LaTeX changed its \nocite so it checks the validity of the +% (no)citation tags. This necessitated adding the "\@extra@b@citeb" hook +% to \nocite. At first, I only redefined \nocite when redefining \cite, +% but there existed citation packages that supported chapterbib by putting +% \@extra@b@citeb into \cite but which did not define \nocite at all! +% These then gave warning messages for every \nocite. With version 1.7, +% I now try exercising the \nocite command with some functions disabled: +% (1) .aux file output is locally switched off; (2) The \@ifundefined +% command is hacked to merely typeset the text of the tag; (3) this is +% done in a disappearing \hbox so it generates no output. This detects +% (by setting a global flag \@gtempa) a \nocite command that executes +% \@ifundefined but not \@extra@b@citeb. In such cases, \nocite must +% be redefined. +% +% \citepunct and \citeform: +% ~~~~~~~~~~~~~~~~~~~~~~~~~ +% These customization hooks are present in cite.sty; others (\citemid, +% \citeleft, \citeright) are not defined here because \@cite is not redefined. +% LaTeX has now adopted \@cite@ofmt, which is normally \hbox, so use both. +% +% We redefine \@testdef so that it properly checks whether the +% \cite labels have changed. +% +% Table of contents etc: +% ~~~~~~~~~~~~~~~~~~~~~~ +% As of version 1.8, definitions of \@extra@b@citeb are written to the +% toc, lot, and lof files to avoid undefined citation tags in those tables. +% This is actually a problem in regular LaTeX with bibTeX -- cites that +% appear in those tables get numbered starting with 1, but they should +% be sequenced by where they originated -- but the problem was worse with +% chapterbib. +% +% \CitationPrefix: +% ~~~~~~~~~~~~~~~~ +% This is a really ugly hack, but \citeform worked poorly for putting +% a chapter-identifier on each cite. It locally redefines both +% \@bibitem and \@lbibitem at each \bibliography. The insertion +% of the prefix is straightforward for \@lbibitem, but for \@bibitem +% the prefix is inserted by a redefined \value macro (eeek!). It has +% a deficiency in not being sorted as a simple number by cite.sty. +% +%--------------------------------------------------------------- +% +% Authors Niel Kempson (original) +% ~~~~~~~ Donald Arseneau <asnd@triumf.ca> March 1993 - Sept 2010 +% +% Changes with ver 1.17: Fix errors made dropping ancient support; +% Make [sectionbib] give warn or info always. +% Changes with ver 1.16: Propagate prefix info to final bibs; +% drop support for ancient LaTeX versions +% Changes with ver 1.15: Fix typo \bibitemPrefix -> \CitationPrefix +% Changes with ver 1.14: No warning from \nocite* in chapters, \CitationPrefix +% Changes with ver 1.13: Rewrite final-bibs titling +% Changes with ver 1.12: Update \@citex \bfseries +% Changes with ver 1.11: Follow LaTeX's barring \nocite from preamble +% Changes with ver 1.10: \CBMainSectioning; \bibsection hook +% Changes with ver 1.9: sectionbib remove \@mkboth +% Changes with ver 1.8: options gather and duplicate; babel workarounds; toc +% Changes with ver 1.7: Change the \sectionbib command re. headings. +% Update \nocite and alter \citeform +% Changes with ver 1.6: Change the \sectionbib command to take arguments. +% Changes with ver 1.5: rootbib option; item 8 in instructions. +% Changes with ver 1.4: sectionbib and draft options +% Changes with ver 1.3: rewrite: +% The filename tag is defined in each .aux file by \include, not as an +% extra parameter to \bibcite. \@bibitem & \@lbibitem are left alone. Add +% \citeform and \citepunct. Add \cbunit and \cbinput for use without \include. +% diff --git a/macros/latex/contrib/cite/cite.ltx b/macros/latex/contrib/cite/cite.ltx new file mode 100644 index 0000000000..663603c369 --- /dev/null +++ b/macros/latex/contrib/cite/cite.ltx @@ -0,0 +1,220 @@ +% +% cite.ltx Manual for cite.sty +% +% +% Copyright (c) 1989-2015 by Donald Arseneau +% +% Version date (Feb 2015) +% +\documentclass[12pt,a4paper]{ltxdoc} +\overfullrule=1pt +\addtolength{\textwidth}{1cm} +\MakeShortVerb{\"} +\hyphenpenalty=600 +\newcommand\snugger{\vspace{-7pt}} +\sloppy + +\setlength\parskip{2pt} + +\title{The cite package:\\ well formed numeric citations} +\author{Donald Arseneau\\ asnd@triumf.ca} +\date{2015/02/27} +\begin{document} +\maketitle + +\begin{abstract} + The cite package modifies \LaTeX's normal citation mechanism for +improved handling of numeric citations. It provides compressed, sorted +lists of numerical or partly-numerical citations, as regular text or +as superscripts. Generally, no changes to the usage of \cs{cite} commands +in the input are required. +\end{abstract} + + +\begin{footnotesize} +\noindent The cite package is Copyright \copyright\ 1989--2015 by +Donald Arseneau (Vancouver, Canada).\\ +The package (cite.sty) and this documentation (cite.ltx, cite.pdf) may be +freely transmitted, reproduced, or modified for any purpose provided that the +copyright notice is left intact. +(Small excerpts may of course be taken and used without any restriction.) +\par +\end{footnotesize} + +\section*{Normal Use} +Insert "\usepackage{cite}" in the document's preamble for improved handling +of numeric citations, behaving as follows: + +\snugger\paragraph*{Spacing} A small space is typeset after commas + in the citation list. The option [nospace] removes that space, and + the option [space] replaces it with an ordinary inter-word space. + +\snugger\paragraph*{Sorting} Citations in a list are sorted into ascending + order. The [nosort] package option turns off sorting. + Sortable citations must be numeric or mostly-numeric (see below). + Non-sortable entries are printed before all sortable ones. + +\snugger\paragraph*{Compression} Groups of three or more consecutive numbers + are compressed into a range using an en-dash. For example, the (poor) list + [7,5,6,?,4,9,8,Einstein,6] would display as [?,Einstein,4--6,6--9]. + Compression of ranges is disabled by the [nocompress] package option. + +\snugger\paragraph*{Non-numbers} Sorting and compression work with (positive) + numbers ("8,6,7,9" gives [6--9]) as well as numbers with prefix or suffix + characters ([5a--5c] or [T1--T4]), and also dual numbers with a separator + character ([1.11--1.15]). Dual numbers don't mix well with single numbers. + Other forms of entry are printed before all sortable forms. + +\snugger\paragraph*{Superscript} With package option [superscript] + (or [super] for short), citations are displayed as superscripts, + except those with an optional note, which are printed on-line + with brackets. + + Superscript citations use \emph{the same input format} as ordinary + citations to produce different output. Blank space before the "\cite" + command is discarded, and trailing punctuation is moved to come before + the superscript citation. For example, `"information \cite{source};"' + ignores the space before "\cite" and puts the semicolon before the number + to give `information;$^{12}$\,', just as if you typed `"information;$^{12}$"'. + Doubling of periods (.., ?., !.) is checked for and suppressed. You may + disable movement with the [nomove] package option. + +\snugger\paragraph*{Line Breaks} Line breaks before and within the citation + (after dashes, and after punctuation) are permitted, but discouraged by + `penalties' (given by "\citeprepenalty", "\citemidpenalty", and + "\citepunctpenalty"; see Customization). The option [nobreak] prohibits + these breaks. No breaks are permitted with superscript cites. + +\snugger\paragraph*{Space before} Regular-text citations have the preceding space + adjusted to be a normal inter-word space, even if there is no space in the + input. The [noadjust] option disables this. Superscript citations + have all preceding space removed. + +\snugger\paragraph*{Numbers alone} The command "\citen" is provided to give + just the citation number(s) without the brackets or superscript + and other formatting. Aliases are "\citenum" and "\citeonline" for easy + conversion to other citation packages. + + +\section*{Options} + +There are several options for "\usepackage{cite}", some already mentioned. +\begin{center} +\begin{tabular}{lp{0.75\linewidth}} + [superscript]& use superscripts for cites without optional notes\\\relax + [super] & alias for [superscript] (like natbib)\\\relax + [ref] & uses the format "[Ref.~12, given note]" (useful with + the superscript option)\\\relax + [nospace] & eliminates the spaces after commas in the number list\\\relax + [space] & uses a full inter-word space after the commas\\\relax + [nobreak] & eliminate all line-breaks\\\relax + [nosort] & prevents sorting of the numbers (default is to sort, \dots\\\relax + [sort] & \dots and this option is provided for completeness).\\\relax + [nomove] & prevents moving the superscript cite after punctuation\\\relax + [move] & moving punctuation is the default\\\relax + [noadjust] & disables `smart' handling of space before a cite\\\relax + [adjust] & is the default\\\relax + [nocompress] & inhibit compression of consecutive numbers into ranges\\\relax + [compress] & is the default\\\relax + [biblabel] & define the bibliography label to match "\cite" +\end{tabular} +\end{center} + +If your citations are not numeric, and not of any near-numeric sortable form, +then you should probably not use cite.sty; but if you must, then at least +use the [nosort,nocompress] options. + + + +\section*{More Customization} + +The punctuation characters that will migrate before superscript cites are +listed in the macro "\CiteMoveChars", which you can redefine (using +"\renewcommand"). The default set of characters is ".,;:". Perhaps +"!"~and~"?" should be included too, but they weren't listed in the +(APS) style manual, and they do put too much visual separation between +the cite and what it applies to. Feel free to redefine "\CiteMoveChars". +Quote marks should be typed before the "\cite", so do not need to move. +This gives one difficulty~-- punctuation following quotes won't migrate +inside the quotation: e.g., "``Transition State Theory''\cite{Eyring}." +gives out ``Transition State Theory''.$^8$, but you may want the period +inside the quotes, thus: ``Transition State Theory.''$^8$ + +When moving punctuation before a superscript cite, the spacing after the +citation is set according to the final punctuation mark moved, and doubling +of periods (.., ?., !.) is checked for and suppressed. There is a problem +with double periods after a capitalized abbreviation or directly after "\@" : +Both of `"N.S.A. \cite{space}."' and `"et al.\@ \cite{many}."' will give +doubled periods. Type `"\ "' (backslash space) after abbreviations like `et +al.' ("et al.\ \cite{many}.") to get the right spacing within a sentence +whether or not a citation follows, and prevent double periods with the +superscript cite. You could use "\@" to fix the N.S.A. example +("N.S.A\@. \cite{space}.") but that gives the wrong spacing when there is no +citation, so it should be inserted only where a cite follows. + +There are several commands that you may redefine to change the +formatting of citation lists: +\begin{center} +\begin{tabular}{@{}lll@{}} +command & function & default\\ +\hline +\cs{citeform} & reformats each number & nothing\\ +\cs{citepunct} & printed between numbers & comma, penalty, thinspace\\ +\cs{citeleft} & left delimiter of list & [\\ +\cs{citeright} & right delimeter of list & ]\\ +\cs{citemid} & printed before note & comma, penalty, space\\ +\cs{citedash} & used in compressed range & endash, penalty\\ +\cs{CiteMoveChars} & characters that get moved & \texttt{.,:;}\\ +\cs{OverciteFont} & font sel. for superscripts & \relax"\fontsize{\sf@size}"\dots\\ +\end{tabular} +\end{center} + +The left/mid/right commands apply to regular test citations, and don't affect the +formatting of superscript citations. You may use "\renewcommand" to change any +of these. Remember, these commands are extensions made by this package; they are not regular +LaTeX. Some examples of changes: + +\begin{flushleft} +"\renewcommand\citeform[1]{\romannumeral 0#1}}" $\to$ roman i,vi\\ +"\renewcommand\citeform[1]{[#1]}" $\to$ individual brackets [1]--[5],[9]\\ +"\renewcommand\citeform{\thechapter.}" $\to$ by chapter: \textsuperscript{2.18--2.21}\\ +"\renewcommand\citepunct{,}" $\to$ no space and no breaks at commas\\ +"\renewcommand\citemid{; }" $\to$ semicolon before optional note\\ +"\renewcommand\citeleft{(}" $\to$ parentheses around whole list\\ +"\renewcommand\citeright{)}" $\to$ parentheses around whole list\\ +\end{flushleft} + + +The appearance of the whole citation list is governed by "\@cite", (for +full-sized cites) and "\@citess" (for superscripts). For more extensive changes +to the formatting, redefine these. For example, to get brackets around the +list of superscript numbers you can do:\\[2pt] +\indent "\renewcommand\@citess[1]{\textsuperscript{[#1]}}"\\[2pt] +(after "\makeatletter"). + +The superscript option does not normally affect the numbering +format of the bibliography, which is controlled by the "\@biblabel" command. +Just for convenience, the cite package now understands a [biblabel] option +that redefines "\@biblabel" to match the format of "\cite". + +Line breaking can be turned off using the [nobreak] option, but it can be +controlled more precisely by changing three numeric values for the +line-break penalties: +\begin{center} +\begin{tabular}{lll} +Command & Location & Default \\ +\hline +\cs{citeprepenalty} & before entire citation & "\@highpenalty"\\ +\cs{citemidpenalty} & in "\citemid", before note & "\@medpenalty"\\ +\cs{citepunctpenalty}& in "\citepunct" and "\citedash" & 1000 +\end{tabular} +\end{center} +Use "\mathchardef" (!)~to change these penalty values, as in \\ +\indent "\mathchardef\citeprepenalty=9999"\\ +(Yes, that is obscure but I don't want to use up counter registers +or to pretend the parameters are counters to be incremented.) + +Alternatively, the commands "\citemid", "\citedash", and "\citepunct" +can be redefined to use different penalty parameters, or none at all. + +\end{document} diff --git a/macros/latex/contrib/cite/cite.pdf b/macros/latex/contrib/cite/cite.pdf Binary files differnew file mode 100644 index 0000000000..f6ae188d33 --- /dev/null +++ b/macros/latex/contrib/cite/cite.pdf diff --git a/macros/latex/contrib/cite/cite.sty b/macros/latex/contrib/cite/cite.sty new file mode 100644 index 0000000000..44c37a841d --- /dev/null +++ b/macros/latex/contrib/cite/cite.sty @@ -0,0 +1,665 @@ +% C I T E . S T Y +% +% version 5.5 (Feb 2015) +% +% Compressed, sorted lists of on-line or superscript numerical citations. +% see also drftcite.sty (And the stub overcite.sty) +% +% Copyright (C) 1989-2015 by Donald Arseneau +% These macros may be freely used, transmitted, reproduced, or modified +% provided that this notice is left intact. +% +% Instructions in cite.pdf and follow \endinput. +% ------------------------------------ +% First, ensure that some catcodes have the expected values +\edef\citenum{% temporary def to restore funny codes later + \catcode\string`\string ` \the\catcode\string`\` + \catcode\string`\string ' \the\catcode\string`\' + \catcode\string`\string . \the\catcode\string`\. + \catcode\string`\string = \the\catcode\string`\= + \catcode\string`\string _ \the\catcode\string`\_ + \catcode\string`\string : \the\catcode\string`\:} +% set codes: +\catcode\string`\` 12 +\catcode`\' 12 +\catcode`\. 12 +\catcode`\= 12 +\catcode`\_ 8 % This is UNusual +\catcode`\: 12 + +% Prepare for optional variations: +% [ verbose, nospace, space, ref, nosort, noadjust, superscript, nomove ], +% \citeform,\citeleft,\citeright,\citemid,\citepunct,\citedash +% +% Set defaults first: + +% [ on the left. Option [ref] does: [Ref. 12, note] +\providecommand\citeleft{[} + +% ] on the right: +\providecommand\citeright{]} + +% , (comma space) before note +\providecommand\citemid{,\penalty\citemidpenalty\ } + +% , (comma thin-space) between entries; [nospace] eliminates the space +\providecommand\citepunct{,\penalty\citepunctpenalty% + \hskip.13emplus.1emminus.1em\relax}% + +% -- (endash) designating range of numbers: +% (using \hbox avoids easy \exhyphenpenalty breaks) +\providecommand{\citedash}{\hbox{--}\penalty\citepunctpenalty} + +% Default line-breaking penalties. Use \mathchardef instead of count registers +\mathchardef\citeprepenalty=\@highpenalty +\mathchardef\citemidpenalty=\@medpenalty +\mathchardef\citepunctpenalty=\@m + +% Each number left as-is: +\providecommand\citeform{} + +% punctuation characters to move for overcite +\providecommand{\CiteMoveChars}{.,:;} + +% font selection for superscript numbers +\providecommand\OverciteFont{\fontsize\sf@size\baselineskip\selectfont} + + +% [verbose] is no-op. Default is to repeat warnings anyway. +%\let\oc@verbo\relax + +%---------------------- +% \citen uses \@nocite to ignore spaces after commas, and write the aux file +% \citation. \citen then loops over the citation tags, using \@make@cite@list +% to make a sorted list of numbers. Finally, \citen executes \@citelist to +% compress ranges of numbers and print the list. \citen can be used by itself +% to give citation numbers without the brackets and other formatting; e.g., +% "See also ref.~\citen{junk}." +% Make internal version called \@cite@n just in case packages put hooks in +% \citen +% +\DeclareRobustCommand\citen{\@cite@n} +\def\@cite@n#1{% + \begingroup + \let\@safe@activesfalse\@empty + \@nocite{#1}% ignores spaces, writes to .aux file, returns #1 in \@no@sparg + \@tempcntb\m@ne % \@tempcntb tracks highest number + \let\@celt\delimiter % an unexpandable, but identifiable, token + \def\@cite@list{}% % empty list to start + \let\@citea\@empty % no punctuation preceding first + \@for \@citeb:=\@no@sparg\do{\@make@cite@list}% make a sorted list of numbers + % After sorted citelist is made, execute it to compress citation ranges. + \@tempcnta\m@ne % no previous number + \mathchardef\@cite@incr\z@ % no previous sequence + \let\@h@ld\@empty % nothing held from list yet + \let\@celt\@compress@cite \@cite@list % output number list with compression + \@h@ld % output anything held over + \endgroup + \@restore@auxhandle + } + +% For each citation, check if it is defined. If so, then extract plain +% value to \@B@citeB (without hyperlink info). Then, +% If it is a pure number, add it to cite list +% Otherwise, try extracting prefix and suffix characters. +% +\def\@make@cite@list{% + \expandafter\ifx\csname b@\@citeb\@extra@b@citeb + \endcsname\relax % undefined: output ? and warning + \@citea {\bfseries ?}\let\@citea\citepunct \G@refundefinedtrue + \@warning {Citation `\@citeb' on page \thepage\space undefined}% + %% always verbose \oc@verbo \global\@namedef{b@\@citeb\@extra@b@citeb}{?}% + \else % defined + \@cite@nonhyper@sanitize + \@addto@cite@list + \fi} + +\def\@nonhyper@@link [#1]#2#3#4{#4} +\def\@cite@nonhyper@sanitize{\begingroup + \let\hyper@@link\@nonhyper@@link + \protected@xdef\@B@citeB{\csname b@\@citeb\@extra@b@citeb \endcsname}% + \endgroup} + +\def\@cite@out#1{\citeform{\csname #1\endcsname}} + +% Add entry to the list of citations. This default definition sorts pure +% numbers as well as numbers with other single-character tags. There +% is presently no other definition than this default, but features may +% be added later. +% +\def\@addto@cite@list{% + \@cite@posnumtest\@B@citeB + {\@addnumto@cite@list\@B@citeB}% a positive number, put in list + {\@cite@combo@num}% not a pure positive number, test for combo forms +} + +% With this \@cite@combo@num we delve into handling of numbers combined +% with non-numeric tags. The specific command name \@cite@combo@num can +% serve as a hook for redefinition, perhaps to give simple non-sorting +% for anything not a pure number, or to attempt even more complicated +% sorting, say dictionary sorting of textual citations. The following +% definition leads down the road of sorting mostly-numbers but with +% optional single-character prefix and/or suffix. + +\def\@cite@combo@num{\expandafter\@cite@try@combo\@B@citeB\delimiter} + +% First of many stages for sorting numbers with prefix/suffix characters. +% Test for a leading token of category letter or other (appropriate for +% all combination types). +% +\def\@cite@try@combo{% + \@if@printable@char{\@cite@try@prefix}{\@cite@gobbledump@now}} + +% First token is good, so test for a character prefix before a number. +% Process first token, either a first digit or a prefix +% +\def\@cite@try@prefix#1{% #1 is first character of citation + \@cite@posnumtest{#1}% a digit else prefix + {\@cite@add@letnumD {\z@}#1}% no prefix character (use zero) + {\@cite@add@letnumC {`#1}}% prefix char; use the char code +} + +% Examine character after prefix to ensure it is a number. First must +% ensure it is a plain character token +% +\def\@cite@add@letnumC#1{\@if@printable@char% + {\@cite@add@letnumD{#1}}% continue with prefix (perhaps zero) + {\@cite@gobbledump@now}% else abandon fancy processing and output citation +} + +% Save prefix (if any) numerically in \@tempcnta, test next character for being +% a digit, then collect main number +% +\def\@cite@add@letnumD#1#2{% #1 = numeric code for prefix, #2 = next char + \@tempcnta=#1\multiply\@tempcnta 16384 % + \@cite@posnumtest{#2}% if next char is a digit, continue with number: + {\afterassignment\@cite@add@letnumE \advance\@tempcnta #2}% + {\@cite@gobbledump@now}% No number so just output citation +} + +% Have collected number. Now look for a non-number suffix or separator. +% +\gdef\@cite@add@letnumE{% + \multiply\@tempcnta\@cclvi + \@if@printable@char{% a suffix or separator given + \@cite@add@letnumF + }{% else, maybe nothing remains + \ifx\@let@token\delimiter % use number, and remove trailing \delimiter + \@citeaddcnta \expandafter\@gobble + \else % non-printable char found, so abandon fancy processing + \expandafter\@cite@gobbledump@now + \fi + }} + +% Have everything up to a suffix or separator character. Check +% following to see which. Three possibilites are (1) nothing => +% a suffix; (2) number => separator-number; (3) other => garbage. +% +\def\@cite@add@letnumF#1#2\delimiter{% #1 = suffix/separator #2=rest + \advance\@tempcnta`#1\relax + \@cite@posnumtest{#2}{\@cite@add@numsepnum{#2}}% handle as num sep num + {% else... + \ifx\delimiter#2\delimiter % nothing left, so #1 is a suffix + \@citeaddcnta + \else % some non-number; dump it + \@cite@dump@now + \fi +}} + +% Handle citation as number separator number. +% Yes, there is a bug that the list 1.1,1.258,1.515 will be compressed as +% 1.1-1.515; so sue me. + +\def\@cite@add@numsepnum#1{% #1 = last number + \ifnum\@tempcnta<262144 % OK numeric range + \multiply\@tempcnta 4096 + \advance\@tempcnta #1 % num,sep,num have maximum numbers: 1023, 255, 4095 + \@citeaddcnta + \else % out of range, treat as raw string + \@cite@dump@now + \fi} + +% This is our bail-out when the citation cannot be processed as +% [prefix]number[suffix] or number[sep]number: it outputs the citation +% immediately (unsorted) and consumes tokens to the \delimiter tag used +% as an end-marker +% +\def\@cite@gobbledump@now#1\delimiter{\@cite@dump@now}% + +\def\@cite@dump@now{% + \@citea \@cite@out{b@\@citeb\@extra@b@citeb}\let\@citea\citepunct} + +% add an entry to the sorted list, using its sort-number \@tempcnta, and +% also saving the plain-text value \@B@citeB as well as the csname +% b@\@citeb\@extra@b@citeb. (The \@B@citeB is actually not used, unless +% somebody extends the definitions.) +\def\@citeaddcnta{% + \ifnum \@tempcnta>\@tempcntb % new highest, add to end (efficiently) + \edef\@cite@list{\@cite@list + \@celt{\number\@tempcnta}{\@B@citeB}{b@\@citeb\@extra@b@citeb}}% + \@tempcntb\@tempcnta + \else % other sortable value: insert appropriately + \edef\@cite@list{\expandafter\@sort@celt\@cite@list \@gobble.\@gobble.}% + \fi + } + +% add pure numeric entry to cite list, with sorting +\def\@addnumto@cite@list#1{% + \@tempcnta#1\relax + \multiply\@tempcnta\@cclvi + \@citeaddcnta} + +% \@sort@celt inserts number (\@tempcnta) into list of \@celt{num}{text}{tag} +% (#1{#2}{#3}{#4}) +% \@celt must not be expandable, and the arguments must not be fragile. +% List should end with four vanishing tokens. +% +\def\@sort@celt#1#2#3#4{\ifx \@celt #1% parameters are \@celt{num}{text}{tag} + \ifnum #2<\@tempcnta % number goes later in list + \@celt{#2}{#3}{#4}% + \expandafter\expandafter\expandafter\@sort@celt % continue + \else % number goes here + \@celt{\number\@tempcnta}{\@B@citeB}{b@\@citeb\@extra@b@citeb}% + \@celt{#2}{#3}{#4}% stop comparing +\fi\fi} + +% Check if each number follows previous and can be put in a range. +% Since there are suffix characters allowed, there are two kinds of +% ranges: ranges of consecutive pure numbers with no (or same) +% suffix, or ranges of the same number with consecutive suffix +% characters. +% +\def\@compress@cite#1#2#3{%% This is executed for each number + \ifnum\@cite@incr=\z@ % no consecutives pending. Try both types of sequence + \advance\@tempcnta\@cclvi % Now \@tempcnta has incremented number + \ifnum #1=\@tempcnta % Start a sequence of consecutive numbers + \expandafter\def\expandafter\@h@ld\expandafter{\@citea\@cite@out{#3}}% + \mathchardef\@cite@incr=\@cclvi + \else % next try increment of suffix + \advance\@tempcnta-\@cclv % Now \@tempcnta has incremented suffix + \ifnum #1=\@tempcnta % Start a sequence of suffix increments + \expandafter\def\expandafter\@h@ld\expandafter{\@citea\@cite@out{#3}}% + \mathchardef\@cite@incr=\@ne + \else % it is no type of sequence -- emit number (nothing is held) + \@citea \@cite@out{#3}% + \fi + \fi + \else % a sequence is running + \advance\@tempcnta\@cite@incr % Now \@tempcnta is next in sequence + \ifnum #1=\@tempcnta % Number follows previous--hold on to it + \def\@h@ld{\citedash \@cite@out{#3}}% + \else % non-successor -- dump what's held and do this one + \@h@ld \@citea \@cite@out{#3}% + \let\@h@ld\@empty + \mathchardef\@cite@incr=\z@ + \fi + \fi + \@tempcnta#1\let\@citea\citepunct +} + +% Ordinary on-line \cite command + +\DeclareRobustCommand{\cite}{% + \@ifnextchar[{\@tempswatrue\@citex}{\@tempswafalse\@citex[]}} + +% Do \cite command on line. +% +\def\@citex[#1]#2{\@cite{\@cite@n{#2}}{#1}} + +\def\@cite#1#2{\leavevmode \cite@adjust + \citeleft{#1\if@tempswa\@safe@activesfalse\citemid{#2}\fi + \spacefactor\@m % punctuation in note doesn't affect outside + }\citeright + \@restore@auxhandle} + +% Put a penalty before the citation, and adjust the spacing: if no space +% already or if there is extra space due to some punctuation, then change +% to one inter-word space. +% +\def\cite@adjust{\begingroup% + \@tempskipa\lastskip \edef\@tempa{\the\@tempskipa}\unskip + \ifnum\lastpenalty=\z@ \penalty\citeprepenalty \fi + \ifx\@tempa\@zero@skip \spacefactor1001 \fi % if no space before, set flag + \ifnum\spacefactor>\@m \ \else \hskip\@tempskipa \fi + \endgroup} + +\edef\@zero@skip{\the\z@skip} + +% \nocite: This is changed to ignore *ALL* spaces and be robust. The +% parameter list, with spaces removed, is `returned' in \@no@sparg, which +% is used by \@cite@n (\citen). +% +\DeclareRobustCommand\nocite[1]{% + \@bsphack \@nocite{#1}% + \@for \@citeb:=\@no@sparg\do{\@ifundefined{b@\@citeb\@extra@b@citeb}% + {\G@refundefinedtrue\@warning{Citation `\@citeb' undefined}% + %%\oc@verbo \global\@namedef{b@\@citeb\@extra@b@citeb}{?} + }{}}% + \@esphack} + +\def\@nocite#1{\begingroup\let\protect\string% normalize active chars + \xdef\@no@sparg{\expandafter\@cite@ignsp#1,\: ,\:}% remove spaces + \if@filesw \immediate\write\@newciteauxhandle % =\@auxout, except with multibib + {\string\citation {\@no@sparg}}\fi + \endgroup} + +% remove spaces before and after commas. One level of braces is also +% stripped, so an item {a,b} is changed to two a and b. +% +\def\@cite@ignsp#1 ,#2{\ifx\:#2\@empty + \expandafter\@cite@ignsp@\romannumeral-`\:\else + \expandafter\@cite@ignsp \fi #1,#2} +\def\@cite@ignsp@#1,#2{#1\ifx\:#2\@empty\expandafter\@gobblethree + \else,\expandafter\@cite@ignsp@\fi #2} + +\long\def\@gobblethree #1#2#3{} + +% \@if@fillglue{glue}{true}{false} +\begingroup + \catcode`F=12 \catcode`I=12\catcode`L=12 + \lowercase{\endgroup + \def\@if@fillglue#1{% + \begingroup \skip@#1\relax + \expandafter\endgroup\expandafter + \@is@fil@ \the\skip@ \relax\@firstoftwo FIL\relax\@secondoftwo\@nil} + \def\@is@fil@ #1FIL#2\relax#3#4\@nil{#3} +} + +% Test if next token is a char of "printable" categories other or letter or +% active. Syntax: +% \@if@printable@char {do if printable}{do if not printable}<char> +% +\def\@if@printable@char#1#2{% + \def\reserved@a{#1}% + \def\reserved@b{#2}% + \futurelet\@let@token\@test@print@char +} + +% Note side-effect of redefining \reserved@a and \reserved@b +\def\@test@print@char{% + \ifnum + \ifcat\noexpand\@let@token A1\fi + \ifcat\noexpand\@let@token 11\fi + \ifcat\noexpand\@let@token \noexpand~1\fi% + 0>\z@ + \expandafter\reserved@a \else + \expandafter\reserved@b \fi +} + +% Test for a pure positive number: {possible number}{true}{false} +\def\@cite@posnumtest#1{% + \ifcat _\ifnum\z@<0#1_\else A\fi + \expandafter\@firstoftwo \else \expandafter\@secondoftwo \fi +} + +\let\nocitecount\relax % in case \nocitecount was used for drftcite + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% option processing +\def\oc@movep{YY}% default Yes move +% +\DeclareOption{verbose}{}% Unused now. Was \def\oc@verbo#1#2#3#4{} +\DeclareOption{nospace}{\def\citepunct{,\penalty\citepunctpenalty}} +\DeclareOption{space}{\def\citepunct{,\penalty\citepunctpenalty\ }} +\DeclareOption{nobreak}{% no line-breaks + \mathchardef\citeprepenalty=\@M + \mathchardef\citemidpenalty=\@M + \mathchardef\citepunctpenalty=\@M +} +\DeclareOption{ref}{\def\citeleft{[Ref.\penalty\@M\ }} +% To disable sorting [nosort], the redefinition depends on whether [nocompress] +% was also selected, so just set a flag first. +\DeclareOption{nosort}{\let\@citeaddcnta\@empty} +\DeclareOption{sort}{}% default! +% Likewise set flag for [nocompress] +\DeclareOption{nocompress}{\let\@compress@cite\@empty} +\DeclareOption{compress}{}% default +\DeclareOption{nomove}{\def\oc@movep{no}}% Flag for later definition +\DeclareOption{move}{\def\oc@movep{YY}}% default +\DeclareOption{super}{\ExecuteOptions{superscript}} +\DeclareOption{superscript}{\let\@citess\cite}% Just a flag redefined below +\DeclareOption{noadjust}{\let\cite@adjust\@empty}% Don't change spaces +\DeclareOption{adjust}{}% adjust space before [ ] +\DeclareOption{biblabel}{\let\@biblabel\def}% see below +\ProvidesPackage{cite}[2015/02/27 \space v 5.5] +\ProcessOptions + +\ifx\@biblabel\def % [biblabel] option + \ifx\@citess\cite % [superscript] option + \def\@biblabel#1{\@citess{#1}\kern-\labelsep\,} + \else % normal + \def\@biblabel#1{\citeleft{#1}\citeright} + \fi +\fi + +% Process [superscript] option, and [nomove]. + +\ifx\@citess\cite + +% Superscript cite, \cite chooses superscript or on-line-with-note +% +\DeclareRobustCommand{\cite}{% + \@ifnextchar[{\@tempswatrue\@citex}{\@tempswafalse\@citew}} + +% Superscript cite, with no optional note. Check for punctuation first. +\def\@citew#1{\begingroup \leavevmode + \@if@fillglue \lastskip \relax \unskip + \def\@tempa{\@tempcnta\spacefactor + \/% this allows the last word to be hyphenated, and it looks better. + \@citess{\@cite@n{#1}}\spacefactor\@tempcnta + \endgroup \@restore@auxhandle}% + \oc@movep\relax}% check for following punctuation (depending on options) + +% \@citess defines the formatting with superscripts and no brackets. +% HOWEVER, trailing punctuation has already been moved over. The +% format for cites with note is given by \@cite. Redefine \@cite and/ +% or \@citex to get different appearance. I don't use \textsuperscript +% because it is defined BADLY in compatibility mode. + +\def\@citess#1{\mbox{$\m@th^{\hbox{\OverciteFont{#1}}}$}} + +\if \oc@movep % Move citation past trailing punctuation; [move] is default + +\def\oc@movep#1{\futurelet\@tempb\@citey} +% +\def\@citey{\let\@tempc\@tempa + % Watch for double periods and suppress them + \ifx\@tempb.\ifnum\spacefactor<\sfcode`.\else + \@citeundouble + \fi\fi + % Move other punctuation + \expandafter\@citepc\CiteMoveChars\delimiter + \@tempc}% + +% This is in a separate macro in case the next "character" (token) +% is \if or \fi, etc. +\def\@citeundouble{% Suppress doubling of periods + \let\@tempb\relax \let\@tempc\oc@movep +} + +\def\@citepc#1{% + \ifx\@tempb#1\@empty #1\let\@tempc\oc@movep \fi + \ifx\delimiter#1\else \expandafter\@citepc\fi} + +% Set detectable sfcodes when \frenchspacing +\mathchardef\cite@mi1001 % +\g@addto@macro\frenchspacing + {\sfcode`\.\cite@mi \sfcode`\?\cite@mi \sfcode`\!\cite@mi }% +\AtBeginDocument {% + \ifnum\sfcode`\.<1002 \frenchspacing \let\normalsfcodes\frenchspacing \fi +}% performed after \normalsfcodes defined + +\else % [nomove] option: + + \def\oc@movep{\@tempa} + \let\@citey\relax + +\fi % end of move/nomove options +% +\fi % end [superscript] option processing +% +% make redefinitions to handle [nosort] [nocompress] and their combination +\ifx\@compress@cite\@empty + \ifx\@citeaddcnta\@empty + % [nosort,nocompress] -- short-circuit much processing + \def\@addto@cite@list{\@cite@dump@now} + \else + % [sort,nocompress] + \def\@compress@cite#1#2#3{% % This is executed for each number + \@h@ld \@citea \@cite@out{#3}% + \let\@h@ld\@empty \let\@citea\citepunct + } + \fi +\else % + \ifx\@citeaddcnta\@empty % [nosort,compress] + % nosort: always add to end of list, but still calculate + % sort-order number (\@tempcnta) because it may be used for + % collapsing consecutive numbers. + \def\@citeaddcnta{% + \edef\@cite@list{\@cite@list + \@celt{\number\@tempcnta}{\@B@citeB}{b@\@citeb\@extra@b@citeb}}% + } + \fi +\fi + +% Compatability with chapterbib (see use of \@extra@b@citeb above and in chapterbib) +\@ifundefined{@extra@b@citeb}{\def\@extra@b@citeb{}}{} + +% Compatability with multibib (see use of \@newciteauxhandle) (Yes, this is +% overly messy, but I asked for it... I can't have multibib putting junk after +% the cite command because it hides following punctuation, but then I have +% to restore the ordinary meaning of \@newciteauxhandle = \@auxout.) +\providecommand\@newciteauxhandle{\@auxout} +\AtBeginDocument{\@ifundefined{newcites}{\global\let\@restore@auxhandle\relax}{}} +\def\@restore@auxhandle{\def\@newciteauxhandle{\@auxout}} + +% compatability with backref: prevent it from redefining \@citex +% in the wrong way (ignoring \@citew and \citen. I install hook in +% \@nocite so it applies to \cite, \citen, and \nocite. +% +\AtBeginDocument{\@ifundefined{Hy@backout}{}{% + \@ifundefined{BRorg@citex}{}{\global\let\@citex\BRorg@citex}% + \global\let\BR@citex\@citex + \global\let\@citeorg@nocite\@nocite % use my own hook -> into \@nocite + \gdef\@nocite#1{\@citeorg@nocite{#1}\Hy@backout{#1}}% +}} + +% compatability with babel: Prevent it from redefining \@citex +\@ifundefined{@safe@activesfalse}{\let\@safe@activesfalse\relax}{} +\@ifundefined{bbl@cite@choice}{}{\@ifundefined{org@@citex}{}% + {\let\org@@citex\@citex}}% Prevent stomping by babel + +\citenum % execute restore-catcodes + +% Aliases: +\def\citenum{\citen} +\def\citeonline{\citen} + +\endinput +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + + CITE.STY + +Modify LaTeX's normal citation mechanism for improved handling of numeric +citations, behaving as follows: + +o Put a comma and a small space between each citation number, allowing + line breaks with penalty. + +o Compress lists of three or more consecutive numbers, or similar, to a + range which can be split, with difficulty, after the dash. + +o Sort citations into ascending order. + +o Sortable and compressible citations are numeric like [5-8]; or numbers + with prefix and/or suffix characters like [18a-18c,19] or [A2,Q1,Q3-Q5]; + or two numbers with separator like [1.9-1.12,2.2]. + +o Allow, but discourage, line breaks within the group of citations (after + dashes, and after punctuation). + +o Adjust spacing before citation. + +o All breaks can be forbidden with the [nobreak] package option. + +o With package option [superscript] (or [super] for short), display citations + as superscripts (unless they have optional notes, causing them to be printed + on-line with brackets). Superscripted citations use THE SAME INPUT FORMAT + as ordinary citations; this style will ignore spaces before the \cite command + and move trailing punctuation before the superscript citation. Doubling of + periods (.., ?., !.) is checked for and suppressed. + +o Define \citen to get just the numbers without the brackets or superscript + and extra formatting. Aliases are \citenum and \citeonline. + +There are several package options for \usepackage{cite}. + + [superscript] use superscrpts for cites without optional notes + [super] alias for [superscript] (like natbib) + [nospace] eliminates the spaces after commas in the number list + [space] uses a full inter-word space after the commas + [nobreak] eliminate all line-breaks + [nosort] prevents sorting of the numbers (default is to sort, and the... + [sort] option is provided for completeness). + [nomove] prevents moving the superscript cite after punctuation. + [move] is the default + [noadjust] disables `smart' handling of space before a cite + [adjust] is the default + [nocompress] inhibit compression of consecutive numbers into ranges + [compress] is the default + [ref] uses the format "[Ref.~12, given note]" (useful with [super]) + [biblabel] define the bibliography label to match \cite + +If your citations are not numeric, then you should probably not use +cite.sty, but if you must, then at least use the [nosort,nocompress] +options. + +See more detailed instructions in cite.pdf (cite.ltx). + + +% Version 1991: Ignore spaces after commas in the parameter list. Move most of +% \citen into \@cmpresscites for speed. Give the proper \spacefactor afterwards. +% Version 1992: make \citepunct hold the punctuation between numbers (for ease +% of changing). Add \/ to allow hyphenation of previous word, and look better +% in italics. +% 1992a: Make it work with NFSS. (Thank you C. Hamlin and Rainer Schoepf) +% +% Version 3.0 (1992): Rewrite, including sorting. Make entries like "4th" +% be treated properly as text. +% 3.1: Bug fixes (and Joerg-Martin Schwarz also convinced me to use \ifcat) +% 3.2: NFSS support was wrong--added \reset@font. Suppress repetitions of +% warnings. Include \@extra@b@citeb hook. +% 3.3: Handle LaTeX2e options. Introduce various customization hooks. +% 3.4: Heuristics to avoid removing \hspace glue before on-line \cite. +% Make \nocite ignore spaces in list, simplify. Aliases for \citen. +% Compatability with amsmath (which defines \over). +% 3.5: Replace \reset@font with \selectfont so italics are preserved +% Include \G@refundefinedtrue. Fix cite-with-note bug (Lars Engebretsen). +% 3.6: Add nosort option. +% 3.7: Add nomove option; catcode preservation and global \@no@sparg for +% french.sty; warnings in \nocite. +% 3.8: \citedash hook, fix token look-ahead (Heiko Selber), noadjust, babel. +% 3.9: More babel-compatibility hacks. Punctuation move with \frencspacing. +% 4.0: Combine overcite with cite: [superscript] option. Also add [nocompress] +% option and \CiteMoveChars; multibib hooks. +% 4.01 \bf -> \bfseries +% 4.02 Bury undouble action in a separate macro to avoid extra \fi error. +% 5.0 Hyperref and backref compatability! Penalty parameters and [nobreak]. +% Letter prefix and suffix sorting! Stop suppressing multiple warnings. +% 5.1 Fix a missing "b@" (disappearing named cites), fix nosort +% 5.2 More robust treatment of non-numbers +% 5.3 Handle sort/compress of compound citation numbers (number by chapter) +% such as 3.18 or 5-3. Note that these compounds cannot have prefix or +% suffix letters (not enough bits in the maximum TeX number). +% 5.4 Only ignore spaces at begin and end of tag (LaTeX ignores at begin) +% 5.5 Improve handling of \frenchspacing. Option rearrangements. +% +% TODO: other sorting, like dictionary or roman numeral +% TODO: create special "final punct" that could be ", and " and likewise +% a "single punct" that could be " and " +% +% Send problem reports to asnd@triumf.ca + +Test file integrity: ASCII 32-57, 58-126: !"#$%&'()*+,-./0123456789 +:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ diff --git a/macros/latex/contrib/cite/drftcite.sty b/macros/latex/contrib/cite/drftcite.sty new file mode 100644 index 0000000000..21b557efbd --- /dev/null +++ b/macros/latex/contrib/cite/drftcite.sty @@ -0,0 +1,264 @@ +% D R F T C I T E . S T Y +% +% version 3.5 (Jan 1995) +% +% Print the tags instead of the numbers for \cite. +% See also CITE.STY and OVERCITE.STY. +% +% Copyright (C) 1989,1991-1995 by Donald Arseneau +% These macros may be freely transmitted, reproduced, or modified +% provided that this notice is left intact. +% +% Instructions are below, after \endinput. +% ........................ +% +% Handle formatting hooks: +% \citeform,\citeleft,\citeright,\citemid,\citepunct +% +% Set defaults: + +% [ on the left. +\@ifundefined{citeleft}{\let\citeleft=[}{} + +% ] on the right: +\@ifundefined{citeright}{\let\citeright=]}{} + +% , (comma space) before note +\@ifundefined{citemid}{\def\citemid{,\penalty\@lowpenalty\ }}{} + +% , (comma space) between entries +\@ifundefined{citepunct}{ +% Default: To put space after the comma. [nospace] eliminates the space + \def\citepunct{,\penalty\@lowpenalty\ }% + }{} + +% Each citation tag left as-is: +\@ifundefined{citeform}{\def\citeform{}}{} + +% Do not repeat warnings. [verbose] reverses +\let\oc@verbo\relax + +% \citen gives the citation tag in the text and writes the aux file entry. +% Use \citen to give citation name without the other formatting; e.g., +% "See also ref.~\citen{junk}" gives "See also ref. junk". +% +\edef\citen{\noexpand\protect \expandafter\noexpand\csname citen \endcsname} + +\@namedef{citen }#1{% +\edef\@tempa{\@ignspaftercomma,#1, \@end, }% ignore spaces in parameter list. +\edef\@tempa{\expandafter\@ignendcommas\@tempa\@end}% +\if@filesw \immediate\write \@auxout {\string\citation {\@tempa}}\fi +\def\@citea{}% +\@for \@citeb:=\@tempa\do {\@citea + \@ifundefined {b@\@citeb\@extra@b@citeb}% + {{\bf \@citeverb{\@citeb}?}%% issue warning only for first mis-use: + \@dftc@ifund {DCN@\@citeb\@extra@b@citeb}{% delete to warn always + \@warning {Citation `\@citeb' on page \thepage\space undefined}% + }{}% delete to warn always + }% else, defined + {\@dftc@hbox{\@citeverb{\@citeb}}}% + \let\@citea\citepunct\@advancecitecount + }} + +% for ignoring spaces in the input: +\def\@ignspaftercomma#1, {\ifx\@end#1\@empty\else + #1,\expandafter\@ignspaftercomma\fi} +\def\@ignendcommas,#1,\@end{#1} + +% Make \cite robust. +% +\edef\cite{\noexpand\protect\expandafter\noexpand\csname cite \endcsname} + +\@namedef{cite }{\@ifnextchar [{\@tempswatrue\@citex}{\@tempswafalse\@citex[]}} + +% Make \@citex refer to \citen: +% (Put a single space before the output) +% +\def\@citex[#1]#2{\@cite{\citen{#2}}{#1}}% + +% Replacement for \@cite which defines the formatting normally done +% around the citation list. Adjust the spacing before the citation: +% if no space or if there is extra space due to some punctuation, then +% change to one inter-word space. The way to change this is by changing +% \citeleft, \citemid, and \citeright; but in extreme cases it might be +% necessary to redefine the whole macro. +% +\def\@cite#1#2{\leavevmode + \@tempskipa\lastskip \edef\@tempa{\the\@tempskipa}\unskip + \ifx\@tempa\@zero@skip \spacefactor1001 \fi % if no space before, set flag + \ifnum\spacefactor>\@m \ \else \hskip\@tempskipa \fi + \citeleft{#1\if@tempswa \citemid #2\fi}\citeright + \spacefactor\@m % punctuation in note doesn't affect outside +} +\edef\@zero@skip{\the\z@skip} +% +% Give the citation tag as the label (even if another label is specified) +% +\def\@lbibitem[#1]#2{\global\@HighCite\z@ + \item[\@biblabel{\@ifundefined{DCN@#2\@extra@b@citeb}{\@warning + {Reference `#2' on page \thepage\space was never cited}}{}% + \DC@llap{$^{\@nameuse{DCN@#2\@extra@b@citeb}}$\ \ }%%o + \@citeverb{#2}}\hfil]\if@filesw{\def\protect##1{\string ##1\space}% + \immediate\write\@auxout{\string\bibcite{#2}{#1}}}\fi\ignorespaces} + +\def\@bibitem#1{\refstepcounter{\@listctr}\@lbibitem[\the\value{\@listctr}]{#1}} + +% make the special characters in the citation tag printable +% +\def\@citeverb#1{% + {\citeform{% to get characters <>_|{}: \citeform->\tt + \expandafter \expandafter \expandafter \@gobblethree % do \csname, \string, + \expandafter \string\csname b@#1\endcsname}% % \@gobble, in that order. +}}% + +\def\@gobblethree#1#2#3{} + +% \@extra@b@citeb is a hook for other style files to further specify +% citations; for example, to number by chapter. +% In case no fancy bib package (chapterbib) defines it: + +\@ifundefined{@extra@b@citeb}{\def\@extra@b@citeb{}}{} + +%------------------------------------ +% Handle optional variations: + +\def\nocitecount{% + \def\@advancecitecount{\global\@namedef{DCN@\@citeb\@extra@b@citeb}{}}% + \let\DC@llap\@gobble} +\nocitecount % in case what follows gets removed + +\newcount\@HighCite \global\@HighCite\z@ +\let\@dftc@ifund\@ifundefined +\let\@dftc@hbox\hbox + +\@ifundefined{DeclareOption}{}% +{ \DeclareOption{nocitecount}{\endinput} + \toks@={\def\@dftc@ifund#1#2#3{#2}} + \DeclareOption{verbose}{\the\toks@} + \DeclareOption{tt}{\def\citeform{\tt}} + \DeclareOption{nospace}{\def\citepunct{,\penalty\z@}} + \DeclareOption{space}{\def\citepunct{,\ }} + \DeclareOption{breakcites}{\let\@dftc@hbox\relax} + \ProvidesPackage{drftcite}[1995/01/23 \space v 3.5] + \ProcessOptions } + +% The rest deals only with counting, and can be removed if counting is never +% desired. + +\let\DC@llap=\llap +% +% count the citations as they appear in the text +% +\def\@advancecitecount{\@ifundefined {DCN@\@citeb\@extra@b@citeb}% +{\global\advance\@HighCite\@ne +\expandafter\xdef\csname DCN@\@citeb\@extra@b@citeb\endcsname{\the\@HighCite}}% +{}} +% +% The remainder handles (counting over) input files skipped by \includeonly. +% It adds code to LaTeX's \include to re-read the .aux file checking the +% \citation commands. +% +% For included files that are skipped (not listed by \includeonly) +% input the .aux file ignoring all commands but \citation, which +% does \@advancecitecount (keeps count of the citations). This adds +% a requirement for other style files that add commands to the .aux +% file: the commands must be safe to execute an extra time. +% +\let\@dftc@include\include +\def\include#1{\relax + \ifx\DC@llap\llap \begingroup % do counting only if wanted + \@ifundefined{cp@#1}{}% don't do if .aux file not there! + {\toks@\expandafter\expandafter\expandafter{\csname cp@#1\endcsname}% + \expandafter\xdef\csname cp@#1\endcsname{\the\toks@ + \noexpand\@dftc@auxcite{#1}}}% + \endgroup\fi \@dftc@include{#1}} +% +\def\@dftc@auxcite#1{\begingroup % disable everything but \citation + \let\bibcite\@gobbletwo \let\newlabel\@gobbletwo \let\@writefile\@gobbletwo + \let\bibdata\@gobble \let\bibstyle\@gobble % already \@gobble normally + \def\citation##1{\@for\@citeb:=##1\do {\@advancecitecount}}% + \makeatletter\@input{#1.aux}\endgroup +} +\endinput + + +% D R F T C I T E . S T Y +% +% version 3.5 (Jan 1995) +% +% This package makes LaTeX use the identifying label instead of the number +% for citations, as if the bibliography had entries like \bibitem[name]{name} +% but LaTeX writes the proper citation number to the aux file for later runs. +% Spaces before the \cite command are ignored, and an ordinary interword +% space is used. This package is particularly useful for draft (draught) +% versions of documents. +% +% The \citen command is provided, as in cite.sty, to print just the citation +% or list of citations without the brackets and other formatting. +% +% Drftcite keeps track of which references were cited, and issues warnings +% for bibliography items that were never cited in the text. +% +% This package also keeps track of the order of first-citations in the text +% for easy sorting (in lieu of BibTeX). To omit this counting... +% LaTeX 2.09: declare \nocitecount before the first \cite; or, for +% a more permanent removal, comment-out the lines ending with %%o +% below, and omit everything following the line that begins with %%o. +% LaTeX2e: specify \usepackage[nocitecount]{drftcite}, or perform the +% editing described above. +% +% The characters <>|_{}\ are not present in the cm roman fonts, so if you use +% them in identifiers, they will have to be typeset in typewriter style. +% To do this,... +% LaTeX 2.09: insert \renewcommand\citeform{\tt} in your preamble +% LaTeX2e: specify \usepackage[tt]{drftcite} +% +% `Citation...undefined' warnings are only given once per undefined +% citation name. In the text, missing numbers are represented with a +% bold `name?'. To restore multiple warnings... +% LaTex 2.09: edit this file, removing the lines with the comments: +% "delete to warn always" +% LaTeX2e: specify \usepackage[verbose]{drftcite} +% +% Other options for \usepackage are: +% [space] - Separate printed names with comma-space (Default). +% [nospace] - Print just a comma (not comma-space) after each name. +% [breakcites] - Allow each printed name to be broken (hyphenated). +% +% There are several commands that you may redefine (using \renewcommand) +% to change the formatting of citation lists: +% +% command function default +% ---------- ----------------------- ---------------------------- +% \citeform reformats every entry nothing +% \citepunct printed between numbers comma + space +% \citeleft left delimiter of list [ +% \citeright right delimeter of list ] +% \citemid printed before note comma + space +% +% This version of drftcite can co-exist with chapterbib.sty (version 1.4 +% or later). +% +% [This file is named "drftcite" because "draftcite" is too long a name for +% some computers. Sorry to those who use the spelling "draught." I could +% have abbreviated the name by selecting the shared letters in "draft" and +% "draught," but "dratcite" somehow conveys the wrong meaning.] +% +% Version 1991: Ignore spaces after commas in the parameter list. Create +% \nocitecount to turn off counting the order of citations. +% Version 3.1 (1992): protect \cite and \citen. (There is no version 3.0) +% Version 3.2 (1993): Supress repetitions of warning messages. Include +% \@extra@b@citeb hook for chapterbib.sty. Make \include handle case that +% \cp@FOO was not defined. +% Version 3.3 (1993): Fix \nocitecount. Change printing of undefined refs. +% Version 3.4 (1994): LaTex2e support, including spaces in protected command +% names; better chapterbib support. +% Version 3.5 (1995): Add tests before removing space + options from cite.sty. +% change \@citeverb to not eat hash space. +% +% Send problem reports to asnd@Reg.triumf.ca +% +% Test integrity of file: +% brackets: round, square, curly, angle: () [] {} <> +% backslash, slash, vertical, at, dollar, and: \ / | @ $ & +% hat, grave, acute (apostrophe), quote, tilde, under: ^ ` ' " ~ _ diff --git a/macros/latex/contrib/cite/overcite.sty b/macros/latex/contrib/cite/overcite.sty new file mode 100644 index 0000000000..ccec9ccdde --- /dev/null +++ b/macros/latex/contrib/cite/overcite.sty @@ -0,0 +1,21 @@ +% O V E R C I T E . S T Y +% +% version 4.0 (May 2003) +% +% Compressed, sorted lists of superscript numerical citations. +% +% Copyright (C) 2003 by Donald Arseneau +% These macros may be freely transmitted, reproduced, or modified +% provided that this notice is left intact. +% +% This package is provided for compatibility with the original +% overcite.sty. All it does is invoke cite.sty with the option +% [superscript]. +% +% It would be a shame to lose this pun. +% +% ------------------------------------ + \ProvidesPackage{overcite}[2003/05/27 \space v 4.0] + \DeclareOption*{\PassOptionsToPackage{\CurrentOption}{cite}} + \ProcessOptions + \RequirePackage[superscript]{cite} |