Formatting Paths, Menus, and Key Shortcuts in Softcover

One of the last tasks on the agenda before shipping my books is to make the formatting support the material instead of making it harder to understand.

Softcover is nice because it lets you stay mostly in Markdown, but you can drop in LaTex for more advanced formatting needs. I started by using inline code formatting for everything from function names, API calls, code snippets, to file paths. For UI instructions, I was using double quotes and a mixture of inline stuff.

I found the menukeys LaTex package which gives you more control over the appearance of menu items, file paths, and key combinations. Here I’ll show you how to use it to make your manuscript look more polished.

Download the finished product and get the code.

Integration

If you don’t want special configuration or styling, it’s pretty easy to add this to your build. Simply add a line to your config/preamble.tex file:

\usepackage{menukeys}

If you don’t already have a softcover book, check out the getting started guide.

Menu Style

Menu Formatting

I prefer the default menu style, so I just use the \menu directive in my text.

When interacting with the menu system to follow \menu{a>set>of>instructions} you'll see this formatting.

Directory Style

Directory Formatting

If you want to use the styles mentioned in the documentation, you’ll need to configure them in your config/preamble.tex after the \usepackage line.

\renewmenumacro{\directory}[/]{pathswithblackfolder}

Defining it here will apply the style throughout the manuscript (this wasn’t clear in the documentation, found the answer and a great tutorial).

Add the \directory directive inline with your markdown:

If you are directed to a particular file, \directory{the/full/file/path} will be shown.

Key Style

Key Formatting

To get the shadowedroundedkeys style,  add this to the the config/preamble.tex:

\renewmenumacro{\keys}[+]{shadowedroundedkeys}

To produce the line above, add this to your manuscript:

Finally, key shortcuts are shown as: \keys{cmd + \Alt + \ctrl + \tab + \shift + \return}.