• Tidak ada hasil yang ditemukan

Displaying a databib database

\DTLbibfieldexists{⟨field label⟩}

\DTLbibfieldexists

This tests whether the field with the given label exists for the current en- try. The field label may be one of: Address, Author, BookTitle, Chapter, Edition, Editor, HowPublished, Institution, Journal, Key, Month, Note, Number,Organization,Pages,Publisher,School,Series,Title,Type,Volume, Year, ISBN,DOI,PubMed,AbstractorUrl.

For example, suppose you have loaded adatabib database called mybibusing

\DTLloadbbl (described in subsection 9.2) then the following bibliography will only include those entries which have aYearfield:

\DTLbibliography[\DTLbibfieldexists{Year}]{mybib}

\DTLbibfieldiseq{⟨field label⟩}{⟨value⟩}

\DTLbibfieldiseq

This tests whether the value of the field given by ⟨field label⟩ equals ⟨value⟩. If the field doesn’t exist for the current entry, this evaluates to false. For example, the following will produce a bibliography which only contains entries which have theYearfield set to 2004:

\DTLbibliography[\DTLbibfieldiseq{Year}{2004}]{mybib}

\DTLbibfieldcontains{⟨field label⟩}{⟨sub string⟩}

\DTLbibfieldcontains

This tests whether the value of the field given by⟨field label⟩contains⟨sub string⟩. For example, the following will produce a bibliography which only contains entries where the author field contains the nameKnuth:

\DTLbibliography[\DTLbibfieldcontains{Author}{Knuth}]{mybib}

\DTLbibfieldislt{⟨field label⟩}{⟨value⟩}

\DTLbibfieldislt

This tests whether the value of the field given by⟨field label⟩is less than⟨value⟩. If the field doesn’t exist for the current entry, this evaluates to false. For example, the following will produce a bibliography which only contains entries whoseYear field is less than 1983:

\DTLbibliography[\DTLbibfieldislt{Year}{1983}]{mybib}

\DTLbibfieldisle{⟨field label⟩}{⟨value⟩}

\DTLbibfieldisle

This tests whether the value of the field given by⟨field label⟩is less than or equal to ⟨value⟩. If the field doesn’t exist for the current entry, this evaluates to false.

For example, the following will produce a bibliography which only contains entries whoseYear field is less than or equal to 1983:

\DTLbibliography[\DTLbibfieldisle{Year}{1983}]{mybib}

\DTLbibfieldisgt{⟨field label⟩}{⟨value⟩}

\DTLbibfieldisgt

This tests whether the value of the field given by ⟨field label⟩ is greater than

⟨value⟩. If the field doesn’t exist for the current entry, this evaluates to false. For example, the following will produce a bibliography which only contains entries whoseYear field is greater than 1983:

\DTLbibliography[\DTLbibfieldisgt{Year}{1983}]{mybib}

\DTLbibfieldisge{⟨field label⟩}{⟨value⟩}

\DTLbibfieldisge

This tests whether the value of the field given by ⟨field label⟩is greater than or equal to ⟨value⟩. If the field doesn’t exist for the current entry, this evaluates to false. For example, the following will produce a bibliography which only contains entries whoseYearfield is greater than or equal to 1983:

\DTLbibliography[\DTLbibfieldisge{Year}{1983}]{mybib}

Note that \DTLbibliographyuses \DTLforeachbibentry (described in sub- section 9.5) so you may also use test the value of the counterDTLbibrowwithin

⟨conditions⟩. You may also use the boolean commands defined by theifthenpack- age, such as\not.

Example 33 (Creating a list of publications since a given year)

Suppose my boss has asked me to produce a list of my publications in reverse chronological order, but doesn’t want any publications published prior to the year 2000. I have a file called nlct.bib which contains all my publications which I keep in the directory$HOME/texmf/bibtex/bib/. I could look through this file, work out the labels for all the publications whose year field is greater or equal to 2000, and create a file with a\nocite command containing all those labels in a comma separated list in reverse chronological order, but I really can’t be bothered to do that. Instead, I can create the following document:

\documentclass{article}

\usepackage{databib}

\begin{document}

\nocite{*}

\DTLloadbbl{mybib}{nlct}

\DTLsort{Year=descending,Month=descending}{mybib}

\DTLbibliography[\DTLbibfieldisge{Year}{2000}]{mybib}

\end{document}

Suppose I save this file asmypubs.tex, then I need to do:

latex mypubs bibtex mypubs latex mypubs Notes:

1. \nocite{*}is used to add all the citations in the bibliography file (nlct.bib in this case) to thedatabib database.

2. \DTLloadbbl{mybib}{nlct} does the following:

(a) writes the line

\bibstyle{databib}

to the auxiliary file. This tells BibTEX to use databib.bst (which is supplied with this package). You therefore shouldn’t use\bibliographystyle. (b) writes the line

\bibdata{nlct}

to the auxiliary file. This tells BibTEX that the bibliography data is stored in the filenlct.bib. Since I have placed this file in TEX’s search path, BibTEX will be able to find it.

(c) creates adatatooldatabase calledmybib.

(d) if the bbl file (mypubs.bbl in this example) exists, it loads this file (which adds the bibliography data to the database), otherwise it does nothing further.

3. In my BibTEX database (nlct.bibin this example), I have remembered to use the BibTEX month macros: jan, febetc. This means that the months are stored in the database in the form\DTLmonthname{⟨nn⟩}, where⟨nn⟩is a two digit number from 01 to 12. \DTLsortignores command names when it compares strings, which means I can not only sort by year, but also by month6.

4. Once I have loaded and sorted my database, I can then display it using

\DTLbibliography. This uses the style given by the databib style pack- age option, or the \DTLbibliographystyle command, both of which are described insubsection 9.4.

5. I have filtered the bibliography using the optional argument [\DTLbibfieldisge{Year}{2000}], which checks if the year field of the current entry is greater than or equal to 2000. (Note that if an entry has no year field, the condition evaluates to false, and the entry will be omitted from the bibliography.)

6. If the bibliography database is large, sorting and creating the bibliography may take a while. Using databib is much slower than using a standard BibTEX style file.

Example 34 (Creating a list of my 10 most recent publica- tions)

Suppose now my boss has asked me to produce a list of my ten most recent publications (in reverse chronological order). As in the previous example, I have a

6as long as I haven’t put anything before the month name in the bibliography file, e.g.

month = 2 # aprwill sort by 2 03, instead of 03

file callednlct.bibwhich contains all my publications. I can create the required document as follows:

\documentclass{article}

\usepackage{databib}

\begin{document}

\nocite{*}

\DTLloadbbl{mybib}{nlct}

\DTLsort{Year=descending,Month=descending}{mybib}

\DTLbibliography[\value{DTLbibrow}<11]{mybib}

\end{document}