3

How to cite References in the bibiliographic part using \eqref{name}?

For example, suppose we have a line as follows:

Using the works of [X1] (I want to see a blue color box) , we get

where the reference is

\bibitem{X1} B. Dragovich, N. Z. Misic, p-Adic Invariant Summation of Some p-Adic Functional Series, p-Adic Numbers, Ultrametric Analysis and Applications, 2014.

I used to \label{X1} and using \eqref{X1}, I got

Using the works of (X1) (just X1 is red color and not obtained 3rd bracket also)

How to get [X1] with red color box ?

11
  • Do you just want to have the link with a red frame, or also want an additional pair of round brackets around it?
    – Tiuri
    Nov 19, 2019 at 7:46
  • @Tiuri, I just want a blue color 3rd bracket around 'X1'
    – learner
    Nov 19, 2019 at 7:48
  • It's still not clear to me. Can you please clarify exactly how the citation should look like: how many brackets of which type (round, square) and of which color?
    – Tiuri
    Nov 19, 2019 at 7:50
  • @Tiuri, square type
    – learner
    Nov 19, 2019 at 7:51
  • 1
    I meant a code example, I know how citations look like. Without a compilable code, I will not be able to help you. However, some guidances: You should really use \cite to refer to the bibliography, not \ref or \eqref - that is most certainly also what was done in the arXiv paper you've linked. And then have a look at the hyperref documentation for how to adjust the colors of the links. Again, if you provide a minimal setup that describes what bibliography and citing macros you use, I'm happy to try to add the necessary adjustments there.
    – Tiuri
    Nov 19, 2019 at 8:02

2 Answers 2

4

\eqref is not intended to refer to bibliography items, but to equations. The correct command to refer to bibliography items is \cite, the label is provided by the \bibitem command, so

\bibitem{X1} B. Dragovich...

can be cited with

\cite{X1}

To get colours, the standard apporach is to use the hyperef package. By default citations are coloured green, but you can change this. To get a blue box, use

\hypersetup{citebordercolor=0 0 1}

Sample output

\documentclass{article}

\usepackage{hyperref}
\hypersetup{citebordercolor=0 0 1}

\begin{document}

Using the works of \cite{X1}, we get\dots

\begin{thebibliography}{9}
\bibitem{X1} B. Dragovich, N. Z. Misic, $p$-Adic Invariant Summation of
  Some $p$-Adic Functional Series, $p$-Adic Numbers, Ultrametric Analysis
  and Applications, 2014.
\end{thebibliography}

\end{document}

If instead you want blue text, then you can use

\hypersetup{colorlinks=true, citecolor=blue}

sample coloured text

Alternatively, you can color citations commands without using hyperef, as follows

sample with color package

\documentclass{article}

\usepackage{color}
\makeatletter
\renewcommand*{\@cite}[1]{\fcolorbox{blue}{white}{#1}}
\renewcommand*{\@biblabel}[1]{{\fcolorbox{blue}{white}{#1}}\hfill}
\makeatother

\begin{document}

Using the works of \cite{X1}, we get\dots

\begin{thebibliography}{9}
\bibitem{X1} B. Dragovich, N. Z. Misic, $p$-Adic Invariant Summation of
  Some $p$-Adic Functional Series, $p$-Adic Numbers, Ultrametric Analysis
  and Applications, 2014.
\end{thebibliography}

\end{document}

Here I have redefined the printing command for citations, namely \@cite, to put the number in a box with a blue border via

\renewcommand*{\@cite}[1]{\fcolorbox{blue}{white}{#1}}

Here white is the background color apply, you could change this too if you wished. I have also changed the printing of the labels in the bibligraphy to match this style by redefining \@biblabel. Note for all this to work, you need to load the color package and to enclose the redefinitions in \makeatletter..\makeatother (due to the @ character in the macro names).

6
  • your \renewcommand formula works fine to highlight a color box around the citation number e.g., say \cite{Mat} but it is not enclosing everything when I need to cite something like \cite[Theorem~22.3]{Mat}
    – learner
    Dec 1, 2021 at 6:56
  • replacing #1 by #2 enclose the whole thing. But it shows some error
    – learner
    Dec 1, 2021 at 7:07
  • @M.A.SARKAR Does \renewcommand*{\@cite}[2]{\fcolorbox{blue}{white}{#1, #2}} do want you want? Dec 1, 2021 at 11:31
  • Or rather \renewcommand*{\@cite}[2]{\fcolorbox{blue}{white}{#1\if@tempswa, #2\fi}} Dec 1, 2021 at 11:38
  • Thanks a lot. Both worked. But the 1st one creating a default comma ' (probably coming from {#1, #2}) after every citation number. If I delete the ' of {#1, #2} leaving with only space then the problem disappear but appears in the citation \cite[Theorem~22.3]{Mat} i.e., it shows something like [4 Theorem. 22.3] with no comma ' between the number 4 and the word Theorem.
    – learner
    Dec 1, 2021 at 12:21
3

I can see no blue boxes in the pdf file you provided a link to. To create light-green boxes, as is one in the pdf file, use \cite rather than \ref or \eqref and load the hyperref package.

enter image description here

\documentclass{article}
\usepackage{amsmath} % for "\nobreakdash" macro
\newcommand\padic{p\nobreakdash-\kern-1.5ptAdic}

\usepackage{hyperref}

\begin{document}
\noindent
\dots\ \cite{X1} \dots

\begin{thebibliography}{9}

\bibitem{X1} B. Dragovich, N. Z. Misic, \padic{} Invariant Summation of Some \padic{} 
Functional Series, \padic{} Numbers, Ultrametric Analysis and Applications, 2014.

\end{thebibliography}
\end{document}
1
  • thank you very much
    – learner
    Nov 19, 2019 at 9:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .