10

menukeys is a very fancy package.

We can use it by:

\usepackage[os=win]{menukeys} % Show keys in Windows style

or by:

\usepackage[os=mac]{menukeys} % Show keys in Mac style

However, in my article, I want to show keys in both styles.

How to dynamically switch the style in the same article?

10

You may define two macros to switch the OS style:

\makeatletter
\def\setmenukeyswin{\def\tw@mk@os{win}}
\def\setmenukeysmac{\def\tw@mk@os{mac}}
\makeatother

Example:

enter image description here

\documentclass{article}
\usepackage{menukeys}
\makeatletter
\def\setmenukeyswin{\def\tw@mk@os{win}}
\def\setmenukeysmac{\def\tw@mk@os{mac}}
\makeatother

\begin{document}

\setmenukeyswin

\shift \capslock \tab \esc \ctrl \Alt \AltGr \cmd \return \winmenu
\enter \backspace \del \arrowkeyup \arrowkeydown \arrowkeyleft
\arrowkeyright \Space \SPACE

\setmenukeysmac

\shift \capslock \tab \esc \ctrl \Alt \AltGr \cmd \return \enter
\backspace \del \arrowkeyup \arrowkeydown \arrowkeyleft \arrowkeyright
\Space \SPACE

\end{document}

Edit:

To change the mackeys option dynamically, you may define the following macros (not tested):

\makeatletter
\def\setmackeystext{\def\tw@mk@mackeys{text}}
\def\setmackeyssymbol{\def\tw@mk@mackeys{symbol}}
\makeatother
| improve this answer | |
  • 2
    It might also be of interest that one can append mac or win to any key macro, e.g., \ctrlwin vs. \ctrlmac instead of just \ctrl. I use this in tables where I contrast key bindings for different operating systems in different columns. – Florian H. Mar 4 '17 at 1:02
  • @FlorianH. You can define your own macros. Ex: \def\ctrlwin{\setmenukeyswin\ctrl} – Paul Gaborit Mar 4 '17 at 1:17
  • 1
    @Paul Gaborit: Wait, I'm saying that \ctrlwin and \ctrlmac` macros are already defined in the menukeys package (and might be useful in a situation like the OP describes). – Florian H. Mar 5 '17 at 3:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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