in the min example below, I cannot get the file to compile as it complains that I must change my typesetting engine to xelatex or lualatex instead of plain latex or pdflatex. In my original program, I can only compile in pdflatex because I am using koma-script. Is it possible to get this min example working in pdflatex?
\documentclass[%
,paper=a4
,pagesize=auto
,BCOR=0.75cm
% ,oneside
,DIV=10
,numbers=noenddot
,captions=heading
,captions=nooneline
,listof=totoc
,bibliography=totoc
,index=totoc
,headings=normal
,USenglish,
]{scrbook}
\usepackage[svgnames]{xcolor}
\definecolor{ocre}{RGB}{243,102,25}
\usepackage{avant}
\usepackage{mathptmx}
\usepackage{microtype}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{fontspec}
\usepackage{filecontents}
\begin{filecontents*}{sample.m}
% create a file for output
!touch testFile.txt
fid = fopen('testFile.text', 'w')
for i=1:10
fprintf(fid,'%6.2f \n', i);
end
\end{filecontents*}
\usepackage[numbered,framed]{matlab-prettifier}
\usepackage[font={color=ocre,bf},figurename=Fig.,labelfont={it}]{caption}
\newfontfamily{\lstconsolas}{Consolas}
\newcommand\ph\mlplaceholder
\renewcommand{\lstlistingname}{Matlab Algorithm}% Listing -> Algorithm
\renewcommand{\lstlistlistingname}{List of \lstlistingname s}% List of Listings -> List of Algorithms
\begin{document}
%\lstlistoflistings
\lstinputlisting[style=Matlab-editor,basicstyle=\lstconsolas,caption=Sample code from Matlab]{sample.m}
\begin{lstlisting}[
style=Matlab-editor,
basicstyle=\lstconsolas\small,
escapechar=`,
caption={For educational purposes},
]
% example of while loop using placeholders
while x2 = 1 + 100 `\ph{condition}`
if `\ph{something-bad-happens}`
break
else
% do something useful
end
% do more things
end
\end{lstlisting}
\end{document}
This is how the output should appear:




\usepackage{fontspec}andConsolasfont. Don't use them and your file will workd with pdflatex. In any case I don't understand "I can only compile in pdflatex because I am using koma-script". – Ignasi Jun 10 '15 at 07:18