Menübefehl-Sequenzen mit LaTeX darstellen

Auf tex.stackexchange kam heute die Frage auf, wie man beliebig lange Menübefehl-Sequenzen mit LaTeX darstellen kann (http://tex.stackexchange.com/questions/40613/create-a-command-for-menu-sequences). Da ich dies auch gelegentlich benötige, hier eine Kopie der Lösung:

\documentclass{article}
\usepackage{etoolbox}% http://ctan.org/pkg/etoolbox
\begin{document}
\newcounter{menucount}\newcounter{curitem}% Counters
\newcommand{\menuitem}{\texttt}% Menu item formatting
\newcommand{\menusep}{\ensuremath{\rightarrow}}% Menu separator
\newcommand{\menuend}{\relax}% Menu end
\newcommand{\menulist}[1]{% \menulist{<menu list>}
  \setcounter{menucount}{0}\setcounter{curitem}{0}% Reset menucount & curitem
  \renewcommand*{\do}[1]{\stepcounter{menucount}}%
  \menulistparser{#1}% Count menu items
  \renewcommand*{\do}[1]{\menuitem{##1}\stepcounter{curitem}\ifnumless{\value{curitem}}{\value{menucount}}{\menusep}{\menuend}}%
  \menulistparser{#1}% Process list
}
\DeclareListParser{\menulistparser}{:}% List separator is ':'
 
\menulist{File:New:Class}% 3 menu items
 
\menulist{Tools:Options:Advanced:Properties:Document}% 5 menu items
 
\menulist{}% 0 menu items/empty list
 
\menulist{Help}% 1 menu item
 
\renewcommand{\menusep}{~\rule{1ex}{1ex}~}\renewcommand{\menuend}{!}% Different separator and end
\menulist{Your:Menu:Sequence:Here}
 
\end{document}

Nachtrag vom 23.03.2012:

Es geht sogar noch eleganter:

\documentclass[justified]{tufte-book}
\usepackage{lipsum}
\begin{document}
\def\spacer{\hspace{3pt}}
\def\test{}
%\def\test{\includegraphics[height=7pt]{./graphics/web/add.png}}
\def\alist{Dashboard, Content, Structure, Hello~yannis, Log Out, \test}
\makeatletter
\noindent\fbox{%
\begin{minipage}{9cm}
\noindent\colorbox{black}{\small
\@for \i:=\alist \do{\color{white}
  \texttt\i\spacer 
}}
\smallskip
\tiny \lipsum[1-2]
\end{minipage}}
\makeatother
\end{document}

Uwe

Uwe Ziegenhagen likes LaTeX and Python, sometimes even combined. Do you like my content and would like to thank me for it? Consider making a small donation to my local fablab, the Dingfabrik Köln. Details on how to donate can be found here Spenden für die Dingfabrik.

More Posts - Website