Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm describing regular expressions, and I would like to have items like this:

\documentclass[10pt,hyperref={pdfpagelabels=false}]{beamer}
\usepackage[utf8x]{inputenc}
\usepackage{default}

\mode<presentation>
{
 \usetheme{Warsaw}
 \setbeamertemplate{background canvas}[vertical shading][bottom=white!10,top=blue!10]
 \setbeamercovered{transparent}
}

\usepackage[brazil]{babel}
\usepackage[T1]{fontenc}
\usepackage[scaled=.80]{helvet}
\usepackage{graphicx}
\setbeamertemplate{caption}[numbered]   

\begin{document}
\section{Search}
\subsection{Regular Exp}
 \begin{frame}[allowframebreaks]{\texttt{Regular Expressions} Operators}{Powerfull}
  \texttt{Regular Expressions} (\texttt{RE}) are good:
  \begin{description}
   \item[\textasciicircum]  Matches the beginning of the line
   \item[\textbackslash] Escape character
   \item[[]] Group characters
   \item[\textbackslash( \textbackslash)] Hell
   \item[$\textbackslash< \textbackslash> $] Hey.
%   \item[{$[:\mathtt{upper}:]$}] Same as $[A-Z]$.
  \end{description}
 \end{frame}
\end{document}

But some of them seem not to work. Some variants I've tried (with ] outside math) gave me half of the item in the correct font/color, and the last char ] in black as if it was normal text.

Please, how can I get this done?

-- Edited: minimal working example added.

share|improve this question
    
The third and the fourth don't work because inner brackets need to be protected: \item[{$[:\mathtt{upper}]$}]. In other words, use braces {...} around optional arguments containing brackets [...]. However you don't need math mode. –  egreg Apr 7 '12 at 13:34
    
Thanks @egreg, but still nothing. I've tried your suggestion like \item[{$[:\mathtt{upper}:]$}] ha!, but I got <blue>[:upper:<\blue> <black>] ha!]<\black>. Very strange, isn't it? –  Dr Beco Apr 7 '12 at 13:40
    
What do the <blue> and <black> tags stand for? –  egreg Apr 7 '12 at 13:49
    
Nothing, just to tell you that the compiled text color should be blue for the label, and black only for ha!. But it is mixed in such way. –  Dr Beco Apr 7 '12 at 13:52
    
@egreg, sorry! I forgot to tell maybe a very important option: \documentclass[10pt,hyperref={pdfpagelabels=false}]{beamer} –  Dr Beco Apr 7 '12 at 14:05
show 6 more comments

2 Answers

up vote 4 down vote accepted

I get what's expected with

\begin{description}
\item[\textasciicircum]  Matches the beginning of the line
\item[\textbackslash] Escape character
\item[{[]}] Group characters
\item[\textbackslash( \textbackslash)] Hell
\item[$\textbackslash< \textbackslash> $] Hey.
\item[{$[:\mathtt{upper}:]$}] Same as $[A-Z]$.
\end{description}

However, math mode is not necessary (and even wrong) in items number 5 and 6. Notice also the braces in the fourth item.

Here's how I would input the description list:

\begin{description}
\item[\texttt{\textasciicircum}]  Matches the beginning of the line
\item[\texttt{\textbackslash}] Escape character
\item[\texttt{[]}] Group characters
\item[\texttt{\textbackslash( \textbackslash)}] Hell
\item[\texttt{\textbackslash< \textbackslash>}] Hey.
\item[\texttt{[:upper:]}] Same as \texttt{[A-Z]}.
\end{description}

which will use typewriter type for the regular expression samples.

If all your description labels in a frame are to be typeset in typewriter type, then Marco Daniel's suggestion is good, but brackets must be hidden:

\setbeamerfont{description item}{family=\ttfamily} % this will hold until \end{frame}
\begin{description}
\item[\textasciicircum]  Matches the beginning of the line
\item[\textbackslash] Escape character
\item[{[]}] Group characters
\item[\textbackslash( \textbackslash)] Hell
\item[\textbackslash< \textbackslash>] Hey.
\item[{[:upper:]}] Same as \texttt{[A-Z]}.
\end{description}
share|improve this answer
    
0 errors, 0 warnings, 0 badboxes. Thanks! Much appreciated. –  Dr Beco Apr 7 '12 at 14:46
    
@DrBeco: In beamer you should use \setbeamerfont{description item}{family=\ttfamily} instead of formating every label. –  Marco Daniel Apr 7 '12 at 14:49
    
@MarcoDaniel I think I do need to format every label. I tried \setbeamerfont and then \item[[:upper:]] would not work again: it move the last ] outside the blue label and make it black font. I think \texttt{} is kind of "protecting" the label. –  Dr Beco Apr 7 '12 at 14:53
    
@egreg: Why do you refer Mico ;-(? –  Marco Daniel Apr 7 '12 at 16:06
    
@MarcoDaniel Oh, sorry! –  egreg Apr 7 '12 at 18:28
show 1 more comment

Update answer

In the comments above it turned out that the @DrBeco uses TeX Live 2009. I suppose it was installed by the default repository of the unix system. However this version isn't up to date. I really recommend to install TeX Live 2011. In this way you can use the update manager tlmgr to get the newest version of nearly every package. If you are using TeX Live 2011 your example will work well.

I want to provide another hint. Don't use utf8x. Some explanation can be found here:

Original answer

Why do you use commands like \textasciicircum or \textbackslash in math mode? The first part of the command indicates text not math.

\documentclass{article}
\begin{document}
  \begin{description}
   \item[\textasciicircum] Matches the beginning of the line
   \item[\textbackslash] Escape character
   \item[{[]}] Group characters
   \item[\textbackslash( \textbackslash) ] Save to a buffer
   \item[{$[:\mathtt{upper}:]$}] Same as $[A-Z]$.
  \end{description}
\end{document}

The same result with beamer:

\documentclass[10pt,hyperref={pdfpagelabels=false}]{beamer}
\begin{document}
\begin{frame}
\setbeamerfont{description item}{family=\ttfamily}
  \begin{description}
   \item[\textasciicircum]  Matches the beginning of the line
   \item[\textbackslash] Escape character
   \item[{[]}] Group characters
   \item[\textbackslash( \textbackslash) ] Save to a buffer
   \item[{$[:\mathtt{upper}:]$}] Same as $[A-Z]$.
  \end{description}
\end{frame}
\end{document}

enter image description here

share|improve this answer
    
Thanks, but it is not working. @egreg gave the suggestion of \item[{$[:\mathtt{upper}:]$}] Same as $[A-Z]$., but now it did not compile. It says there is an extra }. Another one according to you, how would you write: \item[$\textbackslash< \textbackslash>$], please? Thanks. –  Dr Beco Apr 7 '12 at 13:53
    
@egreg: Does the example work for you? I have no problems –  Marco Daniel Apr 7 '12 at 14:00
    
Wow! SORRY! I forgot to tell maybe a very important option: \documentclass[10pt,hyperref={pdfpagelabels=false}]{beamer} –  Dr Beco Apr 7 '12 at 14:03
    
@DrBeco: No problems with beamer. –  Marco Daniel Apr 7 '12 at 14:42
    
For some reason, this doesn't work here. Did you try with babel? Anyway, thanks, the \texttt{} solved the problem. –  Dr Beco Apr 7 '12 at 14:48
show 7 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.