0

I would like to change the color of italic throughout a document. This problem was solved here

Change colour of italics font for the whole document

It appears the solution for pdflatex does not work anymore in TeX Live 2020. The code below does not work on my system. Does anyone know how to fix this

\documentclass{article}

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

\begin{document}
Some text in \textit{blue}
\end{document}
220284
  • 209

1 Answers1

1
\documentclass{article}
\usepackage{xcolor}
\let\oldtextit\textit 
\renewcommand\textit[1]{\oldtextit{\color{blue}#1}}
\begin{document}
Some text in \textit{blue}
\end{document}

You have \oldtextit in case you need colorless italics.

If you want the result with \itshape, add the following line in the preamble, after the packages:

\let\olditshape\itshape 
\def\itshape{\color{blue}\olditshape}
  • Thanks, but this does not appear to affect anything written with \itshapesuch as references generated with bibtex. – 220284 Apr 12 '20 at 16:47
  • I've edited my answer so it works with \itshape. See again. –  Apr 12 '20 at 17:02
  • Yeah, I also tried this. But this does not appear to work with bibtex. – 220284 Apr 12 '20 at 17:52
  • Maybe a more specific example of what you want would be helpful. –  Apr 12 '20 at 17:55
  • Hm, specific in which way? I would like all text that is in italic to be typeset in blue. Your solution works for all text that I put in italic with \textit, but does not appear to work for text in italic that is generated by some other means, such as a reference generated with bibtex or the text in a mathematical theorem written with the amsthm package. – 220284 Apr 12 '20 at 18:04
  • `\documentclass{amsart} \usepackage{amsthm} \newtheorem{thm}{Theorem}[section]

    \usepackage{xcolor} \let\oldtextit\textit \renewcommand\textit[1]{\oldtextit{\color{blue}#1}} \let\olditshape\itshape \def\itshape{\color{blue}\olditshape}

    \begin{document} Some text in \textit{blue} \begin{thm} Some mathematical theorem ... \end{thm} \end{document}`

    – 220284 Apr 12 '20 at 18:09
  • Sorry, I don't know how to edit the above comment correctly. On my system the text in the Theorem is in italic, but not in blue. – 220284 Apr 12 '20 at 18:11