[Tex/LaTex] How to go about typesetting a Genkou Youshi page

templates

I wanted to create a simple sort of template, for printing and then using by hand.

The one I want to create is called Genkō yōshi (原稿用紙, "manuscript paper"), which is nothing more than those squares in vertical position for both writing and practicing Japanese.

This is what I want to do (A4 page):

enter image description here

Note: they must be exact squares.

The irregular border on the top-right corner should not be there I think.

I've thought about using Tikz, but I have no idea of how to approach this… I've searched this site for hints on how to create notebook templates and from there I would've tweaked but found nothing. I've searched some sort of starting point on Texample.net too, but nothing that I could make use of.

I wish I could provide a MWE but here the point is not that I can't make something work, but rather that I have no idea what that something could be.

Best Answer

A solution with \leaders.

  • The boxes are exact squares.
  • Equal margins.

Configuration:

  • \cellunit: width/height of a cell
  • \fboxrule: line width of the frame lines
  • \hnum: number of cells in horizontal direction
  • \vnum: number of cells in vertical direction
  • color setting
  • paper size

The example uses a grid of 10 x 20 cells (= 200 cells).

\documentclass[a4paper]{article}

\usepackage{xcolor} % fixes \fbox

\pagestyle{empty} % no page number

\setlength{\topskip}{0pt} % we do not have text lines
\setlength{\maxdepth}{0pt}

\setlength{\fboxsep}{0pt}

\newlength{\cellunit}
\newlength{\cellsep}

%%% configuration begin %%%
\setlength{\fboxrule}{.8pt} % line width of the frame lines
\setlength{\cellunit}{13mm} % width and height of the cell excluding frame
\newcommand*{\hnum}{10} % number of cells, horizontal direction
\newcommand*{\vnum}{20} % number of cells, vertical direction
\color[RGB]{50,100,200}
%%% configuration end %%%

\newcommand*{\cell}{%
  \fbox{%
    \rule{0pt}{\cellunit}%
    \rule{\cellunit}{0pt}%
  }%
}

% calculate the vertical margin
\fboxrule=2\dimexpr.5\fboxrule\relax % even sp number
\newlength{\margin}
\margin=.5\dimexpr\paperheight-\vnum\cellunit-\vnum\fboxrule-\fboxrule\relax

\ifdim\margin<0pt
  \errmessage{Cell dimensions or cell numbers are too large for the page}%
\fi

% set equal margins everywhere
\usepackage[margin=\margin]{geometry}

\begin{document}
\vbox to \textheight{%
  \kern.5\fboxrule
  \cleaders\vbox{%
    \kern-.5\fboxrule
    \hbox to \textwidth{%
      \cellsep=\dimexpr(
        \textwidth-\hnum\dimexpr\cellunit+2\fboxrule\relax   
      )/\numexpr\hnum-1\relax\relax
      \kern-.5\cellsep   
      \xleaders\hbox{%
        \kern.5\cellsep
        \cell
        \kern.5\cellsep   
      }\hskip\dimexpr\textwidth+\cellsep\relax
      \kern-.5\cellsep
    }%
    \kern-.5\fboxrule
  }\vskip\dimexpr\textheight-\fboxrule\relax
  \kern.5\fboxrule 
}%
\end{document}

Result

Related Question