Less pointy angle brackets

I was looking for a way to beautifully display UML stereotype titles including angle brackets like you can see here:

What I came up with is $\mathtt{\ll metaclass\gg}$, however, as you can see here

the brackets are too pointy (I hope you know what I mean) and the spacing between brackets and expression is too big.

Short version: Does anyone know a command for according brackets?

-

migrated from stackoverflow.comFeb 28 '12 at 0:36

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

Choose a different font? –  meagar Feb 27 '12 at 22:15

I have come up with three solutions:

\documentclass[12pt,a4paper]{article}

\usepackage{graphicx}

% These two packages contain the symbols I hacked (a bit) to get the desired effect:

\usepackage{MnSymbol}
\usepackage{skak}

% Here the symbols are hacked (rotated and shifted as needed):

\newcommand{\gmathleft}{\rotatebox{90}{$\sqdoublefrown$}}
\newcommand{\gmathright}{\rotatebox{90}{$\sqdoublesmile$}}

\newcommand{\gleft}{\qside}
\newcommand{\gright}{\kern-0.01em\raisebox{\depth-.35pt}{\rotatebox{180}{\qside}}}

\begin{document}

% This is the first solution: just switch to typewriter font:

\texttt{<<metaclass>>}

% Here's the solution with MnSymbol:

\gmathleft\texttt{metaclass}\gmathright

% Here's the skak-based solution:

\gleft\texttt{metaclassm}\gright

\end{document}


As you can see the symbols from MnSymbol work only in math mode, while the skak symbols are text mode.

And here are the three solutions lined up:

-

Here is a TikZ-based solution:

\documentclass{article}
\usepackage{tikz}
\newcommand\umlst[1]{%
\kern.05em%
\raisebox{-.025ex}{%
\begin{tikzpicture}[scale=.20,line width=.15ex,join=round,cap=round]
\draw ( 0,0) -- +(-.5,.5) -- +(0,1);
\draw (.5,0) -- +(-.5,.5) -- +(0,1);
\end{tikzpicture}%
}%
\kern.15em%
\texttt{#1}%
\kern.10em%
\raisebox{-.025ex}{%
\begin{tikzpicture}[scale=.20,line width=.15ex,join=round,cap=round]
\draw ( 0,0) -- +(.5,.5) -- +(0,1);
\draw (.5,0) -- +(.5,.5) -- +(0,1);
\end{tikzpicture}
}%
\kern-.25em%
}

\begin{document}
\umlst{Metaclass}\par
\umlst{ObjectCreator}\par
\umlst{RegexLexerMeta}\par
\end{document}

-
I don't think it is good to use TikZ to emulate guillemets. It's an unnecessary complexity, it does not match the font style and can't be searched for/copied in the PDF. –  Andrey Vihrov Feb 28 '12 at 8:51
I think it looks better than guillemets, but maybe that's just me. –  Todd Lehman Feb 28 '12 at 9:23

Use the T1 font encoding to access \guillemotleft and \guillemotright:

\documentclass{article}
\usepackage[T1]{fontenc}% http://ctan.org/pkg/fontenc
\begin{document}
$\ll$~\texttt{metaclass}~$\gg$ \par
\guillemotleft~\texttt{metaclass}~\guillemotright \par
\guillemotleft$\;$\texttt{metaclass}$\;$\guillemotright \par
\guillemotleft\,\texttt{metaclass}\,\guillemotright \par
\guillemotleft\texttt{metaclass}\guillemotright
\end{document}


The above sequence lists some spacing options: ~, $\;$, \, and {} (none).

-
If you should get a pixelated font in your output when using \usepackage[T1]{fontenc}, have a look at tex.stackexchange.com/questions/1291/…. –  doncherry Feb 28 '12 at 1:25
As ekk said the spacing between brackets and expression is to big, I'd remove the spaces altogether or suggest using \,. –  doncherry Feb 28 '12 at 1:27
Brilliant, exactly what I was looking for. Thank you very much! –  ekk Feb 28 '12 at 11:09
Why not listing also the possibity of doing \texttt{<<metaclass>>}? Notice that with T1-encoded fonts the combinations << and >> produce the guillemets. –  egreg Feb 28 '12 at 11:16