Theses, Books, Title pagesThe Legrand Orange Book: changing URL colors to ocre

Classicthesis, Bachelor and Master thesis, PhD, Doctoral degree
Post Reply
kinseikun
Posts: 10
Joined: Mon Feb 05, 2018 5:11 am

The Legrand Orange Book: changing URL colors to ocre

Post by kinseikun »

Hello,

I would not say I am well versed in LaTeX, but I am using the The Legrand Orange Book template to create a textbook.

I have noticed that when I use /href, url links remain black. If I change the structure package for hypersetup from colorlinks=false to true, it makes all links red and messes up the nice chapters in ocre and sections in black in the unit header mini table of contents and makes them all red too. I want to keep the ocre color since it's also our school color!

Is there a way I can toggle colorlinks to true and have ocre links in later chapters without it affecting the table of contents and part headers?

I appreciate any help. Thanks. (2 more questions to come!)

Recommended reading 2024:

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

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

User avatar
Stefan Kottwitz
Site Admin
Posts: 10320
Joined: Mon Mar 10, 2008 9:44 pm

The Legrand Orange Book: changing URL colors to ocre

Post by Stefan Kottwitz »

Hi,

here is a suggestion:

\let\oldhref\href
\renewcommand*{\href}[2]{\oldhref{#1}{\color{ocre}{#2}}}


If this changes colors too much because \href is redefined, you could use it simpler as

\newcommand*{\myhref}[2]{\href{#1}{\color{ocre}{#2}}}

and later use int this way:

\myhref{http://latex.org}{\color{red}{LaTeX Forum}}

Stefan
LaTeX.org admin
kinseikun
Posts: 10
Joined: Mon Feb 05, 2018 5:11 am

The Legrand Orange Book: changing URL colors to ocre

Post by kinseikun »

Hello,

\newcommand*{\myhref}[2]{\href{#1}{\color{ocre}{#2}}} works, but now it won't compile--it gets hung up on urls with % signs in them. I believe putting a \ will break the link, am I correct? What should I do?

It works for urls that do not have %s in them :c
User avatar
Stefan Kottwitz
Site Admin
Posts: 10320
Joined: Mon Mar 10, 2008 9:44 pm

The Legrand Orange Book: changing URL colors to ocre

Post by Stefan Kottwitz »

You could "escape" the percent symbol with a backslash to prevent it from acting as commenting command, that is, write \%.

Stefan
LaTeX.org admin
kinseikun
Posts: 10
Joined: Mon Feb 05, 2018 5:11 am

The Legrand Orange Book: changing URL colors to ocre

Post by kinseikun »

Ah I see...

The issue isn't the % in the url, this url has some weird letters in it and that was causing the error:

\href{https://commons.wikimedia.org/wiki/File:Rhéa_présentant_une_pierre_emmaillotée_à_Cronos_dessin_du_bas-relief_d%27un_autel_romain.jpg} {\textbf{Chapter 2 Rhea:}}

I added unicode to this package: \usepackage[breaklinks,colorlinks=true,
urlcolor=blue,unicode=true]{hyperref}

but it still doesn't work for links with Frenchy things in them :c
User avatar
Stefan Kottwitz
Site Admin
Posts: 10320
Joined: Mon Mar 10, 2008 9:44 pm

The Legrand Orange Book: changing URL colors to ocre

Post by Stefan Kottwitz »

Is your document supporting Unicode? utf8 inputenc package or lualatex or xelatex?

Stefan
LaTeX.org admin
kinseikun
Posts: 10
Joined: Mon Feb 05, 2018 5:11 am

The Legrand Orange Book: changing URL colors to ocre

Post by kinseikun »

Yes, I have these in my structure:

\usepackage[utf8]{inputenc} % Required for including letters with accents
\usepackage[T1]{fontenc} % Use 8-bit encoding that has 256 glyphs

I am using Overleaf to compile. I tried all of them--lualatex and pdflatex compiled, but the links with strange unicode don't work. Xelatex and latex dvipdf had errors in other areas in my document that are usually fine.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10320
Joined: Mon Mar 10, 2008 9:44 pm

The Legrand Orange Book: changing URL colors to ocre

Post by Stefan Kottwitz »

Strange unicode links may be a problem... You can try this:

\href{\detokenize{...}}{...}

Stefan
LaTeX.org admin
kinseikun
Posts: 10
Joined: Mon Feb 05, 2018 5:11 am

The Legrand Orange Book: changing URL colors to ocre

Post by kinseikun »

Detokenize worked! Thanks!

I had to go and change all the %C3 things in the url to their original unicode equivalent though T_T...but now that that's finished, everything is good! Thanks!!!

I feel like I've worked on these links to images in the image credit section longer than the rest of the 250 pages :lol:
Post Reply