如何为 '\bibentry' 提供背景颜色

如何为 '\bibentry' 提供背景颜色

我如何为 指定背景颜色\bibentry?类似这样(通过使用\bibentry{ahlswede2000network}):

Bibentry:Ahlswede, R.、Cai, N.、Li, S.-YR 和 Yeung, RW (2000)。网络信息流。信息理论,IEEE 交易,46(4):1204–1216

这是一个要测试的条目。

@article{ahlswede2000network,
  title={Network information flow},
  author={Ahlswede, Rudolf and Cai, Ning and Li, Shuo-Yen Robert and Yeung, Raymond W},
  journal={Information Theory, IEEE Transactions on},
  volume={46},
  number={4},
  pages={1204--1216},
  year={2000},
  publisher={IEEE}
}

答案1

您可以使用tcolorbox并重新定义了\bibenty。一个小例子(根据需要调整设置):

\documentclass{article}
\usepackage[many]{tcolorbox}
\usepackage{natbib}
\usepackage{bibentry}

\definecolor{bibentrybg}{RGB}{249,245,233}

\makeatletter
\renewcommand\bibentry[1]{
\begin{tcolorbox}[
  breakable,
  enhanced jigsaw,
  boxsep=0pt,
  arc=0pt,
  outer arc=0pt,
  frame code={},
  interior code={
    \fill[bibentrybg] (interior.north west) rectangle (interior.south east);
    \draw[double] (interior.north west) -- (interior.north east);
    \draw[double] (interior.south west) -- (interior.south east);
  }
]%
  \nocite{#1}{\frenchspacing
  \hyper@natanchorstart{#1\@extra@b@citeb}%
  \@nameuse{BR@r@#1\@extra@b@citeb}\hyper@natanchorend}
\end{tcolorbox}  
}
\makeatother

\usepackage{filecontents}
\begin{filecontents*}{xyyzzz.bib}
@article{ahlswede2000network,
  title={Network information flow},
  author={Ahlswede, Rudolf and Cai, Ning and Li, Shuo-Yen Robert and Yeung, Raymond W},
  journal={Information Theory, IEEE Transactions on},
  volume={46},
  number={4},
  pages={1204--1216},
  year={2000},
  publisher={IEEE}
}
\end{filecontents*}

\begin{document}

\nobibliography*
\bibentry{ahlswede2000network}

\bibliographystyle{plain}
\bibliography{xyyzzz}

\end{document}

在此处输入图片描述

如果该框仅应用于选定的框,则无需重新定义\bibentry;只需将括\bibentry在中即可tcolorbox

\documentclass{article}
\usepackage[many]{tcolorbox}
\usepackage{natbib}
\usepackage{bibentry}

\definecolor{bibentrybg}{RGB}{249,245,233}

\newtcolorbox{MyBox}{
  breakable,
  enhanced jigsaw,
  boxsep=0pt,
  arc=0pt,
  outer arc=0pt,
  leftrule=0pt,
  rightrule=0pt,
  colback=bibentrybg,
}

\usepackage{filecontents}
\begin{filecontents*}{xyyzzz.bib}
@article{ahlswede2000network,
  title={Network information flow},
  author={Ahlswede, Rudolf and Cai, Ning and Li, Shuo-Yen Robert and Yeung, Raymond W},
  journal={Information Theory, IEEE Transactions on},
  volume={46},
  number={4},
  pages={1204--1216},
  year={2000},
  publisher={IEEE}
}
\end{filecontents*}

\begin{document}

\nobibliography*

\begin{MyBox}
\bibentry{ahlswede2000network}
\end{MyBox}

\bibliographystyle{plain}
\bibliography{xyyzzz}

\end{document}

相关内容