I have lots of C++ code snippets in my article. Just see the following tex content and you'll get what I mean.
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{xspace}
\NewDocumentCommand{\code}{m}{\texttt{{#1}}}
\begin{document}
My code is \code{cout << hello << world;}\\
But I wish it looks like \verb|cout << hello << world;|
\end{document}
The different is «
and <<
.
How can I avoid ligatures in my \code
macro.
fontenc
, but\usepackage{fontspec}
and you'll see that there are no ligatures by default. – egreg Nov 23 '20 at 11:18\verb
or\lstinline
and adjust the style (font, color, etc.) instead of implementing the commands yourself – DG' Nov 23 '20 at 11:40