34

There is already a question here about a circle of fifths diagram (link) but I would like to include pictures of staves like this diagram here

enter image description here

Is this possible to make it all in LaTeX, I heard there are some packages for writing music (but I have no experience with this). Thank you for your advice.

I managed this using an answer from the linked question. Just labels.

\documentclass[tikz,border=2mm]{standalone}
\begin{document}
\begin{tikzpicture}
\newcommand{\myangle}{30}
\foreach \nota/\text [count=\sector] in {C/C minor,G/G minor,D/D minor,A/A minor,E/E minor, B/B minor, FS/F$\sharp$ minor, CS/C$\sharp$ minor, GS/G$\sharp$ minor, EF/E$\flat$ minor, BF/B$\flat$ minor, F/F minor} 
    {
        \draw[shorten >=3mm] (0,0) -- ++({(4-\sector)*\myangle+90}:3cm) node (\nota) {\text};
    }
\end{tikzpicture}
\end{document}
63

Nice question! Using the MusiXTeX package, there is in fact a really elegant solution. The command for assigning the key signature, \generalsignature{s}, simply requires a number where s > 0 is the number of sharps and s < 0 is the number of flats.

Therefore, we can just create a foreach loop that goes from -6 to +5. And using these integers it is straightforward to assign the required angle around a circle, using TikZ as our drawing tool.

enter image description here

CODE

\documentclass[tikz,margin=0.5cm]{standalone}
\usepackage{musixtex}

\begin{document}
\begin{tikzpicture}

\pgfmathsetmacro{\CircROne}{4.5}
\pgfmathsetmacro{\CircRTwo}{7}
\pgfmathsetmacro{\MusicR}{5.7}
\pgfmathsetmacro{\InnerLabelR}{3.7}
\pgfmathsetmacro{\OuterLabelR}{8}

% THE GRID
\draw (0,0) circle (\CircROne);
\draw (0,0) circle (\CircRTwo);
\foreach \X in {0,1,...,12}
    {
    \draw (0,0)--++(75-\X*360/12:\CircRTwo);
    }
\draw [fill=white] (0,0) circle (1cm);

% THE MUSIC
\foreach \X in {-6,...,5}
    {
    \begin{scope}[shift={(90-\X*360/12:\MusicR)},xshift=-0.3cm]
        \clip (-1,-1) rectangle (1,1);
        \draw (0,0) node 
            {
            \begin{music}
            \generalsignature{\X}
            \nostartrule
            \startextract
            \notes\en
            \zendextract
            \end{music}
            };
    \end{scope}
    }

% INNER LABELS
\foreach \X/\KeyText in {-4/F,-3/C,-2/G,-1/D,0/A,1/E,2/B,3/F$\sharp$,4/C$\sharp$} 
    {
    \draw (90-\X*360/12:\InnerLabelR) node {\KeyText~Minor};
    }
\draw (90-5*360/12:\InnerLabelR) node [align=center] {A$\flat$ Minor\\ G$\sharp$ Minor};
\draw (90+6*360/12:\InnerLabelR) node [align=center] {D$\sharp$ Minor\\ E$\flat$ Minor};
\draw (90+5*360/12:\InnerLabelR) node [align=center] {A$\sharp$ Minor\\ B$\flat$ Minor};

% OUTER LABELS    
\foreach \X/\KeyText in {-4/A$\flat$,-3/E$\flat$,-2/B$\flat$,-1/F,0/C,1/G,2/D,3/A,4/E} 
    {
    \draw (90-\X*360/12:\OuterLabelR) node {\KeyText~Major};
    }
\draw (90-5*360/12:\OuterLabelR) node [align=center] {B Major\\ C$\flat$ Major};
\draw (90+6*360/12:\OuterLabelR) node [align=center] {F$\sharp$ Major\\ G$\flat$ Major};
\draw (90+5*360/12:\OuterLabelR) node [align=center] {D$\flat$ Major\\ C$\sharp$ Major};

