Open main menu

Changes

1,208 bytes removed ,  19:20, 16 January 2014
no edit summary
 
==The data­base==
</pre>
this gives:
{| |+  |
tag
| |
cat­e­gory
| |
fields
| |+  |
demo-001
| |
book
| |
au­thor in­dex ti­tle year
| |+  |
demo-002
| |
book
| |
cross­ref in­dex year
| |+  |
demo-003
| |
book
| |
au­thor com­ment in­dex ti­tle year
| |+  |
demo-004
| |
book
| |
au­thor com­ment in­dex ti­tle year
| |+  |
demo-005
| |
book
| |
au­thor doi in­dex pages se­r­ial ti­tle url year
| |} 
<br/>
You can set the cur­rent ac­tive 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 ex­act ren­der­ing of list en­tries is de­ter­mined by the <tt>alternative</tt> key and de­faults to <tt>apa</tt> which uses de­f­i­n­i­tions from <tt>publ-imp-apa.mkiv</tt>. If you look at that file you will see that each cat­e­gory has its own setup. You may also no­tice that ad­di­tional tests are needed to make sure that empty fields don’t trig­ger sep­a­ra­tors and such.
<br/>
There are three com­mands to flush data:
{| |+  |
<tt>\btxfield</tt>
| |
fetch a ex­plicit field (e.g. <tt>year</tt>)
| |+  |
<tt>\btxdetail</tt>
| |
fetch a de­rived field (e.g. <tt>short</tt>)
| |+  |
<tt>\btxflush</tt>
| |
fetch a de­rived or ex­plicit field
| |} 
<br/>
Nor­mally you can use <tt>\btxfield</tt> or <tt>\btxflush</tt> as de­rived fields just like an­a­lyzed au­thor fields are flushed in a spe­cial way.
<br/>
Keep in mind that nor­mally you don’t need to mess with de­f­i­n­i­tions like this be­cause stan­dard ren­der­ing styles are pro­vided. These styles use a few helpers that in­ject sym­bols but also take care of lead­ing and trail­ing spaces:
{| |+  |
<tt>\btxspace</tt>
| |
be­fore af­ter
| |+  |
<tt>\btxperiod</tt>
| |
be­fore. af­ter
| |+  |
<tt>\btxcomma</tt>
| |
be­fore, af­ter
| |+  |
<tt>\btxlparent</tt>
| |
be­fore (af­ter
| |+  |
<tt>\btxrparent</tt>
| |
be­fore) af­ter
| |+  |
<tt>\btxlbracket</tt>
| |
be­fore [af­ter
| |+  |
<tt>\btxrbracket</tt>
| |
be­fore] af­ter
| |} 
<br/>
So, the pre­vi­ous ex­am­ple setup can be rewrit­ten as:
<br/>
You can use a (con­fig­urable) de­fault or pass di­rec­tives: Valid di­rec­tives are
{| |+  |
con­ver­sion
| |
ren­der­ing
| |+  |
<tt>inverted</tt>
| |
the Frog jr, Ker­mit
| |+  |
<tt>invertedshort</tt>
| |
the Frog jr, K
| |+  |
<tt>normal</tt>
| |
Ker­mit, the Frog, jr
| |+  |
<tt>normalshort</tt>
| |
K, the Frog, jr
| |} 
<br/>
There is a whole bunch of cite op­tions and more can be eas­ily de­fined.
{| |+  |
key
| |
ren­der­ing
| |+  |
<tt>author</tt>
| |
(au­thor)
| |+  |
<tt>authornum</tt>
| |
[au­thor [btx er­ror 1]]
| |+  |
<tt>authoryear</tt>
| |
(au­thor (year))
| |+  |
<tt>authoryears</tt>
| |
(au­thor, year)
| |+  |
<tt>doi</tt>
| |
[todo: doi]
| |+  |
<tt>key</tt>
| |
[demo-005]
| |+  |
<tt>none</tt>
||
|  | |+  |
<tt>num</tt>
| |
[[btx er­ror 1]]
| |+  |
<tt>page</tt>
| |
pages
| |+  |
<tt>serial</tt>
| |
[5]
| |+  |
<tt>short</tt>
| |
[aut00]
| |+  |
<tt>type</tt>
| |
[book]
| |+  |
<tt>url</tt>
| |
[todo: url]
| |+  |
<tt>year</tt>
| |
(year)
| |} 
<br/>
Be­cause we are deal­ing with data­base in­put and be­cause we gen­er­ally need to ma­nip­u­late en­tries, much of the work is del­e­gated to Lua. This makes it eas­ier to main­tain and ex­tend the code. Of course TEX still does the ren­der­ing. The ty­po­graphic de­tails are con­trolled by pa­ra­me­ters but not all are used in all vari­ants. As with most ConTEXt com­mands, it starts out with a gen­eral setup com­mand:
<br/>
<tt>setupbtxcitevariant : author</tt>
{| |+  |
<tt>right</tt>
| |
<tt>)</tt>
| |+  |
<tt>middle</tt>
| |
<tt>, </tt>
| |+  |
<tt>left</tt>
| |
<tt>(</tt>
| |} 
<br/>
<tt>setupbtxcitevariant : authornum</tt>
{| |+  |
<tt>right</tt>
| |
<tt>]</tt>
| |+  |
<tt>middle</tt>
| |
<tt>, </tt>
| |+  |
<tt>left</tt>
| |
<tt>[</tt>
| |} 
<br/>
<tt>setupbtxcitevariant : authoryear</tt>
{| |+  |
<tt>compress</tt>
| |
<tt>yes</tt>
| |+  |
<tt>inbetween</tt>
| |
<tt>, </tt>
| |+  |
<tt>right</tt>
| |
<tt>)</tt>
| |+  |
<tt>middle</tt>
| |
<tt>, </tt>
| |+  |
<tt>left</tt>
| |
<tt>(</tt>
| |} 
<br/>
<tt>setupbtxcitevariant : authoryears</tt>
{| |+  |
<tt>compress</tt>
| |
<tt>yes</tt>
| |+  |
<tt>inbetween</tt>
| |
<tt>, </tt>
| |+  |
<tt>right</tt>
| |
<tt>)</tt>
| |+  |
<tt>middle</tt>
| |
<tt>, </tt>
| |+  |
<tt>left</tt>
| |
<tt>(</tt>
| |} 
<br/>
<tt>setupbtxcitevariant : doi</tt>
{| |+  |
<tt>right</tt>
| |
<tt>]</tt>
| |+  |
<tt>left</tt>
| |
<tt>[</tt>
| |} 
<br/>
<tt>setupbtxcitevariant : key</tt>
{| |+  |
<tt>right</tt>
| |
<tt>]</tt>
| |+  |
<tt>left</tt>
| |
<tt>[</tt>
| |} 
<br/>
<tt>setupbtxcitevariant : none</tt>
{| |+  |
<tt>no specific settings</tt>
| |  | |}
||}
<br/>
<tt>setupbtxcitevariant : num</tt>
{| |+  |
<tt>compress</tt>
| |
<tt>yes</tt>
| |+  |
<tt>inbetween</tt>
| |
<tt>--</tt>
| |+  |
<tt>right</tt>
| |
<tt>]</tt>
| |+  |
<tt>left</tt>
| |
<tt>[</tt>
| |} 
<br/>
<tt>setupbtxcitevariant : page</tt>
{| |+  |
<tt>inbetween</tt>
| |
<tt>–</tt>
| |} 
<br/>
<tt>setupbtxcitevariant : serial</tt>
{| |+  |
<tt>right</tt>
| |
<tt>]</tt>
| |+  |
<tt>left</tt>
| |
<tt>[</tt>
| |} 
<br/>
<tt>setupbtxcitevariant : short</tt>
{| |+  |
<tt>right</tt>
| |
<tt>]</tt>
| |+  |
<tt>left</tt>
| |
<tt>[</tt>
| |} 
<br/>
<tt>setupbtxcitevariant : type</tt>
{| |+  |
<tt>right</tt>
| |
<tt>]</tt>
| |+  |
<tt>left</tt>
| |
<tt>[</tt>
| |} 
<br/>
<tt>setupbtxcitevariant : url</tt>
{| |+  |
<tt>right</tt>
| |
<tt>]</tt>
| |+  |
<tt>left</tt>
| |
<tt>[</tt>
| |} 
<br/>
<tt>setupbtxcitevariant : year</tt>
{| |+  |
<tt>right</tt>
| |
<tt>)</tt>
| |+  |
<tt>left</tt>
| |
<tt>(</tt>
| |} 
A ci­ta­tion vari­ant is de­fined in sev­eral steps and if you re­ally want to know the dirty de­tails, you should look into the <tt>publ-imp-*.mkiv</tt> files. Here we stick to the con­cept.
<pre detail='typing'>\startsetups btx:cite:author
<br/>
This re­sults in:
{| |+  |
<tt>demo-001</tt>
| |
Hag13
| |
bibTEX, the ConTEXt way
| |+  |
<tt>demo-002</tt>
| |
Hag14
| |
bibTEX, the ConTEXt way
| |+  |
<tt>demo-003</tt>
| |
HO96
| |
Type­set­ting ed­u­ca­tion doc­u­ments
| |+  |
<tt>demo-004</tt>
| |
Sca21
| |
De­sign­ing high speed trains
| |+  |
<tt>demo-005</tt>
| |
aut00
| |
ti­tle
| |} 
\stoptabulate
</pre>
{| |+  |
<tt>tag</tt>
| |
Ha­gen:TB17-1-54
| |+  |
<tt>title</tt>
| |
PPCHTEX: type­set­ting chem­i­cal for­mu­las in TEX
| |} 
<pre detail='buffer'>\startxmlsetups btx:demo
\xmlcommand
\xmlsetup{btx:tugboat}{btx:demo}
{| |+  |
<tt>tag</tt>
| |
Ha­gen:TB17-1-54
| |+  |
<tt>title</tt>
| |
PPCHTEX: type­set­ting chem­i­cal for­mu­las in TEX
| |} 
<br/>
Here is an­other ex­am­ple:
\stoptabulate
{| |+  |
Knuth:TB10-1-31
| |
Type­set­ting Con­crete Math­e­mat­ics
| |+  |
Knuth:TB10-1-8
| |
TEX would find it dif­fi­cult …
| |+  |
Knuth:TB10-3-325
| |
The new ver­sions of TEX and MF
| |+  |
Knuth:TB10-4-529
| |
The er­rors of TEX
| |+  |
Knuth:TB11-1-13
| |
Vir­tual Fonts: More Fun for Grand Wiz­ards
| |+  |
Knuth:TB11-2-165
| |
Ex­er­cises for TEX: The Pro­gram
| |+  |
Knuth:TB11-4-489
| |
The fu­ture of TEX and MF
| |+  |
Knuth:TB11-4-497
| |
Arthur Lee Samuel, 1901--1990
| |+  |
Knuth:TB11-4-499
| |
An­swers to Ex­er­cises for TEX: The Pro­gram
| |+  |
Knuth:TB12-2-313
| |
Fixed-point glue set­ting: Er­rata
| |+  |
Knuth:TB14-4-387
| |
Icons for TEX and MF
| |+  |
Knuth:TB17-1-29
| |
Im­por­tant mes­sage re­gard­ing CM fonts
| |+  |
Knuth:TB2-3-5
| |
The cur­rent state of things
| |+  |
Knuth:TB3-1-10
| |
Fixed-point glue set­ting­Dash an ex­am­ple of WEB
| |+  |
Knuth:TB31-2-121
| |
An Earth­shak­ing An­nounce­ment
| |+  |
Knuth:TB4-2-64
| |
A note on hy­phen­ation
| |+  |
Knuth:TB5-1-4
| |
TEX in­cunab­ula
| |+  |
Knuth:TB5-1-67
| |
Com­ments on qual­ity in pub­lish­ing
| |+  |
Knuth:TB5-2-105
| |
A course on MF pro­gram­ming
| |+  |
Knuth:TB6-1-36
| |
Recipes and frac­tions
| |+  |
Knuth:TB7-2-101
| |
The TEX logo in var­i­ous fonts
| |+  |
Knuth:TB7-2-95
| |
Re­marks to cel­e­brate the pub­li­ca­tion of Com­put­ers & Type­set­ting
| |+  |
Knuth:TB8-1-14
| |
Mix­ing right-to-left texts with left-to-right texts
| |+  |
Knuth:TB8-1-6
| |
It hap­pened: an­nounce­ment of TEX 2.1
| |+  |
Knuth:TB8-1-73
| |
Prob­lem for a Sat­ur­day af­ter­noon
| |+  |
Knuth:TB8-2-135
| |
Fonts for dig­i­tal halftones
| |+  |
Knuth:TB8-2-210
| |
Sat­ur­day morn­ing prob­lem­Dash so­lu­tion
| |+  |
Knuth:TB8-2-217
| |
Re­ply: Print­ing out se­lected pages
| |+  |
Knuth:TB8-3-309
| |
Macros for Jill
| |+  |
Knuth:TB9-2-152
| |
A Punk Meta-Font
| |} 
<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.
\xmlsetup{btx:tugboat}{btx:sorter}
{| |+  |
1984
| |
Knuth:TB5-1-67
| |
Don Knuth
| |+  |
1984
| |
Knuth:TB5-1-4
| |
Don­ald E. Knuth
| |+  |
1984
| |
Knuth:TB5-2-105
| |
Don­ald E. Knuth
| |+  |
1985
| |
Knuth:TB6-1-36
| |
Don­ald E. Knuth
| |+  |
1986
| |
Knuth:TB7-2-101
| |
Don­ald E. Knuth
| |+  |
1987
| |
Knuth:TB8-2-135
| |
Don­ald E. Knuth
| |+  |
1987
| |
Knuth:TB8-3-309
| |
Don­ald E. Knuth
| |+  |
1988
| |
Knuth:TB9-2-152
| |
Don­ald E. Knuth
| |+  |
1989
| |
Knuth:TB10-3-325
| |
Don­ald E. Knuth
| |+  |
1989
| |
Knuth:TB10-4-529
| |
Don­ald E. Knuth
| |+  |
1990
| |
Knuth:TB11-4-489
| |
Don­ald E. Knuth
| |+  |
1993
| |
Knuth:TB14-4-387
| |
Don­ald E. Knuth
| |+  |
1996
| |
Knuth:TB17-1-29
| |
Don­ald E. Knuth
| |+  |
1987
| |
Knuth:TB8-1-14
| |
Don­ald Knuth and Pierre MacKay
| |+  |
1981
| |
Knuth:TB2-3-5
| |
Don­ald Knuth
| |+  |
1982
| |
Knuth:TB3-1-10
| |
Don­ald Knuth
| |+  |
1983
| |
Knuth:TB4-2-64
| |
Don­ald Knuth
| |+  |
1986
| |
Knuth:TB7-2-95
| |
Don­ald Knuth
| |+  |
1987
| |
Knuth:TB8-1-6
| |
Don­ald Knuth
| |+  |
1987
| |
Knuth:TB8-1-73
| |
Don­ald Knuth
| |+  |
1987
| |
Knuth:TB8-2-210
| |
Don­ald Knuth
| |+  |
1987
| |
Knuth:TB8-2-217
| |
Don­ald Knuth
| |+  |
1989
| |
Knuth:TB10-1-8
| |
Don­ald Knuth
| |+  |
1989
| |
Knuth:TB10-1-31
| |
Don­ald Knuth
| |+  |
1990
| |
Knuth:TB11-1-13
| |
Don­ald Knuth
| |+  |
1990
| |
Knuth:TB11-2-165
| |
Don­ald Knuth
| |+  |
1990
| |
Knuth:TB11-4-497
| |
Don­ald Knuth
| |+  |
1990
| |
Knuth:TB11-4-499
| |
Don­ald Knuth
| |+  |
1991
| |
Knuth:TB12-2-313
| |
Don­ald Knuth
| |+  |
2010
| |
Knuth:TB31-2-121
| |
Don­ald Knuth
| |} 
<br/>
The orig­i­nal data is stored in a Lua ta­ble, hashed by tag. Start­ing with Lua 5.2 each run of Lua gets a dif­fer­ent or­der­ing of such a hash. In older ver­sions, when you looped over a hash, the or­der was un­de­fined, but the same as long as you used the same bi­nary. This had the ad­van­tage that suc­ces­sive runs, some­thing we of­ten have in doc­u­ment pro­cess­ing gave con­sis­tent re­sults. In to­day’s Lua we need to do much more sort­ing of hashes be­fore we loop, es­pe­cially when we save multi--pass data. It is for this rea­son that the xml tree is sorted by hash key by de­fault. That way lookups (es­pe­cially the first of a set) give con­sis­tent out­comes.