1

Here is the existing document code:

\documentclass[12pt, final, a4paper]{article}

\usepackage[backend=biber,style=authoryear-icomp,sorting=nyt,isbn=false,doi=true,dashed=false,maxbibnames=99,uniquename=init,giveninits]{biblatex}
\addbibresource{referenser.bib}

\begin{document}
Here is one sentence.\cite{Knuth:ct-a}

Here is another sentence.\cite{noauthor_solcell_2020}
\printbibliography
\end{document}

And the .bib file code:

@Book{Knuth:ct-a,
author =       "Donald E. Knuth",
title =        "The {\TeX}book",
publisher =    "Addison-Wesley",
year =         "1986",
volume =       "A",
series =       "Computers and Typesetting",
pages =        "ix + 483",
}

@online{noauthor_solcell_2020,
titleaddon = {Nationalencyklopedin},
title = {solcell},
url = {https://www.ne.se/uppslagsverk/encyklopedi/l%C3%A5ng/solcell},
urldate = {2020-04-13},
date = {2020}
}

As of now it prints out:

enter image description here

How do I make it print out the journaltitle/titleaddon instead of the title when there is no author?

Edit:

Here is the full code modified to use harvard referencing instead of the default:

\usepackage{csquotes}
\usepackage[backend=biber,style=authoryear-icomp,sorting=nyc,isbn=false,doi=true,dashed=false,maxbibnames=99,uniquename=init,giveninits]{biblatex}
\addbibresource{references.bib}
\DeclareFieldFormat[article]{title}{#1}
\renewbibmacro{in:}{}
\renewcommand*{\finalnamedelim}{\ifnumgreater{\value{liststop}}{2}{\finalandcomma}{}\addspace\&\space}
\DefineBibliographyStrings{swedish}{andothers={et\addabbrvspace al\adddot}}
\newcommand{\mkbibnodate}{u\adddot å\adddot}
\AtEveryCitekey{\iffieldundef{year}{\restorefield{labelyear}{\mkbibnodate}}{}}
\DeclareFieldFormat{urldate}{\mkbibbrackets{#1}}
\NewBibliographyString{available}
\DefineBibliographyStrings{swedish}{available={Tillgänglig}}
\DeclareFieldFormat{url}{\bibstring{available}\addcolon\space\url{#1}}
\DeclareFieldFormat[article]{volume}{vol. #1}
\renewbibmacro*{volume+number+eid}{\setunit{\addcomma\space}\printfield{volume}\setunit*{\addnbspace}\printfield{number}\setunit{\addcomma\space}\printfield{eid}}
\DeclareFieldFormat[article]{number}{\mkbibparens{#1}}
\DeclareFieldFormat[article]{pages}{ss. #1 \adddot}
\DeclareNameAlias{sortname}{family-given}
\renewcommand*{\bibfont}{\footnotesize}
\DeclareSortingTemplate{nyc}{\sort{\field{presort}}\sort[final]{\field{sortkey}}\sort{\field{sortname}\field{author}\field{editor}\field{translator}\field{journaltitle}\field{sorttitle}\field{title}}\sort{\field{sortyear}\field{year}}\sort{\citeorder}}

Can I implement some code which creates a titleaddon or label or another author from the url which it defaults to when there is no author? Since all url have www.websitename.xxx, is there some commands to make everything except what's between the two dots disappear? And is there some way to redefine author if no author is provided?

As I do not fully understand what is happening in the code above could you show where it is safe to put these changes in my code for it to work?

Thanks in advance! /Alexander

Alexander
  • 11
  • 2

1 Answers1

2

Why questions can be tricky to answer. Often it's down to common (observed) practice or tradition. But especially with less common edge cases like this often the direct and not very helpful answer is: because the developer or someone who asked the developer about this feature thought it was useful behaviour.

biblatex needs to display something when there is no author/editor/..., because it can't just put the year. The title is the obvious choice because most entries should have a title and there is a chance that the title is going to be reasonably unique. (Choosing the journaltitle or titleaddon instead seems less promising, because not all entries are going to have one and journaltitles can't be reasonably expected to be unique.) So the choice is not completely unreasonable. APA style seems to follow a structurally similar approach.

In situations like this biblatex offers you to suggest a fallback for the author/editor/... in the label field. For example

@online{noauthor_solcell_2020,
  label      = {Nationalencyklopedin},
  titleaddon = {Nationalencyklopedin},
  title      = {solcell},
  url        = {https://www.ne.se/uppslagsverk/encyklopedi/l%C3%A5ng/solcell},
  urldate    = {2020-04-13},
  date       = {2020},
}

I would argue, however, that it is perfectly fine to "upgrade" Nationalencyklopedin to author (or at least editor) here. Not only people can be authors, corporate entities are allowed to be authors as well, just remember to wrap the name of the corporate entity in braces if it consists of more than one word (Using a 'corporate author' in the "author" field of a bibliographic entry (spelling out the name in full))

@online{noauthor_solcell_2020,
  author     = {Nationalencyklopedin},
  title      = {solcell},
  url        = {https://www.ne.se/uppslagsverk/encyklopedi/l%C3%A5ng/solcell},
  urldate    = {2020-04-13},
  date       = {2020},
}

A short click on Information om artikeln in https://www.ne.se/uppslagsverk/encyklopedi/l%C3%A5ng/solcell reveals

Medverkande

Dag Sigurd, Lars Stolt

so possibly

@online{noauthor_solcell_2020,
  author     = {Dag Sigurd and Lars Stolt},
  title      = {solcell},
  titleaddon = {Nationalencyklopedin},
  url        = {https://www.ne.se/uppslagsverk/encyklopedi/l%C3%A5ng/solcell},
  urldate    = {2020-04-13},
  date       = {2020},
}

would also be a valid alternative.

Lastly, it is possible to make biblatex prefer the titleaddon over the title in this case. The decision is made when generating the labeltitle. The default instructions for labeltitle are

\DeclareLabeltitle{%
  \field{shorttitle}
  \field{title}
  \field{maintitle}
}

but you can make that read

\DeclareLabeltitle{%
  \field{titleaddon}
  \field{shorttitle}
  \field{title}
  \field{maintitle}
}

to prefer titleaddon over title.

moewe
  • 175,683
  • Thank you for your answer! I am very new to Latex programming and I did not include all my questions since I didn't know I would get an answer this fast. I am used to python, which to me seems very different from Latex so far. However, since you have been very helpful could you review my full code and answer a few more questions? – Alexander Apr 14 '20 at 07:29
  • @Alexander Could you please ask a new question about thatt (unless it is specifically related to the label/title issue)? That helps to keep the site contents relevant and questions nicely separated. See also https://tex.meta.stackexchange.com/q/7425/35864 – moewe Apr 14 '20 at 10:23
  • @Daniel Fair enough. I tried to tone the passage down a bit. Let me know what you think. – moewe Apr 14 '20 at 15:57
  • @moewe: ACK :-) (I have deleted my other comment as it is no longer relevant) – Daniel Apr 15 '20 at 09:07