ラテックスの二重等号の合字を回避する方法
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}
