Japanese practise paper (Genkou Youshi)

Here you go. My code is a mild extension of this answer by Paul Gaborit.

Code

\documentclass{article}
\usepackage{tikz}
\pagestyle{empty}
\newcommand\genkoyoshi[4]{%
  \def\rowopacities{#1}%
  \def\colnames{#2}%
  \def\size{#3}%
  \def\sep{#4}%
  \begin{tikzpicture}[yscale=-1]
    \pgfmathsetmacro{\inc}{\size+\sep}
    \newcounter{col}
    \newcounter{row}
    \foreach \colname in \colnames{
      \addtocounter{col}{1}
      \setcounter{row}{0}
      \foreach \rowopacity in \rowopacities{
        \addtocounter{row}{1}
        \draw ({(\thecol-1)*\inc pt},{\therow*\size})
        rectangle ++ (\size,\size);
        \node[text=black!\rowopacity] at ({(\thecol-1)*\inc+\size*0.5 pt},{\therow*\size+\size*0.5}) {\colname};
      }
    }
  \end{tikzpicture}%
}
\begin{document}
\genkoyoshi{100,66,33,0,0,0,0,0,0,0}{a,b,c,d,e,f,g,h,i,j,k}{8mm}{2mm}
\end{document}

Comments on the code

  • The list 100,66,33,0,0,0,0,0,0,0 gives the opacity of each row -- 0 is transparent, and 100 is completely black. The length of that list gives the number of rows, hence the 0 fillers at the end.

  • The list a,b,c,d,e,f,g,h,i,j,k gives the character you want in each column.

  • The 8mm is the height and width of each cell, and the 2mm is the size of the gap between columns

  • The notation black!40 gives a colour that is 40% black and 60% white.

  • Each letter is centred horizontally and vertically in its cell, which is why the g looks a bit high and the d looks a bit low. If you don't like this, change {\colname} on line 20 to {\strut\colname}.

Result

enter image description here


I found a suitable basis in How to color the font of a single row in a table?

\documentclass{article}
\usepackage{tabu}
\usepackage{xcolor}

\begin{document}
\begin{tabu}{ |l|l| l| l| l| } \hline
\rowfont{\color{gray!90}}    0   & 1 & 2 & 3 & 4 \\  \hline
\rowfont{\color{gray!80}}        1   & A & B & C & D \\ \hline
\rowfont{\color{gray!70}}        2   & A & B & C & D \\ \hline
\rowfont{\color{gray!60}}        3   & A & B & C & D \\ \hline
\rowfont{\color{gray!50}}        4   & A & B & C & D \\ \hline
\rowfont{\color{gray!40}}        5   & A & B & C & D \\ \hline
\rowfont{\color{gray!30}}        6   & A & B & C & D \\ \hline
\rowfont{\color{gray!20}}        7   & A & B & C & D \\ \hline
\rowfont{\color{gray!10}}        8   & A & B & C & D \\ \hline
\end{tabu}
\end{document}

tabu

Tags:

Templates

Cjk