6

I use the showlabels package to highlight labels, references and citations. It appears that, by default, showlabels cannot wrap the keys in the marginpar. If I have a series of citations in one line, only one or two keys are shown and the rest disappears.

Is it possible to force the wrapping of keys in the marginpar?

MWE:

\documentclass{article}

% \usepackage{showkeys}

\usepackage{showlabels}
\showlabels{cite}

\usepackage{filecontents}
\usepackage[
    style=alphabetic,
    sorting=nyt,
    firstinits=true,
    backend=biber
]{biblatex}

\begin{filecontents}{references.bib}
  @report{example1,
    author={{Archibald Author}},
    title={Archies first report}
    }
  @report{example2,
    author={{Archibald Author}},
    sortname={Author, Archibald},
    title={Archies second report}
    }
  @report{example3,
    author={Archibald Author},
    sortname={Author, Archibald},
    title={Archies third report}
    }
  @report{example4,
    author={Buthor, Baltasar},
    title={Balties report}
    }
  @report{example5,
    author={Cuthor, Charlie},
    title={Charlies report}
    }
\end{filecontents}
\bibliography{references.bib}

\begin{document}
  \cite{example1,example2,example3,example4,example5}
  \printbibliography
\end{document}

enter image description here

Dror
  • 22,613
Jörg
  • 7,653
  • Please make a small example showing the problem, Also have you tried the showkeys package which is similar but different. If there were an MWE it would be easy to compare. – David Carlisle Jun 21 '12 at 14:14
  • @DavidCarlisle MWE added. Yes, I tried showkeys but afaik it always prints labels on the left margin and I use twoside documents. I also tried the inline option of showlabels, but then long lists of keys still disappear somewhere in the margin. – Jörg Jun 21 '12 at 14:30
  • I've added this as an enhancement request. I'm pretty nervous of adding any fragility to showlabels, though... – Norman Gray Dec 06 '14 at 22:42

1 Answers1

2

Always good to hack the opposition:-)

enter image description here

\documentclass{article}

% \usepackage{showkeys}

\usepackage{showlabels}
\showlabels{cite}

\makeatletter
\def\SL@margtext#1{%
  \ifmmode
    \xdef\SL@labelname{\SL@prlabelname{#1}}%
  \else
    \setbox\@tempboxa=\vtop to 0pt{\vss
  \@for\@tmpa:=#1\do{%
      \hbox to \hsize{\expandafter\SL@lrtext\expandafter{\@tmpa}}}\vss}%
    \dp\@tempboxa\z@
    \ifvmode
      \@tempdima=\prevdepth
      \nointerlineskip\box\@tempboxa\nobreak
      \prevdepth=\@tempdima
    \else
      \vadjust{\box\@tempboxa\nobreak}%
    \fi
  \fi
}
\let\SL@setlabel\SL@margtext
\makeatother

\usepackage{filecontents}
\usepackage[
    style=alphabetic,
    sorting=nyt,
    firstinits=true,
    backend=bibtex
]{biblatex}

\begin{filecontents}{references.bib}
  @report{example1,
    author={{Archibald Author}},
    title={Archies first report}
    }
  @report{example2,
    author={{Archibald Author}},
    sortname={Author, Archibald},
    title={Archies second report}
    }
  @report{example3,
    author={Archibald Author},
    sortname={Author, Archibald},
    title={Archies third report}
    }
  @report{example4,
    author={Buthor, Baltasar},
    title={Balties report}
    }
  @report{example5,
    author={Cuthor, Charlie},
    title={Charlies report}
    }
\end{filecontents}
\bibliography{references.bib}

\begin{document}
  \cite{example1,example2,example3,example4,example5}
  \printbibliography
\end{document} 
David Carlisle
  • 757,742
  • Thanks for this! Unfortunately, when having multiple separated citations in one line they are all on overlayed in the maginpar. E.g. try the MWE with In one line: \cite{example1} and \cite{example2} \cite{example3} and \cite{example4} or \cite{example5}. – Jörg Jun 21 '12 at 15:05
  • yes.... but it does that anyway I think, ie my change didn't make it worse:-) It's a bit tricky to change that as showlables buts each in a zero sized box so as not to mess up the document spacing, but that does mean two labels can over-print – David Carlisle Jun 21 '12 at 15:38
  • I just realised that this is the default behaviour of showlabels...oh well. I guess a quick workaround would be to use showlabels for labels in the margin and use your showkeys package to show citations. Do you have a quick-and-dirty workaround to deactivate labels in showkeys? – Jörg Jun 21 '12 at 15:41
  • not loading both packages sounds brave but the showkeys [notref] option may do what you want – David Carlisle Jun 21 '12 at 15:45
  • No, notref still loads labels. – Jörg Jun 21 '12 at 15:59
  • sorry out of time today – David Carlisle Jun 21 '12 at 16:02
  • For what it's worth, I've not tried to add this sort of functionality to showlabels (I'm its author) because I see it as a draft-only package for the most part, so that cosmetic improvements aren't worth the cost of increased fragility. (Hmm: am I able to add a {showlabels} tag?] – Norman Gray Apr 06 '13 at 20:52