Making boxed keys to immitate key presses

Nick Urbanik

September 25, 1995

Abstract For laboratory sheets I needed to show to the student when they were to press a particular key. This style provides the \key command, which encloses its arguments in a box with rounded corners.

1 Producing the documentation

Here is a short driver program that can be extracted with the L^{A}TEX2e docstrip program.

1 ⟨∗driver⟩

 2 \documentclass{article}%
 3 \usepackage{a4,doc}
 4 \EnableCrossrefs   % Make a full index.
 5 \CodelineIndex     % Index by line numbers rather than by page.
 6 \RecordChanges     % Show change history.
 7 \begin{document}
 8 \DocInput{key.dtx}
 9 \PrintIndex
10 \PrintChanges

Now tell the people what they need to do next to get the index and change list:

11 \message{Next, to make the index and changes list for this documentation:}
12 \message{2. makeindx -s gind.ist key}
13 \message{3. makeindx -s gglo.ist -o key.gls key.glo}
14 \message{Finally, run this file through LaTeX once more.}
15 \end{document}

16 ⟨/driver⟩

17 ⟨∗package⟩

18 \ProvidesPackage{key}[\filedate\space\fileversion\space
19  Creates a boxed key image]

20 ⟨/package⟩

2 The package that really does the work

The fancybox package does all the work. This key package is just using that to do the job here.

21 ⟨∗package⟩

22 \RequirePackage{fancybox}

key The key macro takes one argument. This argument will be set in a small sans serif font with a box that is 0.7em in size, and has rounded corners. Really, the work is all done by the fancybox package.

23 \newcommand{\key}[1]{\Ovalbox{\makebox[0.7em]%
24  {{\small\textsf{#1}}\rule[-0.0em]{0pt}{0.7em}}}}

25 ⟨/package⟩

This \endinput command prevents anything else from being read by docstrip, such as the character table.

26 \endinput

Index

The italic numbers denote the pages where the corresponding entry is described, numbers underlined point to the definition, all others indicate the places where it is used.

B

\begin . . . . . . . . . . 7, 14

C

\CodelineIndex . . . . . . 5

D

\DocInput . . . . . . . . . . 8

                          \documentclass . . . . . . 2

E

                          \EnableCrossrefs . . . . 4

P

                          \PrintChanges . . . . . . 10
                          \PrintIndex . . . . . . . . . 9

R

                                                    \RecordChanges . . . . . . 6

T \typeout . . . . . . . 16–19

U

                                                    \usepackage . . . . . . . . . 3

Change History

v1.0 "General": First release . . . . . . . . . 1 v2.0

"General": Added documentation . 1