0

I'm using fancyhdr package and have this tex file:

\documentclass[a4paper]{testcv}
\usepackage{fontspec}
\usepackage[russian]{babel}

\footersection{\today}{Footer text}{}

\begin{document}
Page text
\end{document}

And this class file:

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{testcv}[2016/02/10 CV class]

\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}} 
\ProcessOptions

\LoadClass[titlepage]{article}

\usepackage{fontspec}
\usepackage{color}
\usepackage{fancyhdr}

\fancyhfoffset{0em}
\renewcommand{\headrulewidth}{0pt}
\fancyhf{}
\pagestyle{fancy}


\usepackage[usenames,dvipsnames]{xcolor}
\definecolor{contentcolor}{HTML}{A6A6A6}
\definecolor{footercolor}{HTML}{FF0000}

% (1) Footer color == contentcolor
\setmainfont[Color=contentcolor, Path = ../fonts/ubuntu/]{Ubuntu-L}

% (2) Footer color is ok
% \setmainfont[Path = ../fonts/ubuntu/]{Ubuntu-L} 


\renewcommand{\footrulewidth}{0.5pt}
\def\footrule{{
  \vskip-\footruleskip\vskip-\footrulewidth
  \color{footercolor}
  \hrule\@width\headwidth\@height
  \footrulewidth\vskip\footruleskip
}}


\newcommand{\footersection}[3]{
\fancyfoot{}
\fancyfoot[L]{\color{footercolor}#1}
\fancyfoot[C]{\color{footercolor}#2}
\fancyfoot[R]{\color{footercolor}#3}   
}

With (1) uncommented I have this output with wrong color: wrong color

If we use (2) instead then page text color is black, but footer works ok: good color

Compiling with XeLaTeX on Windows.

How can I set \setmainfont[Color=contentcolor] and have correct red footer?

Already found this answer, but i can't use it.

  • You can setup a dedicated font for the footer, something like \newfontfamily\footerfontfamily[Color=footercolor, Path = ../fonts/ubuntu/]{Ubuntu-L} and then use \footerfontfamily in the footer. – Ulrike Fischer Jul 7 '16 at 12:16
  • Thank you, this does the job, but I need to know why this happend and how to fix it other way. – Nine Jul 7 '16 at 14:13
  • When you are using the Color-key in \setmainfont, this color always wins, you no longer can change it with the \color command. (\addfontfeature{Color=green}Green should work, but I normally avoid to use \addfontfeature to often). – Ulrike Fischer Jul 7 '16 at 14:22
0

As Ulrike Fischer notice, when you are using the Color-key in \setmainfont, this color always wins, you no longer can change it with the \color command. My document was based on popular Deedy Resume and correct solution was:

\newcommand{\footeritem}[1]{
  \color{footercolor}
  \fontspec[Path = ../fonts/ubuntu/]{Ubuntu-L}  
  \selectfont{#1}
}

\newcommand{\footersection}[3]{
\fancyfoot{}
\fancyfoot[L]{\footeritem{#1}}
\fancyfoot[C]{\footeritem{#2}}
\fancyfoot[R]{\footeritem{#3}}
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.