
我一直在試著找出一種製作名為「Kunkunshi」的沖繩樂譜的方法(見下圖)。
基本上,我正在嘗試製作日文字網格。一列應有 12 個方格,各方格之間的間隙約為方格寬度的 66%。字元應該位於正方形的中心,或以較小的字體位於兩個正方形的中間。理想情況下,歌詞可以沿著網格中的字元書寫,如圖所示。
我能找到的最接近的幫助是關於日文手寫模板的問題。
答案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}
結果: