It is needed to print the letter notes in the piano keyboard package, the basic code is as follow:


\usepackage{float} %Paquete para posicionar Tablas


    \caption{Harmonic minor scale structure in A}


The desired output is as follow: desired

  • 1
    If you want more than seven notes, you can use xpiano instead of piano and you can do \keyboard{Ao,Bo,Ct,Dt,Et,Ft,Gst,At}. But for the decorations in the desired output, you need something else, as shown in the given answer.
    – egreg
    Jan 7 at 13:32

1 Answer 1


The piano package is a very very limited package. Here is the complete manual:

This package adds the \keyboard[1][2]..[7] command to your project. When used, it draws a small 2 octaves piano keyboard on your document, with up to 7 keys highlighted.

Keys go : Co, Cso, Do, Dso, Eo, Fo, Fso, Go, Gso, Ao, Aso, Bo, Ct, Cst, Dt, Dst, Et, Ft, Fst, Gt, Gst, At, Ast and Bt.

Suggested use : \begin{figure}[thpb]\ \centering
\keyboard[Co][Eo][Gso][Ct][Et] \caption{C aug chord}
\label{Chord1} \end{figure}

Notice you can highlight max 7 keys. The empty keyboard can with some difficulty be used in a TikZ picture like this:

\documentclass[tikz, border=1cm]{standalone}
white, scale=0.8,
append after command={\pgfextra{\tikzset{every label/.append style={white, scale=0.8}}}}
inner sep=1pt, 
every node/.style={circle, minimum width=14pt, font=\bf},
every label/.style={rectangle, label position=below, label distance=1pt, inner sep=0pt, font=\small}
\node[rectangle, anchor=south west, inner sep=0pt, outer sep=0pt, shift={(0.03,0.3)}, font=\normalsize, scale=2] {\keyboard};
\node[draw, label={Fun}] at (1,1) {C};
\node[fill=orange, label={[white, scale=0.8]Fun}] at (1.5,2) {};
\node[fill=red] at (2.5,2) {};
\node[fill=orange, label={Fun}] at (2,1) {D};
\node[draw=teal, very thick, fill=orange, label={Fun}] at (3,1) {E};
\node[label={R}] at (6,1) {A};
\node[label={m2}] at (7,1) {B};
\node[label={M3}] at (8,1) {C};
\node[label={p4}] at (9,1) {D};
\node[label={p5}] at (10,1) {E};
\node[label={m6}] at (11,1) {F};
\node[label={R(0)}] at (13,1) {A};
\node[blackkey, label={(m7)}] at (12.5,2.5) {G\#};
(6,-0.2)    edge +(0,0.4) -- 
(7,-0.2)    edge +(0,0.4) --
(8,-0.2)    edge +(0,0.4) -- 
(9,-0.2)    edge +(0,0.4) -- 
(10,-0.2)   edge +(0,0.4) -- 
(11,-0.2)   edge +(0,0.4) -- 
(12.4,-0.2) edge +(0,1.4) --
(13,-0.2)   --   +(0,0.4);
\tikzset{every node/.style={font=\normalfont}}
\node at (6.5,-0.5)  {T};
\node at (7.5,-0.5)  {S};
\node at (8.5,-0.5)  {T};
\node at (9.5,-0.5)  {T};
\node at (10.5,-0.5) {S};
\node at (11.8,-0.5) {TS};
\node at (12.7,-0.5) {S};

Keyboard with some highlighted keys and notes


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.