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 do a lot of itemize lists in beamer presentation which, in a later step, I want to format nicely, for instance, typeset everything up to the first colon in boldface and the remaining part scriptsize inside a \parbox. A common idiom I use is to define a custom \Item command for this purpose that parses the item text and emits a \item with the intended formatting:

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

\begin{document}

\def\Item#1:#2\endItem{\item \parbox{2cm}{\strut\textbf{#1:}}\parbox[t]{\linewidth-2cm}{\footnotesize#2}}
\begin{frame}{A frame}
  Common metasyntactic variables (used to name absolutely anything)
  \begin{itemize}
    \Item foo: f*cked over and over? Well, we do not really know the meaning of this beast.\endItem
    \Item bar: beyond all reason?\endItem
  \end{itemize}
\end{frame}

\end{document}

enter image description here However, to scan the "rest" of the item's text as a macro argument, I have to finish eacht item by an explicit end marker \endItem, which I would like to avoid. As in this related question, I also do not want to put the item's text into groups of curly braces.

Is there another, more elegant way to scan to the end of an \item?

share|improve this question
2  
It's actually fubar, which evolved into foobar. –  Werner May 10 '12 at 21:27
1  
You can use \par as delimiter, instead of \endItem, but you'll need to leave a blank line at the end of each item. –  egreg May 10 '12 at 21:30
    
@Werner: I know. My example is furchtbar :-) –  Daniel May 11 '12 at 6:50
    
@egreg: I did consider this, but refrained from it I consider it as too fragile. The fact that the blank lines suddenly are mandatory would be a clear violation of the principle of least surprise for anybody editing my stuff. –  Daniel May 11 '12 at 6:59
    
@Daniel TeX is not a language for general parsing; it's designed for typesetting paragraphs. In order to gather some user input for processing you have to delimit it in some way. An "inner" environment, using the environ package, might be a better solution than using \endItem. –  egreg May 11 '12 at 9:17
show 1 more comment

1 Answer

You can recreate the same effect with a description list and some styling. Unfortunately, beamer doesn't have a template for the description part of the the description list. So setting the font size to \footnotesize has to involve some hack. Maybe someone can come up with a less intrusive one.

\documentclass{beamer}
\usepackage{etoolbox}

\setbeamertemplate{description item}{%
    \usebeamertemplate*{itemize item} %
    \insertdescriptionitem:\hfill%
}
\setbeamercolor{description item}{fg=black}
\setbeamerfont{description item}{series=\bfseries,size=\normalsize}
\setbeamersize{description width=2cm}

\makeatletter
\apptocmd\@@description{\footnotesize}
\makeatother

\begin{document}

\begin{frame}{A useless list}
  \begin{description}
    \item[first] This is the first list item
    \item[bar] And this is the second one
  \end{description}
\end{frame}

\end{document}

result

share|improve this answer
    
+1 Neat trick, which, however only solves this particular example. (Thats always the problem with MWEs, in the end you have oversimplified...). I am actually seeking a general solution that would also work if I want to parse into more than two parts. Moreover, I need to mix my customized \Items and ordinary \items within the same list. –  Daniel May 11 '12 at 6:56
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.