# Memoir citation in margin

by maero21   Last Updated January 14, 2018 03:23 AM

I am trying to add more information about the citations in the margins of the page. I am using the memoir document class. Essentially, I do not want to change anything about the cite command, I just want to add information in the margin.

What I have so far is this:

\documentclass[letterpaper,twoside,openany]{memoir}

\usepackage{lipsum}

\setmarginnotes{0.15in}{1.35in}{\baselineskip}
\setulmarginsandblock{1in}{1in}{*}
\setlrmarginsandblock{2.5in}{1.0in}{*}
\checkandfixthelayout
\reversemarginpar

\usepackage[hyperref=true,style=numeric-comp,
giveninits=true,backref,autocite=superscript,
sorting=none]{biblatex}

\newbibmacro{sidecite}{%
\scriptsize%
\printfield{labelnumber}.
\printnames{labelname}%
\setunit{\printdelim{nametitledelim}}%
\printfield[citetitle]{labeltitle}%
\printfield{year}}

\DeclareCiteCommand{\mcite}
{}
{\printtext[bibhyperref]{\textsuperscript{\printfield{labelnumber}}}%
\marginpar{\usebibmacro{sidecite}}%
}
{}
{}

% bib-file
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@book{Knu86,
author = {Knuth, Donald E.},
year = {1986},
title = {The \TeX book},
}
@BOOK{KandR,
AUTHOR    = {Kernighan, Brian W. and Ritchie, Dennis M.},
TITLE     = {{The C Programming Language Second Edition}},
PUBLISHER = {Prentice-Hall, Inc.},
YEAR      = {1988},
}
publisher = {Back Bay Books},
title = {Blink: The Power of Thinking Without Thinking},
year = {2005},
}
\end{filecontents}

\begin{document}

\lipsum[1] All hail Knuth.\mcite{Knu86}

\lipsum[2-3]
\TeX is hard\mcite{KandR,Gladwell2005}, but not impossible.

It should look like this: \TeX is hard\autocite{KandR,Gladwell2005}, but not impossible. Or perhaps even this\autocite{Knu86,KandR,Gladwell2005}.

\printbibliography

\end{document}


There are several problems here:

1) The superscript in the mcite command does not act as nice as the autocite command, in that it has problems figuring out its proper place when there is punctuation.

2) Citations are no longer being combined nicely, i.e. instead of "2,3", now it says "23". In the same way, citation numbers should be combined to "1-3".

3) The mcite command does not work in captions.

Any idea how to fix any of these issues?

Tags :