7

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

I like

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

don't like

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?

Todd Lehman
  • 13,912
ekk
  • 103

3 Answers3

16

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

enter image description here

\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).

Werner
  • 603,163
  • If you should get a pixelated font in your output when using \usepackage[T1]{fontenc}, have a look at http://tex.stackexchange.com/questions/1291/why-are-bitmap-fonts-used-automatically. – doncherry Feb 28 '12 at 01:25
  • 2
    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 01:27
  • Brilliant, exactly what I was looking for. Thank you very much! – ekk Feb 28 '12 at 11:09
  • 3
    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
4

Here is a TikZ-based solution:

example

\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}
Todd Lehman
  • 13,912
  • 3
    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 08:51
  • 2
    I think it looks better than guillemets, but maybe that's just me. – Todd Lehman Feb 28 '12 at 09:23
1

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:

enter image description here

Count Zero
  • 17,424