4

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.

DrBeco
  • 237
  • 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 07 '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? – DrBeco Apr 07 '12 at 13:40
  • What do the <blue> and <black> tags stand for? – egreg Apr 07 '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. – DrBeco Apr 07 '12 at 13:52
  • @egreg, sorry! I forgot to tell maybe a very important option: \documentclass[10pt,hyperref={pdfpagelabels=false}]{beamer} – DrBeco Apr 07 '12 at 14:05
  • Please, show a complete minimal example. – egreg Apr 07 '12 at 14:07
  • I think I know your problem. You system isn't up to date. – Marco Daniel Apr 07 '12 at 14:52
  • Hi @MarcoDaniel. Please, can you be more specific? Is there a command to see versions? What version I should be seing? I'm using Debian squeeze stable, KDE and Kile. I'm curious about it. Thanks! – DrBeco Apr 07 '12 at 14:56
  • @DrBeco: Your example works fine for me. Please add the command \listfiles before \documentclass and in the log-file you will see all packages with version. I am using ubuntu with TeX Live 2011. I suppose you are using TeX Live 2009. – Marco Daniel Apr 07 '12 at 15:00
  • This is pdfTeX, Version 3.1415926-1.40.10 (TeX Live 2009/Debian) entering extended mode LaTeX2e <2009/09/24> Babel <v3.8l> beamer 2007/03/11 cvs version 3.07 (rcs-revision 1.70) MPS to PDF converter (version 2006.09.02). pgfsys.sty 2008/02/07 v2.00 (rcs-revision 1.31) geometry.sty 2008/12/21 v4.2 amsmath.sty 2000/07/18 v2.13 inputenc.sty 2008/03/30 v1.1d utf8x.def 2004/10/17 ucs.sty 2004/10/17 portuges.ldf 2008/03/18 v1.2q t1enc.def 2005/09/27 v1.99g helvet.sty 2005/04/12 PSNFSS-v9.2a (WaS) bm.sty 2004/02/26 v1.1c nameref.sty 2007/05/29 v2.31 refcount.sty 2008/08/11 v3.1 – DrBeco Apr 07 '12 at 15:16
  • @DrBeco: Please see my updated answer. – Marco Daniel Apr 07 '12 at 16:04

2 Answers2

4

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

Marco Daniel
  • 95,681
4

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}
egreg
  • 1,121,712