menukeys icon indicating copy to clipboard operation
menukeys copied to clipboard

`os=` choice is restrictive

Open mathstuf opened this issue 11 years ago • 4 comments

When making a document which is for Windows and OS X users, I'd like to avoid the OS X symbols except for \cmd which is unique to OS X (and the \enter symbol is always shown for os=mac), but all I get is a warning instead.

Example:

press \keys{\ctrl+F} (or \keys{\cmd+F}) to search

mathstuf avatar Sep 26 '14 20:09 mathstuf

Thanks for your feedback! The bad news is that solving this issue one the package level would require some work, but I don’t have the time at the moment. The good news is there is a workaround :-)

Quoting the manual (p. 12)

… to be able to use a key even if it’s undefined via the os option macros like \⟨key⟩mac and \⟨key⟩win that will always give the right symbol.

That means that you could use os=win and \cmdmac instead of \cmd. To change this at document level say \let\cmd\cmdmac in your preamble after loading menukeys.

minimal working example

example

\documentclass{article}
\usepackage[os=win]{menukeys}
\let\cmd\cmdmac% <------------ magic happens here

\begin{document}
press \keys{\ctrl+F} (or \keys{\cmd+F}) to search
press \keys{\enter} for a new line
\end{document}

I hope this helps!

tweh avatar Oct 02 '14 15:10 tweh

On Thu, Oct 02, 2014 at 08:31:25 -0700, Tobias Weh wrote:

I hope this helps!

Yep, it does, thanks. I guess another thing which doesn't seem to be fixed with the suffixes would be the ability to use both text and symbols for mac keys.

mathstuf avatar Oct 02 '14 16:10 mathstuf

Hm … do you want to have the symbol and the text on the same key or just be able to use both? Here some examples showing both. It is not part of the package and I guess it won’t be in the future but it can be achieved easily at document level.

\documentclass[parskip]{scrartcl}
\usepackage[os=win]{menukeys}
\let\cmd\cmdmac% <------------ magic happens here

% new commad (note the capital C) to combine text and symbol
\newcommand{\Cmd}{cmd\,\cmd}
% or: new command for text only
\newcommand{\cmdt}{cmd}

% with xparse you can define easily define a starred
% version
\usepackage{xparse}
\NewDocumentCommand{ \CMD }{ s }{%
    \IfBooleanTF{#1}{cmd}{\cmd}%
}

\begin{document}
press \keys{\Cmd + C}

press \keys{\cmdt + C} same as \keys{\cmd + C}

press \keys{\CMD + C} i.e. \keys{\CMD* + C}
\end{document}

example

tweh avatar Oct 02 '14 23:10 tweh

For this version changing the behavior would be much work, but for a future version I can think about an implementation like this:

  • \<key>: depends on os (and mackeys) option
  • \<key>win: shows always the Windows key
  • \<key>mac: shows always the Mac key but depends on mackeys option
  • \<key>macS: shows always the Mac key in symbol variant
  • \<key>macT: shows always the Mac key in text variant

another way could be do add an optional argument

  • \<key>: depends on os (and mackeys) option
  • \<key>[os=win]: shows always the Windows key
  • \<key>[os=mac]: shows always the Mac key but depends on mackeys option
  • \<key>[os=mac,mackeys=text]: shows always the Mac key in symbol variant
  • \<key>[os=mac,mackeys=symbol]: shows always the Mac key in text variant

That may be more consigned but longer to type …

tweh avatar Apr 18 '16 09:04 tweh