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}
lstlisting
environments. – Mico Sep 27 '20 at 19:55