From 8194be0d381007aea01bfe7bce63ad7d10291d66 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sun, 28 Oct 2007 22:19:43 +0000 Subject: notes2bib update (27oct07) git-svn-id: svn://tug.org/texlive/trunk@5298 c570f23f-e606-0410-a88d-b1316a301751 --- .../source/latex/notes2bib/notes2bib.dtx | 378 ++++++++++++++------- 1 file changed, 257 insertions(+), 121 deletions(-) (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 c1d75557a1c..9329e2f86d5 100644 --- a/Master/texmf-dist/source/latex/notes2bib/notes2bib.dtx +++ b/Master/texmf-dist/source/latex/notes2bib/notes2bib.dtx @@ -43,13 +43,13 @@ % bibtex8 --wolfgang notes2bib % pdflatex notes2bib.dtx % pdflatex notes2bib.dtx -% +% % Installation: % Copy notes2bib.sty to a location searched by TeX, and % if required by your TeX installation, run the appropriate -% command to build a hash of files (texhash, mpm --update-db, +% command to build a hash of files (texhash, mpm --update-db, % etc.) -% +% % Note: % The jawltxdoc.sty file is not needed for installation, % only for building the documentation. It may be deleted. @@ -108,7 +108,7 @@ % %\fi % -%\CheckSum{433} +%\CheckSum{504} % %\CharacterTable % {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z @@ -135,6 +135,9 @@ %\changes{v1.1}{2007/09/29}{Several code sections re-factored} %\changes{v1.1}{2007/09/29}{Improvements to documentation and % \texttt{dtx} file} +%\changes{v1.2}{2007/10/26}{Altered implementation of \texttt{head} +% and \texttt{tail} options to allow moving of superscript +% citations} % %\DoNotIndex{\@fileswfalse,\@ifnextchar,\@ifpackageloaded} %\DoNotIndex{\@ifundefined,\@nameuse,\AtBeginDocument,\AtEndDocument} @@ -149,7 +152,8 @@ %\DoNotIndex{\printbibliography,\ProcessOptions,\protect} %\DoNotIndex{\ProvidesPackage,\relax,\renewcommand,\RequirePackage} %\DoNotIndex{\space,\stepcounter,\string,\thanks,\the,\theendnotes} -%\DoNotIndex{\unexpanded,\value,\write,\xdef,\z@} +%\DoNotIndex{\unexpanded,\value,\write,\xdef,\z@,\endinput,\endnote} +%\DoNotIndex{\endnotemark,\endnotetext} % % %\DoNotIndex{\NeedsTeXFormat} @@ -248,7 +252,7 @@ % |footnotes| option turns standard LaTeX footnotes into % bibnotes.\footnote{The \cs{thanks} macro used in making titles uses % the footnote mechanism. This is unaffected by loading -% \texttt{notes2bib} even with the \texttt{footnote} option.}. Thus, +% \texttt{notes2bib} even with the \texttt{footnote} option.} Thus, % with the |footnotes| option enables, footnotes appear in the % bibliography with no further user input. The \cmd{\footnotemark} % and \cmd{\footnotetext} macros are supported, and are aliased to @@ -441,30 +445,6 @@ % \bibnote{Some \texttt{\textbackslash verb}-like output}. %\end{LaTeXexample} % -% Currently, when using the |head| option citations can take only one -% optional argument. This is fine for normal citation styles, but -% means that |biblatex| users may have some issues. The package -% author will look again at this if it is a serious problem. A work -% around is to cite as follows (here assuming you wish to use the -% \cmd{\cite} command): -%\begin{LaTeXexample}[\typesetcodeonly] -% \makeatletter -% \begingroup -% \@fileswfalse -% \niib@orig@cite[argument-one][argument-two]{citation} -% \endgroup -% \edef\niib@stack{\niib@stack,citation} -% \makeatother -%\end{LaTeXexample} -% Where ``argument-one,'' ``argument-two'' and ``citation'' should be -% altered to the desired information. -% -% The |cite| and |biblatex| packages move superscript citations after -% punctuation. When these packages are used with standard (not |head| -% or |tail|) mode of |notes2bib|, the same will occur for bibnote -% numbers. Unfortunately, the |head| and |tail| options prevent this -% ``auto-magic'' operation on \emph{bibnote} numbers. -% %\bibliographystyle{unsrt} %\renewcommand*{\refname}{Notes} %\StopEventually{\printbibnotes} @@ -532,7 +512,8 @@ % The |head| and |tail| options use an additional technique. Both % delay writing of selected citations (either notes or real ones) % into the |.aux| file, to control citation position in unsorted -% bibliographies. +% bibliographies. The delay is brought about by altering the +% definition of |\if@filesw|, so that it is dependent on the context. % %\iffalse %<*package> @@ -546,7 +527,7 @@ % \begin{macrocode} \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{notes2bib} - [2007/09/29 v1.1 Integrating notes into the bibliography] + [2007/10/26 v1.2 Integrating notes into the bibliography] % \end{macrocode} % The package requires e-TeX, so before going any further, this is % tested. This code is taken more-or-less verbatim from |biblatex|. @@ -561,12 +542,12 @@ \endinput} {} % \end{macrocode} -% With that check out of the way, Philip Lehmann's |elatex| package -% is loaded to extend various LaTeX commands. Early versions of -% |elatex| ues slightly different macro names, so a version check -% is needed. +%\changes{v1.2}{2007/10/26}{Name change of support package from +% \texttt{elatex} to \texttt{etoolbox}} +% With that check out of the way, Philip Lehmann's |etoolbox| package +% is loaded to extend various LaTeX commands. % \begin{macrocode} -\RequirePackage{elatex}[2007/07/13] +\RequirePackage{etoolbox} % \end{macrocode} % % Option processing takes place. Redefining \cmd{\footnote} or @@ -608,7 +589,7 @@ % \end{macrocode} % Finally, the options are put into effect. % \begin{macrocode} -\ProcessOptions +\ProcessOptions\relax % \end{macrocode} % %\begin{macro}{\niib@fnmark} @@ -616,7 +597,7 @@ %\begin{macro}{\niib@thanks} % If the |footnote| option is active, there is some work to do % because of the \cmd{\thanks} macro. This is all done using the -% |elatex| package. Firstly, it is necessary to back up the original +% |etoolbox| package. Firstly, it is necessary to back up the original % definitions for \cmd{\footnotetext}, \cmd{\footnotetext} and % \cmd{\thanks}. % \begin{macrocode} @@ -909,24 +890,17 @@ %\begin{macro}{\citenote} %\changes{v1.0a}{2007/09/03}{New macro} %\changes{v1.1}{2007/09/29}{Macro made robust} +%\changes{v1.2}{2007/10/26}{\texttt{tail} version altered to work +% with new delaying method} % A ``mode aware'' command for referencing notes is needed (problems % arise with \cmd{\cite} and the |tail| option. Rather than overload % \cmd{\cite} with all of the problems that can bring, a new command % is provided that can be guaranteed to work. % \begin{macrocode} \ifniib@tail - \newrobustcmd*\citenote[2][\relax]{% - \begingroup% - \@fileswfalse% -% \end{macrocode} -% \cmd{\relax} is used as a marker for an empty first argument. -% \begin{macrocode} - \ifx#1\relax% - \niibcite{#2}% - \else - \niibcite[#1]{#2}% - \fi - \endgroup% + \newrobustcmd*\citenote{% + \niib@cnfalse% + \niibcite% }% % \end{macrocode} % If |tail| is not active, then \cmd{\citenote} is simply an alias @@ -990,14 +964,109 @@ % \end{macrocode} %\end{macro} % -% A switch is needed to tell if a note is being cited when using -% ``head'' mode. -% \begin{macrocode} -\newif\ifniib@cn\niib@cnfalse -% \end{macrocode} -% %\subsection{Internal macros} % +% To alter citation ordering, tricks have to be played with writing +% to the |.aux| file. First some switches are needed to track what +% is going on. |\ifniib@cn| tracks is a note is being cited, +% |ifniib@citing| is used to check for any citation, |\ifniib@filesw| +% is used to substitute |\if@filesw|, and |\ifniib@orig@filesw| +% records the original value of the file switch. +% \begin{macrocode} +\newif\ifniib@cn\niib@cnfalse% +\newif\ifniib@citing\niib@citingfalse% +\newif\ifniib@filesw\niib@fileswfalse% +\newif\ifniib@orig@filesw +% \end{macrocode} +% The value of the file switch is backed up. +% \begin{macrocode} +\if@filesw + \niib@orig@fileswtrue% +\else + \niib@orig@fileswfalse% +\fi +% \end{macrocode} +%\begin{macro}{\niib@head@filesw} +%\changes{v1.2}{2007/10/26}{New macro} +% When in |head| mode, |\if@filesw| is modified using this macro. +% \begin{macrocode} +\def\niib@head@filesw{% +% \end{macrocode} +% First, the switching commands are altered. +% \begin{macrocode} + \let\@fileswtrue\niib@orig@fileswtrue% + \let\@fileswfalse\niib@orig@fileswfalse% +% \end{macrocode} +% The switch is now redefined. First, the current value of the +% original switch is transferred to the switch actually in use. +% \begin{macrocode} + \def\if@filesw{% + \ifniib@orig@filesw + \niib@fileswtrue% + \else + \niib@fileswfalse% + \fi +% \end{macrocode} +% If a citation is being made, and it is not a note, then writing to +% the |.aux| file is turned off. +% \begin{macrocode} + \ifniib@citing + \ifniib@cn\else + \niib@fileswfalse% + \fi + \fi +% \end{macrocode} +% The switches are reset, then the new switch is used to give the desired +% behaviour. +% \begin{macrocode} + \global\niib@cnfalse% + \global\niib@citingfalse% + \ifniib@filesw% + } +} +% \end{macrocode} +%\end{macro} +% If |head| mode is on, then this is all activated. +% \begin{macrocode} +\ifniib@head + \niib@head@filesw% +\fi +% \end{macrocode} +%\begin{macro}{\niib@tail@filesw} +%\changes{v1.2}{2007/10/26}{New macro} +% When in |tail| mode, a slightly different set of modifications is needed. +% \begin{macrocode} +\def\niib@tail@filesw{% + \let\@fileswtrue\niib@orig@fileswtrue% + \let\@fileswfalse\niib@orig@fileswfalse% + \def\if@filesw{% + \ifniib@orig@filesw + \niib@fileswtrue% + \else + \niib@fileswfalse% + \fi +% \end{macrocode} +% If a note is being cited, writing to the |.aux| file is disabled. +% \begin{macrocode} + \ifniib@cn + \niib@fileswfalse% + \fi +% \end{macrocode} +% The switches are reset, then the new switch is used to give the desired +% behaviour. +% \begin{macrocode} + \global\niib@cnfalse% + \ifniib@filesw% + } +} +% \end{macrocode} +%\end{macro} +% If |head| mode is on, then this is all activated. +% \begin{macrocode} +\ifniib@tail + \niib@tail@filesw% +\fi +% \end{macrocode} %\begin{macro}{\niib@delaycite} %\changes{v1.0a}{2007/09/03}{Fixed a flaw with checking for % existing redefinition} @@ -1006,60 +1075,86 @@ %\changes{v1.1}{2007/09/29}{Made internal to prevent execution % in preamble} %\changes{v1.1}{2007/09/29}{Macro made robust} -% Normal citations have to be stacked up in the stack when in -% ``head'' mode. To do this, the citation command has to be modified -% to do this, while leaving note citations alone. The trick used in -% this is to set \cmd{\@filesw} to false while the citation takes -% place. +%\changes{v1.2}{2007/10/26}{Significantly altered to use new citation +% delaying method} +% The citation command has to be modified when in |head| mode. This +% is done here. % \begin{macrocode} \newrobustcmd*\niib@delaycite[1]{% \@ifundefined{#1}{% - \PackageWarning{notes2bib} - {Citation macro \@nameuse{#1}undefined\MessageBreak - \protect\delaycite\space cannot operate on this macro} + \PackageWarning{notes2bib} + {Citation macro \@nameuse{#1}undefined\MessageBreak + \protect\delaycite\space cannot operate on this macro} }{% \@ifundefined{niib@orig@#1}{% +% \end{macrocode} +% If the citation is not already modified, the original definition is +% backed up. It is then modified to ensure the correct behaviour of +% the file switch, and to stack up citations if needed. +% \begin{macrocode} \expandafter\expandafter\expandafter\let\expandafter% \csname niib@orig@#1\expandafter\endcsname\csname #1\endcsname% - \expandafter\renewcommand\csname #1\endcsname[2][\relax]{% -% \end{macrocode} -% If a note is being cited, then there will be no optional argument, -% and |##1| will expand to \cmd{\relax}. -% \begin{macrocode} - \ifniib@cn% - \csname niib@orig@#1\endcsname{##2}% - \else% - \begingroup% - \@fileswfalse% -% \end{macrocode} -% If an optional argument has been given, then |##1| will expand to -% something other than \cmd{\relax}. So the original citation -% command is called with the optional argument. -% \begin{macrocode} - \ifx##1\relax% - \csname niib@orig@#1\endcsname{##2}% - \else% - \csname niib@orig@#1\endcsname[##1]{##2}% - \fi% - \endgroup% - \edef\niib@temp{##2}% - \ifx\niib@stack\relax% - \xdef\niib@stack{\niib@temp}% - \else% - \xdef\niib@stack{\niib@stack,\niib@temp}% - \fi% - \fi% - }% - \PackageInfo{notes2bib}% - {Modifying citation type \@nameuse{#1}}% +% \end{macrocode} +% To ensure that the original citation command can see the next +% argument, a bit of complexity is needed. Two different definitions +% are used, depending on whether an optional argument is detected. +% \begin{macrocode} + \expandafter\renewcommand\csname #1\endcsname{% + \niib@citingtrue% + \@ifnextchar[%] + {\@nameuse{niib@optarg@#1}} + {\@nameuse{niib@noarg@#1}} + } +% \end{macrocode} +% There could be two optional arguments when using |biblatex|. So +% a second check is used. +% \begin{macrocode} + \expandafter\def\csname niib@optarg@#1\endcsname[##1]{% + \@ifnextchar[%] + {\@nameuse{niib@twoopt@#1}[##1]} + {\@nameuse{niib@oneopt@#1}[##1]} + } + \expandafter\def\csname niib@oneopt@#1\endcsname[##1]##2{% + \niib@stackup{##2}% + \@nameuse{niib@orig@#1}[##1]{##2}% + } + \expandafter\def\csname niib@twoopt@#1\endcsname[##1][##2]##3{% + \niib@stackup{##3}% + \@nameuse{niib@orig@#1}[##1][##2]{##3}% + } +% \end{macrocode} +% For no optional arguments, life is a bit easier! +% \begin{macrocode} + \expandafter\def\csname niib@noarg@#1\endcsname##1{% + \niib@stackup{##1}% + \@nameuse{niib@orig@#1}{##1}% + } }{% \PackageInfo{notes2bib}% {Already delayed \@nameuse{#1}}% - }% + } } } % \end{macrocode} %\end{macro} +%\begin{macro}{\niib@stackup} +%\changes{v1.2}{2007/10/26}{New macro} +% The various optional argument tricks above all use the same core +% code, which adds the mandatory argument of the citation to the +% stack. +% \begin{macrocode} +\def\niib@stackup#1{% + \ifniib@cn\else + \edef\niib@temp{#1}% + \ifx\niib@stack\relax% + \xdef\niib@stack{\niib@temp}% + \else + \xdef\niib@stack{\niib@stack,\niib@temp}% + \fi + \fi +} +% \end{macrocode} +%\end{macro} % %\begin{macro}{\niib@bibnote} % Two steps are needed here, writing the text of the note to file @@ -1084,6 +1179,7 @@ %\begin{macro}{\niib@cite} %\changes{v1.1}{2007/09/29}{Name change from \cs{niib@citenote}} %\changes{v1.1}{2007/09/29}{Definition made option-specific} +%\changes{v1.2}{2007/10/26}{Moved resetting of \texttt{niib@cn} flag} % The internal macro used to cite notes depends on the package % options in force. First, for |head| mode, the modified real % citation commands need to know that a note is being cited. So the @@ -1093,7 +1189,6 @@ \def\niib@cite#1{% \niib@cntrue% \niibcite{#1}% - \niib@cnfalse% }% % \end{macrocode} % For |tail| mode, the citation has to be added to the stack for use @@ -1103,15 +1198,13 @@ \else% \ifniib@tail% \def\niib@cite#1{% - \ifx\niib@stack\relax% - \xdef\niib@stack{#1}% - \else% - \xdef\niib@stack{\niib@stack,#1}% - \fi% - \begingroup - \@fileswfalse% + \ifx\niib@stack\relax% + \xdef\niib@stack{#1}% + \else% + \xdef\niib@stack{\niib@stack,#1}% + \fi% + \niib@cntrue% \niibcite{#1}% - \endgroup% }% % \end{macrocode} % Without the |head| or |tail| options, none of these tricks are @@ -1174,10 +1267,11 @@ % executed the note file is also processed. |biblatex| does things % very differently, but this actually makes it much easier to patch % for. +%\changes{v1.2}{2007/10/26}{Fixed bug with \texttt{biblatex} support} % \begin{macrocode} \@ifpackageloaded{biblatex}{% \expandafter\bib@gadd\expandafter\blx@bibfiles\expandafter% - {\niibprefix\jobname}% + {,\niibprefix\jobname}% }{% % \end{macrocode} %\begin{macro}{\niib@bib} @@ -1222,20 +1316,26 @@ % users: there is no error checking! However, it is covered by the % LPPL in the same way as the rest of this package. % +% \begin{macrocode} \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{jawltxdoc} - [2007/09/28 v1.0] + [2007/10/23 v1.0 Formatting for .dtx files (JAW)] +% \end{macrocode} % First of all, a number of support packages are loaded. +% \begin{macrocode} \usepackage[T1]{fontenc} \usepackage[english,UKenglish]{babel} \usepackage[scaled=0.95]{helvet} \usepackage[version=3]{mhchem} \usepackage[final]{microtype} -\usepackage{mathpazo,booktabs,array,url,graphicx,courier,unitsdef} +\usepackage[osf]{mathpazo} +\usepackage{booktabs,array,url,graphicx,courier,unitsdef} \usepackage{upgreek,ifpdf,listings} -% If using pdfLaTeX, the source will be attached to the PDF. This -% is basically the system used by Heiko Oberdiek, but with a check -% that PDF mode is enabled. +% \end{macrocode} +% If using PDFLaTeX, the source will be attached to the PDF. This is +% basically the system used by Heiko Oberdiek, but with a check that +% PDF mode is enabled. +% \begin{macrocode} \ifpdf \usepackage{embedfile} \embedfile[% @@ -1246,17 +1346,18 @@ \fi \usepackage{\jobname} \usepackage[numbered]{hypdoc} -% +% \end{macrocode} % To typeset examples, a new environment is needed. The code below % is based on that in used by |listings|, but is modified to get % better formatting for this context. The formatting of the output % is basically that in Will Robertson's |dtx-style| file. +% \begin{macrocode} \newlength\LaTeXwidth \newlength\LaTeXoutdent \newlength\LaTeXgap \setlength\LaTeXgap{1em} \setlength\LaTeXoutdent{-0.15\textwidth} -\def\typesetexampleandcode{ +\def\typesetexampleandcode{% \begin{list}{}{% \setlength\itemindent{0pt} \setlength\leftmargin\LaTeXoutdent @@ -1267,7 +1368,33 @@ \begin{minipage}[c]{\textwidth-\LaTeXwidth-\LaTeXoutdent-\LaTeXgap} \lst@sampleInput \end{minipage}% - \hfill%% + \hfill% + \begin{minipage}[c]{\LaTeXwidth}% + \hbox to\linewidth{\box\lst@samplebox\hss}% + \end{minipage}% + \end{list} +} +\def\typesetcodeandexample{% + \begin{list}{}{% + \setlength\itemindent{0pt} + \setlength\leftmargin{0pt} + \setlength\rightmargin{0pt} + } + \item + \begin{minipage}[c]{\LaTeXwidth}% + \hbox to\linewidth{\box\lst@samplebox\hss}% + \end{minipage}% + \lst@sampleInput + \end{list} +} +\def\typesetfloatexample{% + \begin{list}{}{% + \setlength\itemindent{0pt} + \setlength\leftmargin{0pt} + \setlength\rightmargin{0pt} + } + \item + \lst@sampleInput \begin{minipage}[c]{\LaTeXwidth}% \hbox to\linewidth{\box\lst@samplebox\hss}% \end{minipage}% @@ -1285,7 +1412,7 @@ \end{minipage}% \end{list} } -\makeatletter +\edef\LaTeXexamplefile{\jobname.tmp} \lst@RequireAspects{writefile} \newbox\lst@samplebox \lstnewenvironment{LaTeXexample}[1][\typesetexampleandcode]{% @@ -1295,10 +1422,18 @@ \setkeys{lst}{language=[LaTeX]{TeX},tabsize=4,gobble=2,% breakindent=0pt,basicstyle=\small\ttfamily,basewidth=0.51em,% keywordstyle=\color{blue},% -% Notice that new keywords should be added here. +% \end{macrocode} +% Notice that new keywords should be added here. The list is simply +% macro names needed to typeset documentation of the package +% author. +% \begin{macrocode} morekeywords={bibnote,citenote,bibnotetext,bibnotemark,% - thebibnote,bibnotename}} - \lst@BeginAlsoWriteFile{\jobname.tmp} + thebibnote,bibnotename,includegraphics,schemeref,% + floatcontentsleft,floatcontentsright,floatcontentscentre,% + schemerefmarker,compound,schemerefformat,color,% + startchemical,stopchemical,chemical,setupchemical,bottext,% + listofschemes}} + \lst@BeginAlsoWriteFile{\LaTeXexamplefile} }{% \lst@EndWriteFile\egroup \setlength\LaTeXwidth{\wd\lst@samplebox} @@ -1309,9 +1444,10 @@ \small% {\setkeys{lst}{SelectCharTable=\lst@ReplaceInput{\^\^I}% {\lst@ProcessTabulator}}% - \leavevmode \input{\jobname.tmp}}% + \leavevmode \input{\LaTeXexamplefile}}% \MakePercentIgnore% } -\makeatother +\hyphenation{PDF-LaTeX} +% \end{macrocode} % %\fi -- cgit v1.2.3