4

Im trying to manage references with biblatex and the authoryear-icomp-style and have a hard time to get the citations and bibliography to look exactly like my university wants them to. Most things I have manage to get correct by reading other peoples questions and answers on this website, but one problem remain. When I have two different references written by the same author and both references have no date, i would like them to look like as follows below.

In the text:

Word word word word (Johansson u.å. a).

Word word word word (Johansson u.å. b).

In the bibliography:

Johansson, S. (u.å. a). Sun. [2018-04-12].

Johansson, S. (u.å. b). Earth. [2018-04-12].

Instead I get - In the text:

Word word word word (Johansson u.å.[a]).

Word word word word (Johansson u.å.[b]).

In the bibliography:

Johansson, S. (u.å.[a]). Sun. [2018-04-12].

Johansson, S. (u.å.[b]). Earth. [2018-04-12].

Is there a way to remove the brackets? I also would like this to work for all types of references.

\documentclass[a4paper, 12pt]{article}
\usepackage[swedish]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{csquotes}

% Biblatex
\usepackage[
    backend=biber,
    style=authoryear-icomp,
    sorting=nyc,
    isbn=false, 
    doi=true, 
    dashed=false, 
    maxbibnames=99,
   uniquename=init,
    giveninits 
  ]{biblatex}

\addbibresource{test.bib}

