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

3
  • 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. Commented Jun 21, 2012 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
    Commented Jun 21, 2012 at 14:30
  • I've added this as an enhancement request. I'm pretty nervous of adding any fragility to showlabels, though... Commented Dec 6, 2014 at 22:42

1 Answer 1

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} 
7
  • 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
    Commented Jun 21, 2012 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 Commented Jun 21, 2012 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
    Commented Jun 21, 2012 at 15:41
  • not loading both packages sounds brave but the showkeys [notref] option may do what you want Commented Jun 21, 2012 at 15:45
  • No, notref still loads labels.
    – Jörg
    Commented Jun 21, 2012 at 15:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .