TransWikia.com

Can one have year as bib labels for biblatex publist with plnumbered=false option?

TeX - LaTeX Asked by ss1789 on May 20, 2021

I’m using publist and would like to have lists of publications not numbered but formatted as in this question: Bibliography customization, year as bib label. MWE using publist is

documentclass{article}
usepackage[style=publist,boldyear=false,plnumbered=false,backend=biber,labeldateparts=false]{biblatex}
plauthorname[Gary]{Westfahl}
renewcommand{labelnamepunct}{addspace}
addbibresource{biblatex-examples.bib}    
begin{document}   
nocite{*}   
printbibliography[filter=mine]    
end{document}

yielding this result:
enter image description here
I’d like to have this
enter image description here
which is produced using the answer by gusbrs, based on the alphabetic style:

documentclass{article}

usepackage[style=alphabetic]{biblatex}

addbibresource{biblatex-examples.bib}

DeclareLabelalphaTemplate{
  labelelement{
    field[strwidth=4,strside=right]{year}
  }
}

defbibenvironment{bibliography}
  {list
     {printtext[labelalphawidth]{%
        printfield{labelprefix}%
        printfield{labelalpha}}}
     {setlength{labelwidth}{labelalphawidth}%
      setlength{leftmargin}{labelwidth}%
      setlength{labelsep}{biblabelsep}%
      addtolength{leftmargin}{labelsep}%
      setlength{itemsep}{bibitemsep}%
      setlength{parsep}{bibparsep}}%
      renewcommand*{makelabel}[1]{##1hss}}
  {endlist}
  {item}

renewbibmacro*{date}{%
    ifboolexpr{
        test {iffieldundef{month}}
        and
        test {iffieldundef{season}}
        }
    {}
    {printdate}}

renewbibmacro*{issue+date}{%
    ifboolexpr{
        test {iffieldundef{month}}
        and
        test {iffieldundef{season}}
        and
        test {iffieldundef{issue}}
        }
    {}
    {printtext[parens]{%
     printfield{issue}%
     setunit*{addspace}%
     printdate}}%
     newunit}

DeclareFieldFormat{labelalphawidth}{#1}

begin{document}

nocite{westfahl:space,westfahl:frontier}

printbibliography

end{document}

But I can’t see how to transpose it to publist. Nor, alas, do I see how to port moewe’s answer.

Thanks to moewe for his revised code on Bibliography customization, year as bib label; it now works perfectly!

But his answer to this question is just a tad short of fully working for my purposes.

One weird thing, changing the answer MWE to nocite{*} and running with latexmk I get an error:

! Illegal parameter number in definition of @tempb.
<to be read again> 
                   crcr 
l.327     endentry?
               

Letting latexmk run, the result has some entries run together. For example, wassenberg, herrmann & yoon appear together with year 2010.

Now, since as shown in the screenshot above I’d like no (round brackets) around the date I changed to DeclareFieldFormat{labeldatewidth}{#1}. I tried the author command plauthorname[Gary]{Westfahl} together with printbibliography[filter=mine], again with nocite{*}, with almost perfect results, except for an extra space, or “, ed.” for collections edited by only the cv author, right before the entry. Of course renewcommand{labelnamepunct}{} introduces the problem of omitting the needed space after publist’s “(Some Coeditor).”

One Answer

My fixed answer (thanks for the hint) to Bibliography customization, year as bib label is in principle also applicable to biblatex-publist, but it needs some slight modifications for the different macro names and calls of biblatex-publist. In particular biblatex-publist prints the date in bpl:year+labelyear, so we need to modify that bibmacro as well.

documentclass{scrartcl}

usepackage[style=publist]{biblatex}

DeclareFieldFormat{labeldatewidth}{mkbibparens{#1}}

makeatletter
defbibenvironment{bibliography}
  {list
     {printtext[labeldatewidth]{printlabeldate}}
     {setlength{labelwidth}{labeldatewidth}%
      setlength{leftmargin}{labelwidth}%
      setlength{labelsep}{biblabelsep}%
      addtolength{leftmargin}{labelsep}%
      setlength{itemsep}{bibitemsep}%
      setlength{parsep}{bibparsep}}%
      renewcommand*{makelabel}[1]{##1hss}}
  {endlist}
  {item}


renewbibmacro*{bpl:year+labelyear}{%
    iffieldundef{year}{%
        iffieldundef{pubstate}%
            {letbbx@lasthashundefined}%
            {%
             usebibmacro{bpl:date:labeldate+extradate}%
             savefield{pubstate}{bbx@lasthash}%
             clearfield{pubstate}%
            }%
    }{%
           ifboolexpr{
             test {iflabeldateisdate}
             and
             not test {ifdateshavedifferentprecision{label}{}}
           }
           {printunit{}}
           {usebibmacro{bpl:date:labeldate+extradate}}%
         savefield{year}{bbx@lasthash}%
         clearfield{year}%
    }%
}

renewbibmacro*{author}{%
    if@hlauthor
        ifnameundef{author}
            {}
            {%
             usebibmacro{bpl:marginyear}%
             printnames[][-value{listtotal}]{author}%
             setunit{addspace}%
             iffieldundef{nameaddon}
                 {}
                 {%
                  mkbibbrackets{%
                      bibstring{alias}%
                      addspaceprintfield{nameaddon}%
                  }%
                 }%
            }%
        adddotaddspaceusebibmacro{bpl:year+labelyear}%
    else% if@hlauthor false
        ifnameundef{author}
            {}
            {%
             usebibmacro{bpl:marginyear}%
             usebibmacro{bpl:year+labelyear}setunit{addspace}%
             printnames[][-value{listtotal}]{author}%
             setunit{addspace}%
             iffieldundef{nameaddon}
                 {}
                 {%
                  mkbibbrackets{%
                      bibstring{alias}%
                      addspaceprintfield{nameaddon}%
                  }%
                 }%
            }%
    fi% end of if@hlauthor else condition
}

renewbibmacro*{editor}{%
    if@hlauthor
        ifnameundef{editor}
            {}
            {%
             usebibmacro{bpl:marginyear}%
             printnames[][-value{listtotal}]{editor}%
             setunit{printdelim{editortypedelim}}%
             usebibmacro{editorstrg}%
            }%
            setunit{adddotaddspace}%
            usebibmacro{bpl:year+labelyear}%
            clearname{editor}%
    else% if@hlauthor false
        ifnameundef{editor}
            {}
            {%
             usebibmacro{bpl:marginyear}%
             usebibmacro{bpl:year+labelyear}%
             setunit{addspace}%
             printnames[][-value{listtotal}]{editor}%
             setunit{printdelim{editortypedelim}}%
             usebibmacro{editorstrg}%
             clearname{editor}%
            }%
    fi% end of if@hlauthor else condition
}

renewbibmacro*{editor+others}{%
    if@hlauthor
        ifboolexpr{
            test ifuseeditor
            and not test {ifnameundef{editor}}}
            {%
             usebibmacro{bpl:marginyear}%
             printnames[][-value{listtotal}]{editor}%
             setunit{printdelim{editortypedelim}}%
             usebibmacro{editor+othersstrg}%
             setunit{adddotaddspace}%
             usebibmacro{bpl:year+labelyear}%
             clearname{editor}%
            }
            {}%
    else% if@hlauthor false
        ifboolexpr{
            test ifuseeditor
            and not test {ifnameundef{editor}}}
            {%
             usebibmacro{bpl:marginyear}%
             usebibmacro{bpl:year+labelyear}%
             setunit{addspace}%
             printnames[][-value{listtotal}]{editor}%
             setunit{printdelim{editortypedelim}}%
             usebibmacro{editor+othersstrg}%
             clearname{editor}%
            }
            {}%
    fi% end of if@hlauthor else condition
}


newlength{labeldatewidth}
newlength{locallabeldatewidth}

apptoabx@dolabelwidths{do{labeldate}}

AtDataInput{%
  nottoggle{blx@skipbib}
    {begingroup
     blx@getlabeldata
     blx@setlabwidth{labeldatewidth}{%
       printtext[labeldatewidth]{printlabeldate}}%
     endgroup}
    {}}

AtEveryBibitem{%
  blx@setlabwidth{locallabeldatewidth}{%
     printtext[labeldatewidth]{printlabeldate}}}

newrobustcmd*{changedateformat}[2]{%
  csdef{blx@dateformat@#1date}{#2}%
  protectedcsdef{blx@imc@print#1date}{csuse{mkdaterange#2}{#1}}%
  protectedcsdef{blx@imc@print#1dateextra}{csuse{mkdaterange#2extra}{#1}}}
makeatletter



addbibresource{biblatex-examples.bib}

begin{document}
nocite{sigfridsson,worman,geer}

printbibliography
end{document}

Bibliography with date on the left in list margin.

Answered by moewe on May 20, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP