Text FormattingLink color

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
User avatar
svend_tveskaeg
Posts: 478
Joined: Sun Jul 12, 2009 5:31 am

Link color

Post by svend_tveskaeg »

Hi all.

Consider the following example:

Code: Select all

\documentclass{article}

\usepackage{pst-func,pst-plot,pstricks-add}
\usepackage[
colorlinks=true,
menucolor=black,
urlcolor=black
]{hyperref}

\begin{document}

\tableofcontents

\vfill

\section{Test}
See \url{http://www.google.dk/}.
\begin{figure}[htbp]
 \centering
   \psset{%
     llx=-1.3cm,
     lly=-1cm,
     xAxisLabel={H{\o}jde (cm)},
     xAxisLabelPos={c,-120},
     yAxisLabel={Antal},
   yAxisLabelPos={-9,c},
   }
   \begin{psgraph}[Ox=145,Dx=10,Dy=100]{->}(145,0)(217,928){10cm}{7cm}
     \readdata{\normal}{normal.txt}
     \dataplot[plotstyle=dots,dotsize=4pt,dotstyle=o,color,linecolor=red,fillcolor=blue,fillstyle=solid]{\normal}
     \psGauss[yunit=13427,linecolor=red,mue=179.6215,sigma=6.766667,linewidth=2pt]{153}{210}
   \end{psgraph}
  \caption{Test.}
 \label{figure:1}
\end{figure}

The plot in Figure~\ref{figure:1} indicates that the data is Gaussian distributed.

\end{document}
I would like to have the number in `Figure 1' in red but the `1 Test' in the ToC in black. Is this possible with hyperref and if so, how?

Thank you in advance!
Attachments
normal.txt
Data for making the plot.
(534 Bytes) Downloaded 247 times
Last edited by svend_tveskaeg on Fri Aug 26, 2011 12:18 pm, edited 2 times in total.
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Link color

Post by localghost »

Please get used to always providing a minimal example that is reduced to only relevant code. The complete PSTricks stuff is completely irrelevant for the problem.

Regarding the problem, you have to add some settings for the hyperref package.

Code: Select all

\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage[%
  colorlinks,        % Enable colored links
  linktocpage,       % Make Page numbers in ToC links, not the entries
  linkcolor=red,     % Determines color for links
  menucolor=black,
  urlcolor=black
]{hyperref}

\begin{document}
  \tableofcontents

  \section{Test}
    See \url{http://latex-community.org/}.

    \begin{figure}[!ht]
      \centering
      \rule{6.4cm}{3.6cm}
      \caption{Dummy figure}\label{fig:dummy}
    \end{figure}

    Figure~\ref{fig:dummy}.
\end{document}
For details see the package manual. You have instant access on the command line.

Code: Select all

texdoc hyperref

Thorsten
User avatar
svend_tveskaeg
Posts: 478
Joined: Sun Jul 12, 2009 5:31 am

Link color

Post by svend_tveskaeg »

localghost wrote:Please get used to always providing a minimal example that is reduced to only relevant code. The complete PSTricks stuff is completely irrelevant for the problem.
Sorry. I'll do that in the future.

Thank you for your help. It isn't quite what I am looking for, though; I would like the entire ToC entry (i.e., both the section title and the page number) to be black while the number in `Figure 1' (from my previous post) is red.
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Link color

Post by localghost »

Since the links in the ToC and the links for cross references are of the same kind, it is not possible to assign different colors. You can describe this issue on comp.text.tex (ctt) or address the package maintainer directly for further advice. Feel free to report back after you got an answer.
User avatar
svend_tveskaeg
Posts: 478
Joined: Sun Jul 12, 2009 5:31 am

Re: Link color

Post by svend_tveskaeg »

Okay, thanks.

I will write it here if I get an (useful) answer.
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)
User avatar
svend_tveskaeg
Posts: 478
Joined: Sun Jul 12, 2009 5:31 am

Re: Link color

Post by svend_tveskaeg »

Heiko Oberdiek wrote:

hyperref provides option linktoc, see README:

| Option `linktoc' added
| ----------------------
| The new option `linktoc' allows more control which part
| of an entry in the table of contents is made into a link:
| * `linktoc=none' (no links)
| * `linktoc=section' (default behaviour, same as `linktocpage=false')
| * `linktoc=page' (same as `linktocpage=true')
| * `linktoc=all' (both the section and page part are links)
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)
Post Reply