==The database==
</pre>
this gives:
{||+|
tag
||
||
author doi index pages serial title url year
||}
<br/>
You can set the current active dataset with
<br/>
<tt>setupbtxlistvariant : artauthor</tt>
{||+|
<tt>no specific settings</tt>
||
||}
<br/>
<tt>setupbtxlistvariant : author</tt>
{||+|
<tt>no specific settings</tt>
||
||}
<br/>
<tt>setupbtxlistvariant : editor</tt>
{||+|
<tt>no specific settings</tt>
||
||}
<br/>
The exact rendering of list entries is determined by the <tt>alternative</tt> key and defaults to <tt>apa</tt> which uses definitions from <tt>publ-imp-apa.mkiv</tt>. If you look at that file you will see that each category has its own setup. You may also notice that additional tests are needed to make sure that empty fields don’t trigger separators and such.
<br/>
There are three commands to flush data:
{||+|
<tt>\btxfield</tt>
||
||
fetch a derived or explicit field
||}
<br/>
Normally you can use <tt>\btxfield</tt> or <tt>\btxflush</tt> as derived fields just like analyzed author fields are flushed in a special way.
<br/>
Keep in mind that normally you don’t need to mess with definitions like this because standard rendering styles are provided. These styles use a few helpers that inject symbols but also take care of leading and trailing spaces:
{||+|
<tt>\btxspace</tt>
||
||
before] after
||}
<br/>
So, the previous example setup can be rewritten as:
<br/>
You can use a (configurable) default or pass directives: Valid directives are
{||+|
conversion
||
||
K, the Frog, jr
||}
<br/>
There is a whole bunch of cite options and more can be easily defined.
{||+|
key
||
||
(year)
||}
<br/>
Because we are dealing with database input and because we generally need to manipulate entries, much of the work is delegated to Lua. This makes it easier to maintain and extend the code. Of course TEX still does the rendering. The typographic details are controlled by parameters but not all are used in all variants. As with most ConTEXt commands, it starts out with a general setup command:
<br/>
<tt>setupbtxcitevariant : author</tt>
{||+|
<tt>right</tt>
||
||
<tt>(</tt>
||}
<br/>
<tt>setupbtxcitevariant : authornum</tt>
{||+|
<tt>right</tt>
||
||
<tt>[</tt>
||}
<br/>
<tt>setupbtxcitevariant : authoryear</tt>
{||+|
<tt>compress</tt>
||
||
<tt>(</tt>
||}
<br/>
<tt>setupbtxcitevariant : authoryears</tt>
{||+|
<tt>compress</tt>
||
||
<tt>(</tt>
||}
<br/>
<tt>setupbtxcitevariant : doi</tt>
{||+|
<tt>right</tt>
||
||
<tt>[</tt>
||}
<br/>
<tt>setupbtxcitevariant : key</tt>
{||+|
<tt>right</tt>
||
||
<tt>[</tt>
||}
<br/>
<tt>setupbtxcitevariant : none</tt>
{||+|
<tt>no specific settings</tt>
||
||}
<br/>
<tt>setupbtxcitevariant : num</tt>
{||+|
<tt>compress</tt>
||
||
<tt>[</tt>
||}
<br/>
<tt>setupbtxcitevariant : page</tt>
{||+|
<tt>inbetween</tt>
||
<tt>–</tt>
||}
<br/>
<tt>setupbtxcitevariant : serial</tt>
{||+|
<tt>right</tt>
||
||
<tt>[</tt>
||}
<br/>
<tt>setupbtxcitevariant : short</tt>
{||+|
<tt>right</tt>
||
||
<tt>[</tt>
||}
<br/>
<tt>setupbtxcitevariant : type</tt>
{||+|
<tt>right</tt>
||
||
<tt>[</tt>
||}
<br/>
<tt>setupbtxcitevariant : url</tt>
{||+|
<tt>right</tt>
||
||
<tt>[</tt>
||}
<br/>
<tt>setupbtxcitevariant : year</tt>
{||+|
<tt>right</tt>
||
||
<tt>(</tt>
||}
A citation variant is defined in several steps and if you really want to know the dirty details, you should look into the <tt>publ-imp-*.mkiv</tt> files. Here we stick to the concept.
<pre detail='typing'>\startsetups btx:cite:author
<br/>
This results in:
{||+|
<tt>demo-001</tt>
||
||
title
||}
\stoptabulate
</pre>
{||+|
<tt>tag</tt>
||
||
PPCHTEX: typesetting chemical formulas in TEX
||}
<pre detail='buffer'>\startxmlsetups btx:demo
\xmlcommand
\xmlsetup{btx:tugboat}{btx:demo}
{||+|
<tt>tag</tt>
||
||
PPCHTEX: typesetting chemical formulas in TEX
||}
<br/>
Here is another example:
\stoptabulate
{||+|
Knuth:TB10-1-31
||
||
A Punk Meta-Font
||}
<br/>
A more extensive example is the following. Of course this assumes that you know what xml support mechanisms and macros are available.
\xmlsetup{btx:tugboat}{btx:sorter}
{||+|
1984
||
||
Donald Knuth
||}
<br/>
The original data is stored in a Lua table, hashed by tag. Starting with Lua 5.2 each run of Lua gets a different ordering of such a hash. In older versions, when you looped over a hash, the order was undefined, but the same as long as you used the same binary. This had the advantage that successive runs, something we often have in document processing gave consistent results. In today’s Lua we need to do much more sorting of hashes before we loop, especially when we save multi--pass data. It is for this reason that the xml tree is sorted by hash key by default. That way lookups (especially the first of a set) give consistent outcomes.