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.
\documentclass{beamer}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[utf8]{inputenc}

\begin{document}
\begin{frame}[fragile]{Angle Brackets}
\newcommand{\bbb}{\protect\textless\protect\textless\protect\textless}
\begin{semiverbatim}
Wrong:
a <<< b

Right:
a \bbb b
\end{semiverbatim}

\end{frame}
\end{document}

angle brackets

Why is this happening at all? In the beamer documentation it only says that \, {, and } are handled specially.

Also, I can't say that I like my solution very much. I'd rather be able to use <<< as is. Is my solution the only way to go here?

share|improve this question
    
Why is it happening? This is the work of \usepackage[T1]{fontenc} - remove it. –  Werner Jun 15 '13 at 16:23
    
Hm, you're right, but isn't it good practice to use T1 so that people can copy-paste properly? –  neo Jun 15 '13 at 16:26
    
If good practice leads to this or other problems, then it might not be good practice. It may be your use-case which is problematic. If you wish to keep that functionality, then some intervention is required... –  Werner Jun 15 '13 at 16:38
    
In my case I actually need fontenc because I use the luximono font which requires it. –  neo Jun 15 '13 at 18:18
add comment

2 Answers

up vote 5 down vote accepted

If the question is "how to prevent", an additional grouping will be enough:

\documentclass{beamer}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[utf8]{inputenc}

\begin{document}
\begin{frame}[fragile]{Angle Brackets}
\newcommand{\bbb}{\protect\textless\protect\textless\protect\textless}%} % corrected
\begin{semiverbatim}
Wrong:
a <{<}< b % here - PS

Right:
a \bbb b
\end{semiverbatim}

\end{frame}
\end{document}

enter image description here

share|improve this answer
    
Hm, this doesn't work in lualatex. For the test I used pdflatex where your solution works. –  neo Jun 15 '13 at 18:01
    
@neo Tested in pdfLaTeX and XeLaTeX. Probably a bug in luaLaTeX... –  Przemysław Scherwentke Jun 15 '13 at 18:13
add comment

You can modify the definition of semiverbatim.

\documentclass{beamer}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[utf8]{inputenc}

\makeatletter
\def\semiverbatim{%
  \trivlist\item\relax
  \if@minipage\else
    \vskip\parskip
  \fi
  \leftskip\@totalleftmargin
  \rightskip\z@skip
  \parindent\z@
  \parfillskip\@flushglue
  \parskip\z@skip
  \@@par
  \@tempswafalse
  \def\par{%
    \if@tempswa
      \leavevmode\null\@@par\penalty\interlinepenalty
    \else
      \@tempswatrue
      \ifhmode
        \@@par\penalty\interlinepenalty
      \fi
    \fi}%
   \obeylines
   \def\verbatim@nolig@list{\do\<\do\>}%
   \verbatim@font\@noligs\catcode`\<=\active \catcode`\>=\active
   \let\org@prime'%
   \everymath\expandafter{\the\everymath\catcode`\'=12 \let'\org@prime}%
   \everydisplay\expandafter{\the\everydisplay\catcode`\'=12 \let'\org@prime}%
   \def\dospecials{\do\ \do\$\do\&\do\#\do\^\do\_\do\%\do\~\do\`\do\,\do\'\do\-}%
   \let\do\@makeother\dospecials
   \def\\{\char`\\}%
   \def\{{\char`\{}%
   \def\}{\char`\}}%
   \frenchspacing\@vobeyspaces
   \everypar\expandafter{\the\everypar\unpenalty}%
}
\makeatother

\begin{document}
\begin{frame}[fragile]{Angle Brackets}
\newcommand{\bbb}{\protect\textless\protect\textless\protect\textless}
\begin{semiverbatim}
Wrong:
a <<< b

Right:
a \bbb b
\end{semiverbatim}

\end{frame}
\end{document}

Maybe other characters need to be activated. I only disabled the << and >> ligatures.

Unfortunately a simpler patch is not possible, but this redefinition of semiverbatim is very faithful to the original one.

share|improve this answer
    
Nice, maybe this should be included in the beamer package. If you don't mind I'll suggest that in the beamer google group. –  neo Jun 16 '13 at 8:32
add comment

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.