4

I'm happily using BibLaTeX (3.4) with Biber (2.5).

With some tricks found on http://tex.stackexchange.com I've obtained exactly what I desire for my bibliography but I have a problem with footnote citations.

I would like this result: enter image description here but using the same command for the first and second footnote citations, in oder to avoid bothering about which is the first citation.

Note that I want the automatic “ibidem” only in footnotes (I found here: ibidem only in the footnotes and not in the running text how to do it) and I have some bib items with shortauthor.

Here is the MWE:

\documentclass[11pt,openright]{book}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{verbatim}
\usepackage[british,english]{babel}
\usepackage{filecontents}

% package hyperref
\usepackage[unicode=true,pdfusetitle,
bookmarks=true,bookmarksnumbered=false,bookmarksopen=false,
breaklinks=false,pdfborder={0 0 1},backref=false,colorlinks=false]
{hyperref}

% ibidem only in footnotes
\makeatletter
\def\blx@opt@ibidtracker@foot{%
\let\blx@imc@ifciteibid\blx@ifciteibid@foot
\let\blx@ibidtracker\blx@ibidtracker@foot
\let\blx@ibidreset\blx@ibidreset@foot
\booltrue{citetracker}}

\def\blx@ifciteibid@foot{%
\ifbool{citetracker}
{\iftoggle{blx@footnote}
    {\blx@imc@iffieldequals{entrykey}\blx@lastkey@text}
    {\@secondoftwo}}
{\@secondoftwo}}

 \def\blx@ibidtracker@foot{%
\ifbool{citetracker}
{\iftoggle{blx@footnote}
    {\global\let\blx@lastkey@text\abx@field@entrykey}
    {\global\let\blx@lastkey@foot\abx@field@entrykey}}
{}}

\def\blx@ibidreset@foot{%
\iftoggle{blx@footnote}
{\global\undef\blx@lastkey@text}}
{}
\makeatother

% biblatex package
\usepackage[style=authoryear-icomp, natbib=true, backend=biber, hyperref=true, ibidtracker=foot, pagetracker=page]{biblatex} 
\usepackage{csquotes}

\addbibresource{\jobname.bib}

% CITATION
% no comma in author (year)
\renewcommand{\nameyeardelim}{\addspace}

