0

I was wondering if you would possibly have any input on how to manipulate the following MWE in a way that the Author-year Tag to the left of the bibliography entry in the following example is reduced to footnotesize or script size to prevent line-breaks. (I am using biblatex/Biber and XeTeX)

AUTHOR YEAR [space] SURNAME, Given Name (2017). A title. Place: Publisher.

Somebody had written a great code in a forum which I have applied here, it has all other features but the script-size.

MWE:

\documentclass[12pt,a4paper]{report}

\AtBeginDocument{\addbibresource{C://thesisbibfile/thesis.bib}}

\usepackage[
backend=biber,
autolang=hyphen, %which parameters are important when changing languages according to entry language id in the database
citestyle=authoryear, %style when citing, 
bibstyle=authoryear-icomp, %style in the bibliography
language=auto,
%hyperref,
autocite=inline %plain %inline / footnote
url=true, 
dashed=false,
doi=true,
sortlocale=auto,
]{biblatex}%this style compresses the numbering 


\makeatletter
\setlength{\bibitemsep}{0.5\baselineskip plus 0.5\baselineskip}

\newsavebox\ay@labelbox
\newlength{\labwidthsameline}
\setlength{\labwidthsameline}{2em}   % the {xem} defines the length of the label: best is either 2 or 9 em

\newbibmacro{labelwidthbib}{%
    \begingroup
    \DeclareFieldFormat{bibhyperref}{##1}%
    \csuse{blx@hook@cite}%
    \csuse{blx@hook@citekey}%
    \citetrackerfalse\pagetrackerfalse\backtrackerfalse
    \defcounter{maxnames}{\blx@maxcitenames}%
    \usebibmacro{cite}%
    \endgroup
} 
%-----------------------
\newbibmacro{kicklabel}{% 
    \sbox\ay@labelbox{\usebibmacro{labelwidthbib}}%
    \global\togglefalse{blx@insert}%
    \ifdim\wd\ay@labelbox>\labwidthsameline
    \leavevmode\newline
    \fi
}

\defbibenvironment{bibliography}%
{\list
    {\usebibmacro{labelwidthbib}}%
    {\setlength{\labelwidth}{\labwidthsameline}%
        \setlength{\leftmargin}{\labelwidth}%
        \setlength{\labelsep}{\biblabelsep}%
        \addtolength{\leftmargin}{\labelsep}%
        \setlength{\itemsep}{\bibitemsep}%
        \setlength{\parsep}{\bibparsep}%
        \renewcommand*{\makelabel}[1]{##1\hss}}}%
{\endlist}%
{\item\usebibmacro{kicklabel}}
\makeatother

\begin{document}
\cite{Robertson1989}

\printbibliography
\end{document}
moewe
  • 175,683

1 Answers1

3

Just put the \scriptsize into the labelwidthbib macro as such

\newbibmacro{labelwidthbib}{%
  \begingroup
  \scriptsize
  \delimcontext{cite}%
  \DeclareFieldFormat{bibhyperref}{##1}%
  \csuse{blx@hook@cite}%
  \csuse{blx@hook@citekey}%
  \citetrackerfalse\pagetrackerfalse\backtrackerfalse
  \defcounter{maxnames}{\blx@maxcitenames}%
  \usebibmacro{cite}%
  \endgroup
} 

biblatex-ext has this feature built-in already (the relevant option is called introcite) and so the code can be shortened considerably to

\documentclass[british]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{csquotes}
\usepackage[
  backend=biber,
  style=ext-authoryear-icomp,
  autocite=inline,
  introcite=label,
]{biblatex}

\addbibresource{biblatex-examples.bib}

\setlength{\bibitemsep}{0.5\baselineskip plus 0.5\baselineskip}
\setlength{\introcitewidth}{0em}
\setlength{\introcitesep}{2\biblabelsep}

\DeclareFieldFormat{bbx@introcite}{{\scriptsize #1}}

\begin{document}
\cite{sigfridsson}

\printbibliography
\end{document}

Sigfridsson and Ryde 1998 in <code>\scriptsize</code> followed by the full bib entry in the next line (indented)

moewe
  • 175,683
  • sorry I hit the downvote button by mistake - to remedy, I upvoted twice and marked it as the optimum answer, since it fully answered my question. Excuse the slip. Kindly, thank you, J – Gyalten Jigdrel Feb 12 '17 at 12:06
  • @GyaltenJigdrel Don't worry: your downvote is not counted, as well as one of your upvotes. –  Mar 11 '19 at 15:38