I am trying to draw accordion keyboard layout with Tikz To have results like this with modified variable, Could someone helps me to create something similar with Tikz ? Does anyone have any code exemple close to this ? : [![enter image description here][1]][1]

Could someone helps me to create something similar with Tikz ? Does anyone have any code exemple close to this ?

I am really new in Programmation and I thanks you by advance for your help !


1 Answer 1


Here is my attempt at creating the seemingly evenly placed array of circles on the right image:





        draw,circle split,
        minimum width=1.5cm,minimum height=1.5cm
    basse/.style={mycirc,very thick}
        matrix of nodes,
        every node/.style={anchor=center},
        every odd row/.style={nodes={accord}},
        every even row/.style={nodes={basse}},
        row sep=5mm,column sep=5mm
        & maj\nodepart{lower}maj
        & maj\nodepart{lower}min
        & MI\fl\nodepart{lower}SI\fl
        & SOL\sh\nodepart{lower}SI

        & maj\nodepart{lower}min
        & maj\nodepart{lower}maj
        & MI\fl\nodepart{lower}LA
        & SOL\sh\nodepart{lower}RE

        & |[circle,minimum width=1.5cm,minimum height=1.5cm]|
        & maj\nodepart{lower}maj
        & |[circle,minimum width=1.5cm,minimum height=1.5cm]|
        & DO\sh\nodepart{lower}SOL




Right after \begin{tikzpicture} I define some styles:

  • mycirc is just a split circle with some minimal specified dimensions (so that the circles are evenly sized)
  • accord and basse are just extensions: accord adds nothing extra and just acts as an alias but basse also makes the shape very thick

I then use a matrix to easily create all the accord and basse nodes. Note that you do not have to use the every odd/even row part, it just avoids explicitly specifying the style to use for each element of the matrix.

I hope this helps a little. You can do something similar with the keyboard on the left, but that requires some more advanced positioning (possibly with something other than a matrix).

UPDATE 2020-12-01: Here is another tikzpicture that draws the left image. It uses the chains library instead of a matrix and some loops to avoid writing out all the nodes. There is definitely room for improvements (for example to avoid writing out all the numbers in the loop), but this is what I got so far.





    node distance=2mm,
        draw,circle split,anchor=center,
        minimum width=1.5cm,minimum height=1.5cm
        label distance=-2mm,xshift=-7.5mm
    start chain=1 going below,
    start chain=2 going below,
    start chain=3 going below,
        accord,on chain=1,label={[lb]above:1}
    ] (L) {DO\sh\nodepart{lower}MI\fl};
    \foreach \t/\b/\n in {%
    } \node[%
        accord,on chain=1,label={[lb]above:\n}
    ] {\t\nodepart{lower}\b};

        accord,on chain=2,below right=-2.5mm and 8mm of L,
    ] (M) {LA\nodepart{lower}SOL\sh};
    \foreach \t/\b/\n in {%
    } \node[%
        accord,on chain=2,label={[lb]above:{\n'}}
    ] {\t\nodepart{lower}\b};

        accord,on chain=3,below right=-2.5mm and 8mm of M,
    ] {SOL\sh\nodepart{lower}SI\fl};
    \foreach \t/\b/\n in {%
    } \node[%
        accord,on chain=3,label={[lb]above:{\n''}}
    ] {\t\nodepart{lower}\b};


output of code for image on the left

UPDATE 2021-03-28: The following is one way to arrange the whole thing.

Create all four figures in separate documents (I named these top.tex, left.tex, right.tex, and bottom.tex), all using the standalone document class. You can now remove the border option from the beginning of each of these, it was only for aesthetic purposes when the figures were rendered separately. The standalone package (there is a documentclass and a package as well) allows you to simply do eg. \input{top} to add the output of the standalone document named top.tex.

Now all you need to do is arrange the four figures on one page. This is a lot trickier to do in LaTeX than it sounds. Having tried several methods, I think using tikz yet again to arrange the entire document works best. Examine the code of the final document: it uses tikz to position the individual figures relative to the document’s text area (with some additional ugly manual adjustments).

But first, let’s see the other two figures. They are a lot easier to draw. The top one is simply a circle, a line that goes from the left of the circle to the right (plus a few centimetres) and some text labels:




    \node[draw,circle,minimum width=1.5cm] (c) {};
    \draw (c.west) -- ($(c.east)+(3cm,0cm)$);
    \node[right=1mm of c,yshift=2mm] {\itshape Poussé};
    \node[right=1mm of c,yshift=-2mm] {\itshape Tiré};


The bottom is even easier: just two circles and two labels.




\begin{tikzpicture}[accord/.style={draw,circle,minimum width=1.5cm}]
    \node[accord] (a) {};
    \node[accord,very thick,below=2mm of a] (b) {};
    \node[right=1mm of a] {\itshape Accord};
    \node[right=1mm of b] {\itshape Basse};


Now to put it all together. There is one more thing: the title in the top left corner. I managed to get something similar using a tabular environment. This is how it looks:


% to set margins

% to input standalone documents within this one
% packages and libraries used in included standalone documents

% to get tikz node for document body (-> current page text area)

% to get multirow cells in tables

% to be able to vertically write text

% title drawing command
    \bgroup% so that arraystretch only applies here
                \Large\bfseries Plan de clavier
        & {\Large\bfseries Système Le Tron / Laloy } \\[-2ex]
        %                                               ^^^^
        %       -2ex horizontal shift compensates for \Large
        & Tonalité: sol-do-altératíons. \\
        & Modèles à trois rangèes (33 boutons) \par et dix-huit
          basses \\
        & {} % empty row for vertical line to continue


\thispagestyle{empty} % get rid of page number


\begin{tikzpicture}[remember picture,overlay]
        at ($(current page text area.north)+(0,-6)$)
        at ($(current page text area.north west)
             !.6! % align at a .6 ratio of the top and bottom
             (current page text area.south west)$)
        at ($(current page text area.north east)
             (current page text area.south east)$)
        at (current page text area.south)

    \node at ($(current page text area.west)+(1,8)$)
        {\itshape Haut (graves)};


picture of the output of the entire document

  • 1
    Yes, my problem was mainely on the left side, but your explaiantion and the idea to create separate classes helps a lot ! Do you have any idea to add the text on the top of the page ?
    – zaord
    Dec 1, 2020 at 17:06
  • I have updated my answer with code to create the image on the left. It is not perfect, but it’s a start. What text do you mean? The ‘Systeme le tron’? I will try to add something for that too when I have time :-)
    – bp99
    Dec 1, 2020 at 19:56
  • Oh Wow ! Thanks A lot ! If I could help you in return ... :) My question is how it is possible to combine theese two code in one file, like positionning one block in front to one other ? Merci :)
    – zaord
    Dec 4, 2020 at 9:40
  • I tried to put the things together but I did not manage to to it, I will wait for your answer ! Thanks
    – zaord
    Dec 7, 2020 at 16:02
  • Hey, sorry for the late reply. I am working on my thesis and the deadline is ridiculously close so unfortunately I am unable to invest any more time in this at the moment. I do plan to get back to it later though!
    – bp99
    Dec 8, 2020 at 13:37

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.