% unified hyperlink on author (year) 
\DeclareFieldFormat{citehyperref}{%
\DeclareFieldAlias{bibhyperref}{noformat}% Avoid nested links
\bibhyperref{#1}}
\DeclareFieldFormat{textcitehyperref}{%
\DeclareFieldAlias{bibhyperref}{noformat}% Avoid nested links
\bibhyperref{%
    #1%
    \ifbool{cbx:parens}
    {\bibcloseparen\global\boolfalse{cbx:parens}}
    {}}}
\savebibmacro{cite}
\savebibmacro{textcite}
\renewbibmacro*{cite}{%
\printtext[citehyperref]{%
    \restorebibmacro{cite}%
    \usebibmacro{cite}}}
\renewbibmacro*{textcite}{%
\ifboolexpr{
    not test {\iffieldundef{postnote}} and
    test {\ifnumequal{\value{citecount}}{\value{citetotal}}} 
}
{\DeclareFieldAlias{textcitehyperref}{noformat}}
{}%
\printtext[textcitehyperref]{%
    \restorebibmacro{textcite}%
    \usebibmacro{textcite}}}

% unified hyperlink on (author, year)
\DeclareCiteCommand{\citep}[\mkbibparens]
{\usebibmacro{cite:init}\usebibmacro{prenote}}
{\def\nameyeardelim{\addcomma\addspace}%
\usebibmacro{citeindex}%
\printtext[bibhyperref]{\usebibmacro{cite}%
    \def\nameyeardelim{\addspace}}}
{\multicitedelim}
{\usebibmacro{postnote}}

\begin{filecontents}{\jobname.bib}

@article{item,
title={Title A},
author={AuthorA, NameA},
year={2015}
}
@manual{shortitem,
title={Title C},
author={{Basel Committee on Banking Supervision}},
year={1988},
shortauthor = {BCBS}
}

\end{filecontents}

\begin{document}

First footnote citation when the bib item has only "author".\footnote{\citet{item} for first footnote citation when the bib item has only "author".} \\
Second footnote citation when the bib item has only "author".\footnote{\Cite{item} for second footnote citation when the bib item has only "author".} 

First footnote citation when the bib item also has "shortauthor".\footnote{\citet{shortitem} for first footnote citation when the bib item also has "shortauthor".} \\
Second footnote citation when the bib item also has "shortauthor".\footnote{\Cite{shortitem} for second footnote citation when the bib item also has "shortauthor".} \\
\end{document}

EDIT:

Trying to found a solution by myself, I've added this command (please don't laught):

\DeclareCiteCommand{\citet}
    {\usebibmacro{cite:init}\usebibmacro{prenote}}
    {\ifciteibid{\usebibmacro{cite}}{\usebibmacro{textcite}}}
    {\multicitedelim}
    {\usebibmacro{postnote}}

Now, if I use \Citet for all the citations of the original MWE, it works, but if I try to put the page number in a citation I get the error:

! Package biblatex Error: Unbalanced parentheses or brackets.

See the new MWE:

\documentclass[11pt,openright]{book}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{verbatim}
\usepackage[british,english]{babel}
\usepackage{filecontents}

% package hyperref
\usepackage[unicode=true,pdfusetitle,
bookmarks=true,bookmarksnumbered=false,bookmarksopen=false,
breaklinks=false,pdfborder={0 0 1},backref=false,colorlinks=false]
{hyperref}

% ibidem only in footnotes
\makeatletter
\def\blx@opt@ibidtracker@foot{%
    \let\blx@imc@ifciteibid\blx@ifciteibid@foot
    \let\blx@ibidtracker\blx@ibidtracker@foot
    \let\blx@ibidreset\blx@ibidreset@foot
    \booltrue{citetracker}}

\def\blx@ifciteibid@foot{%
    \ifbool{citetracker}
    {\iftoggle{blx@footnote}
        {\blx@imc@iffieldequals{entrykey}\blx@lastkey@text}
        {\@secondoftwo}}
    {\@secondoftwo}}

\def\blx@ibidtracker@foot{%
    \ifbool{citetracker}
    {\iftoggle{blx@footnote}
        {\global\let\blx@lastkey@text\abx@field@entrykey}
        {\global\let\blx@lastkey@foot\abx@field@entrykey}}
    {}}

\def\blx@ibidreset@foot{%
    \iftoggle{blx@footnote}
    {\global\undef\blx@lastkey@text}}
{}
\makeatother

% biblatex package
\usepackage[style=authoryear-icomp, natbib=true, backend=biber, hyperref=true, ibidtracker=foot, pagetracker=page]{biblatex} 
\usepackage{csquotes}

\addbibresource{\jobname.bib}

% CITATION
% no comma in author (year)
\renewcommand{\nameyeardelim}{\addspace}

% unified hyperlink on author (year) 
\DeclareFieldFormat{citehyperref}{%
    \DeclareFieldAlias{bibhyperref}{noformat}% Avoid nested links
    \bibhyperref{#1}}
\DeclareFieldFormat{textcitehyperref}{%
    \DeclareFieldAlias{bibhyperref}{noformat}% Avoid nested links
    \bibhyperref{%
        #1%
        \ifbool{cbx:parens}
        {\bibcloseparen\global\boolfalse{cbx:parens}}
        {}}}
\savebibmacro{cite}
\savebibmacro{textcite}
\renewbibmacro*{cite}{%
    \printtext[citehyperref]{%
        \restorebibmacro{cite}%
        \usebibmacro{cite}}}
\renewbibmacro*{textcite}{%
    \ifboolexpr{
        not test {\iffieldundef{postnote}} and
        test {\ifnumequal{\value{citecount}}{\value{citetotal}}} 
    }
    {\DeclareFieldAlias{textcitehyperref}{noformat}}
    {}%
    \printtext[textcitehyperref]{%
        \restorebibmacro{textcite}%
        \usebibmacro{textcite}}}

% unified hyperlink on (author, year)
\DeclareCiteCommand{\citep}[\mkbibparens]
{\usebibmacro{cite:init}\usebibmacro{prenote}}
{\def\nameyeardelim{\addcomma\addspace}%
    \usebibmacro{citeindex}%
    \printtext[bibhyperref]{\usebibmacro{cite}%
        \def\nameyeardelim{\addspace}}}
{\multicitedelim}
{\usebibmacro{postnote}}

% My citet command
\DeclareCiteCommand{\citet}
    {\usebibmacro{cite:init}\usebibmacro{prenote}}
    {\ifciteibid{\usebibmacro{cite}}{\usebibmacro{textcite}}}
    {\multicitedelim}
    {\usebibmacro{postnote}}

\begin{filecontents}{\jobname.bib}

    @article{item,
        title={Title A},
        author={AuthorA, NameA},
        year={2015}
    }
        @manual{shortitem,
        title={Title C},
        author={{Basel Committee on Banking Supervision}},
        year={1988},
        shortauthor = {BCBS}
    }

\end{filecontents}

\begin{document}

    First footnote citation when the bib item has only "author".\footnote{\Citet{item} for first footnote citation when the bib item has only "author".} \\
    Second footnote citation when the bib item has only "author".\footnote{\Citet{item} for second footnote citation when the bib item has only "author".} 

    First footnote citation when the bib item also has "shortauthor".\footnote{\Citet{shortitem} for first footnote citation when the bib item also has "shortauthor".} \\
    Second footnote citation when the bib item also has "shortauthor".\footnote{\Citet{shortitem} for second footnote citation when the bib item also has "shortauthor".} \\ 
    Error with \citet[11]{item}.

\end{document}
2

At the end I've found the solution by myself.

I've deleted the code for the "unified hyperlinks" which was referred to authoryear, not to authoryear-icomp, and I've created my own \citet and \citep commands.

Here is the code:

\documentclass[11pt,openright]{book}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{verbatim}
\usepackage[british,english]{babel}
\usepackage{filecontents}

% package hyperref
\usepackage[unicode=true,pdfusetitle,
bookmarks=true,bookmarksnumbered=false,bookmarksopen=false,
breaklinks=false,pdfborder={0 0 1},backref=false,colorlinks=false]
{hyperref}

% ibidem only in footnotes
\makeatletter
\def\blx@opt@ibidtracker@foot{%
    \let\blx@imc@ifciteibid\blx@ifciteibid@foot
    \let\blx@ibidtracker\blx@ibidtracker@foot
    \let\blx@ibidreset\blx@ibidreset@foot
    \booltrue{citetracker}}

\def\blx@ifciteibid@foot{%
    \ifbool{citetracker}
    {\iftoggle{blx@footnote}
        {\blx@imc@iffieldequals{entrykey}\blx@lastkey@text}
        {\@secondoftwo}}
    {\@secondoftwo}}

\def\blx@ibidtracker@foot{%
    \ifbool{citetracker}
    {\iftoggle{blx@footnote}
        {\global\let\blx@lastkey@text\abx@field@entrykey}
        {\global\let\blx@lastkey@foot\abx@field@entrykey}}
    {}}

\def\blx@ibidreset@foot{%
    \iftoggle{blx@footnote}
    {\global\undef\blx@lastkey@text}}
{}
\makeatother

% biblatex package
\usepackage[style=authoryear-icomp, natbib=true, backend=biber, hyperref=true, ibidtracker=foot, pagetracker=page]{biblatex} 
\usepackage{csquotes}

\addbibresource{\jobname.bib}

% CITATION
% no comma in author (year)
\renewcommand{\nameyeardelim}{\addspace}
% semicolon as compcitedelim
\renewcommand{\compcitedelim}{;\addspace}

% my citet command
\DeclareCiteCommand{\citet}
{\usebibmacro{cite:init}%
    \usebibmacro{prenote}}
{\ifciteibid%
    {\usebibmacro{citeindex}\usebibmacro{cite}}%
    {\usebibmacro{citeindex}\usebibmacro{textcite}}}
{}
{\usebibmacro{textcite:postnote}}

% my citep command
\DeclareCiteCommand{\citep}[\mkbibparens]
{\usebibmacro{cite:init}\usebibmacro{prenote}}
{\def\nameyeardelim{\addcomma\addspace}%
    \usebibmacro{citeindex}%
    \usebibmacro{cite}}
{}
{\usebibmacro{cite:postnote}}

\begin{filecontents}{\jobname.bib}

    @article{itemA,
        title={Title A},
        author={AuthorA, NameA},
        year={2015}
    }
    @article{itemB,
        title={Title B},
        author={AuthorA, NameA},
        year={2015}
    }
    @article{itemC,
        title={Title C},
        author={AuthorA, NameA},
        year={2016}
    }
        @manual{shortitemA,
        title={Title A},
        author={{Basel Committee on Banking Supervision}},
        year={1988},
        shortauthor = {BCBS}
    }
     @manual{shortitemB,
        title={Title B},
        author={{Basel Committee on Banking Supervision}},
        year={1988},
        shortauthor = {BCBS}
     } 
     @manual{shortitemC,
        title={Title C},
        author={{Basel Committee on Banking Supervision}},
        year={2006},
        shortauthor = {BCBS}
        }
\end{filecontents}

\begin{document}

    Now footnotes work as I like:\\

    Author: first\footnote{\Citet{itemA} first footnote citation} and second\footnote{\Citet{itemA} second footnote citation} footnote\\
    Shortauthor: first\footnote{\Citet{shortitemA} first footnote citation} and second\footnote{\Citet{shortitemA} second footnote citation} footnote\\

        And also all the rest works:\\

    With author:\\

    \verb|\citet| normal: \citet{itemA} \\
    \verb|\citet| with page: \citet[1]{itemA}\\
    \verb|\citet| multicite: \citet{itemA, itemB, itemC}    \\

    \verb|\citep| normal: \citep{itemA}\\
    \verb|\citep| with page: \citep[1]{itemA}\\
    \verb|\citep| multicite: \citep{itemA, itemB, itemC}\\

    With shortauthor:\\

    \verb|\citet| normal: \citet{shortitemA} \\
    \verb|\citet| with page: \citet[1]{shortitemA}\\
    \verb|\citet| multicite: \citet{shortitemA, shortitemB, shortitemC}\\

    \verb|\citep| normal: \citep{shortitemA}\\
    \verb|\citep| with page: \citep[1]{shortitemA}\\
    \verb|\citep| multicite: \citep{shortitemA, shortitemB, shortitemC}

    \newpage

    Also footnotes with \verb|\citep| works as I like:\\

    Author: first\footnote{First footnote citation \citep{itemA} } and second\footnote{Second footnote citation \citep{itemA}} footnote\\
    Shortauthor: first\footnote{First footnote citation \Citep{shortitemA}} and second\footnote{Second footnote citation \citep{shortitemA}} footnote       

\end{document}

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.