1

My thesis supervisor wants the following format for citations :

This is the body of the text (Author, 2018)1.


  1. Guy Author, Latex love, 2018. DOI:89453XXX:547

Which combination of bib(la)tex/nat/jurabib/styles can achieve this ?

I could only find this related question : Footnotes with author-year inline citation but the footnotes don't have a number. Of course, the full citation should only appear in the footnote for the first occurence. I could insert all the footnotes manually but \bibentry doesn't work with natbib.

Other answers involve pages of macros to achieve very specific needs, but it should be doable 'natively', right? Also now I just get a numerical reference when I compile, even-though I am using Author-year style (https://i.stack.imgur.com/XeREq.jpg). I tried compiling several times, to no avail.

All help welcome.

n49o7
  • 133
  • biblatex is probably your best choice. You are not using biblatex at the moment, so while you are waiting for an answer you may want to check out how to get biblatex to work with LyX. LyX 2.3 (released this spring) has massively improved support for biblatex, so if you can upgrade, you may want to consider doing that (as always upgrades or updates shortly before a deadline can be ill-advised, you never know what breaks). For older versions of LyX you can have a look at https://tex.stackexchange.com/q/298382/35864. For LyX 2.3 see https://wiki.lyx.org/BibTeX/Biblatex – moewe Jul 18 '18 at 14:03
  • LyX 2.3 solves my problem. It has all the required bells and whistles in the Bibliography settings. Should I delete this question ? – n49o7 Jul 18 '18 at 14:32
  • No, please write an answer that describes what you did and how it solved your problem. – moewe Jul 18 '18 at 14:32
  • I will but I'm still trying to figure out how to get the authors' names in normal case and a comma afterwards. I have (AUTHOR 2018) (with weird kerning) and I'm aiming for (Author, 2018). – n49o7 Jul 18 '18 at 15:01
  • Are you French by any chance? Then https://tex.stackexchange.com/q/438423/35864 should help. Otherwise it would help me to see an example of what you are doing and how it goes wrong, see https://tex.meta.stackexchange.com/q/228/35864, https://tex.meta.stackexchange.com/q/4407/35864, https://wiki.lyx.org/FAQ/MinimalExample – moewe Jul 18 '18 at 15:04
  • Indeed the capitalization of names is caused by the french language setting. \DefineBibliographyExtras{french}{\restorecommand\mkbibnamefamily} produces an error when placed in the preamble. MNWE : https://pastebin.com/raw/cjWJ1G9X -- I was able to get a comma by using Biblatex (natbib mode) as style format. – n49o7 Jul 18 '18 at 15:20
  • What error exactly? I suspect your biblatex version is outdated. – moewe Jul 18 '18 at 15:21
  • 'Undefined control sequenceupon parsing the command, and cascading errors from there. Apparently I'm usingBiblatex 3.11, even-though I ran MikTex update before updating toLyX 2.3`, so that could very well be it. I'll sort it out. In the meantime your answer is pretty good. I'll still post mine. – n49o7 Jul 18 '18 at 15:51
  • Mhhh, biblatex 3.11 is the current version. So that can't be it. Can you cite which command exactly is supposed to be undefined? – moewe Jul 18 '18 at 15:52
  • All of them, ha ha. Here's the relevant part of the log : https://pastebin.com/raw/zjKRz0cC I think it's because in Lyx the user can't put anything after \makeatother and before \begin{document}, unless they edit the LyX file directly. – n49o7 Jul 18 '18 at 15:57
  • Ah, I see. These things need to be loaded after biblatex. And biblatex is only loaded right before \begin{document}. Can you somehow tell LyX to move the \DefineBibliographyExtras{french}{\restorecommand\mkbibnamefamily} to after \usepackage{biblatex}? – moewe Jul 18 '18 at 15:59
  • The LyX file does not contain the latex source but commands which are used to generate the source. Depending on where I insert the line, I either get an error when opening the file with LyX or nothing at all. This is a question for the LyX forums. There's probably a way somewhere to pass this as an option. PS : This is like the longest comment thread on SE, right ? – n49o7 Jul 18 '18 at 16:10
  • Just installing LyX to see if there is a way to convince it to accept preamble options after it loads biblatex. But indeed I think this is something you should raise in a LyX forum regardless. If there is non good way, you may want to phrase this is a a feature request. It really is crucial for biblatex's customisability to be able to insert code in the preamble after biblatex is loaded. And no, I don't think this is the longest comment thread, they often have the tendency to grow uncontrollably when I get involved ;-) – moewe Jul 18 '18 at 16:13
  • See the answer here: https://tex.stackexchange.com/questions/313150/prevent-lyx-from-automatically-including-packages and replace "graphicx" with "biblatex". Then you are responsible for loading biblatex in the preamble, and you can put whatever you want before it and after it. – scottkosty Jul 19 '18 at 07:38
  • But then the command \DefineBibliographyExtras{french}{\restorecommand\mkbibnamefamily} is still in the preamble, when it should be between the end of the preamble and the beginning of the document. – n49o7 Jul 19 '18 at 13:15

2 Answers2

1

This is not exactly what your professor seems to want, but it might be close enough

\documentclass[french]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{csquotes}

\usepackage[style=authoryear, backend=biber, citetracker]{biblatex}

\addbibresource{biblatex-examples.bib}

\newbibmacro{fullcite}{%
  \usedriver
    {\DeclareNameAlias{sortname}{default}}
    {\thefield{entrytype}}}

\DeclareFieldFormat{footnote}{\mkbibfootnote{#1}}
\DeclareCiteCommand{\ffparencite}[\mkbibparens]
  {\usebibmacro{prenote}}%
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}%
   \ifciteseen
     {}
     {\printtext[footnote]{\usebibmacro{fullcite}}}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareMultiCiteCommand{\ffparencites}[\mkbibparens]{\ffparencite}{\multicitedelim}

\DeclareAutoCiteCommand{inlineff}{\ffparencite}{\ffparencites}
\ExecuteBibliographyOptions{autocite=inlineff}

\DeclareDelimFormat{nameyeardelim}{\addcomma\space}
\DefineBibliographyExtras{french}{\restorecommand\mkbibnamefamily}

\begin{document}
\autocite{sigfridsson} and \autocite{sigfridsson}

\autocite{nussbaum,geer}

\printbibliography
\end{document}

The code automatically adds a footnote with the full reference on the first citation. The footnote is inside the brackets to give reasonable output for the case \autocite{nussbaum,geer}.

enter image description here

Alternatively,

\documentclass[french]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{csquotes}

\usepackage[style=authoryear, backend=biber, citetracker]{biblatex}

\addbibresource{biblatex-examples.bib}

\makeatletter
\newcommand*{\ffparenwrap}[1]{%
  \undef\blx@ffcite
  \mkbibparens{#1}%
  \ifundef\blx@ffcite
    {}
    {\footfullcite{\blx@ffcite}}%
}

\DeclareCiteCommand{\ffparencite}[\ffparenwrap]
  {\usebibmacro{prenote}}%
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}%
   \ifciteseen
     {}
     {\ifundef\blx@ffcite
        {\xdef\blx@ffcite{\thefield{entrykey}}}
        {\xappto\blx@ffcite{,\thefield{entrykey}}}}}
  {\multicitedelim}
  {\usebibmacro{postnote}}
\makeatother

\DeclareMultiCiteCommand{\ffparencites}[\mkbibparens]{\ffparencite}{\multicitedelim}

\DeclareAutoCiteCommand{inlineff}{\ffparencite}{\ffparencites}
\ExecuteBibliographyOptions{autocite=inlineff}

\DeclareDelimFormat{nameyeardelim}{\addcomma\space}
\DefineBibliographyExtras{french}{\restorecommand\mkbibnamefamily}

\begin{document}
\autocite{sigfridsson} and \autocite{sigfridsson}

\autocite{nussbaum,geer}

\printbibliography
\end{document}

makes sure that the footnote comes outside the round brackets. But it has to coerce several citations into one footnote to achieve this.

enter image description here

If you change \makeatletter...\makeatother block to

\makeatletter
\newcommand*{\ffparenwrap}[1]{%
  \let\blx@ffcite\@empty
  \mkbibparens{#1}%
  \ifdefvoid\blx@ffcite
    {}
    {\forlistloop{\footfullcite}{\blx@ffcite}}%
}

\DeclareCiteCommand{\ffparencite}[\ffparenwrap]
  {\usebibmacro{prenote}}%
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}%
   \ifciteseen
     {}
     {\listxadd\blx@ffcite{\thefield{entrykey}}}}
  {\multicitedelim}
  {\usebibmacro{postnote}}
\makeatother

the citations get a footnote each at the expense of possibly clashing footnotes.

moewe
  • 175,683
1

LyX 2.3 makes this a breeze. Just select your settings in the 'Bibliography' tab of the document settings.

document settings

To get a comma between author and date, use Biblatex (natbib mode).

I then added the footnotes manually, which gave me more flexibility.

For a way to do all this automatically in LaTeX, check out meowe's answer.

n49o7
  • 133