# Formatting Kunkunshi: Okinawan sheet music

I've gotten stuck trying to figure out a way to make Okinawan sheet music called "Kunkunshi" (see image below).

Basically, I'm trying to make a grid of Japanese Characters. There should be twelve squares in a column, separated by a gap about 66% of the width of the squares. The characters should be either centered in the square, or in a smaller font in the middle of two squares. Ideally, lyrics could be written along side the characters in the grid as shown in the image.

The closest help I could find was this question about Japanese handwriting templates.

• @Lucas, I do not understand how the link you provided does not answer your own question. There you can use the command make a grid where you control the square size and the gap... Feb 2 '17 at 8:48

## 1 Answer

The following will provide something to start with. There is a loop to draw the grid, and a rudimentary API to put letters at some cells, lines or "lyrics" places. Ask for clarification in the comments if needed.

\documentclass [border=2mm]{standalone}
\usepackage{tikz}

\begin{document}

\def\atcenter#1#2#3{
% Puts #3 at cell (#1,#2)
\path (#1,#2) +(.3,.5) node {#3};
}

\def\atline#1#2#3{
% Puts #3 at the line between cells (#1, #2-0.5) and (#1, #2+0.5)
\path (#1,#2) +(.3,.5) node[fill=white, font=\tiny, inner xsep=1mm, inner ysep=0] {#3};
}

\def\lyrics#1#2#3{
% Puts #3 at the right side of the column #1, at fractional y-coordinate #2
\path (#1,.5) +(.6,#2) node[font=\tiny,anchor=west, inner sep=0.5mm] {#3};
}

\begin{tikzpicture}[x=10mm,y=-6mm]

% Draw the grid
\draw[thick] (1,1) rectangle (11,13);
\foreach \column in {1,...,10} {
\foreach \row in {1,...,12} {
\draw (\column,\row) rectangle +(0.6,1);
}
}

% Some example letters in cells
\foreach \letter [count=\i  from 1] in {A,B,C,D,E,F,G,H,I,J,K,L} {
\atcenter{10}{\i}{\letter};
}

% Some example letters at lines
\atline{10}{2.5}{a};
\atline{10}{3.5}{b};

% Another column with letter
\foreach \letter [count=\i  from 1] in {M,N,O,P,Q,R} {
\atcenter{9}{\i}{\letter};
}

% Example "lyrics". Note the expression used as #2
\foreach \letter [count=\i from 1] in {f,o,o,b,a,r} {
\lyrics{9}{3+\i*0.4}{\letter}
}
\end{tikzpicture}
\end{document}


Above code produces:

# Update

Just for fun, tried it with japanese characters, to see if it would work. It worked! (requires xelatex and AozoraMinchoRegular.ttf font, which is free).

Disclaimer I don't understand a word of Japanese :-)

Code:

\documentclass [border=2mm]{standalone}
\usepackage{xeCJK}
\setCJKmainfont{AozoraMinchoRegular.ttf}
\usepackage{tikz}

\begin{document}

\def\atcenter#1#2#3{
% Puts #3 at cell (#1,#2)
\path (#1,#2) +(.3,.5) node {#3};
}

\def\atline#1#2#3{
% Puts #3 at the line between cells (#1, #2-0.5) and (#1, #2+0.5)
\path (#1,#2) +(.3,.5) node[fill=white, font=\tiny, inner xsep=1mm, inner ysep=0] {#3};
}

\def\lyrics#1#2#3{
% Puts #3 at the right side of the column #1, at fractional y-coordinate #2
\path (#1,.5) +(.6,#2) node[font=\tiny,anchor=west, inner sep=0.5mm] {#3};
}

\begin{tikzpicture}[x=10mm,y=-6mm]

% Draw the grid
\draw[thick] (1,1) rectangle (11,13);
\foreach \column in {1,...,10} {
\foreach \row in {1,...,12} {
\draw (\column,\row) rectangle +(0.6,1);
}
}

% Some example letters in cells
\foreach \letter [count=\i  from 1] in {中,中,工,上,四,合,四,五,中,中,工,上}
{
\atcenter{10}{\i}{\letter};
}

% Some example letters at lines
\atline{10}{2.5}{五};
\atline{10}{3.5}{中};

% Another column with letter
\foreach \letter [count=\i  from 1] in {四,合,四,五,中,中,工,上}
{
\atcenter{9}{\i}{\letter};
}

% Example "lyrics". Note the expression used as #2
\foreach \letter [count=\i from 1] in {日,本,語,で} {
\lyrics{9}{3+\i*0.5}{\letter}
}
\end{tikzpicture}
\end{document}


Result: