Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am using Lyx and Layout report for my thesis. I would like to change the colour of chapters sections and subsections (only the headings) from black to blue.

I attach a screenshot in order to understand what colours i am trying to achieve only on headings (Chapter /section and subsection )

Also is it possible to change the colour of table of contents to blue ? (again only the heading)

share|improve this question

2 Answers 2

up vote 6 down vote accepted

You can use the package sectsty to do change the headings, and xcolor to get the colour definitions.

For example, add to your preamble (Document --> Settings --> LaTeX preamble) the following:

\usepackage{xcolor}
\usepackage{sectsty}
\chapterfont{\color{blue}}  % sets colour of chapters
\sectionfont{\color{cyan}}  % sets colour of sections

enter image description here

You can use colours predefined in xcolor (see manual), or define your own, e.g.

\definecolor{MyBlue}{rgb}{0.1,0.1,1}

Put such definitions in the preamble as well.

share|improve this answer
    
Thanks i'll try this and ill come back if i have problems by using xcolor :) –  ALdaperan Oct 7 '12 at 9:03
1  
@ALdaperan I forgot to mention that the TOC heading is just an unnumbered chapter, so that will also be influenced by \chapterfont{\color{blue}}. –  Torbjørn T. Oct 7 '12 at 9:19
    
@TorbjørnT. does this also work with chapters in book style? I have changed sections with ease but it did not work for chapters... –  Enthusiastic Student Oct 30 at 20:36
    
@EnthusiasticStudent Yes, it does. Do you use Book (Standard Class)? –  Torbjørn T. Oct 30 at 20:42
    
@TorbjørnT. this is in my preamble: \documentclass[a4paper,12pt,twosided,openright]{book} –  Enthusiastic Student Oct 30 at 20:45

This thread seems to be closed fo quite a while, but as I found it right after searching for a solution some minutes ago, I just thought I could add the solution I found for solving the problem.

For all those of you who use KOMA Script Classes: its just adding one line if you are going for changing the color of all headlines during your document; be it chapters, sections, subsections and what not alltogether.

By adding

\setkomafont{disposition}{\normalcolor\bfseries}

you change all the headlines to the standard font you are using during your document, and by replacing \normalcolor by anything you whish you change the color for all headlines. It workes for selfdefined colors and as the other solution it applies for the \tableofcontents, too.

Example

\definecolor{schrift}{RGB}{0,73,114}
\setkomafont{disposition}{\color{schrift}\bfseries}

Here we have an example of code in which I used that method

\documentclass[oneside, twocolumn=false, 12pt]{scrbook}
\usepackage[ngerman]{babel}
\usepackage[utf8x]{inputenc}
\usepackage{delarray, graphicx, url, fancybox, calc, cancel, caption, mathtools, amsmath, amssymb, wrapfig, subcaption, floatrow, amsthm}
\usepackage[usenames,dvipsnames]{color}
\usepackage[margin={0.08\paperwidth,0.10\paperheight}, heightrounded]{geometry}

\usepackage[onlytext]{MinionPro}

\parindent 0pt
\parskip 6pt

\usepackage[pdftex, colorlinks=true,pdfstartview=FitB,bookmarks=false, urlcolor=schrift, linkcolor=schrift]{hyperref}
\hypersetup{
  colorlinks,
  linkcolor=schrift,
  linktoc=all
}

\makeatletter
\renewcommand{\l@section}{\@dottedtocline{1}{1.5em}{2.6em}}
\renewcommand{\l@subsection}{\@dottedtocline{2}{4.0em}{3.6em}}
\renewcommand{\l@subsubsection}{\@dottedtocline{3}{7.4em}{4.5em}}
\makeatother

\fboxrule0pt

\definecolor{rahmen}{RGB}{0,73,114}
\definecolor{grund}{RGB}{238,241,251}          
\definecolor{schrift}{RGB}{0,73,114}

\captionsetup{format=plain, labelfont={color=rahmen,bf}}

%\usepackage[nomath]{kpfonts}

\SetSymbolFont{letters}{normal}{OML}{cmbr}{m}{it}
\SetSymbolFont{operators}{normal}{OT1}{cmbr}{m}{n}
\SetSymbolFont{symbols}{normal}{OMS}{cmbr}{m}{n}

\DeclareMathAlphabet{\mathbf} {OT1}{cmbr}{bx}{n}

\setkomafont{disposition}{\color{schrift}\bfseries}

\renewcommand{\labelitemi}{-}
\renewcommand{\labelitemii}{$\cdot$}
\renewcommand{\labelitemiii}{$\circ$}
\renewcommand{\labelitemiv}{$\bullet$}

\captionsetup{format=plain, labelfont={color=schrift,bf}}

\allowdisplaybreaks

\newcommand{\defeq}{\vcentcolon=}
\newcommand{\eqdef}{=\vcentcolon}

\hfuzz 100pt
\hbadness 10000

\renewcommand{\chapterheadstartvskip}{\vspace *{-\baselineskip }}

\begin{document}

\chapter{Zentralkraftbewegungen}

