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 Answers1

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.

moewe
  • 175,683
  • 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 '22 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 '22 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 '22 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 '22 at 07: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 '22 at 08:35
  • @ArminMeise I'm guessing it should be possible, but before I edit the answer, are you really sure this is what your university wants? (And also what you want?) The number of brackets is already quite large and adding another pair just makes the citation look ridiculous. (It already looks very unusual due to the fact that it essentially combines two citation styles for a lot of redundancy. I have never seen a published paper or serious book using such a style.) – moewe Apr 29 '22 at 12:16
  • I know, it is a lot of redundancy but I thought [[2](Springer 1950)] looks maybe better then [2](Springer 1950) – ArminMeise Apr 29 '22 at 14:46
  • @ArminMeise See the edit. I don't really think the additional brackets make things better, but if you insist ... (As you requested I made the additional brackets slightly bigger, which I find not very elegant, but...) – moewe Apr 29 '22 at 15:38
  • thanks a lot! you realy helped me! – ArminMeise Apr 29 '22 at 15:51
  • I tried your modified and it works realy fine! Thanks again. Your right about the bracket size, it looks a little bit ridiculous. Maybe it is possible to change the font size of autocite, so that the outer bracket is in the same size like the text and the [2](Springer 1950) font size is a little smaller? maybe this looks more compacted. but only in the text and not in the biblography – ArminMeise Apr 30 '22 at 09:39
  • @ArminMeise Try \newrobustcmd*{\mkbibbiggerbrackets}[1]{[{\small#1}]} then. But in the end I still think this is a lipstick-on-a-pig situation. The citation style itself is so unwieldy (and I would argue flawed) that cosmetic changes like this don't make a huge difference. – moewe Apr 30 '22 at 09:56
  • but that changed only the outer brackets to small right? but the input like [2](Springer 1950) should also be onefont size smaller – ArminMeise Apr 30 '22 at 10:04
  • and I got an error : ! LaTeX Error: Command \mkbibbiggerbrackets already defined. – ArminMeise Apr 30 '22 at 10:06
  • @ArminMeise Well, you need to replace the previous definition of \mkbibbiggerbrackets. – moewe Apr 30 '22 at 10:08