4

I want to color the brackets of inline citation like: some text[9] where it is written in latex like this some text\cite{9}. Now hyperref only colors the number "9" without the brackets "[]". Is there any workaround for this?

  • I don't know about the color of the brackets, but consider to cite like text~\cite{id}, this inserts a blank space between the text and the citation which will not be broken by a line break. – Dominikus K. Mar 10 '13 at 9:14
  • 2
    Please add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – Marco Daniel Mar 10 '13 at 10:12
  • 2
    The colour applies to the active link. Given that you can put several references into the cite command, \cite{paper1,paper2,paper8}, and these would have to link to different places, it doesn't make much sense to include the brackets in the link area. – Andrew Swann Mar 10 '13 at 10:45
  • @AndrewSwann that is right, but if we have like 5 cites, it will write for example [1-5] so we don't have link for each citation, only to the first one. – Hesham Saeed Mar 11 '13 at 5:11
  • You only get [1-5] if you load certain citation styles, standard plain will print [1,3,2,5,4] and each reference will be linked. If you add a minimal working example as Marco Daniel requests, you tell us which packages and citation styles you are using and we can better answer your question. – Andrew Swann Mar 11 '13 at 7:42
5

You can use the cite package:

\documentclass{article}
\usepackage{color}
\usepackage{hyperref}
\usepackage{cite}
\renewcommand{\citeleft}{\textcolor{red}{[}}
\renewcommand{\citeright}{\textcolor{red}{]}}
\begin{document}
Hello \cite{world}!
\begin{thebibliography}{99}
\bibitem{world} created some time ago
\end{thebibliography}
\end{document}
  • This doesn't solve the issue, if you do something like \cite[Example 1]{world}. – Simon Marynissen Feb 6 '18 at 14:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.
https://tex.stackexchange.com/questions/101747/how-to-color-citation-brackets-using-hyperref
tex.stackexchange.com
crawl=CC-MAIN-2021-04
151395
application/http; msgtype=response
sha1:DL6P5D3XUQENVD6ZF5HAXEH5SJW6KP6F
<urn:uuid:f8e6ec73-ea90-4ab2-9b86-492421dfd6e0>
2021-01-18T04:37:54Z
151.101.193.69
text/html
sha1:PPH26KSWFHHWR7JKZZAAZZ5446I5XN6U
<urn:uuid:4ba99dbe-e8af-4c32-a93f-0a77852e43aa>
https://tex.stackexchange.com/questions/101747/how-to-color-citation-brackets-using-hyperref
response
<urn:uuid:ea0647d7-68a9-4d2a-bb02-4ab67ab9916a>
isPartOf: CC-MAIN-2021-04
publisher: Common Crawl
description: Wide crawl of the web for January 2021
operator: Common Crawl Admin (info@commoncrawl.org)
hostname: ip-10-67-67-250.ec2.internal
software: Apache Nutch 1.17 (modified, https://github.com/commoncrawl/nutch/)
robots: checked via crawler-commons 1.2-SNAPSHOT (https://github.com/crawler-commons/crawler-commons)
format: WARC File Format 1.1
conformsTo: http://iipc.github.io/warc-specifications/specifications/warc-format/warc-1.1/