TeX - LaTeX Asked on September 28, 2021
I use biblatex-apa for my citations and bibliography. Unfortunately I need a special way for online sources in the bibliography.
I would be happy, if someone can point out, what I have to change.
My MWE (with a try):
documentclass[ngerman, toc=listof, toc=bibliography, footnotes=multiple, numbers=noendperiod]{scrartcl}
usepackage[T1]{fontenc}
usepackage[utf8]{inputenc}
usepackage[ngerman]{babel}
usepackage[
backend=biber,
autocite=inline,
style=apa,
%citestyle=authortitle-icomp,
sortlocale=de_DE,
natbib=true,
isbn=false,
url=false,
doi=false,
eprint=false,
dashed=false,
pagetracker,
ibidtracker=constrict
]{biblatex}
addbibresource{biblatex-examples.bib}
DeclareNameAlias{sortname}{family-given}
DeclareNameAlias{default}{given-family}
renewcommand*{newunitpunct}{addcommaspace}
renewcommand*{subtitlepunct}{addperiodspace}
DeclareDelimFormat{multinamedelim}{addslashspace}
DeclareDelimAlias{finalnamedelim}{multinamedelim}
renewbibmacro*{url+urldate}{%
ifthenelse{iffieldundef{url}ORNOTiffieldundef{doi}}
{}
{iffieldundef{urlyear}
{}
{bibstring{retrieved}%
setunit{addspace}%
printtext{bibstring{from}}%
setunit{addspace}}%
iffieldundef{url}{}{printfield{url}renewcommand*{finentrypunct}{relax}}
setunit*{addspace}%
printurldate
setunit{urldatecomma}%
}}
makeatletter
newbool{cbx:loccit}
DeclareBibliographyOption[boolean]{ibidpage}[true]{%
ifstrequal{#1}{true}
{ExecuteBibliographyOptions{loccittracker=constrict}}
{ExecuteBibliographyOptions{loccittracker=false}}}
providecommand*{mkibid}[1]{#1}
newbibmacro*{cite:ibid}{%
printtext[bibhyperref]{bibstring[mkibid]{ibidem}}%
ifloccit
{globalbooltrue{cbx:loccit}}
{}}
renewbibmacro*{cite}{%
globalboolfalse{cbx:loccit}%
ifthenelse{ifciteibidANDNOTiffirstonpage}
{usebibmacro{cite:ibid}}
{iffieldequals{fullhash}{cbx@lasthash}
% Multiple cites in one command
{setunit{compcitedelim}%
usebibmacro{cite:plabelyear+extradate}}%
% Single cite
{ifnameundef{labelname}
% No author/editor
{usebibmacro{cite:noname}%
setunit{printdelim{nameyeardelim}}%
usebibmacro{cite:plabelyear+extradate}%
savefield{fullhash}{cbx@lasthash}}
% Normal cite
{ifnameundef{shortauthor}
{printnames{labelname}}%
{cbx@apa@ifnamesaved
{printnames{shortauthor}}
{ifnameundef{groupauthor}
{printnames[labelname]{author}}
{printnames[labelname]{groupauthor}}%
addspaceprintnames[sabrackets]{shortauthor}}}%
setunit{printdelim{nameyeardelim}}%
usebibmacro{cite:plabelyear+extradate}%
savefield{fullhash}{cbx@lasthash}}}%
setunit{multicitedelim}}}
renewbibmacro*{textcite}{%
globalboolfalse{cbx:loccit}%
iffieldequals{fullhash}{cbx@lasthash}
% Compact cite - more than one thing for same author
{setunit{compcitedelim}%
usebibmacro{cite:plabelyear+extradate}}
% New cite
{ifbool{cbx:parens}
{bibcloseparenglobalboolfalse{cbx:parens}}
{}%
setunit{textcitedelim}%
ifnameundef{labelname}
% No author/editor
{iffieldundef{shorthand}%
% Cite using title
{usebibmacro{cite:noname}%
setunit{globalbooltrue{cbx:parens}addspacebibopenparen}%
usebibmacro{cite:plabelyear+extradate}}
% Cite using shorthand
{usebibmacro{cite:shorthand}}}
% Normal cite with author/editor
% Normal full cite
{ifnameundef{shortauthor}%
% Normal full cite
{printnames{labelname}}
% Cite using short author
{cbx@apa@ifnamesaved
{printnames{shortauthor}}
{ifnameundef{groupauthor}
{printnames[labelname]{author}}
{printnames[labelname]{groupauthor}}}}%
% Year
setunit{globalbooltrue{cbx:parens}addspacebibopenparen}%
% Put the shortauthor inside the year brackets if necessary
ifnameundef{shortauthor}
{}
{cbx@apa@ifnamesaved
{}
{printnames{shortauthor}%
setunit{printdelim{nameyeardelim}}}}%
% Print prenote (belongs to first cite)
ifnumequal{value{citecount}}{1}
{usebibmacro{prenote}}
{}%
% Actual year printing
ifthenelse{ifciteibidANDNOTiffirstonpage}
{usebibmacro{cite:ibid}}
{usebibmacro{cite:plabelyear+extradate}}%
% Save name hash for checks later
savefield{fullhash}{cbx@lasthash}}%
stepcounter{textcitecount}}}
letbibmacro{orig:postnote}{postnote}
renewbibmacro*{postnote}{%
ifbool{cbx:loccit}
{}
{usebibmacro{orig:postnote}}}
makeatother
ExecuteBibliographyOptions{ibidpage=true}
DeclareSourcemap{
maps[datatype=bibtex]{
map{
step[fieldsource=urldate, match=regexp{A(d{2}).(d{2}).(d{4})Z}, replace={$3-$2-$1}]
}
}
}
DeclareStyleSourcemap{
maps[datatype=bibtex, overwrite=true]{
map{
step[fieldsource=url, final]
step[typesource=misc, typetarget=online]
}
}
}
begin{document}
Lorem ipsum.autocite{ctan}
printbibliography
end{document}
The example citation you give is more of a @report
than an @online
resource. Specifically, @report
has the fields type
and number
for designators such as "Working Paper 2014/9".
Note that ctan
is not particularly suitable as an example for these kind of entry types, since it does not have an author and is in fact much closer to a real @online
entry than the NIDI paper.
With your setup you'll get
documentclass[ngerman, toc=listof, toc=bibliography, footnotes=multiple, numbers=noendperiod]{scrartcl}
usepackage[T1]{fontenc}
usepackage[utf8]{inputenc}
usepackage[ngerman]{babel}
usepackage[
backend=biber,
style=apa,
autocite=inline,
natbib=true,
isbn=false,
doi=false,
eprint=false,
dashed=false,
pagetracker,
ibidtracker=constrict
]{biblatex}
DeclareNameAlias{sortname}{family-given}
DeclareNameAlias{default}{given-family}
renewcommand*{newunitpunct}{addcommaspace}
renewcommand*{subtitlepunct}{addperiodspace}
DeclareDelimFormat{multinamedelim}{addslashspace}
DeclareDelimAlias{finalnamedelim}{multinamedelim}
renewbibmacro*{url+urldate}{%
ifthenelse{iffieldundef{url}ORNOTiffieldundef{doi}}
{}
{iffieldundef{urlyear}
{}
{bibstring{retrieved}%
setunit{addspace}%
printtext{bibstring{from}}%
setunit{addspace}}%
iffieldundef{url}{}{printfield{url}renewcommand*{finentrypunct}{relax}}
setunit*{addspace}%
printurldate
setunit{urldatecomma}%
}}
makeatletter
newbool{cbx:loccit}
DeclareBibliographyOption[boolean]{ibidpage}[true]{%
ifstrequal{#1}{true}
{ExecuteBibliographyOptions{loccittracker=constrict}}
{ExecuteBibliographyOptions{loccittracker=false}}}
providecommand*{mkibid}[1]{#1}
newbibmacro*{cite:ibid}{%
printtext[bibhyperref]{bibstring[mkibid]{ibidem}}%
ifloccit
{globalbooltrue{cbx:loccit}}
{}}
renewbibmacro*{cite}{%
globalboolfalse{cbx:loccit}%
ifthenelse{ifciteibidANDNOTiffirstonpage}
{usebibmacro{cite:ibid}}
{iffieldequals{fullhash}{cbx@lasthash}
% Multiple cites in one command
{setunit{compcitedelim}%
usebibmacro{cite:plabelyear+extradate}}%
% Single cite
{ifnameundef{labelname}
% No author/editor
{usebibmacro{cite:noname}%
setunit{printdelim{nameyeardelim}}%
usebibmacro{cite:plabelyear+extradate}%
savefield{fullhash}{cbx@lasthash}}
% Normal cite
{ifnameundef{shortauthor}
{printnames{labelname}}%
{cbx@apa@ifnamesaved
{printnames{shortauthor}}
{ifnameundef{groupauthor}
{printnames[labelname]{author}}
{printnames[labelname]{groupauthor}}%
addspaceprintnames[sabrackets]{shortauthor}}}%
setunit{printdelim{nameyeardelim}}%
usebibmacro{cite:plabelyear+extradate}%
savefield{fullhash}{cbx@lasthash}}}%
setunit{multicitedelim}}}
renewbibmacro*{textcite}{%
globalboolfalse{cbx:loccit}%
iffieldequals{fullhash}{cbx@lasthash}
% Compact cite - more than one thing for same author
{setunit{compcitedelim}%
usebibmacro{cite:plabelyear+extradate}}
% New cite
{ifbool{cbx:parens}
{bibcloseparenglobalboolfalse{cbx:parens}}
{}%
setunit{textcitedelim}%
ifnameundef{labelname}
% No author/editor
{iffieldundef{shorthand}%
% Cite using title
{usebibmacro{cite:noname}%
setunit{globalbooltrue{cbx:parens}addspacebibopenparen}%
usebibmacro{cite:plabelyear+extradate}}
% Cite using shorthand
{usebibmacro{cite:shorthand}}}
% Normal cite with author/editor
% Normal full cite
{ifnameundef{shortauthor}%
% Normal full cite
{printnames{labelname}}
% Cite using short author
{cbx@apa@ifnamesaved
{printnames{shortauthor}}
{ifnameundef{groupauthor}
{printnames[labelname]{author}}
{printnames[labelname]{groupauthor}}}}%
% Year
setunit{globalbooltrue{cbx:parens}addspacebibopenparen}%
% Put the shortauthor inside the year brackets if necessary
ifnameundef{shortauthor}
{}
{cbx@apa@ifnamesaved
{}
{printnames{shortauthor}%
setunit{printdelim{nameyeardelim}}}}%
% Print prenote (belongs to first cite)
ifnumequal{value{citecount}}{1}
{usebibmacro{prenote}}
{}%
% Actual year printing
ifthenelse{ifciteibidANDNOTiffirstonpage}
{usebibmacro{cite:ibid}}
{usebibmacro{cite:plabelyear+extradate}}%
% Save name hash for checks later
savefield{fullhash}{cbx@lasthash}}%
stepcounter{textcitecount}}}
letbibmacro{orig:postnote}{postnote}
renewbibmacro*{postnote}{%
ifbool{cbx:loccit}
{}
{usebibmacro{orig:postnote}}}
makeatother
ExecuteBibliographyOptions{ibidpage=true}
DeclareSourcemap{
maps[datatype=bibtex]{
map{
step[fieldsource=urldate, match=regexp{A(d{2}).(d{2}).(d{4})Z}, replace={$3-$2-$1}]
}
}
}
DeclareStyleSourcemap{
maps[datatype=bibtex, overwrite=true]{
map{
step[fieldsource=url, final]
step[typesource=misc, typetarget=online]
}
}
}
begin{filecontents}{jobname.bib}
@report{kristiansen,
author = {Marcus H. Kristiansen},
title = {Agency as an Empirical Concept},
subtitle = {An Assessment of Theory and Operationalization},
date = {2014},
type = {Working Paper},
number = {2014/9},
location = {Den Haag},
publisher = {NIDI},
url = {https://www.nidi.nl/shared/content/output/papers/nidi-wp-2014-09.pdf},
urldate = {2020-07-28},
}
end{filecontents}
addbibresource{jobname.bib}
addbibresource{biblatex-examples.bib}
begin{document}
Lorem ipsum. autocite{kristiansen}
printbibliography
end{document}
which isn't quite what you show in the picture, but comes close.
I note, though, that your picture includes the location, which is not usually done in the 7th edition of APA style, which biblatex-apa
implements. And indeed if I switch to biblatex-apa6
for 6th edition APA style I get something much closer to what you need.
documentclass[ngerman, toc=listof, toc=bibliography, footnotes=multiple, numbers=noendperiod]{scrartcl}
usepackage[T1]{fontenc}
usepackage[utf8]{inputenc}
usepackage[ngerman]{babel}
usepackage[backend=biber,
style=apa6]{biblatex}
begin{filecontents}{jobname.bib}
@report{kristiansen,
author = {Marcus H. Kristiansen},
title = {Agency as an Empirical Concept},
subtitle = {An Assessment of Theory and Operationalization},
date = {2014},
type = {Working Paper},
number = {2014/9},
location = {Den Haag},
publisher = {NIDI},
url = {https://www.nidi.nl/shared/content/output/papers/nidi-wp-2014-09.pdf},
urldate = {2020-07-28},
}
end{filecontents}
addbibresource{jobname.bib}
begin{document}
Lorem ipsum. autocite{kristiansen}
printbibliography
end{document}
Correct answer by moewe on September 28, 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