Changes

Jump to navigation Jump to search
no edit summary
==The data­base==
The bibTEX for­mat is rather pop­u­lar in the TEX com­mu­nity and even with its short­com­ings it will stay around for a while. Many pub­li­ca­tion web­sites can ex­port and many tools are avail­able to work with this data­base for­mat. It is rather sim­ple and looks a bit like Lua ta­bles. Un­for­tu­nately the con­tent can be pol­luted with non-stan­dard­ized TEX com­mands which com­pli­cates pre- or post­pro­cess­ing out­side TEX. In that sense a bibTEX data­base is of­ten not coded neu­trally. Some lim­i­ta­tions, like the use of com­mands to en­code ac­cented char­ac­ters root in the ascii world and can be by­passed by us­ing utf in­stead (as han­dled some­what in LATEX through ex­ten­sions such as <tt style="color:rgb(0,102,102);font-size:120%;" >bibtex8</tt>).
<br/>
Un­known com­mands do not stall pro­cess­ing, but their names are then type­set in a mono- spaced font so they prob­a­bly stand out for proof­read­ing. You can ac­cess the com­mands with <tt style="color:rgb(0,102,102);font-size:120%;" >\btxcommand{...}</tt>, as in:
<pre style="color:rgb(102,0,102);font-size:120%">commands like \btxcommand{MySpecialCommand} are handled in an indirect way</pre>
<br/>
As this is an un­de­fined com­mand we get: “com­mands like MySpe­cial­Com­mand are han­dled in an in­di­rect way”.
<br/>
In this doc­u­ment we use some ex­am­ple data­bases, so let’s load one of them now:
<pre style="color:rgb(102,0,102);font-size:120%">\definebtxdataset[example]
\usebtxdataset[example][mkiv-publications.bib]
</pre>
<br/>
You can ask for an overview of en­tries in a dataset with:
<pre style="color:rgb(102,0,102);font-size:120%">\showbtxdatasetfields[example]</pre>
<br/>
this gives:
<br/>
If you want to see what pub­li­ca­tions are in the data­base, the eas­i­est way is to ask for a com­plete list:
<pre style="color:rgb(102,0,102);font-size:120%">\definebtxrendering
[example]
[dataset=example,
[example]
[criterium=all]
</pre>
<br/>
This gives:1 Ha­gen, H. and Ot­ten, T. (1996). Type­set­ting ed­u­ca­tion doc­u­ments2 Scarso, L. (2021). De­sign­ing high speed trains3 au­thor (year). ti­tle pages p.
Ci­ta­tions are ref­er­ences to bib­li­o­graphic en­tries that nor­mally show up in lists some­place in the doc­u­ment: at the end of a chap­ter, in an ap­pen­dix, at the end of an ar­ti­cle, etc. We dis­cussed the ren­der­ing of these lists in the pre­vi­ous chap­ter. A ci­ta­tion is nor­mally pretty short as its main pur­pose is to re­fer uniquely to a more de­tailed de­scrip­tion. But, there are sev­eral ways to re­fer, which is why the ci­ta­tion sub­sys­tem is con­fig­urable and ex­ten­si­ble. Just look at the fol­low­ing com­mands:
<pre style="color:rgb(102,0,102);font-size:120%">\cite[author][example::demo-003]
\cite[authoryear][example::demo-003]
\cite[authoryears][example::demo-003]
\cite[authoryear][example::demo-004,demo-003]
\cite[authoryears][example::demo-004,demo-003]
</pre>
(Hans Ha­gen and Ton Ot­ten)
<br/>
You can tune the way a ci­ta­tion shows up:
<pre style="color:rgb(102,0,102);font-size:120%">\setupbtxcitevariant[author] [sorttype=author,color=darkyellow]
\setupbtxcitevariant[authoryear] [sorttype=author,color=darkyellow]
\setupbtxcitevariant[authoryears][sorttype=author,color=darkyellow]
</pre>
\cite[author][example::demo-004,demo-003]
\cite[authoryear][example::demo-004,demo-003]
<br/>
You can loop over the en­tries us­ing reg­u­lar Lua code com­bined with MkIV helpers:
<pre style="color:rgb(102,0,102);font-size:120%">local dataset = publications.datasets.example</pre>
context.starttabulate { "|l|l|l|" }
for tag, entry in table.sortedhash(dataset.luadata) do
<br/>
Once a dataset is ac­ces­si­ble as xml tree, you can use the reg­u­lar <tt style="color:rgb(0,102,102);font-size:120%;" >\xml...</tt> com­mands. We start with load­ing a dataset, in this case from just one file.
<pre style="color:rgb(102,0,102);font-size:120%">\usebtxdataset[tugboat][tugboat.bib]</pre>
<br/>
The dataset has to be con­verted to xml:
<pre style="color:rgb(102,0,102);font-size:120%">\convertbtxdatasettoxml[tugboat]</pre>
<br/>
The tree is now ac­ces­si­ble by its root ref­er­ence <tt style="color:rgb(0,102,102);font-size:120%;" >btx:tugboat</tt>. If we want sim­ple field ac­cess we can use a few se­tups:
<pre style="color:rgb(102,0,102);font-size:120%">\startxmlsetups btx:initialize
\xmlsetsetup{#1}{bibtex|entry|field}{btx:*}
\xmlmain{#1}
\stopxmlsetups
</pre>
\startxmlsetups btx:field
\xmlflushcontext{#1}
<br/>
The two se­tups are pre­de­fined in the core al­ready, but you might want to change them. They are ap­plied in for in­stance:
<pre style="color:rgb(102,0,102);font-size:120%">\starttabulate[|||]
\NC \type {tag} \NC \xmlfirst {btx:tugboat}
{/bibtex/entry[string.find(@tag,'Hagen')]/attribute('tag')}
\NC \NR
\stoptabulate
</pre>
{|
|}
<pre style="color:rgb(102,0,102);font-size:120%">\startxmlsetups btx:demo
\xmlcommand
{#1}
{/bibtex/entry[string.find(@tag,'Hagen')][1]}{btx:table}
\stopxmlsetups
</pre>
\startxmlsetups btx:table
\starttabulate[|||]
<br/>
Here is an­other ex­am­ple:
<pre style="color:rgb(102,0,102);font-size:120%">\startxmlsetups btx:row
\NC \xmlatt{#1}{tag}
\NC \xmlfirst{#1}{/field[@name='title']}
\NC \NR
\stopxmlsetups
</pre>
\startxmlsetups btx:demo
\xmlfilter {#1} {
<br/>
A more ex­ten­sive ex­am­ple is the fol­low­ing. Of course this as­sumes that you know what xml sup­port mech­a­nisms and macros are avail­able.
<pre style="color:rgb(102,0,102);font-size:120%">\startxmlsetups btx:getkeys
\xmladdsortentry{btx}{#1}{\xmlfilter{#1}{/field[@name='author']/text()}}
\xmladdsortentry{btx}{#1}{\xmlfilter{#1}{/field[@name='year' ]/text()}}
\xmladdsortentry{btx}{#1}{\xmlatt{#1}{tag}}
\stopxmlsetups
</pre>
\startxmlsetups btx:sorter
\xmlresetsorter{btx}

Navigation menu