라텍스에서 이중 덜 등호 합자를 피하는 방법

Nov 23 2020

내 기사에 많은 C ++ 코드 조각이 있습니다. 다음 tex 내용을 보시면 제가 의미하는 바를 알 수있을 것입니다.

\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}

다른 점은 «<<입니다.

\code매크로 에서 합자를 어떻게 피할 수 있습니까 ?

답변

3 Rmano Nov 23 2020 at 15:58

합자를 비활성화하려면 어떻게해야합니까?에microtype 표시된대로 사용할 수 있습니다 . :

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{xparse}% not needed in recent kernels
\usepackage{xspace}
\usepackage{microtype}
\DisableLigatures{encoding=T1, family=tt*}

\NewDocumentCommand{\code}{m}{\texttt{{#1}}}

\begin{document}
My code is \code{cout << hello << world;}

But I wish it looks like \verb|cout << hello << world;|

Normal ff and ffi ligatures still here.
\end{document}