| 1 |
% bookdb.tex User manual for the bookdb.bst package |
| 2 |
\begin{filecontents}{bookdb.bib} |
| 3 |
|
| 4 |
@misc{DALY, |
| 5 |
author = {Patrick W. Daly}, |
| 6 |
title = {Customizing Bibliograhic Style Files}, |
| 7 |
note = "\url{http://mirror.ctan.org/macros/latex/contrib/custom-bib/makebst.pdf}", |
| 8 |
month = aug, |
| 9 |
year = 2003 |
| 10 |
} |
| 11 |
|
| 12 |
@misc{NATBIB, |
| 13 |
author = {Patrick W. Daly}, |
| 14 |
title = {Natural Sciences Citations and References}, |
| 15 |
note = "\url{http://mirror.ctan.org/macros/latex/contrib/natbib/natbib.pdf}", |
| 16 |
month = sep, |
| 17 |
year = 2010 |
| 18 |
} |
| 19 |
|
| 20 |
@misc{LEHMAN, |
| 21 |
author = {Philipp Lehman}, |
| 22 |
title = {The biblatex package}, |
| 23 |
note = "\url{http://mirror.ctan.org/macros/latex/contrib/biblatex/doc/biblatex.pdf}", |
| 24 |
month = jul, |
| 25 |
year = 2009 |
| 26 |
} |
| 27 |
|
| 28 |
@misc{MARKEY, |
| 29 |
author = {Nicolas Markey}, |
| 30 |
title = {Tame the BeaST}, |
| 31 |
note = "\url{http://mirror.ctan.org/info/bibtex/tamethebeast/ttb_en.pdf}", |
| 32 |
month = oct, |
| 33 |
year = 2009 |
| 34 |
} |
| 35 |
|
| 36 |
@misc{PATASHNIK, |
| 37 |
author = {Oren Patashnik}, |
| 38 |
title = {Designing BibTeX Styles}, |
| 39 |
note = "\url{http://mirror.ctan.org/biblio/bibtex/base/btxhak.pdf}", |
| 40 |
month = feb, |
| 41 |
year = 1988 |
| 42 |
} |
| 43 |
|
| 44 |
\end{filecontents} |
| 45 |
|
| 46 |
\documentclass{article} |
| 47 |
\fontencoding{T1} |
| 48 |
\usepackage{booktabs} |
| 49 |
%\usepackage{natbib} |
| 50 |
|
| 51 |
\bibliographystyle{plain} |
| 52 |
\usepackage{url} |
| 53 |
\usepackage{alltt} |
| 54 |
\usepackage{lmodern} |
| 55 |
\usepackage{comment} |
| 56 |
|
| 57 |
\addtolength{\topmargin}{-1in} |
| 58 |
\addtolength{\textheight}{2in} |
| 59 |
\addtolength{\oddsidemargin}{-0.75in} |
| 60 |
\addtolength{\textwidth}{1.5in} |
| 61 |
\addtolength{\evensidemargin}{-0.75in} |
| 62 |
|
| 63 |
\newenvironment{ttdesc}[1] |
| 64 |
{\begin{list}{}% |
| 65 |
{\renewcommand{\makelabel}[1]{\texttt{##1:}\hfil}% |
| 66 |
\settowidth{\labelwidth}{\makelabel{#1}}% |
| 67 |
\setlength{\leftmargin}{\labelwidth}% |
| 68 |
\addtolength{\leftmargin}{\labelsep}}}% |
| 69 |
{\end{list}} |
| 70 |
|
| 71 |
\newcommand{\BibTeX}{\texttt{BibTeX}} |
| 72 |
\newcommand{\file}[1]{\texttt{#1}} |
| 73 |
\newcommand{\field}[1]{\texttt{#1}} |
| 74 |
\newcommand{\pack}[1]{\texttt{#1}} |
| 75 |
|
| 76 |
\title{\texttt{bookdb.bst} --- A Personal Book Catalogue} |
| 77 |
\author{Peter Wilson} |
| 78 |
\date{4 June 2015} |
| 79 |
|
| 80 |
\begin{document} |
| 81 |
\maketitle |
| 82 |
|
| 83 |
\section{Introduction} |
| 84 |
|
| 85 |
For many years I have been collecting books. They are located in five rooms, as well as |
| 86 |
two bookcases in my printing and binding workshop. But recently I found that I was buying |
| 87 |
books that I already had. I decided that the best way to save money was to catalogue all |
| 88 |
the books that I owned and where they were kept. |
| 89 |
|
| 90 |
I searched on the web for free database programs that would be appropriate. There were only |
| 91 |
a few that would run under Linux, which is the operating system I am most comfortable with. |
| 92 |
Of those, some I could not install, and the one that I could I couldn't get to work |
| 93 |
for me. |
| 94 |
|
| 95 |
I contacted several booksellers that I |
| 96 |
dealt with and asked them what they used for catalogueing their stock. They all replied |
| 97 |
but most used proprietry and expensive software that included things like preparing |
| 98 |
invoices that were |
| 99 |
irrelevant as far as I was concerned. The two responses that grabbed my attention were |
| 100 |
`use a card index' (but I needed space for books, not card indexes) and `try Bibtex', |
| 101 |
which immediately appealed as I had used it for many years; why I hadn't thought of it myself |
| 102 |
I'll never know. |
| 103 |
|
| 104 |
\section{Usage} |
| 105 |
|
| 106 |
The standard \BibTeX\ enries did not meet my needs so I looked at |
| 107 |
\pack{biblatex}~\cite{LEHMAN} |
| 108 |
but its entries also didn't match my requirements so I decided to tweak \BibTeX. |
| 109 |
To that end I used Patrick Daly's \texttt{makebst} program~\cite{DALY} |
| 110 |
for generating a \file{*.bst} |
| 111 |
file that went someway towards meeting my needs. This required some hand-coded additions |
| 112 |
later; I read the articles by Oren Patashnik~\cite{PATASHNIK}, the creator of \BibTeX, |
| 113 |
and Nicolas Markey~\cite{MARKEY} which helped me on my way. |
| 114 |
In the end I had a \BibTeX\ file called \file{bookdb.bst} that included all the |
| 115 |
regular entries but a greatly expanded \texttt{book} entry, as follows: |
| 116 |
|
| 117 |
\vspace{0.5\baselineskip} |
| 118 |
\noindent \begin{tabular}{lp{0.9\textwidth}} \toprule |
| 119 |
\texttt{book} & A book with a publisher \\ |
| 120 |
& \textit{Required:} \texttt{author} or {editor}, \texttt{title, publisher, year} \\ |
| 121 |
& \textit{Optional:} \texttt{volume} or \texttt{number, series, address, edition, |
| 122 |
month, note, collator, foreword, preface, introduction, volumes, pages, illustrations, |
| 123 |
binding, size, condition, copy, location, category, value} \\ \bottomrule |
| 124 |
\end{tabular} |
| 125 |
\vspace{0.2\baselineskip} |
| 126 |
|
| 127 |
And also I created a new entry called \texttt{heading}, as follows: |
| 128 |
|
| 129 |
\vspace{0.5\baselineskip} |
| 130 |
\noindent \begin{tabular}{lp{0.87\textwidth}} \toprule |
| 131 |
\texttt{heading} & A heading in the bibliography \\ |
| 132 |
& \textit{Required:} \texttt{key} \\ |
| 133 |
& \textit{Optional:} \texttt{note} \\ \bottomrule |
| 134 |
\end{tabular} |
| 135 |
\vspace{0.5\baselineskip} |
| 136 |
|
| 137 |
The additional fields in the \texttt{book} entry are: |
| 138 |
\begin{ttdesc}{condition} |
| 139 |
\item[binding] Information about the book's binding. Output as: \\ |
| 140 |
Binding: `binding.' |
| 141 |
\item[category] The general theme of the book. Output as: \\ |
| 142 |
Category: `\textbf{category.}' |
| 143 |
\item[collator] The name(s) of those who collated the book contents. Output as: \\ |
| 144 |
`collator' (collator(s)) |
| 145 |
\item[condition] The book's condition. Output as: \\ |
| 146 |
Condition: `condition.' |
| 147 |
\item[copy] For a limited edition, the particular copy. Output as: \\ |
| 148 |
Copy: `copy.' |
| 149 |
\item[foreword] The name(s) of the author(s) of the Foreword, if not written by the |
| 150 |
author(s) of the main text. Output as: \\ |
| 151 |
foreword by `foreword' |
| 152 |
\item[illustrations] \mbox{} \\ Information about the number and kind of any illustrations and |
| 153 |
possibly who created them. Output as: \\ |
| 154 |
Illustrations: `illustrations.' |
| 155 |
\item[introduction] \mbox{} \\ The name(s) of the author(s) of the book's Introduction, if not |
| 156 |
written by the author(s) of the main text. Output as: \\ |
| 157 |
introduction by `introduction' |
| 158 |
\item[location] Where the book is located. Output as: \\ |
| 159 |
Location: `location.' |
| 160 |
\item[pages] The total number of pages. Output as: \\ |
| 161 |
`pages' pp., |
| 162 |
\item[preface] The name(s) of the author(s) of the Preface, if not written by the |
| 163 |
author(s) of the main text. Output as: \\ |
| 164 |
preface by `preface' |
| 165 |
\item[size] The book's physical dimensions. Output as: \\ |
| 166 |
Size: `size.' |
| 167 |
\item[value] The book's value. Output as: \\ |
| 168 |
Value: `\textbf{value}.' |
| 169 |
\item[volumes] The number of volumes. Output as: \\ |
| 170 |
Volumes: `volumes.' |
| 171 |
\end{ttdesc} |
| 172 |
|
| 173 |
I use the \texttt{heading} entry for putting a heading or division marker into |
| 174 |
a bibliography. The \field{key} is required so that the \texttt{heading} is sorted |
| 175 |
into the correct position in the bibliography (normally sorting is based on the author |
| 176 |
or editor). The contents of the \field{note} |
| 177 |
form the printed heading. For instance if you wanted a heading before each alphabetical |
| 178 |
group of authors you could do something like: |
| 179 |
\begin{verbatim} |
| 180 |
@heading{A1, |
| 181 |
key = {A1}, |
| 182 |
note = {\ahead{AAAAAAAA...}} |
| 183 |
} |
| 184 |
@heading{B1, |
| 185 |
key ={B1}, |
| 186 |
note = {\ahead{BBBBBBBB...}} |
| 187 |
} |
| 188 |
etc |
| 189 |
\end{verbatim} |
| 190 |
where \verb!\ahead! might be defined as: |
| 191 |
\begin{verbatim} |
| 192 |
\providecommand{\ahead}[1]{% |
| 193 |
\textbf{\large #1}} |
| 194 |
\end{verbatim} |
| 195 |
|
| 196 |
To help clarify matters Figure~\ref{fig:data} shows a possible entry in a |
| 197 |
\file{*.bib} file. The output after processing in a document using |
| 198 |
\file{bookdb.bst} is illustrated in Figure~\ref{fig:result}. |
| 199 |
|
| 200 |
%\noindent |
| 201 |
\begin{figure} |
| 202 |
\centering |
| 203 |
\begin{minipage}{0.75\columnwidth} |
| 204 |
\rule{0.75\columnwidth}{0.4pt} |
| 205 |
\begin{verbatim} |
| 206 |
@book{ABOOK, |
| 207 |
author = {A. N. Author and A. Nother}, |
| 208 |
title = {A Book Entry}, |
| 209 |
editor = {Smith and Jones}, |
| 210 |
collator = {Jane and Tim}, |
| 211 |
translator = {Jo and Mary}, |
| 212 |
foreword = {Alpha}, |
| 213 |
preface = {Zoe}, |
| 214 |
introduction = {Bloggs and Friend}, |
| 215 |
volume = 7, |
| 216 |
publisher = {Herries Press}, |
| 217 |
year = 2020, |
| 218 |
pages = {xii + 278 + vi}, |
| 219 |
edition = {Third}, |
| 220 |
isbn = {0-201-36299-8}, |
| 221 |
volumes = 9, |
| 222 |
illustrations = {11 wood engravings}, |
| 223 |
binding = {full red leather}, |
| 224 |
size = {11 by 17 inches}, |
| 225 |
note = {This is a note}, |
| 226 |
condition = {Hot off the press}, |
| 227 |
copy = {23 of 125}, |
| 228 |
location = {my study}, |
| 229 |
category = {private press}, |
| 230 |
value = {\$270} |
| 231 |
} |
| 232 |
\end{verbatim} |
| 233 |
\rule{0.75\columnwidth}{0.4pt} |
| 234 |
\end{minipage} |
| 235 |
\caption{An example entry for \texttt{bookdb} processing} \label{fig:data} |
| 236 |
\end{figure} |
| 237 |
|
| 238 |
\begin{figure} |
| 239 |
\rule{\textwidth}{0.4pt} \par |
| 240 |
\hangindent=1.5em\hangafter=1 |
| 241 |
\noindent A. N. Author and A. Nother. \textit{A Book Entry}, Smith and Jones (eds.), |
| 242 |
Jane and Tim (collators), Jo and Mary (translators), foreword by Alpha, |
| 243 |
preface by Zoe, introduction by |
| 244 |
Bloggs and Friend, volume 7 (Herries Press, 2020), xii + 278 + vi pp., |
| 245 |
third edition. ISBN 0-201-36299-8. Volumes: 9. Illustrations: 11 wood |
| 246 |
engravings. Binding: full red leather. |
| 247 |
Size: 11 by 17 inches. This is a note. Condition: Hot off the press. |
| 248 |
Copy: 23 of 125. Location: my study. Category: \textbf{private press}. |
| 249 |
Value: \textbf{\$270}. \par |
| 250 |
\noindent\rule{\textwidth}{0.4pt} |
| 251 |
\caption{The example's output} \label{fig:result} |
| 252 |
\end{figure} |
| 253 |
|
| 254 |
\clearpage |
| 255 |
|
| 256 |
As an example this is a file that I use for printing a catalogue of my books, |
| 257 |
where the book details are in file \file{mybooks.bib}. Note that using |
| 258 |
\pack{bookdb} requires the use of the \pack{natbib} package ~\cite{NATBIB}. |
| 259 |
\begin{verbatim} |
| 260 |
% books.tex a catalogue of my books |
| 261 |
\documentclass[11pt,a4paper]{memoir} |
| 262 |
\usepackage[T1]{fontenc} |
| 263 |
\usepackage{natbib} |
| 264 |
\pagestyle{empty} |
| 265 |
\begin{document} |
| 266 |
\nocite{*} |
| 267 |
\bibliographystyle{bookdb} |
| 268 |
\bibliography{mybooks} |
| 269 |
\end{document} |
| 270 |
\end{verbatim} |
| 271 |
|
| 272 |
|
| 273 |
\begin{comment} |
| 274 |
\section{Implementation} |
| 275 |
|
| 276 |
As I said earlier I had to extend the \file{bookdb.bst} file produced by |
| 277 |
the \texttt{makebst} program. I didn't really know how it all worked but after |
| 278 |
much trial and many errors I got something that on the whole met my needs. My |
| 279 |
basic process was to copy elements of the original \file{bst}, change some names, |
| 280 |
and see what was produced. |
| 281 |
|
| 282 |
First of all I added the new \texttt{book} fields to the \file{bookdb.bst} \texttt{ENTRY} |
| 283 |
command as: |
| 284 |
\begin{verbatim} |
| 285 |
ENTRY |
| 286 |
{ ... |
| 287 |
binding |
| 288 |
category |
| 289 |
collator |
| 290 |
condition |
| 291 |
copy |
| 292 |
illustrations |
| 293 |
introduction |
| 294 |
location |
| 295 |
pages |
| 296 |
size |
| 297 |
translator |
| 298 |
value |
| 299 |
volumes |
| 300 |
} |
| 301 |
\end{verbatim} |
| 302 |
|
| 303 |
The next thing was to add the new entries in the correct order to the function that output |
| 304 |
the \texttt{book} bibliography entries, together with how they should be formatted. This |
| 305 |
was the final result after much try it, \BibTeX\ it, change it, and repeat |
| 306 |
(the original code is in |
| 307 |
a typewriter font and my additions are in an italic font). |
| 308 |
|
| 309 |
\begin{alltt} |
| 310 |
{\ttfamily |
| 311 |
FUNCTION \{book\} |
| 312 |
\{ output.bibitem |
| 313 |
author empty$ |
| 314 |
\{ format.editors "author and editor" |
| 315 |
output.check |
| 316 |
editor format.key output |
| 317 |
add.blank |
| 318 |
\} |
| 319 |
\{ format.authors output.nonnull |
| 320 |
crossref missing$ |
| 321 |
\{ "author and editor" editor |
| 322 |
either.or.check \} |
| 323 |
'skip$ |
| 324 |
if$ |
| 325 |
\} |
| 326 |
if$ |
| 327 |
new.block |
| 328 |
format.btitle "title" output.check }{\itshape |
| 329 |
format.editors output |
| 330 |
format.collator output |
| 331 |
format.translator output |
| 332 |
format.introduction output }{\ttfamily |
| 333 |
crossref missing$ |
| 334 |
\{ format.bvolume output |
| 335 |
new.block |
| 336 |
format.number.series output |
| 337 |
new.sentence |
| 338 |
format.publisher.address output |
| 339 |
\} |
| 340 |
\{ |
| 341 |
new.block |
| 342 |
format.book.crossref output.nonnull |
| 343 |
\} |
| 344 |
if$ |
| 345 |
format.book.pages output |
| 346 |
format.edition output |
| 347 |
format.isbn output }{\itshape |
| 348 |
format.volumes output |
| 349 |
format.illustrations output |
| 350 |
format.binding output |
| 351 |
format.size output }{\ttfamily |
| 352 |
new.block |
| 353 |
format.note output }{\itshape |
| 354 |
format.condition output |
| 355 |
format.copy output |
| 356 |
format.location output |
| 357 |
format.category output |
| 358 |
format.value output }{\ttfamily |
| 359 |
fin.entry |
| 360 |
\} } |
| 361 |
\end{alltt} |
| 362 |
|
| 363 |
Effectively `all' I had left to do was to specify the formatting of my new fields. |
| 364 |
I used three basic forms: |
| 365 |
\begin{enumerate} |
| 366 |
\item Some introductory text, like `introduction by' or `Illustrations:', followed by |
| 367 |
the field data. |
| 368 |
\item Like the first form but with the field data in a bold font. |
| 369 |
\item Name(s) forming the field data followed by what their contribution was |
| 370 |
in parentheses. |
| 371 |
\end{enumerate} |
| 372 |
|
| 373 |
As an example of the first form here is the code for \field{binding}: |
| 374 |
|
| 375 |
\begin{verbatim} |
| 376 |
FUNCTION {format.binding} |
| 377 |
{ binding "binding" bibinfo.check |
| 378 |
duplicate$ empty$ 'skip$ |
| 379 |
{ |
| 380 |
new.block |
| 381 |
"Binding: " swap$ * |
| 382 |
} |
| 383 |
if$ |
| 384 |
} |
| 385 |
\end{verbatim} |
| 386 |
|
| 387 |
Life was a little more complicated for the second form. This is the code for the |
| 388 |
\field{value} field which requires two functions, the first dealing with the |
| 389 |
bolding and the second with the output. |
| 390 |
|
| 391 |
\begin{verbatim} |
| 392 |
FUNCTION {boldval} |
| 393 |
{ duplicate$ empty$ |
| 394 |
{ pop$ "" } |
| 395 |
{ "Value: \textbf{" swap$ * "}" * } |
| 396 |
if$ |
| 397 |
} |
| 398 |
FUNCTION {format.value} |
| 399 |
{ value "value" bibinfo.check |
| 400 |
duplicate$ empty$ 'skip$ |
| 401 |
{ |
| 402 |
new.block |
| 403 |
boldval |
| 404 |
} |
| 405 |
if$ |
| 406 |
} |
| 407 |
\end{verbatim} |
| 408 |
|
| 409 |
The third form required several functions, as in the code for \field{collator}, where if there |
| 410 |
is a single collator this is output as `Name (collator)' but if the are multiple collators |
| 411 |
the output is `Name1 and Name2 ... (collators)'. |
| 412 |
|
| 413 |
\begin{verbatim} |
| 414 |
FUNCTION {bbl.collator} |
| 415 |
{ "collator" } |
| 416 |
FUNCTION {bbl.collators} |
| 417 |
{ "collators" } |
| 418 |
FUNCTION {get.bbl.collator} |
| 419 |
{ collator num.names$ #1 > |
| 420 |
'bbl.collators 'bbl.collator |
| 421 |
if$ |
| 422 |
} |
| 423 |
FUNCTION {format.collator} |
| 424 |
{ collator "collator" format.names |
| 425 |
duplicate$ empty$ 'skip$ |
| 426 |
{ " " * |
| 427 |
get.bbl.collator |
| 428 |
"(" swap$ * ")" * |
| 429 |
} |
| 430 |
if$ |
| 431 |
} |
| 432 |
\end{verbatim} |
| 433 |
|
| 434 |
\end{comment} |
| 435 |
|
| 436 |
%\clearpage |
| 437 |
|
| 438 |
\section{My book database} |
| 439 |
|
| 440 |
The \file{*.bib} for my book catalogue looks somewhat like this: |
| 441 |
\begin{verbatim} |
| 442 |
%%% mybooks.bib 2015/04/22 |
| 443 |
|
| 444 |
%%% for formating headings |
| 445 |
@preamble{ "\providecommand{\ahead}[1]{% |
| 446 |
\textbf{\large #1}}" } |
| 447 |
|
| 448 |
%%% publishers |
| 449 |
@string{CUP = |
| 450 |
"Cambridge University Press"} |
| 451 |
% etc |
| 452 |
%%% categories |
| 453 |
@string{science = |
| 454 |
"science, mathematics, computers"} |
| 455 |
% etc |
| 456 |
|
| 457 |
@heading{A1, |
| 458 |
key = {A}, |
| 459 |
note = {\ahead{AAAAAAAAAAA....} |
| 460 |
} |
| 461 |
|
| 462 |
@book{A1KEY, |
| 463 |
author = {First A. Author}, |
| 464 |
% etc |
| 465 |
} |
| 466 |
|
| 467 |
@book{A2KEY, |
| 468 |
author = {Second A. Author}, |
| 469 |
% etc |
| 470 |
} |
| 471 |
|
| 472 |
% etc |
| 473 |
\end{verbatim} |
| 474 |
|
| 475 |
I used the \BibTeX\ \verb!@preamble! command to provide a definition of the \verb!\ahead! |
| 476 |
macro. This, if required, can be overridden by an existing definition in the |
| 477 |
document used to print the bibliography. |
| 478 |
|
| 479 |
I added various \verb!@string! commands to provide shorthands for many of the |
| 480 |
fields in the \file{.bib} file, such as publisher, location, category, that |
| 481 |
would have the same value. This meant that I could have a shortened field entry |
| 482 |
that looked like: |
| 483 |
\begin{verbatim} |
| 484 |
publisher = CUP, |
| 485 |
\end{verbatim} |
| 486 |
instead of: |
| 487 |
\begin{verbatim} |
| 488 |
publisher = {Cambridge University Press}, |
| 489 |
\end{verbatim} |
| 490 |
|
| 491 |
\section{Infelicities} |
| 492 |
|
| 493 |
|
| 494 |
\BibTeX\ uses a stack-based language which I find hard to understand. |
| 495 |
%Many years ago I wrote an interpreter for a stack-based language whose name |
| 496 |
%I have forgotten but even so I was unable to use the language itself. I think |
| 497 |
%that it is a little like crosswords. I like doing `cryptic' crosswords but |
| 498 |
%I find that with some setters I can follow their clues easily but with |
| 499 |
%others I haven't a clue. |
| 500 |
|
| 501 |
My basic approach was to take an existing \file{*.bst} file, try and see what it did, |
| 502 |
then copy and modify what seemed relevant to my needs. |
| 503 |
|
| 504 |
I did have a couple of infelicities that I did not manage to resolve. |
| 505 |
|
| 506 |
The first was that no matter what I tried I could not stop the \texttt{heading} |
| 507 |
from outputting its \field{key}, so it should be made as short and unobtrusive as possible. |
| 508 |
|
| 509 |
The second was that I couldn't stop the warning message issued by \BibTeX\ if both |
| 510 |
an \field{author} and \field{editor} were supplied although the output was printed |
| 511 |
including both. |
| 512 |
|
| 513 |
In spite of these, if you are a collector then you may want to consider tweaking a |
| 514 |
\file{*.bst} file to meet your particular needs. |
| 515 |
|
| 516 |
|
| 517 |
\bibliography{bookdb} |
| 518 |
|
| 519 |
\end{document} |
| 520 |
|
| 521 |
|
| 522 |
|
| 523 |
|
| 524 |
|
| 525 |
|
| 526 |
|
| 527 |
|
| 528 |
|
| 529 |
|
| 530 |
|