使用不同背景颜色的Latex突出显示\引文和\ref

使用不同背景颜色的Latex突出显示\引文和\ref,latex,pdflatex,Latex,Pdflatex,嗨,我正在写一篇修改过的文章。我用不同的背景色突出显示修订文本的背景。我成功地突出了它们,但我无法突出底部参考文献中的引用 \documentclass[journal]{IEEEtran} \ifCLASSINFOpdf \else \fi %% Following for different color highlight using \textcolor{r1}{text} \usepackage[dvipsnames]{xcolor} \usepackage{soul} \colorle

嗨,我正在写一篇修改过的文章。我用不同的背景色突出显示修订文本的背景。我成功地突出了它们,但我无法突出底部参考文献中的引用

\documentclass[journal]{IEEEtran}
\ifCLASSINFOpdf
\else
\fi
%% Following for different color highlight using \textcolor{r1}{text}
\usepackage[dvipsnames]{xcolor}
\usepackage{soul}
\colorlet{r1}{ForestGreen!20}
\colorlet{r2}{Red!20}
\colorlet{r3}{RoyalPurple!20}
\newcommand{\Hl}[2][\empty]{%
\ifx#1\empty
\else
\sethlcolor{#1}%
\fi
\hl{#2}}
\usepackage{soul,color}
\soulregister\Hl{7}
\soulregister\ref7
\soulregister\pageref7

\begin{document}

 \Hl[r2]{I wanted to highlight this \cite{miguel14anestimator}. It was  
 successful highlighted in the main text. But the problem is it was not  
 highlighted in the Bottom References?} 

   @ARTICLE{miguel14anestimator,
    author={M. {Carrasco} and F. {Mancilla-David} and R. {Ortega}},
    journal={IEEE Trans. Ind. Electron.},
    title={An Estimator of Solar Irradiance in Photovoltaic Arrays With Guaranteed Stability Properties},
    year={2014},
    volume={61},
    number={7},
    pages={3359-3366},} 
\end{document}

\ref
与您的代码一起已经开箱即用。要使
\cite
也兼容,您可以添加
\soulregister\cite7

\documentclass[journal]{IEEEtran}
\ifCLASSINFOpdf
\else
\fi
%\usepackage[left=0.5in, right=0.5in,top=0.1in,bottom=0.1in]{geometry}
\usepackage{graphicx}
\usepackage{float}
\usepackage[skip=2pt,font=scriptsize]{caption} %\usepackage{caption}
\usepackage{subcaption}
\usepackage{array}
\usepackage{mdwmath}
\usepackage{mdwtab}
\usepackage{multirow}
\usepackage{amsmath}
\usepackage{siunitx}
%\usepackage{xcolor, soul}
%\sethlcolor{lightgray}
\usepackage{cancel}
\usepackage{amssymb}% http://ctan.org/pkg/amssymb
\usepackage{pifont}% http://ctan.org/pkg/pifont
%\usetikzlibrary{calc,matrix}
\usepackage{color,soul}
\usepackage{cite}
\newtheorem{theorem}{Theorem}{}
\newtheorem{corollary}{Corollary}{}
\newtheorem{remark}{Remark}{}
\hyphenation{op-tical net-works semi-conduc-tor}
%% Following for different color highlight using \textcolor{r1}{text}
\usepackage[dvipsnames]{xcolor}
\usepackage{soul}
\colorlet{r1}{ForestGreen!20}
\colorlet{r2}{Red!20}
\colorlet{r3}{RoyalPurple!20}
\newcommand{\Hl}[2][\empty]{%
\ifx#1\empty
\else
\sethlcolor{#1}%
\fi
\hl{#2}}
\usepackage{soul,color}
\soulregister\Hl{7}
\soulregister\ref7
\soulregister\cite7
\soulregister\pageref7

\begin{document}

\section{title}
\label{key}

\Hl{\ref{key}}

\Hl{\cite{knuth:ct:a}}

\bibliographystyle{plain}
\bibliography{biblatex-examples}

\end{document}


要突出显示bititem,请执行以下操作:

\documentclass[journal]{IEEEtran}
\ifCLASSINFOpdf
\else
\fi
%\usepackage[left=0.5in, right=0.5in,top=0.1in,bottom=0.1in]{geometry}
\usepackage{graphicx}
\usepackage{float}
\usepackage[skip=2pt,font=scriptsize]{caption} %\usepackage{caption}
\usepackage{subcaption}
\usepackage{array}
\usepackage{mdwmath}
\usepackage{mdwtab}
\usepackage{multirow}
\usepackage{amsmath}
\usepackage{siunitx}
%\usepackage{xcolor, soul}
%\sethlcolor{lightgray}
\usepackage{cancel}
\usepackage{amssymb}% http://ctan.org/pkg/amssymb
\usepackage{pifont}% http://ctan.org/pkg/pifont
%\usetikzlibrary{calc,matrix}
\usepackage{color,soul}
\usepackage{cite}
\newtheorem{theorem}{Theorem}{}
\newtheorem{corollary}{Corollary}{}
\newtheorem{remark}{Remark}{}
\hyphenation{op-tical net-works semi-conduc-tor}
%% Following for different color highlight using \textcolor{r1}{text}
\usepackage[dvipsnames]{xcolor}
\usepackage{soul}
\colorlet{r1}{ForestGreen!20}
\colorlet{r2}{Red!20}
\colorlet{r3}{RoyalPurple!20}
\newcommand{\Hl}[2][\empty]{%
\ifx#1\empty
\else
\sethlcolor{#1}%
\fi
\hl{#2}}
\usepackage{soul,color}
\soulregister\Hl{7}
\soulregister\ref7
\soulregister\cite7
\soulregister\pageref7

\usepackage{etoolbox}
\makeatletter 
\pretocmd\@bibitem{\csname keycolor#1\endcsname}{}{\fail}
\newcommand\citecolor[2][yellow]{\@namedef{keycolor#2}{\hspace*{-\labelwidth}\hspace*{-\labelsep}{\color{#1}\rule[-0.3em]{\dimexpr\linewidth+\labelwidth+\labelsep\relax}{1\baselineskip}}\vspace*{\itemsep}\vspace*{-\baselineskip}}}
\makeatother
\citecolor{knuth:ct:a}
\citecolor[red]{knuth:ct:c}

\begin{document}

\section{title}
\label{key}

\Hl{\ref{key}}

\Hl[red]{\cite{knuth:ct:c}}
\Hl[yellow]{\cite{knuth:ct:a}}
\cite{knuth:ct:b}

\bibliographystyle{plain}
\bibliography{biblatex-examples}

\end{document}
(如果引用跨越多行,则相应增加
1\baselineskip

您附加的图像中有很多错误。检查它们,也许解决它们有助于解决你的问题。@Eddymage没错。错误就在突出显示中包含的
\cite
时出现。好的,然后请发布错误,以便尝试了解发生了什么。您可以制作一个允许我们重现问题的文件吗?@samcarter_is_at_topanswers.xyz我更新了我的问题。现在我缩短了我的问题。谢谢。对你的代码成功了。我还有两个问题。1.如何在参考文献中突出显示
[1]
?2.请看我发布的屏幕截图。令人惊讶的是,
[19]
在同一篇文章中被成功引用,但第二次失败。这里可能有什么问题?@大陆请不要发布代码快照。我不会为了调查问题所在而重新键入它们。制作一个屏幕截图并将其作为文本添加到您的问题中。现在,我通过删除屏幕截图编辑了我的问题。谢谢你的帮助。在你的回答中,[1]在正文中被成功引用。但是如何在底部引用中突出显示它呢?我的代码执行时没有错误,但在引用部分没有突出显示新引用?从您的答案中引用的代码部分是
\usepackage{etoolbox}\makeatletter\pretocmd\@bibibitem{\csname keycolor}{\1\endcsname}{{}{\fail}\newcommand\citecolor[1]{\namedef{keycolor}\1}{\hspace*{-\labelwidth}\hspace*{\labelsep*{\labelsep}{\yellow}\rule[-0.3em]\linewidth}\basespace skip}{\basespace\makeatother