From 6d406252a4add5f456a627298ffdbed4d682adec Mon Sep 17 00:00:00 2001 From: Manuel Pégourié-Gonnard Date: Tue, 9 Sep 2008 20:20:25 +0000 Subject: notes2bib v1.5 2008/09/08 git-svn-id: svn://tug.org/texlive/trunk@10526 c570f23f-e606-0410-a88d-b1316a301751 --- .../source/latex/notes2bib/notes2bib.dtx | 26 +- .../source/latex/notes2bib/xnotes2bib.dtx | 1159 ++++++++++++++++++++ .../source/latex/notes2bib/xnotes2bib.ins | 85 ++ 3 files changed, 1256 insertions(+), 14 deletions(-) create mode 100644 Master/texmf-dist/source/latex/notes2bib/xnotes2bib.dtx create mode 100644 Master/texmf-dist/source/latex/notes2bib/xnotes2bib.ins (limited to 'Master/texmf-dist/source/latex/notes2bib') diff --git a/Master/texmf-dist/source/latex/notes2bib/notes2bib.dtx b/Master/texmf-dist/source/latex/notes2bib/notes2bib.dtx index 6b7358304da..f57de5c6e80 100644 --- a/Master/texmf-dist/source/latex/notes2bib/notes2bib.dtx +++ b/Master/texmf-dist/source/latex/notes2bib/notes2bib.dtx @@ -15,13 +15,14 @@ % % The current maintainer of this work is Joseph Wright. % -% This work consists of the source file notes2bib.dtx -% and the derived files notes2bib.ins, -% notes2bib.sty, -% jawltxdoc.sty, -% notes2bib-manual.pdf, -% notes2bib.pdf and -% README +% This work consists of the file notes2bib.dtx +% xnotes2bib.dtx +% and the derived files notes2bib.pdf, +% notes2bib.sty, +% notes2bib.ins, +% xnotes2bib.pdf, +% xnotes2bib.sty and +% xnotes2bib.ins. % % TDS-ready files: % The compressed file notes2bib.tds.zip contains an unpacked @@ -135,7 +136,7 @@ unsorted bibliography styles are supported. \EnableCrossrefs \CodelineIndex \RecordChanges -%\OnlyDescription +\OnlyDescription \usepackage{jawltxdoc} \begin{document} \DocInput{\jobname.dtx} @@ -179,6 +180,8 @@ unsorted bibliography styles are supported. % and \opt{tail} implementation} %\changes{v1.4}{2008/06/21}{\eTeX\ made optional (again), with % control option to turn off use even if available} +%\changes{v1.5}{2008/09/08}{Bundle now includes experimental +% \LaTeX3 support} % %\DoNotIndex{\@auxout,\@empty,\@fileswfalse,\@for,\@ifnextchar} %\DoNotIndex{\@ifpackagelater,\@ifpackageloaded,\@ifundefined} @@ -553,20 +556,15 @@ unsorted bibliography styles are supported. %\section{The package code} % %\subsection{Package setup code} -%\begin{macro}{\niib@id} %\changes{v1.1}{2007/09/29}{Removed use of \pkg{xspace}} % The package starts with the usual identification code and support % loading. % \begin{macrocode} \NeedsTeXFormat{LaTeX2e} -\def\niib@id$#1: #2.#3 #4 #5-#6-#7 #8 #9${% - #5/#6/#7\space v1.4a\space} \ProvidesPackage{notes2bib} - [\niib@id$Id: notes2bib.dtx 13 2008-07-22 20:06:39Z joseph $ - Integrating notes into the bibliography] + [2008/09/08 v1.5 Integrating notes into the bibliography] \RequirePackage{xkeyval}[2005/05/07] % \end{macrocode} -%\end{macro} %\begin{macro}{\niib@tempa} %\begin{macro}{\niib@tempb} % Some private temporary macros are declared. diff --git a/Master/texmf-dist/source/latex/notes2bib/xnotes2bib.dtx b/Master/texmf-dist/source/latex/notes2bib/xnotes2bib.dtx new file mode 100644 index 00000000000..a4563bc76fc --- /dev/null +++ b/Master/texmf-dist/source/latex/notes2bib/xnotes2bib.dtx @@ -0,0 +1,1159 @@ +% \iffalse meta-comment +%<*internal> +\iffalse +% +%<*readme> +--------------------------------------------------------------- +The notes2bib bundle --- Integrating notes into the + bibliography +Maintained by Joseph Wright +E-mail: joseph.wright@morningstar2.co.uk +Released under the LaTeX Project Public License v1.3c or later +See http://www.latex-project.org/lppl.txt +--------------------------------------------------------------- + +The notes2bib package defines a new type of note, bibnote, +which will always be added to the bibliography. The package +allows footnotes and endnotes to be moved into the bibliography +in the same way. The package can be used with natbib and +biblatex as well as plain LaTeX citations. Both sorted and +unsorted bibliography styles are supported. + +The bundle includes both a current release version of the package +(notes2bib.sty) and an experimental re-implementation using +LaTeX3 syntax where possible (xnotes2bib.sty). +% +%<*internal> +\fi +\begingroup +% +%<*install> +\input docstrip.tex +\keepsilent +\askforoverwritefalse +\preamble +--------------------------------------------------------------- +The notes2bib bundle --- Integrating notes into the + bibliography +Maintained by Joseph Wright +E-mail: joseph.wright@morningstar2.co.uk +Released under the LaTeX Project Public License v1.3c or later +See http://www.latex-project.org/lppl.txt +--------------------------------------------------------------- + +\endpreamble +\postamble + +Copyright (C) 2007-2008 by + Joseph Wright + +It may be distributed and/or modified under the conditions of +the LaTeX Project Public License (LPPL), either version 1.3c of +this license or (at your option) any later version. The latest +version of this license is in the file: + + http://www.latex-project.org/lppl.txt + +This work is "maintained" (as per LPPL maintenance status) by + Joseph Wright. + +This work consists of the file notes2bib.dtx + xnotes2bib.dtx + and the derived files notes2bib.pdf, + notes2bib.sty, + notes2bib.ins, + xnotes2bib.pdf, + xnotes2bib.sty and + xnotes2bib.ins. + +\endpostamble +\usedir{tex/latex/notes2bib} +\generate{ + \file{\jobname.sty}{\from{\jobname.dtx}{package}} +} +% +%\endbatchfile +%<*internal> +\usedir{source/latex/notes2bib} +\generate{ + \file{\jobname.ins}{\from{\jobname.dtx}{install}} +} +\nopreamble\nopostamble +\usedir{doc/latex/notes2bib} +\generate{ + \file{README.txt}{\from{\jobname.dtx}{readme}} +} +\def\destdir{} +\generate{ + \file{jawl3doc.sty}{\from{\jobname.dtx}{jawl3doc}} +} +\endgroup +\immediate + \write18{makeindex -s gind.ist -o \jobname.ind \jobname.idx} +\immediate + \write18{makeindex -s gglo.ist -o \jobname.gls \jobname.glo} +% +%<*driver> +\documentclass{l3doc} +\EnableCrossrefs +\CodelineIndex +\RecordChanges +%\OnlyDescription +\usepackage{jawl3doc} +\begin{document} + \DocInput{\jobname.dtx} +\end{document} +% +% \fi +% +%\CheckSum{468} +% +%\GetFileInfo{\jobname.sty} +% +%\title{\texorpdfstring{\currpkg}{\jobname} --- +% Integrating notes into the bibliography^^A +% \thanks{This file describes version \fileversion, last +% revised \filedate.}} +%\author{Joseph Wright^^A +% \thanks{E-mail: joseph.wright@morningstar2.co.uk}} +%\date{Released \filedate} +% +%\maketitle +% +%\begin{abstract} +% The \currpkg\ package is an \emph{experimental} +% re-implementation of \pkg{notes2bib} using \LaTeX3 commands +% internally (taken from the \pkg{expl3} bundle). The user +% interface is almost identical to \pkg{notes2bib}. +% +% The \currpkg package defines a new type of note, +% \cs{bibnote}, which will always be added to the bibliography. +% The package allows footnotes and endnotes to be moved into +% the bibliography in the same way. The package can be used +% with \pkg{natbib} and \pkg{biblatex} as well as plain \LaTeX\ +% citations. Both sorted and unsorted bibliography styles are +% supported. +%\end{abstract} +% +%\begin{multicols}{2} +% \tableofcontents +%\end{multicols} +% +%\section{Introduction} +% The new code syntax introduced by \LaTeX3 is very different +% from plain \TeX\ or \LaTeXe. This means that converting +% packages to \LaTeX3 requires working from the ground up if +% the new ideas are to be exploited fully. This package +% re-implements \pkg{notes2bib} using the experimental syntax +% for internal commands. +% +% The internal logic of the package remains broadly similar to +% that in \pkg{notes2bib}. However, some opportunities to +% simplify the code or make the flow clearer have been taken. +% There is therefore no one-to-one correspondence between the +% internals of the two packages. In particular, this package +% does not guarantee backward-compatibility with +% \pkg{notes2bib} under all circumstances. \LaTeX3 will +% require significant changes to documents, and so alterations +% to the logic of packages in order to make them more useful in +% the long term seem sensible. +% +%\section{Using the package} +%\subsection{Macros} +%\DescribeMacro{\bibnote} +%\DescribeMacro{\bibnotemark} +%\DescribeMacro{\bibnotetext} +%\DescribeMacro{\flushnotestack} +% The user macros of \currpkg\ are intended to +% work in the same way as those in \pkg{notes2bib}. Please +% see \file{notes2bib.pdf} for details of: +%\begin{itemize} +% \item \cs{bibnote} +% \item \cs{bibnotemark} +% \item \cs{bibnotetext} +% \item \cs{flushnotestack} +%\end{itemize} +% The \cs{citenote} macro can be replaced by using +% \cs{bibnotemark} to cite the note for a second time. +% +%\subsection{Control values} +%\DescribeMacro{\niibsetup} +% The main user changes between \pkg{notes2bib} and +% \pkg{xnotes2bib} are in the user options. These have been +% completely re-written here, to improve the logic of the +% interface and to remove unnecessary options. All package +% control is currently carried out using the \cs{niibsetup} +% macro, as the \LaTeXe\ kernel expands options and removes +% spaces. As in \pkg{notes2bib}, the \cs{niibsetup} macro +% accepts a key--value list as input. +% +% There are four types of control key. Boolean keys take the +% values \opt{true} and \opt{false}. If the key name alone is +% given, this is the same as giving the \opt{true} value. +% String keys save their value as a string for internal use: +% they can therefore take any input. Choice keys take one of a +% range of pre-determined values, in a similar way to Boolean +% options. However, the list of possible values varies from +% key to key. Finally, macro keys require a macro as the value. +% +%\DescribeOption{convert~endnotes} +%\DescribeOption{convert~footnotes} +% To convert endnotes and footnotes into bibnotes, the options +% \opt{convert~endnotes} and \opt{convert~footnotes} are +% available. Both taken Boolean values, and are set to +% \opt{false} when loading \currpkg. If endnotes are not +% defined elsewhere, the \opt{convert~endnotes} only defines +% them when set to \opt{true}. +% +%\DescribeOption{placement} +% The package is able to position notes in three ways in the +% bibliography. The standard method is to create the notes +% interspersed with ``real'' citations. The order in the source +% then determines the position in the bibliography. The package +% can also create notes such that they appear either before or +% after normal citations. The behaviour here is controlled by +% the \opt{placement} option, which takes a choice from the +% list \opt{after}, \opt{before} and \opt{mixed}. The +% \opt{after} option places notes after normal citations, +% \opt{before} places notes first and \opt{mixed} mixes notes +% and citations based on the order in the source. +% +%\newcommand*{\field}[1]{\texttt{#1}} +%\DescribeOption{key~after} +%\DescribeOption{key~before} +%\DescribeOption{key~mixed} +% Most sorted bibliography styles provide methods for +% controlling the sort order of entries. With standard +% \BibTeX\ styles, the \field{key} field is used for this +% purpose. The options \opt{key~after}, \opt{key~before} and +% \opt{key~mixed} are used to set this up. They contain an +% item to be added before the note label when creating the +% \field{key} field. The standard values are \opt{aaa} for +% \opt{key~before} and \opt{zzz} for \opt{key~after}: +% \opt{key~mixed} is empty. +%\DescribeOption{presort~after} +%\DescribeOption{presort~before} +%\DescribeOption{presort~mixed} +% When using \pkg{biblatex}, \field{presort} field is +% available. The values used by \currpkg\ for this field are +% stored as \opt{presort~after}, \opt{presort~before} and +% \opt{presort~mixed}, with default values \opt{mn}, \opt{ml} +% and \opt{mm}, respectively. The \opt{presort} system is +% described in the \pkg{biblatex} manual. +% +%\DescribeOption{cite} +% As \currpkg\ uses \BibTeX\ to create notes, it uses a +% citation command to mark the notes in the body of the text. +% The command used is controlled by the macro key \opt{cite}. +% The standard value is \cs{cite}. +% +%\DescribeOption{field} +%\DescribeOption{notename} +%\DescribeOption{prefix} +%\DescribeOption{record} +% Four control values are available to affect low-level aspects +% of the creation of the notes database. The \opt{prefix} +% option sets the string used by \currpkg\ to name the +% database, and is set to \opt{niib-} initially. The +% \opt{field} and \opt{record} options contain the name of the +% field used for the note, and the \BibTeX\ record type used. +% The standard values are \opt{note} and \opt{Misc}, +% respectively. Finally, the \opt{notename} option sets the +% text used in addition to a number when automatically +% labelling notes. This is set to \opt{Bibnote}: there is no +% space between this text and the number as this will confuse +% \BibTeX. +% +%\DescribeOption{debug} +% The \opt{debug} Boolean option is available for understanding +% what the package is doing. When set to \opt{true}, the +% package writes additional information to the log to aid +% problem solving. +% +%\section{Testing the package} +% +% This release of \currpkg\ has several aims, all related to +% testing. Firstly, it provides a method to examine new ideas +% for \pkg{notes2bib}: feedback on the altered options is +% welcome. Second, it is a test-bed for using \pkg{expl3} to +% create packages. People familiar with the current \LaTeX3 +% ideas are encouraged to read the source and make suggestions. +% The new coding environment requires a more structured +% approach than \LaTeXe, and so it is possible ideas have been +% missed. +% +% In order to use \currpkg, you will need an up-to-date \TeX\ +% system and recent copies of \pkg{expl3} and \pkg{xparse}. The +% package is tested with the current SVN release of the \LaTeX3 +% packages, but these may change on a day-to-day basis. So +% testers should be prepared for problems such as undefined +% macros from the new kernel! The \eTeX\ extensions to \TeX\ +% are required by \currpkg. +% +% Due to the experimental nature of the package, it currently +% has no version number. The package date should be used to +% check if versions are identical. That said, the version of +% \pkg{notes2bib} will be stepped when new copies of \currpkg\ +% are created. +% +% While the package is experimental, it should work properly as +% a replacement for \pkg{notes2bib}, with the proviso that the +% options are very different. Any problems of function should +% be reported as normal. +% +%\section{Installation} +% +% The entire bundle is supplied with the TDS-ready \ext{zip} +% file \file{notes2bib.tds.zip}. Simply unzip this into your +% local texmf tree and run your hash program (\texttt{texhash} +% for \TeX{}Live or \texttt{initextmf -u} for MiK\TeX) +% +% To extract the package \file{xnotes2bib.sty} from +% \file{xnotes2bib.dtx}, run (pdf)\LaTeX\ on the later. This +% will also create the documentation and \file{README.txt} +% file. Three (pdf)\LaTeX\ runs with \cs{write18} enabled will +% also build the index and table of contents in the \ext{pdf}. +% +%\StopEventually{% +% \PrintChanges +% \PrintIndex} +% +%\iffalse +%<*package> +%\fi +% +%\section{The code} +%\subsection{Preliminaries} +% The package starts by loading the basics of \pkg{expl3}. To +% keep things clear, first \pkg{l3names} is loaded to do the +% basic identification, and then everything else is started up. +% This is based on Morten H{\o}gholm's \pkg{xfrac} package +% lead-off. +% \begin{macrocode} +\NeedsTeXFormat{LaTeX2e} +\begingroup + \@ifundefined{eTeXversion}{% + \PackageError{xnotes2bib} + {Not running under e-TeX} + {This package requires e-TeX: enable the extensions!}% + \endgroup\endinput + }{% + \endgroup + } +\RequirePackage{l3names} +\ProvidesExplPackage + {xnotes2bib}{2008/09/08}{0.0} + {Integrating notes into the bibliography (expl3 version)} +\RequirePackage{expl3,xparse} +% \end{macrocode} +% As the \pkg{expl3} syntax is in use, there is no need to +% worry about white space in the code. So there are very few +% |%| characters in the following. As far as possible, +% \pkg{expl3} or \pkg{xparse} macros are used here; however, a +% lot of the user-space \LaTeXe\ macros should still be valid +% in \LaTeX3. There are also a few |@| macros where things are +% tidied closely to the \LaTeXe\ kernel at present (for example +% \cs{@filesw}). +% +% As the \LaTeXe\ kernel expands package options, for the +% moment \currpkg\ does not accept any load-time options. +% \begin{macrocode} +\DeclareOption*{ + \PackageWarning{xnotes2bib}{ + All~package~control~should~be~given~using~the\MessageBreak + \token_to_string:N\niibsetup\space macro + } +} +\ProcessOptions\scan_stop: +% \end{macrocode} +% +%\begin{macro}{\g_niib_note_int} +% A counter for the automatically-created notes is needed. This +% is a global value (life will get very complicated if not). +% \begin{macrocode} +\int_new:N \g_niib_note_int +% \end{macrocode} +%\end{macro} +%\begin{macro}{\niib_thenote:} +% The counter needs to be expressed as a usable name. A check +% is made so that if there are more than ten notes then the +% number is padded. +% \begin{macrocode} +\def_new:NNn \niib_thenote: 0 { + \niib_notename: + \num_compare:nNnT {\g_niib_totalnotes_int} > {\c_nine}{ + \num_compare:nNnF {\g_niib_note_int} > {\c_nine}{ + 0 + } + } + \int_to_arabic:n \g_niib_note_int +} +% \end{macrocode} +%\end{macro} +% +%\subsection{User options} +%\begin{macro}{\g_niib_KV_bool_clist} +%\begin{macro}{\niib_KV_bool:nT} +%\begin{macro}{\niib_KV_choice:nnT} +%\begin{macro}{\niib_KV_cs_n:n} +%\begin{macro}{\niib_KV_string:n} +% To be going on with, the key-defining macros are created +% using \pkg{keyval}. +% \begin{macrocode} +\RequirePackage{keyval} +\clist_new:N\g_niib_KV_bool_clist +\clist_put_left:Nn\g_niib_KV_bool_clist{true,false} +\def_new:NNn\niib_KV_bool:nT 2 { + \define@key{niib}{#1}[true]{ + \clist_if_in:cnTF{g_niib_KV_bool_clist}{##1}{ + #2 + }{ + \PackageError{xnotes2bib}{ + Unknown~choice~`##1' + }{ + The~Boolean~option~`#1'~accepts~only~the\MessageBreak + values~true~and~false + } + } + } +} +\def_new:NNn\niib_KV_choice:nnT 3 { + \cs_if_free:cTF{g_niib_KV_#1_clist}{ + \clist_new:c{g_niib_KV_#1_clist} + }{ + \clist_gclear:c{g_niib_KV_#1_clist} + } + \clist_put_left:cn{g_niib_KV_#1_clist}{#2} + \define@key{niib}{#1}{ + \clist_if_in:cnTF{g_niib_KV_#1_clist}{##1}{ + #3 + }{ + \PackageError{xnotes2bib}{ + Unknown~choice~`##1' + }{ + The~option~`#1'~accepts~only~the~values:\MessageBreak + #2 + } + } + } +} +\def_new:NNn\niib_KV_cs_n:n 1 { + \define@key{niib}{#1}{ + \def:cNn{niib_#1:n} 0 {##1} + } +} +\def_new:NNn\niib_KV_string:n 1 { + \define@key{niib}{#1}{ + \def:cNn{niib_#1:} 0 {##1} + } +} +% \end{macrocode} +%\end{macro} +%\end{macro} +%\end{macro} +%\end{macro} +%\end{macro} +%\begin{macro}{\niib_cite:n} +% Options for storing macro names +% \begin{macrocode} +\niib_KV_cs_n:n{cite} +% \end{macrocode} +%\end{macro} +%\begin{macro}{\niib_field:} +%\begin{macro}{\niib_key after:} +%\begin{macro}{\niib_key before:} +%\begin{macro}{\niib_key mixed:} +%\begin{macro}{\niib_notename:} +%\begin{macro}{\niib_prefix:} +%\begin{macro}{\niib_presort after:} +%\begin{macro}{\niib_presort before:} +%\begin{macro}{\niib_presort mixed:} +%\begin{macro}{\niib_record:} +% A series of value-storing are created. +% \begin{macrocode} +\niib_KV_string:n{field} +\niib_KV_string:n{key~after} +\niib_KV_string:n{key~before} +\niib_KV_string:n{key~mixed} +\niib_KV_string:n{notename} +\niib_KV_string:n{prefix} +\niib_KV_string:n{presort~after} +\niib_KV_string:n{presort~before} +\niib_KV_string:n{presort~mixed} +\niib_KV_string:n{record} +% \end{macrocode} +%\end{macro} +%\end{macro} +%\end{macro} +%\end{macro} +%\end{macro} +%\end{macro} +%\end{macro} +%\end{macro} +%\end{macro} +%\end{macro} +%\begin{macro}{\niib_convert_endnotes:} +%\begin{macro}{\niib_convert_footnotes:} +% None of the Boolean keys actually work quite as simply as +% creating a switch. For footnote and endnote manipulation, +% the keys created here have to be altered later in any case. +% \begin{macrocode} +\let_new:NN\niib_convert_endnotes:\scan_stop: +\let_new:NN\niib_convert_footnotes:\scan_stop: +\niib_KV_bool:nT{convert~endnotes}{ + \let:Nc\niib_convert_endnotes:{niib_convert_endnotes_#1:} +} +\niib_KV_bool:nT{convert~footnotes}{ + \let:Nc\niib_convert_footnotes:{niib_convert_footnotes_#1:} +} +% \end{macrocode} +%\end{macro} +%\end{macro} +%\begin{macro}{\niib_debug:n} +%\begin{macro}{\niib_debug_true:n} +%\begin{macro}{\niib_debug_false:n} +% The \opt{debug} option is implemented as a choice, to save on +% some complexity. +% \begin{macrocode} +\niib_KV_bool:nT{debug}{ + \let:Nc\niib_debug:n{niib_debug_#1:n} +} +\def_new:NNn\niib_debug_true:n 1 { + \PackageInfo{xnotes2bib}{#1} +} +\let_new:NN\niib_debug_false:n\use_none:n +% \end{macrocode} +%\end{macro} +%\end{macro} +%\end{macro} +%\begin{macro}{\l_niib_after_bool} +%\begin{macro}{\l_niib_before_bool} +% The \opt{placement} option sets one or other flag if needed. +% \begin{macrocode} +\bool_new:N\l_niib_after_bool +\bool_new:N\l_niib_before_bool +\niib_KV_choice:nnT{placement}{after,before,mixed}{ + \bool_set_false:N\l_niib_before_bool + \bool_set_false:N\l_niib_after_bool + \cs_if_really_exist:cT{l_niib_#1_bool}{ + \bool_set_true:c{l_niib_#1_bool} + } +} +% \end{macrocode} +%\end{macro} +%\end{macro} +% All of the default values are set. +% \begin{macrocode} +\setkeys{niib}{ + cite = \cite, + debug = false, + field = note, + key~after = zzz, + key~before = aaa, + key~mixed = {}, + notename = Bibnote, + placement = mixed, + prefix = niib-, + presort~after = mn, + presort~before = ml, + presort~mixed = mm, + record = Misc} +% \end{macrocode} +% +%\subsection{User macros} +%\begin{macro}{\bibnote} +%\doarg{label} +%\darg{text} +% The main user macro has to check if the automatic note number +% is needed. If it is, the optional argument is note used to +% \cs{bibnotetext} as this automatically assumes the current +% value of \cs{niib_thenote:}. The note text must be sorted +% out before the mark is made, as otherwise packages such as +% \pkg{cite} do not work correctly with punctuation. As the +% package is designed for \LaTeX3, it is assumed \eTeX\ is +% available and so \cs{scantokens} can be used on the mandatory +% argument. Hence everything is absorbed here without worrying +% about category codes. +% \begin{macrocode} +\NewDocumentCommand{\bibnote}{o>{P}m}{ + \IfNoValueTF{#1}{ + \int_gincr:N \g_niib_note_int + \bibnotetext{#2} + \bibnotemark[\niib_thenote:] + }{ + \bibnotetext[#1]{#2} + \bibnotemark[#1] + } +} +% \end{macrocode} +%\end{macro} +%\begin{macro}{\bibnotemark} +%\doarg{label} +% As with \cs{bibnote}, if no optional argument is given the +% global note tracking counter is incremented before carrying +% out the citation. +% \begin{macrocode} +\NewDocumentCommand{\bibnotemark}{o}{ + \IfNoValueTF{#1}{ + \int_gincr:N \g_niib_note_int + \niib_notemark:n{\niib_thenote:} + }{ + \niib_notemark:n{#1} + } +} +% \end{macrocode} +%\end{macro} +%\begin{macro}{\bibnotetext} +%\doarg{label} +%\darg{text} +% Writing the note text to the database should only occur if +% files are being written. For the moment, this uses the +% \LaTeXe\ flag (and so the tradition syntax). +% \begin{macrocode} +\NewDocumentCommand{\bibnotetext}{O{\niib_thenote:}>{P}m}{ + \if@filesw +% \end{macrocode} +%\begin{macro}{\g_niib_out_stream} +% A new output stream may need to be created, if this is the +% first note to write. The \LaTeXe\ file switch is checked to +% see if this should occur. +% \begin{macrocode} + \cs_if_free:NT \g_niib_out_stream { + \iow_new:N \g_niib_out_stream + \iow_open:Nn \g_niib_out_stream + {\niib_prefix:\c_job_name_tlp.bib} + \iow_expanded:Nn \g_niib_out_stream + {This~is~an~auxiliary~file~used~by~the~`xnotes2bib'~ + package.^^J This~file~may~safely~be~deleted.^^J It~ + will~be~recreated~as~required.^^J} + } +% \end{macrocode} +% The writing macro works in expanded mode, as everything +% except the note text does need expansion. Notice that +% \cs{space} has to be used here after the macro names, as |~| +% does not work. +% \begin{macrocode} + \niib_debug:n{ + Writing~text:\MessageBreak #2\MessageBreak to~database~ + for~note~`#1' + } + \iow_expanded:Nn \g_niib_out_stream { + @\niib_record:{ + #1,^^J + \space\space \niib_field:\space + =~{\exp_not:n{#2}},^^J + \space\space \niib_keyname:\space + =~{#1} ,^^J + \space\space presort~ + =~{\niib_presort:},^^J + }^^J + } + \fi +} +% \end{macrocode} +%\end{macro} +%\end{macro} +%\begin{macro}{\flushnotestack} +% In order to delay citations to the end of the bibliography +% (and thus force others to the start), note citations are held +% in a clist until being added to the \ext{aux} file using +% \cs{flushnotestack}. At that point, the stack is cleared so +% that collection can begin again. +% \begin{macrocode} +\NewDocumentCommand{\flushnotestack}{}{ + \clist_if_empty:NF\g_niib_beforecite_clist{ + \if@filesw + \iow_expanded:Nn\@auxout{ + \token_to_string:N\niibbeforecite{ + \g_niib_beforecite_clist + } + } + \fi + } + \clist_if_empty:NF\g_niib_aftercite_clist{ + \nocite{\g_niib_aftercite_clist} + \if@filesw + \iow_expanded:Nn\@auxout{ + \token_to_string:N\niibaftercite{\g_niib_aftercite_clist} + } + \fi + } + \clist_gclear:N\g_niib_aftercite_clist +} +% \end{macrocode} +%\end{macro} +%\begin{macro}{\niibsetup} +% \begin{macrocode} +\NewDocumentCommand{\niibsetup}{m}{\setkeys{niib}{#1}} +% \end{macrocode} +%\end{macro} +% +%\subsection{Macros for the \texorpdfstring{\ext{aux}}{.aux} +% file} +% To allow tracking of the need to re-run \LaTeX, each run +% writes the current out-of-order citations to the \ext{aux} +% file. This requires two user-space macros, although it is +% not intended the user ever applies them! +% +%\begin{macro}{\g_niib_oldbeforecite_clist} +%\begin{macro}{\g_niib_oldaftercite_clist} +% Two lists are created to track the out-of-order citations +% written in the previous run to the \ext{aux} file. +% \begin{macrocode} +\clist_new:N\g_niib_oldbeforecite_clist +\clist_new:N\g_niib_oldaftercite_clist +% \end{macrocode} +%\end{macro} +%\end{macro} +%\begin{macro}{\g_niib_document_tlp} +% A hook into the \cs{document} macro is needed by +% \cs{niibbeforecite}; this needs to exist before \cs{document} +% is executed, hence needing a tlp for this. +% \begin{macrocode} +\tlp_new:N\g_niib_document_tlp +\tlp_put_right:Nn\document{\g_niib_document_tlp} +% \end{macrocode} +%\end{macro} +%\begin{macro}{\niibbeforecite} +%\begin{macro}{\niibaftercite} +%\darg{citations} +% The macros themselves are quite simple. +% \cs{clist_gset_eq:Nc} is not used as the macros could appear +% more than once in the \ext{aux} file. +% \begin{macrocode} +\NewDocumentCommand{\niibbeforecite}{m}{ + \clist_gput_right:Nn\g_niib_oldbeforecite_clist{#1} + \tlp_gput_right:Nn\g_niib_document_tlp{\nocite{#1}} +} +\NewDocumentCommand{\niibaftercite}{m}{ + \clist_gput_right:Nn\g_niib_oldaftercite_clist{#1} +} +% \end{macrocode} +%\end{macro} +%\end{macro} +%\begin{macro}{\g_niib_totalnotes_int} +% The total number of notes in the last run is needed +% \begin{macrocode} +\int_new:N \g_niib_totalnotes_int +% \end{macrocode} +%\end{macro} +%\begin{macro}{\niibtotalnotes} +%\darg{number} +% The total number of notes created is stored for the next run. +% \begin{macrocode} +\NewDocumentCommand{\niibtotalnotes}{m}{ + \int_gset:Nn \g_niib_totalnotes_int {#1} +} +% \end{macrocode} +%\end{macro} +% +%\subsection{Internal macros} +%\begin{macro}{\niib_notemark:n} +% The citation command itself is in an internal macro, as it is +% called from a few places. Both the \opt{before} and +% \opt{after} modes require some tracking of the citations. For +% the moment this is using \cs{clist_put_right:Nx}, but it +% really should be \cs{clist_gput_right:Nx} (which does not +% currently exist). +% \begin{macrocode} +\def_new:NNn \niib_notemark:n 1 { + \niib_debug:n{Creating~citation~for~note~`#1'} + \bool_if:NT\l_niib_before_bool{ + \niib_debug:n{Note~`#1'~before~real~citations} + \clist_put_right:Nx\g_niib_beforecite_clist{#1} + } + \bool_if:NTF\l_niib_after_bool{ + \niib_debug:n{Note~`#1'~after~real~citations} + \clist_put_right:Nx\g_niib_aftercite_clist{#1} + \niib_aftercite:n{#1} + }{ + \niib_cite:n{#1} + } +} +% \end{macrocode} +%\end{macro} +%\begin{macro}{\g_niib_beforecite_clist} +%\begin{macro}{\g_niib_aftercite_clist} +% Out-of-order citations in the current run are followed using +% two clists. +% \begin{macrocode} +\clist_new:N\g_niib_beforecite_clist +\clist_new:N\g_niib_aftercite_clist +% \end{macrocode} +%\end{macro} +%\end{macro} +%\begin{macro}{\niib_key:} +%\begin{macro}{\niib_presort:} +% The key and presort information for the database needs to be +% created dynamically from the various keys. +% \begin{macrocode} +\def_new:NNn\niib_key: 0 { + \bool_if:NTF\l_niib_before_bool{ + \cs_use:c{niib_key~before:} + }{ + \bool_if:NTF\l_niib_after_bool{ + \cs_use:c{niib_key~after:} + }{ + \cs_use:c{niib_within~key:} + } + } +} +\def_new:NNn\niib_presort: 0 { + \bool_if:NTF\l_niib_before_bool{ + \cs_use:c{niib_presort~before:} + }{ + \bool_if:NTF\l_niib_after_bool{ + \cs_use:c{niib_presort~after:} + }{ + \cs_use:c{niib_within~presort:} + } + } +} +% \end{macrocode} +%\end{macro} +%\end{macro} +%\begin{macro}{\niib_convert_endnotes_false:} +%\begin{macro}{\niib_convert_endnotes_true:} +%\begin{macro}{\niib_convert_footnotes_false:} +%\begin{macro}{\niib_convert_footnotes_true:} +% Conversion of footnotes and endnotes takes place using four +% dedicated macros, which can then be called by csname. +% \begin{macrocode} +\def_new:NNn\niib_convert_endnotes_false: 0 { + \niib_debug:n{Restoring~normal~endnotes} + \let:NN\endnote\niib_saved_endnote: + \let:NN\endnotemark\niib_saved_endnotemark: + \let:NN\endnotetext\niib_saved_endnotetext: +} +\def_new:NNn\niib_convert_endnotes_true: 0 { + \niib_debug:n{Converting~endnotes~to~bibnotes} + \let:NN\endnote\bibnote + \let:NN\endnotemark\bibnotemark + \let:NN\endnotetext\bibnotetext +} +\def_new:NNn\niib_convert_footnotes_false: 0 { + \niib_debug:n{Restoring~normal~footnotes} + \let:NN\footnote\niib_saved_footnote: + \let:NN\footnotemark\niib_saved_footnotemark: + \let:NN\footnotetext\niib_saved_footnotetext: +} +\def_new:NNn\niib_convert_footnotes_true: 0 { + \niib_debug:n{Converting~footnotes~to~bibnotes} + \let:NN\footnote\bibnote + \let:NN\footnotemark\bibnotemark + \let:NN\footnotetext\bibnotetext +} +% \end{macrocode} +%\end{macro} +%\end{macro} +%\end{macro} +%\end{macro} +%\begin{macro}{\thanks} +% The \cs{thanks} macro has to be replaced by one that uses the +% original \cs{footnotemark} and \cs{footnotetext}. +% \begin{macrocode} +\def:NNn\thanks 1 { + \niib_saved_footnotemark: + \protected@xdef\@thanks{\@thanks + \protect\niib_saved_footnotetext:[\the\c@footnote]{#1}} +} +% \end{macrocode} +%\end{macro} +% +%\subsection{Finalising} +%\begin{macro}{\niib_keyname:} +%\begin{macro}{\niib_biliography:n} +%\begin{macro}{\printbibnotes} +%\begin{macro}{\niib_aftercite:n} +% Various macro definitions depend on the loading of other +% packages. When \pkg{biblatex} is in use, life is rather +% different to when the standard citation method is +% operational. The \cs{niib_key:} macro is used to control +% sorting: \pkg{biblatex} uses a different macro name for this +% function than normal \LaTeX\ does. The \cs{printbibnotes} +% user macro always prints the bibliography, using only the +% notes database if possible. The \cs{niib_aftercite:n} macro +% has to keep a track of the appropriate bibnotes and also +% fiddle with the \cs{@filesw} switch to prevent writing at the +% wrong time. +% \begin{macrocode} +\AtBeginDocument{ + \PackageInfo{xnotes2bib}{ + Beginning~\token_to_string:N\AtBeginDocument\space tasks + } + \@ifpackageloaded{biblatex}{ + \def_new:NNn \niib_keyname: 0 {keysort} + \gappto\blx@bibfiles{,\niib_prefix\c_job_name_tlp} + \let_new:NN\printbibnotes\printbibliography + \def_new:NNn\niib_aftercite:n 1 { + \AtNextCite{\@fileswfalse} + \niib_cite:n{#1} + } + }{ + \def_new:NNn \niib_keyname: 0 {key} + \let_new:NN\niib_biliography:n\bibliography + \def:NNn\bibliography 1 { + \int_compare:nNnTF{\g_niib_note_int}={\c_zero}{ + \niib_biliography:n{#1} + }{ + \niib_biliography:n{#1,\niib_prefix:\c_job_name_tlp} + } + } + \NewDocumentCommand{\printbibnotes}{}{ + \niib_biliography:n{\niib_prefix:\c_job_name_tlp} + } +% \end{macrocode} +%\begin{macro}{\ifniib@filesw} +% There is a need to back-up the \cs{@filesw} switch. As this +% is a \LaTeXe\ switch, the name and creation method used here +% are not \LaTeX3-based. +% \begin{macrocode} + \newif\ifniib@filesw +% \end{macrocode} +%\end{macro} +%\begin{macro}{\@restore@auxhandle} +%\begin{macro}{\niib_auxhandle:} +% If \pkg{cite} is loaded, there is further trouble. +% \begin{macrocode} + \@ifpackageloaded{cite}{ + \def_new:NNn\niib_aftercite:n 1 { + \let:NN\ifniib@filesw\if@filesw + \@fileswfalse + \def:NNn{\niib_auxhandle:} 0 { + \let:NN\if@filesw\ifniib@filesw + \let:NN\niib_auxhandle:\scan_stop: + } + \niib_cite:n{#1} + } + \cs_if_exist:NTF\@restore@auxhandle{ + \tlp_put_right:Nn\@restore@auxhandle{\niib_auxhandle:} + }{ + \def_new:NNn\@restore@auxhandle 0 {\niib_auxhandle:} + } + \let_new:NN\niib_auxhandle:\scan_stop: +% \end{macrocode} +%\end{macro} +%\end{macro} +% Life is slightly easier without \pkg{cite}. +% \begin{macrocode} + }{ + \def_new:NNn\niib_aftercite:n 1 { + \let\ifniib@filesw\if@filesw + \@fileswfalse + \niib_cite:n{#1} + \let\if@filesw\ifniib@filesw + } + } + } +% \end{macrocode} +%\end{macro} +%\end{macro} +%\end{macro} +%\end{macro} +%\begin{macro}{\niib_saved_footnote:} +%\begin{macro}{\niib_saved_footnotemark:} +%\begin{macro}{\niib_saved_footnotetext:} +%\begin{macro}{\niib_saved_endnote:} +%\begin{macro}{\niib_saved_endnotemark:} +%\begin{macro}{\niib_saved_endnotetext:} +% The second thing to worry about is footnotes and endnotes. +% The definitions are saved here so that any other packages can +% have made their changes. No argument specifiers are given as +% these are saving user space macros. +% \begin{macrocode} + \let_new:NN\niib_saved_footnote:\footnote + \let_new:NN\niib_saved_footnotemark:\footnotemark + \let_new:NN\niib_saved_footnotetext:\footnotetext + \let_new:NN\niib_saved_endnote:\endnote + \let_new:NN\niib_saved_endnotemark:\endnotemark + \let_new:NN\niib_saved_endnotetext:\endnotetext +% \end{macrocode} +% Any conversion can now be applied, before the \opt{convert +% footnotes} and \opt{convert endnotes} options are redefined +% to work immediately. +% \begin{macrocode} + \niib_convert_endnotes: + \niib_convert_footnotes: + \niib_KV_bool:nT{convert~endnotes}{ + \cs_use:c{niib_convert_endnotes_#1:} + } + \niib_KV_bool:nT{convert~footnotes}{ + \cs_use:c{niib_convert_footnotes_#1:} + } + \PackageInfo{xnotes2bib}{ + Finished~\token_to_string:N\AtBeginDocument\space tasks + } +} +% \end{macrocode} +%\end{macro} +%\end{macro} +%\end{macro} +%\end{macro} +%\end{macro} +%\end{macro} +%\begin{macro}{\niib_reruncheck:n} +% If either of the out-of-order options are in use, then a +% comparison of the citations used with those used in the last +% run is needed. There are a couple of easy checks to make: if +% only one list is empty, there must be changes. If both lists +% are occupied, a check of every item must be made. +% \begin{macrocode} +\def_new:NNn\niib_rerun_check:n 1 { + \clist_if_empty:cTF {g_niib_old#1cite_clist}{ + \clist_if_empty:cF {g_niib_#1cite_clist}{ + \niib_rerun_log:n {#1} + } + }{ + \clist_if_empty:cTF {g_niib_#1cite_clist}{ + \niib_rerun_log:n {#1} +% \end{macrocode} +% If both lists are occupied by data, the total contents of +% each one have to be compared with the other. This needs to +% be done both ways round. +% \begin{macrocode} + }{ + \bool_set_false:N\l_tmpa_bool + \def:NNn\niib_rerun_test:n 1 { + \clist_if_in:cnTF{g_niib_old#1cite_clist}{##1}{ + \bool_set_true:N\l_tmpa_bool + \clist_map_break:w + }{ + } + } + \clist_map_function:cN{g_niib_#1cite_clist} + \niib_rerun_test:n + \def:NNn\niib_rerun_test:n 1 { + \clist_if_in:cnTF{g_niib_#1cite_clist}{##1}{ + \bool_set_true:N\l_tmpa_bool + \clist_map_break:w + }{ + } + } + \clist_map_function:cN{g_niib_old#1cite_clist} + \niib_rerun_test:n + \bool_if:NF\l_tmpa_bool{ + \niib_rerun_log:n {#1} + } + } + } +} +% \end{macrocode} +%\end{macro} +%\begin{macro}{\niib_rerun_test:n} +% This is redefined in the above, but is made available here. +% \begin{macrocode} +\def:NNn\niib_rerun_test:n 0 {} +% \end{macrocode} +%\end{macro} +%\begin{macro}{\niib_rerun_log:n} +% The information message needs to be available in a few +% different places. +% \begin{macrocode} +\def_new:NNn\niib_rerun_log:n 1 { + \PackageInfo{xnotes2bib}{ + To~get~`#1'~notes~in~the~correct~order,~please\MessageBreak + rerun~LaTeX,~(re)run~BibTeX~on~the~file~\c_job_name_tlp.aux + \MessageBreak and~rerun~LaTeX~again~afterwards + } + \io_put_log:x { + REQ:3:latex:REQ\iow_newline: + REQ:2:bibtex:REQ\iow_newline: + REQ:1:latex:REQ\iow_newline: + } +} +% \end{macrocode} +%\end{macro} +% +% At the end of the document, the package should tidy up. +% \begin{macrocode} +\AtEndDocument{ + \niib_rerun_check:n{before} + \niib_rerun_check:n{after} + \flushnotestack + \iow_expanded:Nn\@auxout{ + \token_to_string:N\niibtotalnotes{ + \int_to_arabic:n \g_niib_note_int + } + } + \num_compare:nNnF{\g_niib_totalnotes_int}={\g_niib_note_int}{ + \niib_rerun_log:n + } + \cs_if_free:NF \g_niib_out_stream{ + \iow_close:N \g_niib_out_stream + } +} +% \end{macrocode} +% +%\iffalse +% +%\fi +% +%\Finale +% +%\iffalse +%<*jawl3doc> +\NeedsTeXFormat{LaTeX2e} +\RequirePackage{l3names} +\ProvidesExplPackage + {jawl3doc}{2008/09/08}{0.0} + {Additions to l3doc (JAW)} +\DeleteShortVerb\| +\DeleteShortVerb\" +\RequirePackage{expl3,xparse} +\MakeShortVerb\| +\IfFileExists{\c_job_name_tlp.sty} + {\RequirePackage{\c_job_name_tlp}}{} +\RequirePackage{helvet,mathpazo} +\RequirePackage[final]{listings} + +\NewDocumentCommand{\pkg}{m}{\textsf{#1}} +\NewDocumentCommand{\currpkg}{}{\pkg{\c_job_name_tlp}} +\NewDocumentCommand{\latin}{m}{\emph{#1}} +\NewDocumentCommand{\etc}{}{\latin{etc}} +\NewDocumentCommand{\ext}{m}{\file{.#1}} +\NewDocumentCommand{\opt}{m}{\texttt{#1}} + +\int_new:N \g_jawldoc_arg_int +\def_new:NNn \jawldoc_thearg: 0 { + \int_to_arabic:n \g_jawldoc_arg_int +} +\NewDocumentCommand{\darg}{m}{ + \int_gincr:N \g_jawldoc_arg_int + {\ttfamily\char`\#\jawldoc_thearg:~:~}#1 + \par\noindent\ignorespaces +} +\NewDocumentCommand{\doarg}{m}{ + \int_gincr:N \g_jawldoc_arg_int + {\ttfamily\makebox[0pt][r]{[} + \char`\#\jawldoc_thearg:]:~}#1 + \par\noindent\ignorespaces +} +\tlp_put_right:Nn\endmacro{\int_gzero:N\g_jawldoc_arg_int} +\NewDocumentCommand{\DescribeOption}{}{ + \leavevmode \@bsphack + \group_begin: + \MakePrivateLetters + \Describe_Option: +} +\def_new:NNn\Describe_Option: 1 { + \group_end: + \marginpar{ + \raggedleft\PrintDescribeEnv{#1} + } + \SpecialOptionIndex{#1} + \@esphack\ignorespaces +} +\NewDocumentCommand{\SpecialOptionIndex}{m}{ + \@bsphack + \index{ + #1\actualchar{\protect\ttfamily#1} + \space(option)\encapchar usage + } + \index{ + options:\levelchar#1\actualchar{\protect\ttfamily#1} + \encapchar usage + } + \@esphack +} +% +%\fi diff --git a/Master/texmf-dist/source/latex/notes2bib/xnotes2bib.ins b/Master/texmf-dist/source/latex/notes2bib/xnotes2bib.ins new file mode 100644 index 00000000000..ed3202d6b0a --- /dev/null +++ b/Master/texmf-dist/source/latex/notes2bib/xnotes2bib.ins @@ -0,0 +1,85 @@ +%% +%% This is file `xnotes2bib.ins', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% xnotes2bib.dtx (with options: `install') +%% --------------------------------------------------------------- +%% The notes2bib bundle --- Integrating notes into the +%% bibliography +%% Maintained by Joseph Wright +%% E-mail: joseph.wright@morningstar2.co.uk +%% Released under the LaTeX Project Public License v1.3c or later +%% See http://www.latex-project.org/lppl.txt +%% --------------------------------------------------------------- +%% +\input docstrip.tex +\keepsilent +\askforoverwritefalse +\preamble +--------------------------------------------------------------- +The notes2bib bundle --- Integrating notes into the + bibliography +Maintained by Joseph Wright +E-mail: joseph.wright@morningstar2.co.uk +Released under the LaTeX Project Public License v1.3c or later +See http://www.latex-project.org/lppl.txt +--------------------------------------------------------------- + +\endpreamble +\postamble + +Copyright (C) 2007-2008 by + Joseph Wright + +It may be distributed and/or modified under the conditions of +the LaTeX Project Public License (LPPL), either version 1.3c of +this license or (at your option) any later version. The latest +version of this license is in the file: + + http://www.latex-project.org/lppl.txt + +This work is "maintained" (as per LPPL maintenance status) by + Joseph Wright. + +This work consists of the file notes2bib.dtx + xnotes2bib.dtx + and the derived files notes2bib.pdf, + notes2bib.sty, + notes2bib.ins, + xnotes2bib.pdf, + xnotes2bib.sty and + xnotes2bib.ins. + +\endpostamble +\usedir{tex/latex/notes2bib} +\generate{ + \file{\jobname.sty}{\from{\jobname.dtx}{package}} +} +\endbatchfile +%% +%% Copyright (C) 2007-2008 by +%% Joseph Wright +%% +%% It may be distributed and/or modified under the conditions of +%% the LaTeX Project Public License (LPPL), either version 1.3c of +%% this license or (at your option) any later version. The latest +%% version of this license is in the file: +%% +%% http://www.latex-project.org/lppl.txt +%% +%% This work is "maintained" (as per LPPL maintenance status) by +%% Joseph Wright. +%% +%% This work consists of the file notes2bib.dtx +%% xnotes2bib.dtx +%% and the derived files notes2bib.pdf, +%% notes2bib.sty, +%% notes2bib.ins, +%% xnotes2bib.pdf, +%% xnotes2bib.sty and +%% xnotes2bib.ins. +%% +%% +%% End of file `xnotes2bib.ins'. -- cgit v1.2.3