3

I need to change the command \parencite for a specific case but I have absolutely no clue how to rewrite ist. Could anyone help me?

What I have as a database entry is this:

@online{ref1,
   author = {{A Company}},
   title = "Page Title",
   year = "no date",
   url = {https://url.xy},
   urldate = "2017-10-14"
}

If I now use \parencite, I will get

Some text (A Company, no date).

But what I need is

Some text (A Company, online).

So basically, I need to overwrite \parencite for the following criteria:

  • IF the db entry is @online AND IF there is "no date" specified in 'year', PRINT (author, online).
  • IF there are several entries of the same author and declared with @online without a date, PRINT (author (a), online).
  • In every other case, use the APA-Citation style as before
  • No impacts on bibliography!

MWE:

\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[german]{babel}

\usepackage[style=apa]{biblatex}
\usepackage{csquotes}
\DeclareLanguageMapping{ngerman}{ngerman-apa}
\addbibresource{references.bib}
\NewBibliographyString{from}
\NewBibliographyString{retrieved}
\DefineBibliographyStrings{ngerman}{
   retrieved = {Abgerufen am},
   from = {von},
   nodate = {{}},
}
\DeclareFieldFormat[online]{title}{\mkbibemph{#1}}

\begin{filecontents}{\sample.bib}
    @online{ref1,
       author = {{A Company}},
       title = "Title",
       year = "no date",
       url = {https://url.xy},
       urldate = "2017-11-15"
    }

    @online{ref2,
       author = {{A Company}},
       title = "Page Title",
       year = "no date",
       url = {https://url.xy},
       urldate = "2017-10-14"
    }
 \end{filecontents}
 \begin{document}
 There is some text \parencite{ref1} and some other \parencite{ref2}.
 \printbibliography
 \end{document} 
5
  • You say 'no changes on the bibliography', but with your current set up you get 'no date' in an otherwise German bibliography. Is that not a bit weird? If you write in post-1996 orthography, you need \usepackage[ngerman]{babel} (ngerman with n instead of german). With recent versions of biblatex and biblatex-apa \DeclareLanguageMapping{ngerman}{ngerman-apa} is not needed any more and it does nothing in your example since the document uses german and not ngerman. The same holds for \DefineBibliographyStrings{ngerman}.
    – moewe
    Commented May 28, 2018 at 10:12
  • I actually write 'ohne Datum' instead of 'no date'... so you mean I just use 'german' everywhere?
    – Tina
    Commented May 28, 2018 at 10:29
  • The document as shown uses only german. None of the settings for ngerman are picked up and you will get possibly incorrect (read: old orthography) hyphenation and string translations.
    – moewe
    Commented May 28, 2018 at 10:35
  • ah I see, thanks. Is there also a way for German in Switzerland?
    – Tina
    Commented May 28, 2018 at 10:38
  • nswissgerman for new orthography and swissgerman for old.
    – moewe
    Commented May 28, 2018 at 10:46

1 Answer 1

1

Obligatory warning: Any changes to biblatex-apa will result in a style that is not APA-compliant any more. Proceed with care and only if you must.

I am working under the assumption that your text is written in nswissgerman as discussed in the comments.

The macro cite:plabelyear+extradate prints the year in citations. The macro is modified to not print nodate but to skip the year and print the entry type (online in this case) instead.

There is no need to write year = {no date} or similar if there is no date. Just don't give a year at all if there is none. biblatex can figure the rest out on its own.

\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[nswissgerman]{babel}

\usepackage[style=apa]{biblatex}
\usepackage{csquotes}
\addbibresource{\jobname.bib}
\NewBibliographyString{from}
\NewBibliographyString{retrieved}
\DefineBibliographyStrings{nswissgerman}{
  retrieved = {Abgerufen am},
  from      = {von},
  nodate    = {{}ohne Datum},
}

\DeclareFieldFormat{extradate:special}{\bibhyperref{\mkbibparens{\mknumalph{#1}}}}
\newbibmacro*{cite:plabelyear+extradate}{%
  \iffieldundef{labelyear}{}
    {\iffieldequalstr{labelyear}{nodate}
       {\setunit{\addspace}%
        \printfield[extradate:special]{extradate}%
        \setunit{\addcomma\space}%
        \printfield{entrytype}}
       {\printtext[bibhyperref]{%
           \clearfield{labelmonth}% don't want months in citations
           \clearfield{labelday}% don't want days in citations
           \clearfield{labelendmonth}% don't want months in citations
           \clearfield{labelendday}% don't want days in citations
           \iffieldsequal{labelyear}{labelendyear}% Don't want no-op year ranges
             {\clearfield{labelendyear}}
             {}%
           \iffieldundef{origyear}{}
             {\ifboolexpr{ test {\iforigdatecirca} or test {\iforigdateuncertain} }
               {\mkbibbrackets{\printorigdate}}
               {\printorigdate}%
              \setunit*{\addslash}}%
          \ifboolexpr{ test {\iflabeldatecirca} or test {\iflabeldateuncertain} }
            {\mkbibbrackets{\printlabeldateextra}}
            {\printlabeldateextra}}%
        \iffieldundef{issue}
          {}
          {\addcomma\addspace\printfield{issue}}}}}

\DeclareFieldFormat[online]{title}{\mkbibemph{#1}}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@online{ref1,
  author = {{A Company}},
  title = "Title",
  url = {https://url.xy},
  urldate = "2017-11-15"
}

@online{ref2,
  author = {{A Company}},
  title = "Page Title",
  url = {https://url.xy},
  urldate = "2017-10-14"
}
\end{filecontents}
\begin{document}
There is some text \parencite{ref1} and some other \parencite{ref2}.
\printbibliography
\end{document} 

enter image description here

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .