-1

Hi I am writing a revised article. I am highlight the background of the revised text with different background color. I was succesful in highlighting them but I could not highlight the citations in the Bottom References.

\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}
Mainland
  • 4,110
  • 3
  • 25
  • 56
  • There are a lot of errors in the image that you attached. Check them, maybe solving them helps wiht your problem. – Eddymage Apr 15 '20 at 13:26
  • @Eddymage That's right. The errors came just when `\cite` included in highlight. – Mainland Apr 15 '20 at 13:35
  • Ok, please post the errors then, in order to try to understand what is happening – Eddymage Apr 15 '20 at 13:38
  • 1
    Can you make a [mre] that allows us to reproduce the problem? – samcarter_is_at_topanswers.xyz Apr 15 '20 at 13:46
  • @samcarter_is_at_topanswers.xyz I updated my question. Now I shorted my question. – Mainland Apr 15 '20 at 13:59
  • @Eddymage I updated my question. Now I shorted my question. – Mainland Apr 15 '20 at 13:59
  • @Mainland The problem is not the length, but that your code is only a fragment that is not compilable and does not allow us to reproduce the problem – samcarter_is_at_topanswers.xyz Apr 15 '20 at 14:09
  • @samcarter_is_at_topanswers.xyz I updated my question that might be possible to reproduce at your end. – Mainland Apr 15 '20 at 14:15
  • So now your problem is that you want that the reference number is highlighted also in the reference list, right? I think that this requires modification on the bibstyle, and in this case you are not allowed to to so (because you are using IEEE doc class and the relative bib style). – Eddymage Apr 15 '20 at 14:20
  • @Eddymage Does this mean, highlighting in the References in not possible with IEEE doc? – Mainland Apr 15 '20 at 14:21
  • No, what I meant is that it is possible, but you have to 1) edit the bibstyle file in order to make the ref numbers colored 2) write the modification in your manuscript 3) when you have to submitt it to IEEE journal/conf, use their doc class and bibstyle, removing ALL the modification you put in. If you are working with other authors, I suggest to use `latexdiff` or similar tools. – Eddymage Apr 15 '20 at 14:29
  • @Eddymage Thanks for letting about `latexdiff` which I heard first time here. Sounds interesting. But what I am trying to do is using a different color for each reviewer. Otherwise, how to highlight the cites in the References? – Mainland Apr 15 '20 at 14:35
  • Wow, so much effort just for the reviewers! Congrats! But imho is not worthy, just write your revised manuscript and then the reviewers will read it. You can explicit (some) differences from the last versionin the rebuttal letter, but we're going OT with this comments! Have a look at `latexdiff` if you want: https://www.ctan.org/pkg/latexdiff – Eddymage Apr 15 '20 at 14:39
  • @Eddymage Thanks. In between, give an example how the people highlight the citations in the bottom REFERENCES section? – Mainland Apr 15 '20 at 14:43
  • That's not easy (at least for me), but if you have time have a look here: http://ctan.mirror.garr.it/mirrors/CTAN/info/bibtex/tamethebeast/ttb_en.pdf – Eddymage Apr 15 '20 at 14:58

1 Answers1

2

\ref worked already out of the box with your code. To make \cite also compatible, you can add \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


To highlight the bititem as well:

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

(if the reference spans more than one line, increase 1\baselineskip accordingly) enter image description here

  • Thanks. Yes! your code worked. I got two more questions. 1. How to highlight the `[1]` in References as well? 2. Please look at the screen shot images I posted. In that surprisingly `[19]` was successfully cited but failed second time in the same text. What could be wrong here? – Mainland Apr 15 '20 at 14:03
  • 1
    @Mainland Please don't post screeshots of code. I'm not going to re-type them in order to investige what the problem might be. Make a [mre] and add it as text to your question. – samcarter_is_at_topanswers.xyz Apr 15 '20 at 14:08
  • Now I edited my question by removing the screenshots. Thanks for helping. – Mainland Apr 15 '20 at 14:11
  • In your answer, [1] was successfully cited in the main text. But how to highlight it in the bottom References as well? – Mainland Apr 15 '20 at 14:17
  • My code executed with no errors but it did not highlight the new citations in the Reference section? The part of the code referenced from your answer is `\usepackage{etoolbox} \makeatletter \pretocmd\@bibitem{\csname keycolor#1\endcsname}{}{\fail} \newcommand\citecolor[1]{\@namedef{keycolor#1}{\hspace*{-\labelwidth}\hspace*{-\labelsep}{\color{yellow}\rule[-0.3em]{\linewidth}{1\baselineskip}}\vspace*{\itemsep}\vspace*{-\baselineskip}}} \makeatother` – Mainland Apr 16 '20 at 10:24
  • @Mainland You also have to tell which references should be highlighted, e.g. `\citecolor{knuth:ct:a}` – samcarter_is_at_topanswers.xyz Apr 16 '20 at 11:02
  • If understood this correctly, I have 4 new citations. Do I have to state them in the preamble as `\citecolor{article1}\citecolor{article2}\citecolor{article3}\citecolor{article4}` ? Am I right? I understood from the you code is, we are highlighting them in yellow. But how do I highlight them different colors as in the preamble? – Mainland Apr 16 '20 at 11:39
  • Thanks for the help. It would be great if I can highlight the citation using `\Hl[r1]` because I have three different background colors. Is there a way I can include them in the citation as well? In your example, you have used yellow and red. Can you edit the same to use `\Hl[r1], \Hl[r2]` respectively. – Mainland Apr 16 '20 at 12:14
  • @Mainland red and yellow are just colours like r1 and r2. Use whatever colour you want – samcarter_is_at_topanswers.xyz Apr 16 '20 at 12:16
  • Thank you. I will do that. One more question: Yes! as mentioned in your edits, my citation is more than three lines so i put this `{\color{yellow}\rule[-0.3em]{\linewidth}{3\baselineskip}}`. I got the first line of citation highlighted in yellow and also two empty lines above it in yellow. What could be wrong here. – Mainland Apr 16 '20 at 12:48
  • @Mainland It is really tiring having to puzzle together your code fragments. If you have follow up questions, please make compilable [mre] that allows us to just copy and past the code to reproduce your problem. Best thing would be to ask this as a new question. – samcarter_is_at_topanswers.xyz Apr 16 '20 at 13:19
  • Sorry to have bothered you. Yes! I did create a new question: https://stackoverflow.com/questions/61252125/latex-highlighting-the-citations-in-the-reference-section-using-different-backgr – Mainland Apr 16 '20 at 13:59