\section{Erhaltungsgr\"oßen der Zentralkraftbewegung}

\subsection{Der Lenz-Runge Vektor}

\begin{equation}
    \Lambda =   \frac{1}{m\alpha} \Big( \mathbf{p} \times \mathbf{L} \Big) - \mathbf{e}_r
\end{equation}

Zu zeigen:

\begin{equation*}
    \Lambda = \mathrm{~const.} \leftrightarrow \frac{\mathrm{d}}{\mathrm{d}t} ~\Lambda = 0
\end{equation*}

Zur Diskussion des Problems sind Zylinderkoodinaten mit konstanter Höhe erforderlich. Wähle also als Höhe $z=0$. Der Nabla-Operator in Zylinderkoordinaten hat die Form

\begin{equation}
    \boldsymbol\nabla   = \mathbf{e}_r \frac{\partial}{\partial r} + \mathbf{e}_{\varphi} \frac{1}{r} \frac{\partial}{\partial \varphi} + \mathbf{e}_z \frac{\partial}{\partial z} 
\end{equation}

Das Keplerpotential hat die Form

\begin{equation}
    V = -\frac{\alpha}{r}
\end{equation}

\begin{proof}[Beweis für den Lenz-Runge Vektor als Erhaltungsgröße des Keplerproblems]
\begin{align*}
    \frac{\mathrm{d}}{\mathrm{d}t} \Lambda      &= \frac{\mathrm{d}}{\mathrm{d}t} \bigg\{ \frac{1}{m\alpha} \Big(\mathbf{p} \times \mathbf{L} \Big) \bigg\} - \dot{\mathbf{e}}_r \\
                                                                        &= \frac{1}{m\alpha} \frac{\mathrm{d}}{\mathrm{d}t} \bigg\{ \mathbf{p} \times \mathbf{L} \bigg\} - \dot{\mathbf{e}}_r \\
                                                                        &= \frac{1}{m\alpha} \bigg\{ \dot{\mathbf{p}} \times \mathbf{L} + \cancel{\mathbf{p} \times \dot{\mathbf{L}}} \bigg\} - \dot{\mathbf{e}}_r 
\end{align*}

\noindent\fcolorbox{rahmen}{grund}{\parbox{\linewidth -2\fboxsep -2\fboxrule}{%
Für die Kraft $\mathbf{F}$ folgt aus der Konservativität und dem Keplerpotential

\begin{equation}
    \mathbf{F}  = -\boldsymbol\nabla V = - \bigg[\Big( \mathbf{e}_r \frac{\partial}{\partial r} + \mathbf{e}_{\varphi} \frac{1}{r} \frac{\partial}{\partial \varphi} + \mathrm{e}_z \frac{\partial}{\partial z}  \Big) \cdot \Big(-\frac{\alpha}{r} \Big) \bigg] = -\mathbf{e}_r \frac{\alpha}{r^2}
\end{equation}
}}

\begin{align*}
    \frac{\mathrm{d}}{\mathrm{d}t} \Lambda      &= \frac{1}{m\alpha} \bigg\{ \mathbf{F} \times \mathbf{L} \bigg\} - \dot{\mathbf{e}}_r \\
                                                                        &= -\frac{1}{mr^2} \bigg\{ \mathbf{e}_r \times \mathbf{L} \bigg\} - \dot{\mathbf{e}}_r \\
                                                                        &= -\frac{1}{r^2} \bigg\{ \mathbf{e}_r \times \Big( \mathbf{r} \times \dot{\mathbf{r}} \Big) \bigg\} - \dot{\mathbf{e}}_r 
\end{align*}
\noindent\fcolorbox{rahmen}{grund}{\parbox{\linewidth -2\fboxsep -2\fboxrule}{%
Für Orts- und Geschwindigkeitsvektor in Zylinderkoordinaten mit konstanter Höhe gilt analog zu ebenen Polarkoordinaten

\begin{equation}
    \mathbf{r} = r \mathbf{e}_r \quad , \quad \dot{\mathbf{r}} = \dot{r} \mathbf{e}_r + r\mathbf{e}_{\varphi} \dot{\varphi}
\end{equation}

Die Graßmann-Identität lautet

\begin{equation}
    \mathbf{a} \times (\mathbf{b} \times \mathbf{c}) = (\mathbf{a} \cdot \mathbf{c}) \cdot \mathbf{b} - (\mathbf{a} \cdot \mathbf{b}) \cdot \mathbf{c}
\end{equation}

}}

Daraus folgt schließlich

\begin{align*}
    \frac{\mathrm{d}}{\mathrm{d}t} \Lambda          &= -\frac{1}{r^2} \bigg\{(\mathbf{e}_r \cdot \dot{\mathbf{r}}) \cdot \mathbf{r} - (\mathbf{e}_r \cdot \mathbf{r}) \cdot \dot{\mathbf{r}} \bigg\} - \dot{\mathbf{e}}_r \\
                                                                        &= -\frac{1}{r^2} \bigg\{ \left( \mathbf{e}_r \cdot \left[ \dot{r}\mathbf{e}_r + r\mathbf{e}_{\varphi}\dot{\varphi} \right] \right)r\mathbf{e}_r - \left(\mathbf{e}_r \cdot r\mathbf{e}_r \right) \cdot \left[ \dot{r}\mathbf{e}_r + r\mathbf{e}_{\varphi}\dot{\varphi} \right] \bigg\} - \dot{\mathbf{e}}_r \\
                                                                        &= -\frac{1}{r^2} \bigg\{ r\dot{r}\mathbf{e}_r - r\left(\dot{r}\mathbf{e}_r + r\mathbf{e}_{\varphi}\dot{\varphi} \right) \bigg\}  - \dot{\mathbf{e}}_r \\
                                                                        &= -\frac{1}{r} \bigg\{ \dot{r}\mathbf{e}_r - \dot{r}\mathbf{e}_r - r\mathbf{e}_{\varphi}\dot{\varphi} \bigg\} - \dot{\mathbf{e}}_r \\
                                                                        &= \dot{\mathbf{e}}_r - \dot{\mathbf{e}}_r 
                                                                        = 0 \qedhere
\end{align*}
\end{proof}



\end{document}

Which produces the output

page one of two of that document page two of two of that document

share|improve this answer
    
Welcome to TeX.SX! Could you provide a complete example and a screen shot, to make this a real answer? –  Christian Hupfer Aug 22 at 10:56

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.