Coder Social home page Coder Social logo

Comments (15)

jspitz avatar jspitz commented on September 28, 2024

This was by accident. Fixed for the net release.

from biblatex-publist.

moewew avatar moewew commented on September 28, 2024

Thank you very much for the quick response and fix.

from biblatex-publist.

jspitz avatar jspitz commented on September 28, 2024

Actually, @moewew, since you are around: Is there a better way to achieve what I am hacking here? I.e. give an extradate suffix for all works of an author within a year, also if the co-authors differ?

I am aware of \DeclareExtraDate, but this does not seem to cover scopes above year.

from biblatex-publist.

moewew avatar moewew commented on September 28, 2024

I don't think so. The extradate field is always calculated for a labelname+labeldate combination. In practice that means that all works must have the same labelname to be lumped together for extradate. Writing to shortauthor is a straightforward solution. A much more complicated alternative would be to use a custom name field so as to not overwrite shortauthor, but that does not solve a lot of issues. Unlike \DeclareLabeldate \DeclareLabelname does not support literal input (plk/biblatex#334), which would allow you to ditch the sourcemap for a \DeclareLabelname definition.

\DeclareExtraDate is a bit of a misnomer, it should probably have been called \DeclareExtraDateDateScope or the like, but that sounds odd. (Unfortunately I'm only good at coming up with reasons why I think existing names are confusing and not nearly as good at coming up with good names in the first place.)

In theory you could also calculate the extradate yourself in \AtDataInput, if you only need to take into account the year that should be doable. If you need to take into account more complicated name dependencies (and uniqueness etc.), though, that will get messy quickly.

from biblatex-publist.

jspitz avatar jspitz commented on September 28, 2024

\DeclareExtraDate is a bit of a misnomer, it should probably have been called \DeclareExtraDateDateScope or the like, but that sounds odd.

\DeclareExtraDateScopes?

In theory you could also calculate the extradate yourself in \AtDataInput, if you only need to take into account the year that should be doable. If you need to take into account more complicated name dependencies (and uniqueness etc.), though, that will get messy quickly.

Could you elaborate on this a bit more? I don't need to account for name dependencies or uniquenesses, so I am interested whether this would improve things.

Anyway, thanks for the detailed explanation.

from biblatex-publist.

moewew avatar moewew commented on September 28, 2024

It doesn't improve things much: The only advantage of the approach is that we don't botch the labelname field.

This is just a proof of concept, it does not deal with negative years (probably not that important for a list of publications, but who knows) and other date properties such as 'uncertain' or 'circa'.

The order of extradate follows the sorting order.

\documentclass[british]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{csquotes}

\usepackage[style=authoryear, backend=biber]{biblatex}

\makeatletter
\AtDataInput{%
  \edef\blxpublist@tempfakeextradate{%
    blxpublist@fakeextradate@\the\c@refsection
    @\thefield{\thefield{labledatesource}year}}%
  \ifcsundef{\blxpublist@tempfakeextradate}
    {\csnumdef{\blxpublist@tempfakeextradate}{0}}
    {}%
  \csnumgdef{\blxpublist@tempfakeextradate}{%
    \csuse{\blxpublist@tempfakeextradate}+1}%
  % overwrite extradate with our faked version
  \blx@bbl@addfield{extradate}{\csuse{\blxpublist@tempfakeextradate}}%
}
\makeatother

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@book{1980:a,
  author = {Anne Elk},
  title  = {A},
  date   = {1980},
}
@book{1980:b,
  author = {Anne Elk},
  title  = {B},
  date   = {1980},
}
@book{1980:c,
  author = {Anne Celk},
  title  = {C},
  date   = {1980},
}
@book{1981:a,
  author = {Anne Elk},
  title  = {A},
  date   = {1981},
}
@book{1981:b,
  author = {Anne Belk},
  title  = {B},
  date   = {1981},
}
@book{1982:b,
  author = {Emma Sigfridsson},
  title  = {B},
  date   = {1982},
}
\end{filecontents}

\addbibresource{\jobname.bib}

\nocite{*}
\begin{document}
\printbibliography
\end{document}

from biblatex-publist.

jspitz avatar jspitz commented on September 28, 2024

OK, thank you. This does seem to append the extra label always (also if only one item per year exists).

from biblatex-publist.

moewew avatar moewew commented on September 28, 2024

Ah yes, I forgot about that. You'd have to loop over all entries again after that is done and delete the entries for those where the counter stayed at 1. Probably not worth the effort since you don't gain a lot.

from biblatex-publist.

jspitz avatar jspitz commented on September 28, 2024

I see. Thanks. I'll leave things as they are for the time being.

from biblatex-publist.

moewew avatar moewew commented on September 28, 2024

It is possible, but I doubt that it is wort it:

\documentclass[british]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{csquotes}

\usepackage[style=authoryear, backend=biber]{biblatex}

\makeatletter
\AtDataInput{%
  \ifcsundef{blxpublist@extradateentries@\the\c@refsection}
    {\global\cslet{blxpublist@extradateentries@\the\c@refsection}\@empty}
    {}%
  \listcsxadd{blxpublist@extradateentries@\the\c@refsection}{\thefield{entrykey}}%
  \edef\blxpublist@tempfakeextradate{%
    blxpublist@fakeextradate@\the\c@refsection
    @\thefield{\thefield{labledatesource}year}}%
  \ifcsundef{\blxpublist@tempfakeextradate}
    {\csnumdef{\blxpublist@tempfakeextradate}{0}}
    {}%
  \csnumgdef{\blxpublist@tempfakeextradate}{%
    \csuse{\blxpublist@tempfakeextradate}+1}%
  % overwrite extradate with our faked version
  \blx@bbl@addfield{extradate}{\csuse{\blxpublist@tempfakeextradate}}%
}

\long\def\blx@bbl@undeffield#1{%
  \csxappto\blx@bbl@data{%
    \undef\expandafter\noexpand\csname abx@field@#1\endcsname}}

\def\blxpublist@clearuniqueextradate#1{%
  \edef\blx@bbl@data{blx@data@\the\c@refsection @\blx@refcontext@context @#1}%
  \entrydata{#1}{%
    \ifnumgreater{%
      \csuse{%
        blxpublist@fakeextradate@\the\c@refsection
        @\thefield{\thefield{labledatesource}year}}}{1}
      {}
      {\blx@bbl@undeffield{extradate}}%
  }%
}

\appto\blx@bblend{%
  \forlistcsloop
    {\blxpublist@clearuniqueextradate}
    {blxpublist@extradateentries@\the\c@refsection}}
\makeatother

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@book{1980:a,
  author = {Anne Elk},
  title  = {A},
  date   = {1980},
}
@book{1980:b,
  author = {Anne Elk},
  title  = {B},
  date   = {1980},
}
@book{1980:c,
  author = {Anne Celk},
  title  = {C},
  date   = {1980},
}
@book{1981:a,
  author = {Anne Elk},
  title  = {A},
  date   = {1981},
}
@book{1981:b,
  author = {Anne Belk},
  title  = {B},
  date   = {1981},
}
@book{1982:b,
  author = {Emma Sigfridsson},
  title  = {B},
  date   = {1982},
}
\end{filecontents}

\addbibresource{\jobname.bib}

\nocite{*}
\begin{document}
\printbibliography
\end{document}

Since this changes the normal behaviour of extradate the status quo that also visibly changes the labelname has the advantage that it is a warning to users that things might not be as expected. So I think it is a good idea to leave things as they are for now.

from biblatex-publist.

jspitz avatar jspitz commented on September 28, 2024

@moewew I'm coming back to this due to #36. Is it possible to:

  1. move existing shortauthor fields to, say, xshortauthor
  2. then populate shortauthor with the dummy value (as I already do)
  3. and finally, after the extradate has been generated, remove the shortauthor dummy values again and, where applicable, move back xshortauthor to shortauthor?

I know that 1. and 2. is doable via SourceMap. I figure that 3. could be doable within \blx@bblend, but I don't know exactly how. I figure this could resolve #36 while keeping the modified extradate.

from biblatex-publist.

moewew avatar moewew commented on September 28, 2024

The "moving back" would have to happen on the LaTeX side. Theoretically that is possible in \AtDataInput, but that does not solve all problems, since Biber also notes down which field it used for labelname in labelnamesource. This will always be shortauthor if it is set, but we cannot recover the "correct" labelnamesource value ignoring shortauthor without going through the steps Biber went through to compute it in the first place.

So things break down in the following example

\documentclass[british]{article}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage{csquotes}

\usepackage[backend=biber, style=authoryear]{biblatex}

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map[overwrite]{
      \step[fieldsource=shortauthor, final]
      \step[fieldset=namea, origfieldval]
    }
    \map[overwrite]{
      \step[fieldset=shortauthor, fieldvalue={1111}]
    }
  }
}

