% \iffalse meta-comment % % Copyright %<*driver> \documentclass{ltxdoc} \usepackage{doc} \def\script#1{\texttt{#1}} \def\ext#1{\texttt{.#1}} \def\var#1{\texttt{\$#1}} \def\entry#1{\texttt{@#1}} \def\lang#1{\textsc{#1}} \def\bst#1{\textsf{#1.bst}} \def\BibTeX{Bib\TeX} %%%\AtBeginDocument{\CodelineIndex\EnableCrossrefs} %%%\AtEndDocument{\PrintIndex} \begin{document} \def\docdate{2019/03/30} \def\fileversion{3.03} %%% Please also change date at the beginning of the script %%% %%% (VERSION and VDATE below) %%% \DocInput{bibexport.dtx} \end{document} % % % \fi % \CheckSum{45} %% \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 %% Lower-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 %% Digits \0\1\2\3\4\5\6\7\8\9 %% Exclamation \! Double quote \" Hash (number) \# %% Dollar \$ Percent \% Ampersand \& %% Acute accent \' Left paren \( Right paren \) %% Asterisk \* Plus \+ Comma \, %% Minus \- Point \. Solidus \/ %% Colon \: Semicolon \; Less than \< %% Equals \= Greater than \> Question mark \? %% Commercial at \@ Left bracket \[ Backslash \\ %% Right bracket \] Circumflex \^ Underscore \_ %% Grave accent \` Left brace \{ Vertical bar \| %% Right brace \} Tilde \~} %% % % \title{The \script{bibexport.sh} script} % \author{Nicolas Markey} % \date{\docdate} % \maketitle % \StopEventually{} % % \begin{abstract} % \script{bibexport.sh} is a small shell script, relying on \BibTeX, that % extracts entries of one or several \ext{bib} file(s). It~will expand % abbreviations and cross-references, except standard month and journal % abbreviations. The output is indented as neatly as possible, yielding a % readable \ext{bib} file even if the original file is~not. % \end{abstract} % % % \section{Exporting \ext{bib} files} % % \subsection{Why and how?} % % \BibTeX{} aims at allowing for the use of one single \ext{bib} file, % containing many entries, from which \BibTeX{} extracts only the % \verb+\cite+d ones. When sending a document to someone else, this % requires either sending the whole file, or extracting the \verb+\cite+d % entries from the \ext{bib} file. % % \BibTeX{} also has a mechanism for using abbreviations and % cross-references. When extracting entries of a large \ext{bib} file, % it can be interesting to develop those abbreviations, in order to get a % clean, self-contained \ext{bib} file. Also, it may be useful to develop % cross-references in a \ext{bib} file, independently of any document. % % \medskip % \script{bibexport} can either extract entries that are cited in a document, % or all the entries of one or several \ext{bib} files. It will always develop % cross-references and abreviations, except standard abbreviations for months or % some journals, that are defined in standard \BibTeX{} styles. This script % uses \BibTeX{}. This has both pros and cons: % \begin{itemize} %\item[$+$] it is very simple. Basicaly, the script simply calls \BibTeX{}, and the % \ext{bst} file just outputs the name and the content of each field. %\item[$+$] since it uses \BibTeX, we are sure that it will handle everything % "properly", \emph{i.e.} in the same way as they will be handled when cited in % a \LaTeX{} document; %\item[$=$] \BibTeX{} has some strict limitations (especially "no more than 78 consecutive % non-space characters") that we must be aware~of. On~the other hand, any such % problem occuring within the script would also occur when compiling a % document; %\item[$-$] abbreviations and cross-references will \emph{always} be % developped. It~could be argued that this is also a positive point, but % having the choice would be better. %\item[$-$] Many people seem to find \BibTeX's internal language clumsy, and thus % the script could be difficult to adapt to special needs. However, this is % not \emph{that} difficult, as will be explained later~on. In the present case, % adding more fields to be exported is quite easy. % \end{itemize} % % \subsection{Related scripts} % % Several other tools exist for achieving this task: % \begin{itemize} %\item \verb+aux2bib+, written by Ralf Treinen, relies on \verb+bib2bib+, % which is a \lang{CaML} program for selecting some entries in one or several \ext{bib} % files. It does not expand anything, but includes all the necessary % definitions and entries. %\item \verb+bibextract.sh+, by Nelson Beebe. This script uses \lang{awk} for % extracting some entries out of a \ext{bib} file. It~is said not to be % compliant with cross-references. %\item \bst{subset}, by David Kotz. \bst{export} develops the same ideas (but % I discovered that only later~on). \bst{subset} does not handle % \entry{preamble}, neither does it "protect" standard abbreviations. % \end{itemize} % % \subsection{Some examples} % % \begin{itemize} %\item extracting \verb+\cite+d references of a document, also including % cross-references: %\begin{center} % \ttfamily bibexport.sh -o {\itshape }.bib {\itshape }.aux %\end{center} %\item extracting \verb+\cite+d references of a document, without crossrefs, % and using a special \ext{bst} file: %\begin{center} % \ttfamily bibexport.sh -b {\itshape