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.

migrated from stackoverflow.com Sep 5 '11 at 20:04

This question came from our site for professional and enthusiast programmers.

  • 1
    \rangle\rangle works for me. What problem do you have? – Konrad Rudolph Sep 5 '11 at 12:25
  • Better use the listings package, which provides both inline and block verbatim environments for code display. – Svante Sep 5 '11 at 15:45
  • I was pondering whether {symbols} or {punctuation} is more appropriate. I decided for the former because I (a non-mathematician) have never heard of "punctuation" in mathematical context. – doncherry Sep 5 '11 at 21:00
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}}
  • Expression(\langle)Func(\langle)T, bool(\rangle\rangle) worked perfectly thanks! – JMc Sep 5 '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 5 '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 5 '11 at 20:34
2

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

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>)$
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>>|?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy