[Tex/LaTex] Change text color of ToC entries in LyX

colorlyxtable of contents

I've inserted a table of contents with LyX using Insert->List/TOC->Table of Contents and it is good, but the text color text is red and I want it black. I'm using book(KOMA-script) as document class.

Thanks!

Ok, here's a .lyx testing code

#LyX 2.0 created this file. For more info see http://www.lyx.org/
\lyxformat 413
\begin_document
\begin_header
\textclass scrbook
\begin_preamble
\usepackage{mathpazo}

\usepackage{graphicx}
\usepackage{color,xcolor}
\usepackage{tikz, pgf, pgfplots}
\usetikzlibrary{arrows,backgrounds,plotmarks}
\pgfplotsset{width=7cm,compat=1.8}
\pgfplotsset{plot coordinates/math parser=false}

\newlength\figureheight  
\newlength\figurewidth  

\usepackage{icomma} 
\usepackage{fancyhdr} %activamos el paquete
\usepackage{endnotes} 
\usepackage{fancyvrb}
\date {}
\let\footnote=\endnote
\def\footnotetext{\endnotetext[\number\numexpr\value{endnote}+1]}
\let\footnotemark\endnotemark 
\pagestyle{fancy} %seleccionamos un estilo
 \lhead{ECUACIONES} %texto izquierda de la cabecera
 \rhead{\thepage }
\chead{TEORÍA Y EJERCICIOS} %texto centro de la cabecera
 \rfoot{RESOLUCIÓN ECUACIONES} %texto izquierda del pie
\rhead{\thepage } %número de página a la derecha
\renewcommand{\footrulewidth}{0.5pt} 
\renewcommand{\headrulewidth}{0.5pt}

% Referencias - Enlaces
\usepackage[hyphens]{url}
\usepackage[breaklinks,colorlinks=true,linkcolor=red,
citecolor=red, urlcolor=blue]{hyperref}

\usepackage{caption}
\captionsetup{font=small,format=plain,parskip=1pt,justification=centering}
\captionsetup[figure]{font=small,format=plain,parskip=1pt,justification=centering}
\renewcommand{\thefigure}{\arabic {figure}}

\usepackage[total={15cm,21cm},left=2cm,top=2cm]{geometry}
\parindent=0mm
\renewcommand{\baselinestretch }{1.2}

\usepackage[superscript]{cite} %las citas

\renewcommand\citeform[1]{\textcolor{blue}{#1}}  % Ponemos las citas en azul

\let\footnote=\endnote
\def\footnotetext{\endnotetext[\number\numexpr\value{endnote}+1]}
\let\footnotemark\endnotemark 

\renewcommand{\bibname}{Bibliografía}
\end_preamble
\use_default_options true
\begin_modules
theorems-ams
eqs-within-sections
figs-within-sections
fixltx2e
foottoend
customHeadersFooters
endnotes
hanging
initials
tabs-within-sections
\end_modules
\maintain_unincluded_children false
\language spanish
\language_package default
\inputencoding auto
\fontencoding global
\font_roman default
\font_sans default
\font_typewriter default
\font_default_family default
\use_non_tex_fonts false
\font_sc false
\font_osf false
\font_sf_scale 100
\font_tt_scale 100

\graphics default
\default_output_format default
\output_sync 0
\bibtex_command default
\index_command default
\paperfontsize default
\spacing onehalf
\use_hyperref false
\papersize a4paper
\use_geometry false
\use_amsmath 1
\use_esint 1
\use_mhchem 1
\use_mathdots 1
\cite_engine basic
\use_bibtopic false
\use_indices false
\paperorientation portrait
\suppress_date false
\use_refstyle 0
\index Index
\shortcut idx
\color #008000
\end_index
\leftmargin 3cm
\topmargin 2cm
\rightmargin 3cm
\bottommargin 2cm
\headheight 3cm
\headsep 3cm
\footskip 3cm
\secnumdepth 3
\tocdepth 3
\paragraph_separation indent
\paragraph_indentation default
\quotes_language english
\papercolumns 1
\papersides 1
\paperpagestyle default
\tracking_changes false
\output_changes false
\html_math_output 0
\html_css_as_file 0
\html_be_strict false
\end_header

\begin_body

\begin_layout Title
Testing
\end_layout

\begin_layout Subtitle
Testing 2
\end_layout

\begin_layout Author
Joy Division
\end_layout

\begin_layout Standard
\begin_inset CommandInset toc
LatexCommand tableofcontents

\end_inset


\end_layout

\begin_layout Chapter
Chapter 1
\end_layout

\begin_layout Section
Section 1
\end_layout

\begin_layout Standard
A testing section
\end_layout

\begin_layout Subsection
Subsection 1
\end_layout

\begin_layout Standard
A testing subsection
\end_layout

\begin_layout Chapter
Chapter 2
\end_layout

\begin_layout Section
Section 2
\end_layout

\begin_layout Standard
Another testing section
\end_layout

\begin_layout Subsection
Subsection 2
\end_layout

\begin_layout Standard
Another subsection
\end_layout

\end_body
\end_document

Best Answer

In your preamble you have the following:

\usepackage[breaklinks,colorlinks=true,linkcolor=red,
citecolor=red, urlcolor=blue]{hyperref}

This activates the hyperref package, which creates clickable hyperlinks of table of contents entries, cross references and similar. With colorlinks=true these links are given a colour, and as you've specified linkcolor=red the ToC entries are red. Change the colours to black, or use

\usepackage[breaklinks,hidelinks]{hyperref}

instead. hidelinks causes all links to be printed black, as the surrounding text.

If you have activated hyperref using the LyX interface you need to change this inside the Document --> Settings --> PDF Properties, where Use Hyperref Support will be checked. There is a box for additional options at the bottom, in here you can add your details, for example

linkcolor=black,citecolor=black

So as my TOC and internal links are in black (rather than the default of red and green). If you have both activated this and added \usepackage{hyperref} with other options to the LaTeX preamble, you may get errors when viewing the PDF.