%--changes to get citations and bibliography the way my university wants---- 
\DeclareFieldFormat[article]{title}{#1}
\renewbibmacro{in:}{}

\renewcommand*{\finalnamedelim}{%
  \ifnumgreater{\value{liststop}}{2}{\finalandcomma}{}%
  \addspace\&\space}

\DefineBibliographyStrings{swedish}{%
  andothers = {et\addabbrvspace al\adddot}
}

%u.å is swedish for n.d. (no date)
\newcommand{\mkbibnodate}{u\adddot å\adddot}
\AtEveryCitekey{\iffieldundef{year}{\restorefield{labelyear}{\mkbibnodate}}{}}
\AtEveryBibitem{\iffieldundef{year}{\restorefield{labelyear}{\mkbibnodate}}{}}

\DeclareFieldFormat{urldate}{\mkbibbrackets{#1}}
\NewBibliographyString{available}

%tillgänglig is swedish for available
\DefineBibliographyStrings{swedish}{%
  available = {Tillgänglig},
}

\DeclareFieldFormat{url}{\bibstring{available}\addcolon\space\url{#1}}

%", Vol. x (x),"
 \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}}

%"ss. XX-XX."
\DeclareFieldFormat[article]{pages}{ss. #1 \adddot}

\DeclareNameAlias{sortname}{last-first}

\DeclareSortingScheme{nyc}{
  \sort{
    \field{presort}
  }
  \sort[final]{
    \field{sortkey}
  }
  \sort{
    \field{sortname}
    \field{author}
    \field{editor}
    \field{translator}
    \field{sorttitle}
    \field{title}
  }
  \sort{
    \field{sortyear}
    \field{year}
  }
  \sort{\citeorder}
}
%----------------end of changes------------------
\begin{document}
Word word word word \parencite{johansson_sun_????}. \\
Word word word word \parencite{johansson_earth_????}.\\

\printbibliography
\end{document}

(u.å is swedish för n.d (no date)).

My .bib-file:

@online{johansson_sun_????,
    title = {Sun},
    author = {Johansson, Sven},
    urldate = {2018-04-12},
}

@online{johansson_earth_????,
    title = {Earth},
    author = {Johansson, Sven},
    urldate = {2018-04-12},
}
  • The problem is caused by %\AtEveryCitekey{\iffieldundef{year}{\restorefield{labelyear}{\mkbibnodate}}{}} %\AtEveryBibitem{\iffieldundef{year}{\restorefield{labelyear}{\mkbibnodate}}{}}. Can you show an example what these lines should do? maybe there is another way – user36296 Apr 18 '18 at 13:19
  • @samcarter, true, but if the default nodate string is used there (as opposed to the year number), the brackets will also show up. – gusbrs Apr 18 '18 at 13:45
4

Well, there were some things to be done to achieve what you want. The lines of code that @samcarter mentioned seemed to try to override the underlying mechanism for labeldate. I assumed here you wanted to do so only for online entries, not letting urldate take the place of labeldate. That was done by commenting the mentioned lines of code, and redefining the fields labeldate takes into account:

\DeclareLabeldate{%
  \field{date}
  \field{year}
  \field{eventdate}
  \field{origdate}
  % \field{urldate}
  \literal{nodate}
}

You also wanted to have a localized string for "n.d.". That usually should work out of the box. But swedish.lbx has a %FIXME on that particular string. (You may want to report this at https://github.com/plk/biblatex/issues. The maintenance of biblatex's localization strings relies on native speakers to supply them). Anyway, for the time being, you have to add the string to your \DefineBibliographyString:

nodate = {u\adddot å\adddot},

Finally, to remove the brackets of extradate, you can use:

\DeclareFieldFormat{extradate}{%
  \iffieldnums{labelyear}
    {\mknumalph{#1}}
    {\addnbthinspace\mknumalph{#1}}}

I also changed your deprecated \DeclareSortingScheme for the current \DeclareSortingTemplate.

Putting it all together (with a thorough update of your biblatex customizations, by courtesy of @moewe):

\documentclass[a4paper, 12pt]{article}
\usepackage[swedish]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{csquotes}

% Biblatex
\usepackage[
    backend=biber,
    style=authoryear-icomp,
    sorting=nyc,
    isbn=false, 
    doi=true, 
    dashed=false, 
    maxbibnames=99,
    uniquename=init,
    giveninits 
  ]{biblatex}

\addbibresource{test.bib}

%--changes to get citations and bibliography the way my university wants---- 
\DeclareFieldFormat[article]{title}{#1}
\renewbibmacro{in:}{}

% \renewcommand*{\finalnamedelim}{%
%   \ifnumgreater{\value{liststop}}{2}{\finalandcomma}{}%
%   \addspace\&\space}
\DeclareDelimFormat{finalnamedelim}{%
  \ifnumgreater{\value{liststop}}{2}{\finalandcomma}{}%
  \addspace\&\space}


%u.å is swedish for n.d. (no date) % better to do this with the
%localized "nodate" string
% \newcommand{\mkbibnodate}{u\adddot å\adddot}
% \AtEveryCitekey{\iffieldundef{year}{\restorefield{labelyear}{\mkbibnodate}}{}}
% \AtEveryBibitem{\iffieldundef{year}{\restorefield{labelyear}{\mkbibnodate}}{}}

% do not consider "urldate" as a candidate for labeldate
\DeclareLabeldate{%
  \field{date}
  \field{year}
  \field{eventdate}
  \field{origdate}
  % \field{urldate}
  \literal{nodate}
}

% This is the original definition
% \DeclareFieldFormat{extradate}{%
%   \iffieldnums{labelyear}
%     {\mknumalph{#1}}
%     {\mkbibparens{\mknumalph{#1}}}}
% If you don't want brackets in any case:
\DeclareFieldFormat{extradate}{%
  \iffieldnums{labelyear}
    {\mknumalph{#1}}
    {\addnbthinspace\mknumalph{#1}}}

\DeclareFieldFormat{urldate}{\mkbibbrackets{#1}}
% \NewBibliographyString{available}

%tillgänglig is swedish for available
\DefineBibliographyStrings{swedish}{%
  % available = {Tillgänglig},
  urlfrom     = {Tillgänglig},
  andothers   = {et\addabbrvspace al\adddot},
  nodate      = {u\adddot å\adddot}, % added: that currently stands with a % FIXME in swedish.lbx
  pages       = {ss\adddot},
}

\DeclareFieldFormat{url}{\bibstring{urlfrom}\addcolon\space\url{#1}}

%", Vol. x (x),"
% \DeclareFieldFormat[article]{volume}{vol. #1}
\DeclareFieldFormat[article]{volume}{\bibstring{volume}~#1}

\renewbibmacro*{volume+number+eid}{%
  \setunit{\addcomma\space}%
  \printfield{volume}%
  \setunit*{\addnbspace}% 
  \printfield{number}%
  \setunit{\addcomma\space}%
  \printfield{eid}}
\DeclareFieldFormat[article]{number}{\mkbibparens{#1}}

%"ss. XX-XX."
% \DeclareFieldFormat[article]{pages}{ss. #1 \adddot}
\DeclareFieldFormat{pages}{\mkpageprefix[bookpagination]{#1}}

% \DeclareNameAlias{sortname}{last-first}
\DeclareNameAlias{sortname}{family-given}

\DeclareSortingTemplate{nyc}{
  \sort{
    \field{presort}
  }
  \sort[final]{
    \field{sortkey}
  }
  \sort{
    \field{sortname}
    \field{author}
    \field{editor}
    \field{translator}
    \field{sorttitle}
    \field{title}
  }
  \sort{
    \field{sortyear}
    \field{year}
  }
  \sort{\citeorder}
}
%----------------end of changes------------------
\begin{document}
Word word word word \parencite{johansson_sun_????}.

Word word word word \parencite{johansson_earth_????}.

\printbibliography
\end{document}

enter image description here

Edit: A working setup with Overleaf's current biblatex version (3.4) was provided by moewe at https://www.overleaf.com/read/ydgxhpnsfyxs

I leave the code here too:

\documentclass[a4paper, 12pt]{article}
\usepackage[swedish]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{csquotes}

% Biblatex
\usepackage[
    backend=biber,
    style=authoryear-icomp,
    sorting=nyc,
    isbn=false, 
    doi=true, 
    dashed=false, 
    maxbibnames=99,
    uniquename=init,
    giveninits 
  ]{biblatex}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@online{johansson_sun_????,
    title = {Sun},
    author = {Johansson, Sven},
    urldate = {2018-04-12},
}

@online{johansson_earth_????,
    title = {Earth},
    author = {Johansson, Sven},
    urldate = {2018-04-12},
}
\end{filecontents}
\addbibresource{\jobname.bib}

%--changes to get citations and bibliography the way my university wants---- 
\DeclareFieldFormat[article]{title}{#1}
\renewbibmacro{in:}{}

\renewcommand*{\finalnamedelim}{%
  \ifnumgreater{\value{liststop}}{2}{\finalandcomma}{}%
  \addspace\&\space}

\DeclareLabeldate{%
  \field{date}
  \field{year}
  \field{eventdate}
  \field{origdate}
  % \field{urldate}
  \literal{nodate}
}

%u.å is swedish for n.d. (no date)
\DeclareFieldFormat{extrayear}{%
  \iffieldnums{labelyear}
    {\mknumalph{#1}}
    {\addnbthinspace\mknumalph{#1}}}

\DeclareFieldFormat{urldate}{\mkbibbrackets{#1}}
% \NewBibliographyString{available}

%tillgänglig is swedish for available
\DefineBibliographyStrings{swedish}{%
  urlfrom   = {Tillgänglig},
  andothers = {et\addabbrvspace al\adddot},
  nodate    = {u\adddot å\adddot}, % added: that currently stands with a % FIXME in swedish.lbx
  pages     = {ss\adddot},
}

\DeclareFieldFormat{url}{\bibstring{urlfrom}\addcolon\space\url{#1}}

%", Vol. x (x),"
% \DeclareFieldFormat[article]{volume}{vol. #1}
\DeclareFieldFormat[article]{volume}{\bibstring{volume}~#1}

\renewbibmacro*{volume+number+eid}{%
  \setunit{\addcomma\space}%
  \printfield{volume}%
  \setunit*{\addnbspace}% 
  \printfield{number}%
  \setunit{\addcomma\space}%
  \printfield{eid}}
\DeclareFieldFormat[article]{number}{\mkbibparens{#1}}

%"ss. XX-XX."
% \DeclareFieldFormat[article]{pages}{ss. #1 \adddot}
\DeclareFieldFormat{pages}{\mkpageprefix[bookpagination]{#1}}

% \DeclareNameAlias{sortname}{last-first}
\DeclareNameAlias{sortname}{family-given}
\DeclareSortingScheme{nyc}{
  \sort{
    \field{presort}
  }
  \sort[final]{
    \field{sortkey}
  }
  \sort{
    \field{sortname}
    \field{author}
    \field{editor}
    \field{translator}
    \field{sorttitle}
    \field{title}
  }
  \sort{
    \field{sortyear}
    \field{year}
  }
  \sort{\citeorder}
}
%----------------end of changes------------------
\begin{document}
Word word word word \parencite{johansson_sun_????}. \\
Word word word word \parencite{johansson_earth_????}.\\

\printbibliography
\end{document}
  • 2
    +1 Let me just add that instead of \DeclareFieldFormat[article]{volume}{vol. #1} \DeclareFieldFormat[article]{volume}{\bibstring{volume}~#1} (or \DeclareFieldFormat[article]{volume}{\bibstring{jourvol}~#1}) would be preferable. Instead of \DeclareFieldFormat[article]{pages}{ss. #1 \adddot} one might want to use \DeclareFieldFormat{pages}{\mkpageprefix[bookpagination]{#1}}, but that will give 's.' and not 'ss.', so the pages bibstring would have to be changed to ss\adddot. \DeclareNameAlias{sortname}{last-first} is \DeclareNameAlias{sortname}{family-given} now. ... – moewe Apr 18 '18 at 14:19
  • 1
    ... For \finalnamedelim I'd use \DeclareDelimFormat now. Finally one need not define the new string available, urlfrom is already available for that purpose (it needs to be redefined, though because it is tillg\"anglig fr\aa n: close, but no cigar) – moewe Apr 18 '18 at 14:23
  • 1
    @MariaHelin If \DeclareSortingTemplate throws an error, then that is because your biblatex version is outdated. A while ago there was a bug that could affect nodate, maybe your version is affected (I don't remember the details, sorry). If you are using a really ancient version, chances are the whole nodate business is still working differently. Can you find out the version of biblatex you are using? The easiest way is to add \listfiles to the beginning of your .tex file and then read the version numbers off in the .log file. – moewe Apr 18 '18 at 17:03
  • 1
    Thanks for all the help gusbrs and @moewe, I accept that I cant solve this in Overleaf. Instead I will try to compile on my own computer, with the latest version of biblatex, in the way you first proposed. – Maria Helin Apr 18 '18 at 19:34
  • 2
    @gusbrs unfortunately only one vote is possible - all the hard work would only be the second best reason :) – user36296 Apr 19 '18 at 11:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.