[Tex/LaTex] Change colour of italics font for the whole document

colordefaultfonts

I would like to see the following in my latex file: once I use the \textit{...} command, I would like to see that this text does not only get the italics font, but also gets the colour blue. I want to apply this on the whole document. Instead of having to specify it for every part of text that should get this font, is there a way I can specify it in the beginning of the document such that it is applied to the whole doc? Basically I want to change the default properties of the \textit{...} command.

Best Answer

This is very easy with (Xe|Lua)LaTeX:

\documentclass{article}

\usepackage{fontspec}
\usepackage{xcolor}

\setmainfont{Latin Modern Roman}[
  ItalicFeatures={Color=blue},
]

\begin{document}

Some text \emph{emphasized} and \textit{in italic}.

\end{document}

enter image description here

With pdflatex it's a bit more complicated:

\documentclass{article}

\usepackage{xcolor}

\makeatletter
\DeclareRobustCommand{\itshape}{%
  \not@math@alphabet\itshape\mathit
  \fontshape\itdefault\selectfont
  \color{blue}%
}
\makeatother

\begin{document}

Some text \emph{emphasized} and \textit{in italic}.

\end{document}

Be careful of not using \itshape between paragraphs, though.

Related Question