LaTeX forum ⇒ Theses, Books, Title pagesThe Legrand Orange Book: changing URL colors to ocre Topic is solved

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

The Legrand Orange Book: changing URL colors to ocre

Postby kinseikun » Mon Feb 05, 2018 5:23 am

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!)

Tags:

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

Postby Stefan Kottwitz » Mon Feb 05, 2018 10:02 pm

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
Site admin

kinseikun
Posts: 9
Joined: Mon Feb 05, 2018 5:11 am

Postby kinseikun » Mon Feb 05, 2018 10:40 pm

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: 8790
Joined: Mon Mar 10, 2008 9:44 pm

Postby Stefan Kottwitz » Mon Feb 05, 2018 10:49 pm

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

Stefan
Site admin

kinseikun
Posts: 9
Joined: Mon Feb 05, 2018 5:11 am

Postby kinseikun » Mon Feb 05, 2018 11:05 pm

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: 8790
Joined: Mon Mar 10, 2008 9:44 pm

Postby Stefan Kottwitz » Mon Feb 05, 2018 11:10 pm

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

Stefan
Site admin

kinseikun
Posts: 9
Joined: Mon Feb 05, 2018 5:11 am

Postby kinseikun » Mon Feb 05, 2018 11:36 pm

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: 8790
Joined: Mon Mar 10, 2008 9:44 pm

Postby Stefan Kottwitz » Mon Feb 05, 2018 11:52 pm

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

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

Stefan
Site admin

kinseikun
Posts: 9
Joined: Mon Feb 05, 2018 5:11 am

Postby kinseikun » Tue Feb 06, 2018 1:13 am

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:


Return to “Theses, Books, Title pages”

Who is online

Users browsing this forum: No registered users and 2 guests