1

I want to type the angle bracket inside a listings inline code.

like ⟨this⟩

I set up listings to be (globally) typed in the Latin Modern Mono.

With the following

% !TEX TS-program = xelatex
% !TEX encoding = UTF-8 Unicode
\documentclass[a4paper,11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{fontspec,hyperref,listings}
\lstset{%
basicstyle=\ttfamily\small,
breaklines=true,
language=TeX,
extendedchars=true
}

\usepackage{polyglossia} \setdefaultlanguage{english} \setotherlanguage{hebrew}

\makeatletter \lst@InputCatcodes \def\lst@DefEC{% \lst@CCECUse \lst@ProcessLetter ^^^^27e8% Left-Pointing Angle Bracket ^^^^27e9% Right-Pointing Angle Bracket} ^^00} \lst@RestoreCatcodes \makeatother

\setmainfont{Latin Modern Roman} \newfontfamily\hebrewfont{Arial} \begin{document} The command is \lstinline$\newfontfamily⟨cmd⟩{font}{options}$. \end{document}

I get this output:

enter image description here

Even after adding the makeatletter-makeatlatter code suggested in the comments, the brackets are not displayed in the output.

What is it that I am missing here?

tush
  • 1,115
  • 1
  • According to the font catalog https://tug.org/FontCatalogue/typewriterfonts.html the name should be "Latin Modern Mono". 2. listings is known not to play well with "extended" characters. There's a whole section about it in the documentation, including some suggestions (such as "escape to LaTeX"). 3. With typewriter font, why not just use < and >?
  • – Willie Wong Jan 24 '22 at 03:05
  • 1
    the \ttfamily doesn't have the glyphs, only 〈〉. To use such chars in the input of listings you must add them to the processing list, see https://tex.stackexchange.com/a/25396/2388 – Ulrike Fischer Jan 28 '22 at 17:56
  • @UlrikeFischer I edited the original question. I still don't succeed getting it right. – tush Jan 29 '22 at 15:20
  • @UlrikeFischer Besides, Could you give some explanation about where this code block (the one beginning with \lst@InputCatcodes \def\lst@DefEC{%) comes from? – tush Jan 29 '22 at 15:32
  • the code is from the sty. I looked that up some years ago. – Ulrike Fischer Jan 29 '22 at 15:39