\makeatletter
\AtDataInput{%
  \csgappto\blx@bbl@data{%
    \let\c@shortauthor\c@namea
    \let\abx@name@shortauthor\abx@name@namea
    \ifdefstring\abx@field@labelnamesource{shortauthor}
      {\ifundef\abx@name@shortauthor
         {\def\abx@field@labelnamesource{author}}
         {}}
      {}}}
\makeatother

\addbibresource{biblatex-examples.bib}

\begin{document}
Lorem \autocite{sigfridsson}

ipsum \autocite{westfahl:frontier}

\printbibliography
\end{document}

from biblatex-publist.

jspitz avatar jspitz commented on September 28, 2024

Thank you so much, @moewew. I see. However, if we extend the method to editor, it might still not be perfect, but maybe just
"good enough" (TM) and definitely better that what we have?

\AtDataInput{%
	\csgappto\blx@bbl@data{%
		\let\c@shortauthor\c@namea
		\let\abx@name@shortauthor\abx@name@namea
		\ifdefstring\abx@field@labelnamesource{shortauthor}
		{\ifundef\abx@name@shortauthor
			{\ifundef\abx@name@author
				{\def\abx@field@labelnamesource{editor}}
				{\def\abx@field@labelnamesource{author}}}
			{}}
		{}}}

from biblatex-publist.

moewew avatar moewew commented on September 28, 2024

You can make this arbitrarily complicated, yes. But \DeclareLabelname is user-definable and I don't see a way to respond to that. If your users redefine the labelname generation this hard-coded order might lead to confusion.

from biblatex-publist.

jspitz avatar jspitz commented on September 28, 2024

Sure, but since publist is not meant for citing, I think the risk is rather low. And without this hack, even basic citing without labelname redefinition will lead to confusion.

I don't see an alternative to hacking as long as biblatex doesn't provide a native way to have extradate disambiguation that disregards co-authors (which is to be expected in publication list of the omit sort).

from biblatex-publist.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.