TeX - LaTeX Asked by belyplatula on July 24, 2021
I can use a bibliography style by specifying it in the usepackage
invocation:
usepackage[style=alphabetic]{biblatex}
And then I print it with
printbibliography
However I have some extra citations with a keyword = {recommended}
which I can print separately in printbibliography
with a filter. So far so good. Can I set the bibliography style reading
to a specific printbibliography
scope even though the global setting is alphabetic
?
Something like
printbibliography[title={Citations},notkeyword=recommended]
{
% Somehow set style=reading here
printbibliography[title={Further reading},keyword=recommended]
}
In general it is not possible to use different styles for different priontbibliography
calls in a document, but very often it is possible to emulate the behaviour.
The following solution emulates the reading list by copying all the relevant definitions from reading.bbx
. Then it is just a question of when these definitions are executed, because some settings are used by both bibliographies. Luckily, here all problematic definitions could be delayed until the last minute and there are no clashes. This may not always be possible and in those cases we may have to rename macros or work around this differently.
documentclass[british]{article}
usepackage[T1]{fontenc}
usepackage{babel}
usepackage{csquotes}
usepackage[backend=biber, style=alphabetic]{biblatex}
makeatletter
InitializeBibliographyStyle{%
globalundefbbx@lasthash}
defbibenvironment{readingbib}
{mkreadingbib
list
{}
{setlength{leftmargin}{0pt}%
setlength{itemindent}{0pt}%
setlength{itemsep}{bibitemsep}%
setlength{parsep}{bibparsep}}}
{endlist}
{bbx@item}
defbbx@item@false{%
itemsep2bibitemsep
itemrelax
itemsepbibitemsep}
defbbx@item@true{%
bbx@item@full}
defbbx@item@full{%
itemsep2bibitemsep
@itempenaltyz@
itemrelax
begingroup
samepagebfseries
deffinentrypunct{strut}%
usebibmacro{entryhead:full}%
ifbool{bbx:entrykey}
{defnewblockpunct{%
nobreakhskipz@skipstrut
hfillpenalty100hskip1emrelax
hbox{}nobreakhfillstrut}%
deffinentrypunct{%
parfillskipz@finalhyphendemeritsz@
parnobreak}%
newblock
printfield{entrykey}}
{}%
finentry
endgroup
hrule height 1.25ptrelax
itemsepbibitemsep
@itempenalty@M
itemstrut
@itempenaltyz@}
defbbx@item@name{%
iffieldequals{fullhash}{bbx@lasthash}
{bbx@item@false}
{itemsep2bibitemsep
@itempenaltyz@
itemrelax
begingroup
samepagebfseries
deffinentrypunct{strut}%
usebibmacro{entryhead:name}%
finentry
endgroup
hrule height 1.25ptrelax
itemsepbibitemsep
@itempenalty@M
itemstrut
@itempenaltyz@}}
newbool{bbx:entrykey}
newbool{bbx:annotation}
newbool{bbx:abstract}
newbool{bbx:library}
newbool{bbx:file}
DeclareBiblatexOption{global,type,entry}[boolean]{entryhead}[true]{%
ifcsdef{bbx@item@#1}
{letcsbbx@item{bbx@item@#1}}
{PackageError{biblatex}
{Invalid option 'header=#1'}
{Valid values: header=true, false, full, name.}}}
DeclareBiblatexOption{global,type,entry}[boolean]{entrykey}[true]{%
setbool{bbx:entrykey}{#1}}
DeclareBiblatexOption{global,type,entry}[boolean]{annotation}[true]{%
setbool{bbx:annotation}{#1}}
DeclareBiblatexOption{global,type,entry}[boolean]{abstract}[true]{%
setbool{bbx:abstract}{#1}}
DeclareBiblatexOption{global,type,entry}[boolean]{library}[true]{%
setbool{bbx:library}{#1}}
DeclareBiblatexOption{global,type,entry}[boolean]{file}[true]{%
setbool{bbx:file}{#1}}
ExecuteBibliographyOptions{loadfiles,entryhead,entrykey,annotation,abstract,library,file}
newbibmacro*{entryhead:full}{%
printnames[labelname][-1]{labelname}%
setunit*{addcolonspace}%
printfield{labeltitle}}
newbibmacro*{entryhead:name}{%
ifnameundef{labelname}
{printfield{labeltitle}}
{printnames[labelname]{labelname}}%
savefield{fullhash}{bbx@lasthash}}
newbibmacro*{entrytail}{%
newunitnewblock
begingroup
defnewblockpunct{item}%
ifbool{bbx:annotation}
{usebibmacro{annotation}%
newunitnewblock}
{}%
ifbool{bbx:abstract}
{usebibmacro{abstract}%
newunitnewblock}
{}%
ifbool{bbx:file}
{printfield{file}%
newunitnewblock}
{}%
ifbool{bbx:library}
{printfield{library}%
newunitnewblock}
{}%
endgroup}
newcommand*{mkreadingbib}{%
DeclareNameAlias{author}{default}%
DeclareNameAlias{editor}{default}%
DeclareNameAlias{translator}{default}%
%
DeclareNameWrapperAlias{author}{default}%
DeclareNameWrapperAlias{editor}{default}%
DeclareNameWrapperAlias{translator}{default}%
%
DeclareFieldFormat{entrykey}{mbox{bfseries##1}}%
DeclareFieldFormat{annotation}{bibstring{annotation}addcolonspace ##1}%
DeclareFieldFormat{abstract}{bibstring{abstract}addcolonspace ##1}%
DeclareFieldFormat{library}{bibstring{library}addcolonspace ##1}%
DeclareFieldFormat{file}{bibstring{file}addcolonspace url{##1}}%
DeclareFieldFormat{shorthandwidth}{##1}%
%
setlength{bibitemsep}{0.5baselineskip}%
setlength{bibparsep}{0pt}%
%
renewbibmacro*{finentry}{%
ifbibliography
{usebibmacro{entrytail}}
{}%
finentry}}
makeatother
begin{filecontents}{jobname.bib}
@book{elk,
author = {Anne Elk},
title = {A Theory on Brontosauruses},
year = {1972},
publisher = {Monthy & Co.},
location = {London},
keywords = {recommended},
}
end{filecontents}
addbibresource{jobname.bib}
addbibresource{biblatex-examples.bib}
begin{document}
Lorem autocite{sigfridsson}
nocite{elk}
printbibliography[title={Citations},notkeyword=recommended]
printbibliography[title={Further reading},keyword=recommended,env=readingbib]
end{document}
Correct answer by moewe on July 24, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP