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

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

\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}
%% different color for different reviewer  \textcolor{r1}{text}
\usepackage[dvipsnames]{xcolor}
\usepackage{soul}
\colorlet{r1}{ForestGreen!20}
\colorlet{r2}{Red!20}
\colorlet{r3}{RoyalPurple!20}
%\definecolor{r1}{r1!50}%{rgb}{0.8, 0.5, 0.2}
%\definecolor{r2}{rgb}{0.61, 0.87, 1}
%\definecolor{r3}{rgb}{1, 0.87, 0.8}
\newcommand{\Hl}[2][\empty]{%
    \ifx#1\empty
    \else
    \sethlcolor{#1}%
    \fi
    \hl{#2}}
%% Highlighting the citations and references as well using different background color
\soulregister\Hl{7}
\soulregister\cite7
\soulregister\ref7
\soulregister\pageref7
%% Highlighting citations in the Reference section using different background color
\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
\citecolor{miguel14anestimator}
\begin{document}
I want to highlight \Hl[r1]{\cite{cite1}}, \Hl[r2]{\cite{cite2}} ,\Hl[r3]{\cite{cite3}} in Reference section using appropriate colors. 
\bibliography{BIBfile}{}
\bibliographystyle{IEEEtran}

\end{document}

Мой текущий вывод: выделяет цитаты желтым цветом по умолчанию, который также создает два пробела.

enter image description here

Мои цитаты хранятся в отдельном файле bib как

@ARTICLE{cite1,
    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},}


@ONLINE{cite2,
    author={Licor},
    title={Pyranometer products specifications},
    year={2020},
    month={Apr.},
    url={https://www.licor.com/documents/3bjwy50xsb49jqof0wz4}
}

@article{cite3,
    title = "An assessment of series resistance estimation techniques for different silicon based SPV modules",
    journal = "Renewable and Sustainable Energy Reviews",
    volume = "98",
    pages = "199 - 216",
    year = "2018",
    author = "Rashmi Singh and Madhu Sharma and Rahul Rawat and Chandan Banerjee"
}

1 Ответ

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

Я добавил необязательный аргумент к \citecolor, который позволяет вам указать, сколько строк в каждом кусочке имеет

\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}
%% different color for different reviewer  \textcolor{r1}{text}
\usepackage[dvipsnames]{xcolor}
\usepackage{soul}
\colorlet{r1}{ForestGreen!20}
\colorlet{r2}{Red!20}
\colorlet{r3}{RoyalPurple!20}
%\definecolor{r1}{r1!50}%{rgb}{0.8, 0.5, 0.2}
%\definecolor{r2}{rgb}{0.61, 0.87, 1}
%\definecolor{r3}{rgb}{1, 0.87, 0.8}
\newcommand{\Hl}[2][\empty]{%
    \ifx#1\empty
    \else
    \sethlcolor{#1}%
    \fi
    \hl{#2}}
%% Highlighting the citations and references as well using different background color
\soulregister\Hl{7}
\soulregister\cite7
\soulregister\ref7
\soulregister\pageref7
%% Highlighting citations in the Reference section using different background color
\usepackage{etoolbox}
\makeatletter 
\pretocmd\@bibitem{\csname keycolor#1\endcsname}{}{\fail}
\newcommand\citecolor[3][1]{\@namedef{keycolor#3}{\hspace*{-\labelwidth}\hspace*{-\labelsep}{\color{#2}\rule[-0.3em]{\dimexpr\linewidth+\labelwidth+\labelsep\relax}{#1\baselineskip}}\vspace*{\itemsep}\vspace*{-#1\baselineskip}}}
\makeatother

\citecolor[3]{r1}{cite1}
\citecolor[2]{r2}{cite2}
\citecolor[3]{r3}{cite3}

\begin{filecontents*}[overwrite]{\jobname.bib}

@article{einstein,
    author = {Einstein, A.},
    title = {Die Grundlage der allgemeinen Relativitätstheorie},
    journal = {Annalen der Physik},
    volume = {354},
    number = {7},
    doi = {10.1002/andp.19163540702},
    pages = {769--822},
    year = {1916}
}


@ARTICLE{cite1,
    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},}


@ONLINE{cite2,
    author={Licor},
    title={Pyranometer products specifications},
    year={2020},
    month={Apr.},
    url={https://www.licor.com/documents/3bjwy50xsb49jqof0wz4}
}

@article{cite3,
    title = "An assessment of series resistance estimation techniques for different silicon based SPV modules",
    journal = "Renewable and Sustainable Energy Reviews",
    volume = "98",
    pages = "199 - 216",
    year = "2018",
    author = "Rashmi Singh and Madhu Sharma and Rahul Rawat and Chandan Banerjee"
}
\end{filecontents*}

\begin{document}

normal cite: \cite{einstein}

I want to highlight \Hl[r1]{\cite{cite1}}, \Hl[r2]{\cite{cite2}} ,\Hl[r3]{\cite{cite3}} in Reference section using appropriate colors. 
\bibliography{\jobname}
\bibliographystyle{IEEEtran}

\end{document}

enter image description here

...