Bibliography mkiv

From ConTeXt wiki
Jump to: navigation, search

< Bibliographies in mkii | sample bib file >

Contents

ConTeXt MkIV Bibliography

Please see

Quickstart

From the manual:

\usebtxdataset[mkiv-publications.bib]
\starttext

\startbodymatter
a citation: \cite[article,book]
\stopbodymatter

\startbackmatter
    \startchapter[title=Bibliography]
        \placelistofpublications
    \stopchapter
\stopbackmatter

\stoptext

Database Formats

ConTeXt MkIV Bibliography can read several different formats of bibliographic databases:

BibTeX .bib format

ConTeXt is independent from the BibTeX program, but can read .bib databases, if it’s not polluted with non-standarddized (LaTeX) commands. This format is the oldest, but supported by most bibliography management programs. The other supported formats use the same structure of records, just ported to different “languages”.

A BibTeX database is a text file, consisting of entries like:

@Article {Hagen2010,

 author = "One or more authors",
 title = "Some interesting title",
 journal = "Publisher’s Weekly",
 volume = "27",
 number = "2",
 pages = "21--30",
 month = may,
 year = "2020",
 ISSN = "1234-5678"

}

@Article is an example for a common category, like @Book, @unpublished etc. Letter case doesn’t matter. The first argument reference must not contain spaces and is ended with a comma. Spacing within an entry doesn’t matter. If values consist of only one word, you don’t need quotes, otherwise you can also use brackets.

ConTeXt understands UTF-8 encoded bib files as well as old fashioned TeX accent combinations.

Fields

Some known fields of @Article are (see manual p.14):

There’s a (complete?) overview of categories and their fields in the manual on page 18 (Table 3.2).

Commands in entries

You can define unknown commands like this:

\definebtxcommand\TUB {TUGboat}
\definebtxcommand\sltt{\tt}
\definebtxcommand\<#1>{\type{#1}}

btx commands use a separate namespace.

MkII .bbl format

This intermediate format is still supported, but obsolete. Just an example to let you know what it means:

\startpublication[k=Hagen:Second,t=article,a={Hans Hagen},y=2013,s=HH01] 
    \artauthor[]{Hans}[H.]{}{Hagen}
    \arttitle{Who knows more?}
    \journal{MyJournal}
    \pubyear{2013}
    \month{8}
    \volume{1}
    \issue{3}
    \issn{1234-5678}
    \pages{123--126}
\stoppublication

Lua tables

Since internally everything anyway are Lua tables, you can use them directly as a database format:

   return { ["Hagen:First"] = {
       author = "Hans Hagen",
       category = "article",
       issn = "1234-5678",
       issue = "3",
       journal = "MyJournal",
       month = "8",
       pages = "123--126",
       tag = "Hagen:First",
       title = "Who knows nothing?",
       volume = "1",
       year = "2013", },
   }

XML

    <?xml version="2.0" standalone="yes" ?>
    <bibtex>
        <entry tag="Hagen:First" category="article">
            <field name="author">Hans Hagen</field>
            <field name="category">article</field>
            <field name="issn">1234-5678</field>
            <field name="issue">3</field>
            <field name="journal">MyJournal</field>
            <field name="month">8</field>
            <field name="pages">123--126</field>
            <field name="tag">Hagen:First</field>
            <field name="title">Who knows nothing?</field>
            <field name="volume">1</field>
            <field name="year">2013</field>
        </entry>
    </bibtex>

Setup

\usebtxdataset[default][mybooks.bib]
\setupbtx[dataset=default]
\usebtxdefinitions[apa] % see p.15
\placelistofpublications
\definebtxrendering[example][apa][%  setup "example" inherits from "apa"
  specification=apa,
  sorttype=authoryear,
  numbering=no
]

sorttypes

rendering

See manual, p.24ff.

\setupbtxlist[apa][
  alternative=paragraph,
  width=fit,
  distance=.5em,
  margin=3em % hanging list
]

Predefined renderings include:

Language

Bibliography lists and citations are rendered in the language of the document (\mainlanguage). If an entry includes a language field, this can be used, depending on the rendering specification.

You can force the main language on all entries with \setupdelimitedtext[language=global].

You can define and use translated titles with language modifiers, e.g. title:de or booktitle:fr.

Citations

See p.31ff. of the manual. E.g.

\cite[num][reference] % [77]
\cite[authoryear][reference] % (Hagen 1977)
\cite[short][reference] % [HHH+77b]
and even
\cite[num][ref1,ref2,ref3] % [2,15,77] see p.35f.

The first argument defaults to the default citation rendering, as defined by \setupbtx[default:cite][alternative=num].

(work in progress)

Simple manual bibliography

If you don’t need bibliographical databases, but just references within one document, this approach might be enough for you:

\def\dostartbibitem[#1][#2]%
	{\doifsomethingelse{#2}%
    {\startBibItem[reference={#1},title={#2}]}%
    {\startBibItem[reference={#1},title={#1}]}%
}
\def\startbibitem{\dodoubleempty\dostartbibitem}
\def\stopbibitem{\stopBibItem}

\definedescription[BibItem][
	width=broad,
	margin=4em,
	indenting={no},
	indentnext=no,
	alternative=hanging,
	hang=1,
	headcommand=\gobbleoneargument,
	align=flushleft
]

\def\bibitemrule{\noindentation\vrule height0.5pt width4em depth0pt\thinspace}

\definereferenceformat [cite]  [type=title,left={},right={}]
\definereferenceformat [bibpage]   [type=page]

\starttext

\section{Content}

While we wait for the perfect book about ConTeXt\footnote{Maybe \cite[Hagen 2050]), we can at least read a nice novel (\cite[Hagen 2014]).

\section{Bibliography}

\startbibitem[Hagen 2014]
Hagen, Hans: \emph{The Cow in the Ridderstraat.} Hasselt 2014.
\stopbibitem

\startbibitem[Hagen 2050]
\bibitemrule \emph{ConTeXt complete compendium.} Hasselt 2050.
\stopbibitem

\startbibitem[Hagen 2060][The Wizard 1899] % First parameter is reference, second gets displayed
\bibitemrule \emph{Optional differing reference title.} Hasselt 2060
\stopbibitem

\stoptext

C O N T E X T G A R D E N

Personal tools
Namespaces
Variants
Actions
Help
External Help
Installation
Navigation
Toolbox