I want to use times in headings but I want to use Consolas inside listings, however times and fontspec overrides one with another. I have tried the following:

\usepackage{times} % Use the Times font for headings
\lstdefinestyle{c++} {%
    backgroundcolor=\color{format-color!6!white}, % set backgroundcolor
    basicstyle=\footnotesize\ttfamily\color{white!10!black},% basic font setting
%... more things down

But naturally I doesn't work, my headings are print different with a different font.

I just want the Consolas font in my listings, nothing more. I would really appreciate your help.

Edit: I use my listings next way:

% In the class document
    %#1 is the file path
% In the document
  • 2
    don't use \usepackage{times} with an unicode engine. Set a times font with \setmainfont. – Ulrike Fischer Sep 27 at 19:52
  • Please edit your posting to provide an example of how you use lstlisting environments. – Mico Sep 27 at 19:55
  • @Mico I have edited the post – Miguel Avila Sep 27 at 20:17

Your Answer

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

Browse other questions tagged or ask your own question.