1

I'm using XeLaTeX and Tikz for creating Kanji training sheets, but somehow it seems like the character 一 is not centered vertically, and hits too high. First, I thought it was a font issue, but it seems centered in every other context (I've tested writing in Gimp and Chromium). Also, it happens for every CJK font. I'm using two fonts at the same time, but I believe you'd get the same result using any CJK font.

\documentclass{article}

\usepackage{tikz}
\usepackage{xeCJK}
\setCJKmainfont{Noto Sans Mono CJK JP}
\newCJKfontfamily\drawingKanji{Chihaya Jyun}

\newcommand{\kanjiRow}[1]{
  \resizebox{\textwidth}{!}{
    \begin{tikzpicture}[font=\drawingKanji, text centered]

      % Main Frame
      \draw[line width=1.6pt, rounded corners=4pt] (0, 0) rectangle (14, 6);

      % Horizontal lines
      \draw (0,2) -- (14,2);
      \draw (0,4) -- (14,4);

      % Vertical lines
      \draw (2,0) -- (2,6);
      \draw (4,0) -- (4,6);
      \draw (6,0) -- (6,6);
      \draw (8,0) -- (8,6);
      \draw (10,0) -- (10,6);
      \draw (12,0) -- (12,6);

      % Grid Top
      \draw[dashed, opacity=.5] (0,5) -- (14,5);
      \draw[dashed, opacity=.5] (1,4) -- (1,6);
      \draw[dashed, opacity=.5] (3,4) -- (3,6);
      \draw[dashed, opacity=.5] (5,4) -- (5,6);
      \draw[dashed, opacity=.5] (7,4) -- (7,6);
      \draw[dashed, opacity=.5] (9,4) -- (9,6);
      \draw[dashed, opacity=.5] (11,4) -- (11,6);
      \draw[dashed, opacity=.5] (13,4) -- (13,6);

      % Grid Bottom
      \draw(0,1) -- (14,1);
      \draw (1,0) -- (1,2);
      \draw (3,0) -- (3,2);
      \draw (5,0) -- (5,2);
      \draw (7,0) -- (7,2);
      \draw (9,0) -- (9,2);
      \draw (11,0) -- (11,2);
      \draw (13,0) -- (13,2);

      % Big Characters 
      \draw (1,5) node[scale=5, font=\CJKfamily{Noto Sans CJK JP}]{#1};
      \draw (3,5) node[scale=5, opacity=.2, inner sep=0pt]{#1};
      \draw (5,5) node[scale=5, opacity=.15]{#1};
      \draw (7,5) node[scale=5, opacity=.12]{#1};
      \draw (9,5) node[scale=5, opacity=.08]{#1};
      \draw (11,5) node[scale=5, opacity=.04]{#1};

      % Small characters
      \draw (0.5,1.5) node[scale=2, font=\CJKfamily{Noto Sans CJK JP}]{#1};
      \draw (0.5,0.5) node[scale=2, opacity=.2]{#1};
      \draw (1.5,1.5) node[scale=2, opacity=.15]{#1};
      \draw (1.5,0.5) node[scale=2, opacity=.12]{#1};
      \draw (2.5,1.5) node[scale=2, opacity=.08]{#1};
      \draw (2.5,0.5) node[scale=2, opacity=.04]{#1};

    \end{tikzpicture}
  }
}

\begin{document}
  \kanjiRow{時}
  \kanjiRow{一}
\end{document}

Edit: I found that I could narrow it down to being a font issue (contrary to what I thought previously) by encapsulating both characters by fboxes:

\fbox{\fbox{一}\fbox{時}}

which produces

And connects the question to this one

However, I'm still unsure about how center it.

h7x4
  • 97
  • Your code is not complete so I cannot test. But can you put and side by side to see if is offset? – Symbol 1 Apr 28 '20 at 16:53
  • @Symbol1: I've edited the question and the code. It should be reproducable now. As you can see, it centers itself next to 時 even though the glyphs don't have the same height values. – h7x4 Apr 28 '20 at 17:25
  • 3
    OK. So the problem is definitely due to that is not a square. Instead of text centered, you should use anchor=base. – Symbol 1 Apr 28 '20 at 17:32
  • Thank you, that solved my problem! – h7x4 Apr 28 '20 at 17:59

0 Answers0