\end{tikzpicture}
\end{document}

A rotating circle of fifths...

enter image description here

\documentclass[tikz,margin=0.5cm]{standalone}
\usepackage{musixtex}

\begin{document}
\foreach \Y in {0,2.5,...,357.5}
{
\begin{tikzpicture}

\pgfmathsetmacro{\CircROne}{4.5}
\pgfmathsetmacro{\CircRTwo}{7}
\pgfmathsetmacro{\MusicR}{5.7}
\pgfmathsetmacro{\InnerLabelR}{3.7}
\pgfmathsetmacro{\OuterLabelR}{8}

\path [use as bounding box] (-9,-9) rectangle (9,9);

% THE GRID
\draw (0,0) circle (\CircROne);
\draw (0,0) circle (\CircRTwo);
\foreach \X in {0,1,...,12}
    {
    \draw (0,0)--++(\Y+75-\X*360/12:\CircRTwo);
    }
\draw [fill=white] (0,0) circle (1cm);

% THE MUSIC
\foreach \X in {-6,...,5}
    {
    \begin{scope}[shift={(\Y+90-\X*360/12:\MusicR)},xshift=-0.3cm]
        \clip (-1,-1) rectangle (1,1);
        \draw (0,0) node {
            \begin{music}
            \generalsignature{\X}
            \nostartrule
            \startextract
            \notes\en
            \zendextract
            \end{music}
            };
    \end{scope}
    }

% INNER LABELS
\foreach \X/\text in {-4/F,-3/C,-2/G,-1/D,0/A,1/E,2/B,3/F$\sharp$,4/C$\sharp$} 
    {
    \draw (\Y+90-\X*360/12:\InnerLabelR) node {\text~Minor};
    }
\draw (\Y+90-5*360/12:\InnerLabelR) node [align=center] {A$\flat$ Minor\\ G$\sharp$ Minor};
\draw (\Y+90+6*360/12:\InnerLabelR) node [align=center] {D$\sharp$ Minor\\ E$\flat$ Minor};
\draw (\Y+90+5*360/12:\InnerLabelR) node [align=center] {A$\sharp$ Minor\\ B$\flat$ Minor};

% OUTER LABELS    
\foreach \X/\text in {-4/A$\flat$,-3/E$\flat$,-2/B$\flat$,-1/F,0/C,1/G,2/D,3/A,4/E} 
    {
    \draw (\Y+90-\X*360/12:\OuterLabelR) node {\text~Major};
    }
\draw (\Y+90-5*360/12:\OuterLabelR) node [align=center] {B Major\\ C$\flat$ Major};
\draw (\Y+90+6*360/12:\OuterLabelR) node [align=center] {F$\sharp$ Major\\ G$\flat$ Major};
\draw (\Y+90+5*360/12:\OuterLabelR) node [align=center] {D$\flat$ Major\\ C$\sharp$ Major};

\end{tikzpicture}
}
\end{document}
  • 1
    That's really awesome! – Johnny J. L. Jul 22 '18 at 23:39
  • You're very good is to super vote your answer as the previous ones. – Sebastiano Jul 23 '18 at 7:57
  • 6
    Can one go too far with Tikz? A question that I never considered until reading answers like this in Tex.SE. Take a vote! – Ander Biguri Jul 23 '18 at 10:27
  • Gorgeous, but, ya know, sometimes it's really a ton easier just to create an image file and embed it in your document. xkcd.com/1205 – Carl Witthoft Jul 24 '18 at 14:24
  • @CarlWitthoft Just inserting the original image would have been easier I guess... but in this circumstance, I would like to - at a minimum - have the diagram made from vector graphics and have the labels match the font of my document. In which case, this TikZ and MusiXTeX solution is actually surprisingly quick and easy! :) – Milo Jul 24 '18 at 15:56

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.