2

Since I used an obsolete package in my previous question, I tried again with the correct one.

I load the database, make \cite use it, and define the \cite default style:

\startbuffer[main]
@Article {Foo2016, author = "Foo", title = "Text 1", year = "2016"}
@Article {Bar2017, author = "Bar", title = "Text 2", year = "2017"}
@Article {Baz2018, author = "Baz", title = "Text 3", year = "2018"}
\stopbuffer

\usebtxdataset[main][main.buffer]
\setupbtx[dataset=main] % make cite use this db by default
\setupbtx[default:cite][alternative=authoryear]

\starttext

Let’s cite a thing for the references at the end \cite[Bar2017].

Now I try to use Lua to create a new publist database containing copies of a few entries, and then render all of them:

\startsection[title={Manual DB}]
\startluacode
local current = publications.datasets.main
local mine = {"Foo2016", "Bar2017"}
local pub = publications.new("Publications")
for _, tag in ipairs(mine) do
    local entry = table.copy(current.luadata[tag])
    entry.index = publications.getindex(current, current.luadata, tag)
    pub.luadata[tag] = entry
end
print(table.serialize(pub.luadata))
publications.datasets["publist"] = pub
\stopluacode
\definebtxrendering[publist][apa][dataset=publist, numbering=yes]
\placebtxrendering[publist][method=database]
\stopsection

But to my surprise, even though the print line prints exactly what I would expect, the section stays empty. Why?

The main database renders fine:

Another citation which should show up below \cite[Baz2018].

\startsection[title={Traditional DB}]
\definebtxrendering[main][apa][dataset=main, sorttype=authoryear, numbering=no]
\placebtxrendering[main][method=global]
\stopsection

\stoptext

here’s the image showing that the “Manual DB” section stays empty while the “Traditional DB” section looks as expected

rendering

  • Just as the last question, this needs a MWE. – Henri Menke Oct 16 at 17:21
  • Are you sure you can get your main rendering to show up? You seem to be missing \usebtxdefinitions[apa], which I thought was necessary before referring to apa elsewhere. But this would clearer with a MWE. – ssokolen Oct 16 at 17:23
  • Also, I don't know enough about the underlying mechanisms to offer an answer, but it seems like when I try something similar to your code but replace publications.datasets["publist"] = pub with publications.datasets["publist"] = current, everything works fine. Which suggests that just copying over luadata is insufficient. Not sure what else you might need, but perhaps you can do a deepcopy first and then trim the entries you don't want as an alternative approach. – ssokolen Oct 16 at 17:27
  • @HenriMenke converted into a MWE. @ssokolen it works despite that part missing. I poured over the code but didn’t find where the code loading the dbs does anything other than calling getindex and adding to luadata. – flying sheep Oct 17 at 9:24

Your Answer

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

Browse other questions tagged or ask your own question.