Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

share|improve this question
    
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

1 Answer 1

up vote 2 down vote accepted

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} 
share|improve this answer
    
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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.