2

I'm using \usepackage[backend=biber,style=authoryear]{biblatex} in my document followed by square brackets and full hyperlink which gives me this in the document [MacRae and Pattison 2002] and this in the references

MacRae, K. and J. Pattison (2002). “Home chemotherapy.” In: Nursing Times 98.35, pp. 34–35.

How can I get it so that I also have the same squared-bracketed citation in the references please?

  • 2
    I'm afraid your objective isn't entirely clear (to me at least). Are you looking to prefix the string [MacRae and Pattison 2002] to the bibliographic entry? Please advise. – Mico May 18 '14 at 16:20
  • @Mico; yes, in front of its appropriate entry. – boudiccas May 18 '14 at 16:43
1

Something like this??

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[american]{babel}
\usepackage{csquotes}
\usepackage[style=authoryear]{biblatex}
\renewcommand\mkbibparens[1]{[#1]}
\addbibresource{IEEEexample.bib}

\begin{document}

foo~\parencite{IEEEexample:masterstype}
\printbibliography

\end{document}

enter image description here

  • No, in this example it should be [Karnik A,1999], that is what I'm looking for – boudiccas May 18 '14 at 16:42
  • @boudiccas Where should it be "[Karnik A, 1999]", because from your question (where you had "[MacRae and Pattison 2002]", no first names, not even a comma) I get the expression Herbert's answer does what you asked for. – moewe May 19 '14 at 5:08
  • I do not think redefining the fundamental and often-used macro \mkbibparens is such a good idea. – moewe May 19 '14 at 5:11
  • @moewe: I would like it to say [Karnik A,1999] in the "references" section, just before its actual references is listed – boudiccas May 19 '14 at 11:49
  • I've been able to use square brackets in the "references" section using this adding-an-authoryear-block-at-the-beginning-of-bibliography-entries. Now all I need is a comma "," between the names and the year inside the square brackets. Can it be done please? – boudiccas May 19 '14 at 12:59
1

Having read your new comments on Herbert's answer, I came up with the following

\newcounter{mymaxcitenames}
\AtBeginDocument{%
  \setcounter{mymaxcitenames}{\value{maxnames}}%
}

\makeatletter
\renewbibmacro*{begentry}{%
  \begingroup
    \undef\cbx@lasthash
    \undef\cbx@lastyear
    \defcounter{maxnames}{\value{mymaxcitenames}}%
    \parencite{\thefield{entrykey}}%
  \endgroup
  \addspace
}
\makeatother

Similar to what Lockstep did in Adding an [AuthorYear] block at the beginning of bibliography entries, but shorter. (Of course you can use \cite or any other cite command instead of \parencite above.)

The delimiter between name and year is changed with

\renewcommand*{\nameyeardelim}{\addcomma\space}

So we have

The MWE

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[british]{babel}
\usepackage{csquotes}
\usepackage[style=authoryear]{biblatex}
\addbibresource{biblatex-examples.bib}

\DeclareCiteCommand{\parencite}[\mkbibbrackets]
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand*{\parencite}[\mkbibbrackets]
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{citeyear}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\newcounter{mymaxcitenames}
\AtBeginDocument{%
  \setcounter{mymaxcitenames}{\value{maxnames}}%
}

\makeatletter
\renewbibmacro*{begentry}{%
  \begingroup
    \undef\cbx@lasthash
    \undef\cbx@lastyear
    \defcounter{maxnames}{\value{mymaxcitenames}}%
    \parencite{\thefield{entrykey}}%
  \endgroup
  \addspace
}
\makeatother

\renewcommand*{\nameyeardelim}{\addcomma\space}

\begin{document}

foo~\parencite{baez/article,wilde}
\printbibliography

\end{document}

MWE

If you only want the comma locally (why would you though?), you can use

\makeatletter
\renewbibmacro*{begentry}{%
  \begingroup
    \undef\cbx@lasthash
    \undef\cbx@lastyear
    \renewcommand*{\nameyeardelim}{\addcomma\space}
    \parencite{\thefield{entrykey}}%
  \endgroup
  \addspace
}
\makeatother

Old answer

Instead of redefining the very fundamental \mkbibparens, I would go with a redefinition of \parencite to use \mkbibbrackets instead of \mkbibparens:

\DeclareCiteCommand{\parencite}[\mkbibbrackets]
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand*{\parencite}[\mkbibbrackets]
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{citeyear}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

Of course you could also redefine \cite:

\DeclareCiteCommand{\cite}[\mkbibbrackets]
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand*{\cite}[\mkbibbrackets]
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{citeyear}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

or define a new command \brackcite

\DeclareCiteCommand{\brackcite}[\mkbibbrackets]
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand*{\brackcite}[\mkbibbrackets]
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{citeyear}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

Even though this is slightly more code than Herbert's solution to me it seems more robust.

MWE

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[british]{babel}
\usepackage{csquotes}
\usepackage[style=authoryear]{biblatex}
\addbibresource{biblatex-examples.bib}

\DeclareCiteCommand{\parencite}[\mkbibbrackets]
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand*{\parencite}[\mkbibbrackets]
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{citeyear}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\begin{document}

foo~\parencite{baez/article,wilde}
\printbibliography

\end{document}

enter image description here


After you comments on Herbert's answer.

I'm not entirely sure what you're after, you can change the separator between name and year in the citation with

\newcommand*{\nameyeardelim}{\addcomma\space}

for example.

The way the names are displayed in citations is controlled by the name format labeldate. To always get last name initials, no matter what, try

\DeclareNameFormat{labelname}{%
  \ifcase\value{uniquename}%
    \usebibmacro{name:last-first}{#1}{#4}{#5}{#7}%
  \or
    \ifuseprefix
      {\usebibmacro{name:last-first}{#1}{#4}{#5}{#8}}
      {\usebibmacro{name:last-first}{#1}{#4}{#6}{#8}}%
  \or
    \usebibmacro{name:last-first}{#1}{#3}{#5}{#7}%
  \fi
  \usebibmacro{name:andothers}}
  • @boudiccas Please have a look at the edited answer and comment on what you are missing. – moewe May 19 '14 at 16:18
  • @boudiccas If it does, you might consider accepting (and up-voting, if you have not already) this answer. – moewe May 25 '14 at 16:18
  • since I wrote that I've found that in the document it shows [author,date] all hyperlinked, and in the references it shows [author,date] but only the date is hyperlinked, not quite what I'm wanting. Ideally I'm looking for both sets of references to be fully hyperlinked, instead of at present, only partially. – boudiccas May 25 '14 at 16:46
  • @boudiccas If I add the code you linked to above to make the entire citation hyperlinked to my MWE above, I get full hyperlinks. If you for some reason do not get what you want, please consider to ask a new question ideally with an MWE. (But be warned that hyperlinking entire citations is quite a tricky business, especially with compressing stiles such as authoryear-icomp.) – moewe May 25 '14 at 20:05

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.