I solved it, although it's kinda hacky. I'm pretty sure that
publications.citevariants.short is not meant to be called directly.

Do you know why `context.getdetail(dataset, tag, "author")` does not work in 
render_cite?
It always returns nil.


```
\setupinteraction[state=start]

\startbuffer[testdata]
@Book{knuth1,
        author = {Donald E. Knuth},
        title = {TEX and METAFONT. New directions in typesetting},
        year = {1979},
        publisher = {Addison-Wesley},
}
@Article{someother,
        author = {Some Person and Some Otherperson},
        title = {Another title},
        year = {1900},
}
\stopbuffer

% enable tracing
\enabletrackers[publications, publications.crossref, publications.details, 
publications.cite, publications.strings]

\usebtxdataset[main][testdata.buffer]
\usebtxdefinitions[aps]
\setupbtx[dataset=main]
\definebtxrendering[bibrendering][aps][dataset=main, numbering=short]
\setupbtxlist[aps][
  alternative=b,
  distance=.5em,
]

\definebtx[aps:cite:special][aps:cite]
\startluacode
function render_cite(dataset, tag, righttext)
        local luadata = publications.datasets[dataset].luadata
        local entry = luadata[tag]
        local extrasign = ""
        if entry.author:lower():find("knuth") then
                extrasign = ">"
        end
        context("[" .. extrasign)
        print(righttext)
        publications.citevariants.short({dataset = dataset, reference = tag, 
variant = "short", righttext = righttext})
        context("]")
end
\stopluacode

\startsetups btx:aps:cite:special
        \btxcitereference
        \ctxlua{render_cite([==[\currentbtxdataset]==], [==[\currentbtxtag]==], 
[==[\currentbtxrighttext]==])}
\stopsetups
\setupbtx[aps:cite][alternative=special]

\starttext

\def\comma{,}

Knuth developed \TeX~\cite[knuth1]
Several persons said something~\cite[someother].

\placelistofpublications[bibrendering]

\stoptext
```

Gerion

