showlabels: 在 marginpar 中包装标签

showlabels: 在 marginpar 中包装标签

我使用该showlabels包来突出显示标签、参考文献和引文。默认情况下,似乎showlabels无法将键包装在 marginpar 中。如果我在一行中有一系列引文,则只会显示一个或两个键,其余的键会消失。

是否可以强制在 marginpar 中包装密钥?

梅威瑟:

\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}

在此处输入图片描述

答案1

攻击对手总是好的:-)

在此处输入图片描述

\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} 

相关内容