0

My university want to use a cite style mixture from Harvard and Numeric style. Number I only get [Number (Author+Year)] with my example instead of [ Number ] (Author+Year). So I have some issues with brackets.

\documentclass[a4paper,fontsize=12pt,parskip]{scrbook}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Layout
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
%
\usepackage[labelfont={bf}]{caption}
\usepackage{subcaption}
\usepackage[pdfborder={0 0 0}]{hyperref}
\usepackage[]{geometry}
\renewcommand{\baselinestretch}{1.2}          
\setlength\parindent{0pt}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Seitenränder und Abstände
\geometry{
    textwidth=150mm,
    textheight=220mm,
    top=40mm,
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Literaturverzeichnis
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[german=guillemets]{csquotes}
%
\usepackage[backend=biber,style=numeric,maxnames=5,minnames=5,maxcitenames=2,mincitenames=1,datamodel=eprint-hal]{biblatex}

\renewbibmacro*{cite}{%
  \printtext[bibhyperref]{%
      \printtext[hardbrackets]{%
      \printfield{prefixnumber}%
      \printfield{labelnumber}%
      \ifbool{bbx:subentry}
        {\printfield{entrysetcount}}
        {}}
    \printtext[parens]{%
    \printnames{labelname}%
    \setunit{\nameyeardelim}%
    \setunit{\addcomma\space}
    \printfield{year}%
}}}
%
\addbibresource{biblatex-examples.bib}
\begin{document}


ba bla
\cite{springer}
%Literaturverzeichnis
\printbibliography[heading=bibintoc,title=Literaturverzeichnis]
\end{document}

1 Answer 1

2

In the code that you are using (probably from Is there a package that allows a citation style of [Author, year] [number]?) the brackets are implicitly added by \cite via its wrapper command. This is not something we want for your application, because we have different types of brackets.

It appears to me that it would be easiest to define a new \cite command so that we get full control over the brackets. The remainder of the approach is similar to Is there a package that allows a citation style of [Author, year] [number]?.

\documentclass[12pt]{article}

\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage[pdfborder={0 0 0}]{hyperref}
\usepackage[german=guillemets]{csquotes}

\usepackage[
  backend=biber,
  style=numeric,
  maxbibnames=5, minbibnames=5,
  maxcitenames=2, mincitenames=1,
]{biblatex}

\newbibmacro*{naycite}{%
  \printtext[bibhyperref]{%
    \printtext[brackets]{%
      \printfield{labelprefix}%
      \printfield{labelnumber}%
      \ifbool{bbx:subentry}
        {\printfield{entrysetcount}}
        {}}
    \setunit{\addspace}%
    \printtext[parens]{%
      \printnames{labelname}%
      \setunit{\printdelim{nameyeardelim}}%
      \printdate}}}

\DeclareCiteCommand{\naycite}
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{naycite}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareMultiCiteCommand{\naycites}{\naycite}{\multicitedelim}
\DeclareAutoCiteCommand{nay}{\naycite}{\naycites}
\ExecuteBibliographyOptions{autocite=nay}

\addbibresource{biblatex-examples.bib}

\begin{document}
lorem \autocite{sigfridsson}
lorem \autocite{springer}

\printbibliography[heading=bibintoc,title=Literaturverzeichnis]
\end{document}

lorem [1] (Sigfridsson und Ryde 1998) lorem [2] (Springer 1950)

If you want bigger brackets around the entire expression you could try something like

\newrobustcmd*{\mkbibbiggerbrackets}[1]{%
  {\large[}#1{\large]}}

\DeclareCiteCommand{\naycite}[\mkbibbiggerbrackets]
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{naycite}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

Not that I'd recommend it in any shape or form.

14
  • Thanks for your support and the quick response. I hoped to fined a solution were I can still use \cite (just in case I want to change it back to calssic numeric or whatever) but maybe this is the best solution. Or is possible to change it to ([2] Springer,1950) and still use \cite?
    – ArminMeise
    Apr 27, 2022 at 17:32
  • @ArminMeise Actually, \autocite makes it extremely easy to switch back to a different citation style. Just change \ExecuteBibliographyOptions{autocite=nay} in the example to \ExecuteBibliographyOptions{autocite=plain} to get numeric citations with just one simple change. (It should be trivial to change your existing document from \cite to \autocite as every good editor has a search-and-replace feature.)
    – moewe
    Apr 27, 2022 at 19:50
  • Of course it is also possible to adapt my answer to modify \cite instead of \autocite, but I really want to advertise the advantages of \autocite.
    – moewe
    Apr 27, 2022 at 19:51
  • Thank you! Youre right, it is easy to switch from cite to autocite and thats the best solution for me.
    – ArminMeise
    Apr 28, 2022 at 7:18
  • Is it also possible with your solution to do something like [[2](Springer 1950)] but the first and last bracket should be bigger then the bracket around [2]. Any Ideas? Hope you can help me ;-)
    – ArminMeise
    Apr 29, 2022 at 8:35

You must log in to answer this question.

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