0

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
%------------------------------------------------------------------------------------
%\usepackage{inconsolata}
%\renewcommand*{\ttdefault}{cmtt}
%------------------------------------------------------------------------------------
\usepackage{fontspec}
\setmonofont{Consolas}
\lstdefinestyle{c++} {%
    language=C++,
    backgroundcolor=\color{format-color!6!white}, % set backgroundcolor
    keywordstyle=\bfseries\color{keyword},
    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
\newcommand{\includesilentsnipet}[3]{
    %#1 is the file path
    \lstinputlisting[firstnumber=#2,firstline=#2,lastline=#3]{#1}
}
% In the document
\includecodeexample{var\_op.cpp}{source/functional/var-op.cpp}
  • 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.