Text FormattingHow to change text colour in

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
BastienBastien
Posts: 40
Joined: Mon Aug 20, 2012 2:27 pm

How to change text colour in

Post by BastienBastien »

Hello,

I am writing a book by using TexLive 2012 on ArchLinux GNU/Linux distribution. It does work fine !

But I have a problem while trying to change the colour of the chapters. I have done :

Code: Select all

\chapter{\color{red} Identification du Système \color{black}}
This works fine. But, when I open the PDF file with Acrobat Reader, in the left pane "Bookmark" (where you can see all chapters and so on), it displays :
\color{red} Identification du Système \color{black}
Instead of :

Identification du Système

Please note that the chapter name is in red color, this is okay, but how to make it not showing the \color command ?

Thanks a lot !
Bastien

Recommended reading 2024:

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

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

Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

How to change text colour in

Post by Stefan Kottwitz »

Hi Bastien,

welcome to the board!

Use \texorpdfstring of hyperref, i.e.

Code: Select all

\chapter{\texorpdfstring{\color{red} Identification du Système \color{black}}{Identification du Système}}
The second argument will be used for the bookmark.

Stefan
LaTeX.org admin
BastienBastien
Posts: 40
Joined: Mon Aug 20, 2012 2:27 pm

Re: How to change text colour in

Post by BastienBastien »

Hello Stefan_K

I gonna try this evening and I'll tell you.

By the way, how is it possible to know this mysterious texorpdfstring command ? Have you read the \LeTeX2e programm from A to Z ? I guess not, so how is it possible to know such very specific command ? 'cause general books does not talk about it !

Kind regards,
Bastien
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

How to change text colour in

Post by cgnieder »

BastienBastien wrote:By the way, how is it possible to know this mysterious texorpdfstring command ?
It's documented in the manual of the hyperref package which is used to create the PDF links and bookmarks.

Regards
site moderator & package author
josephwright
Site Moderator
Posts: 814
Joined: Tue Jul 01, 2008 2:19 pm

How to change text colour in

Post by josephwright »

You would also be better to use \textcolor rather than \color

Code: Select all

\chapter{\textcolor{red}{Identification du Système}}
Joseph Wright
BastienBastien
Posts: 40
Joined: Mon Aug 20, 2012 2:27 pm

Re: How to change text colour in

Post by BastienBastien »

Hi,

Thanks a lot. It works fine !

I have tried the first possibility, but I also will write down somewhere the second possibility.

Have a good day,
Bastien
Post Reply