6

I can create an angle bracket with the commands $\langle and \rangle$.

So if I want to say something like

IList<T>

I can achieve this with

IList $\langle T \rangle$

But I am unable to create double angled brackets. I am trying to say:

(Expression<Func<T, bool>>)

And I cannot get the two sets of angle brackets in place. Can anyone advise how I can get double angle brackets to work?

EDIT:

Actually, I just found that I can do the following to get double angle brackets:

$\llangle and \rrangle$

However, its still not possible to have two single left angle brackets followed by a double angle, which is what I need for the expression above.

dremodaris
  • 464
  • 4
  • 13

4 Answers4

6

The following works for me:

Expression\(\langle\)Func\(\langle\)T, bool\(\rangle\rangle\)

(\(…\) is the same as $…$ but the latter is deprecated in LaTeX.)

Notice that you probably want to define macros for this to make it more readable:

\newcommand*\template[1]{\(\langle\)#1\(\rangle\)}
…
Expression\template{Func\template{T, bool}}
Konrad Rudolph
  • 39,394
  • 22
  • 107
  • 160
  • Expression(\langle)Func(\langle)T, bool(\rangle\rangle) worked perfectly thanks! –  Sep 05 '11 at 13:06
  • I disagree that $…$ is deprecated. The moment it is removed, if ever, is the moment I'm assigning catcode 3 to $ myself! – Andrey Vihrov Sep 05 '11 at 20:25
  • @Andrey Well, I’m merely referring what people from the LaTeX team (Joseph!) said. I’m however unable to find his original comment – you cannot search for those symbols. Either way, editors usually play nicer with \(…\) since it’s easier to infer a lexical range from it and unless you’re editing a really math-heavy text it just makes more sense. – Konrad Rudolph Sep 05 '11 at 20:34
1

Assuming you're annoyed by the white-spaces due to the fact that < and > are treated as binary operators, and not opening / closing delimiters, you can try the following:

$(Expression\mathopen<Func\mathopen<T, bool\mathclose>\mathclose>)$
aioobe
  • 2,376
1

Without having to enter math mode, perhaps try this:

\usepackage[T1]{fontenc}
\usepackage{xspace}
\newcommand{\rrangle}{>\kern-1.2ex~>\xspace}

The fontenc package ensures that the angle brackets are interpreted correctly. The xspace package is there to fix up spacing issues that could occur. Feel free to adjust the amount of negative space; what I have here just looks nice to me. Here's the difference that you should see:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{xspace}
\newcommand{\rrangle}{>\kern-1.2ex~>\xspace}
\begin{document}
(Expression<Func<T, bool>>)

(Expression<Func<T, bool\rrangle)
\end{document}

Minimum working example - double right-angle brackets

Rhyme
  • 119
0

If you are trying to enter code fragments in LaTex you might be better using one of the packages (such as listings) that provide appropriate verbatim environments and commands.

If you just want a quick hack what about \verb|Expression<Func<T,bool>>|?

Konrad Rudolph
  • 39,394
  • 22
  • 107
  • 160