アップデート

アップデート

私は「くんくんし」と呼ばれる沖縄の楽譜(下の画像を参照)を作成する方法を見つけようとして行き詰まっています。

ティンサグヌハナクンクンシ

基本的に、私は日本語の文字のグリッドを作ろうとしています。1 列に 12 個の正方形があり、正方形の幅の約 66% の間隔で区切られています。文字は正方形の中央に配置するか、2 つの正方形の中央に小さいフォントで配置します。理想的には、画像に示すように、グリッド内の文字の横に歌詞を書くことができます。

私が見つけることができた一番の助けは日本語の手書きテンプレートに関する質問

答え1

以下は、開始するためのものです。グリッドを描画するためのループと、いくつかのセル、行、または「歌詞」の場所に文字を配置するための基本的な API があります。必要に応じて、コメントで説明を求めてください。

\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}

上記のコードは次のものを生成します:

結果

アップデート

楽しみのために、日本語の文字で試してみました。うまくいきました!(xelatexとAozoraMinchoRegular.ttfフォントが必要です。無料)。

免責事項日本語が全く分かりません :-)

コード:

\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}

結果:

日本の結果

関連情報