2

Assuming one provides the reference, e.g. \cite{historynow1765}, how can I get ConTeXt to display specific fields for that reference, such as the title, publish date, publish location, author's full name, etc.?

E.g., assume the BibTeX file contains this entry:

@misc{historynow1765,
title={The Stamp Act, 1765: A Spotlight on a Primary Source    by George III},
url={https://www.gilderlehrman.org/history-now/spotlight-primary-source/stamp-act-1765},
journal={History Now},
publisher={The Gilder Institute of American History}
}

Some code like this might call the title information:

\cite[title]{historynow1765}

Some code like this might call the publisher information:

\cite[publisher]{historynow1765}

How can I get this specific information about a source printed in ConTeXt, taking the data from the BibTeX file?

1 Answer 1

4
+350

Based on https://mailman.ntg.nl/pipermail/ntg-context/2018/090903.html I came up with the following solution, which seems needlessy complicated but it works nonetheless.

The idea is to add separate \cite setups for each individual field using

\startsetups btx:[stylename]:cite:[fieldname]
\btxfield{fieldname}
\stopsetups

This enables the syntax \cite[fieldname][refname].

The complicated part is how to convince ConTeXt to actually use these definitions. For this a new style can be created, for example named singlefields. This style can be based on an existing style, such as apa. Following the link above I did the following:

  • copy publ-imp-apa.lua and publ-imp-apa.mkvi to the working directory and rename them as publ-imp-singlefields.lua and publ-imp-singlefields.mkvi. Note that this means that regular \cite and the reference list will be formatted in APA style.
  • in publ-imp-singlefields.mkvi replace all occurrences of apa with singlefields
  • add the \startsetups code (see below)
  • in publ-imp-singlefields.lua, add the extra fields to the misc entry (see below)

Single field code:

\startsetups btx:singlefields:cite:publisher
\btxfield{publisher}
\stopsetups

\startsetups btx:singlefields:cite:journal
\btxfield{journal}
\stopsetups

\startsetups btx:singlefields:cite:title
\btxfield{title}
\stopsetups

\startsetups btx:singlefields:cite:url
\btxfield{url}
\stopsetups

Misc entry:

categories.misc = {
    sets = {
        doi  = generic.doi,
    },
    required = {
        -- nothing is really important here
    },
    optional = {
        "author", "withauthor", "translator",
        "title", "subtitle", "file",
        "year", "month",
        "howpublished",
        "doi", "note",
        "publisher", "journal", "url",
    },
}

Document:

\usebtxdataset[ctxfields.bib]
\usebtxdefinitions[singlefields]

\starttext

Only title: \cite[title][historynow1765]

Only journal: \cite[journal][historynow1765]

Only publisher: \cite[publisher][historynow1765]

\subject[title=\bf References]

\placelistofpublications

\stoptext

Result:

enter image description here

Remark: for some reason this also works out of the box with only adding the fields to the .lua file and not changing the .mkvi file at all, however then the journal and publisher are printed in a monospace font. Besides this, another advantage of the outlined approach is that you can also change the appearance of the bibliography entries, using the setup \startsetups btx:[stylename]:list:[entrytype] syntax.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.