Латексная подсветка \ цитата и \ ссылка с использованием различных цветов фона - PullRequest
0 голосов
/ 15 апреля 2020

Привет, я пишу исправленную статью. Я выделяю фон пересмотренного текста другим цветом фона. Мне удалось выделить их, но я не смог выделить цитаты из нижних ссылок.

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

1 Ответ

2 голосов
/ 15 апреля 2020

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

enter image description here


Для выделения битового элемента также:

\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) enter image description here

...