Am Dienstag, 23. April 2024, 16:03:50 MESZ schrieb Gerion Entrup:
> Here is a solution for the first part of my question. This is based on
> https://www.mail-archive.com/ntg-context@ntg.nl/msg101156.html
> and try and error based on publ-imp-aps.mkvi and publ-imp-apa.mkvi:
> 
> It display now the citation _and_ numbering labels in the short form:
> ```
> \setupinteraction[state=start]
> 
> \startbuffer[testdata]
> @Book{knuth1,
>       author = {Donald E. Knuth},
>       title = {TEX and METAFONT. New directions in typesetting},
>       year = {1979},
>       publisher = {Addison-Wesley},
> }
> @Article{someother,
>       author = {Some Person and Some Otherperson},
>       title = {Another title},
>       year = {1900},
> }
> \stopbuffer
> 
> % enable tracing
> \enabletrackers[publications, publications.crossref, publications.details, 
> publications.cite, publications.strings]
> 
> \usebtxdataset[main][testdata.buffer]
> \usebtxdefinitions[aps]
> \setupbtx[dataset=main]
> \definebtxrendering[bibrendering][aps][dataset=main, numbering=short]
> \setupbtxlist[aps][
>   alternative=b,
>   distance=.5em,
> ]
> \setupbtx[aps:cite][alternative=short]
> 
> \starttext
> 
> Knuth developed \TeX \cite[knuth1]
> Several persons said something \cite[someother].
> 
> \placelistofpublications[bibrendering]
> 
> \stoptext
> ```
> 
> The remaining part now is to mark publications of Knuth in a different way.
> I have tried this and failed. Here is my code so far:
> ```
> \startluacode
> function render_cite(short, author)
>       print(author)
>       if author:lower():find("knuth") then
>               context("[>" .. short .. "]")
>       else
>               context("[" .. short .. "]")
>       end
> end
> \stopluacode
> \definebtx[aps:cite:special][aps:cite]
> \startsetups btx:aps:cite:special
>       \btxcitereference
>       \ctxlua{render_cite([==[\btxflush{year}]==], [==[\btxflush{author}]==])}
> \stopsetups
> % use it with \cite[special][knuth1]
> ```
> This has several problems:
> - \btxflush{short} does not work as I expected that. How can I get the short 
> form?
> - \btxflush to pass arguments to lua does not work as intended. On the lua 
> side the
>    variable "author" resolves to "\btxflushauthor{author}" and not to "D. E. 
> Knuth".
>    How can I pass the data?
> 
> I use Lua only because I find it more convenient as a programming language. 
> If a
> plain tex solution is simpler, I'm happy to use that. 
> 
> 
> Another question that came up while studying the source code:
> What effect have \c!, \s!, and \v!? These commands exist a lot in the above
> cited files.
> 
> Gerion
> 
> 
> Am Mittwoch, 17. April 2024, 15:44:12 MESZ schrieb Gerion Entrup:
> > Hi,
> > 
> > > The APS style is an example of a number-based citation system. As you
> > > are looking for a tag-based citation, it might be better to start with
> > > something like the APA style.
> > 
> > I'm kind of satisfied with the publication-list layout of the APS style so 
> > I chose
> > this as a base. If it is simpler to start with the APA style, I can do that.
> > 
> > My hope is that it is possible to just change the "label" that is used for
> > referencing and keep everything else as is.
> > 
> > > Is there some specification for your short tag-based citation style?
> > 
> > biblatex implements this with the "alphabetic" style. I'm not aware of
> > a specification, though. Does the "short" form in ConTeXt exist for a
> > specific reason? :)
> > 
> > Gerion
> > 
> > > On Tue, 16 Apr 2024 06:04:35 +0200
> > > Gerion Entrup <gerion.ent...@flump.de> wrote:
> > > 
> > > > Hi,
> > > > 
> > > > I'm trying to customize a cite format in a bibliography. Currently,
> > > > I'm using the aps style which fits so far, except of the plain number
> > > > as reference. In concrete, I want to change the following:
> > > > - Use the first letter of the last name and the year as reference
> > > > (this should be exactly the short form). It is more less also
> > > > described here [1].
> > > > - Highlight publications of a certain author with an extra char (e.g.
> > > > '>')
> > > > 
> > > > Here is a minimal example (lets assume, every occurrence of Knuth
> > > > should be highlighted): ```
> > > > \setupinteraction[state=start]
> > > > 
> > > > \startbuffer[testdata]
> > > > @Book{knuth1,
> > > >         author = {Donald E. Knuth},
> > > >         title = {TEX and METAFONT. New directions in typesetting},
> > > >         year = {1979},
> > > >         publisher = {Addison-Wesley},
> > > > }
> > > > @Article{someother,
> > > >         author = {Some Person and Some Otherperson},
> > > >         title = {Another title},
> > > >         year = {1900},
> > > > }
> > > > \stopbuffer
> > > > 
> > > > % enable tracing
> > > > \enabletrackers[publications, publications.crossref,
> > > > publications.details, publications.cite, publications.strings]
> > > > 
> > > > \usebtxdataset[main][testdata.buffer]
> > > > \usebtxdefinitions[aps]
> > > > \setupbtx[dataset=main]
> > > > \definebtxrendering[bibrendering][aps][dataset=main]
> > > > 
> > > > % this seems to have no effect?
> > > > \setupbtx[alternative=short]
> > > > 
> > > > \starttext
> > > > 
> > > > Knuth developed \TeX \cite[knuth1].
> > > > Several persons said something \cite[someother].
> > > > 
> > > > \placelistofpublications[bibrendering]
> > > > 
> > > > \stoptext
> > > > ```
> > > > 
> > > > It should be rendered as:
> > > > ```
> > > > Knuth developed TeX [>Knu79].
> > > > Several persons said something [PO00].
> > > > 
> > > > [Knu79] D.E. Knuth, TEX and METAFONT. New directions in
> > > > typesetting (Addi­son-Wesley, 1979). [PO00]     S. Person and S.
> > > > Otherperson, Another title, (1900). ```
> > > > 
> > > > How can I achieve that \cite[something] always renders in the short
> > > > form by default? How can I customize that references to Knuth contain
> > > > this extra '>'? How can I customize the APS style to also use the
> > > > short form in the list of publications instead of numbers?
> > > > 
> > > > Best
> > > > Gerion
> > > > 
> > > > [1]
> > > > https://tex.stackexchange.com/questions/295444/citation-style-with-first-letters-of-authors-lastname
> 

Attachment: signature.asc
Description: This is a digitally signed message part.

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

Reply via email to