First of all, make sure you have installed Kanji Stroke Order font before trying to compile the following MWE. The font can be downloaded here (click).
I want to create a note about my study in Japanese language. In the enumerate environment I will make a list of sentences in both Japanese and English. The Chinese characters will be rendered twice, i.e., first in the Japanese sentences and second in the table. The desired output of my code is as follows.
Minimal Working Example
\documentclass[dvipsnames]{article}
\usepackage[a5paper,hmargin=1cm,vmargin=15mm]{geometry}
\usepackage{xeCJK}
\setmainfont{Cambria}
\setCJKmainfont{ipaexm.ttf} % For furigana and other Japanese characters
\newCJKfontfamily\strokefont{KanjiStrokeOrders_v3.001.ttf} % For stroke order
\usepackage{ruby}
\usepackage[many]{tcolorbox}
\def\GlobalSettings{%
\renewcommand\rubysep{0pt}%
\renewcommand\rubysize{0.4}%
\let\oldruby\ruby%
\renewcommand\ruby[2]{\oldruby{##1}{\textcolor{Red}{##2}}}%
}
\AtBeginDocument{\GlobalSettings}
\def\LocalSettings{%
\renewcommand\rubysep{1ex}%
\renewcommand\rubysize{.3}%
\renewcommand\ruby[2]{\oldruby{\fontsize{65}{0}\selectfont\strokefont##1}{\fontsize{15}{0}\selectfont\textcolor{Red}{##2}}}%
}
\def\FlashCard[#1]#2{\begin{tcolorbox}\LocalSettings{\fontsize{15}{0}\selectfont#1\par}\vspace{15pt}\textcolor{Cyan}{\bfseries#2}\end{tcolorbox}}
\newcommand\DeclareWord[4][]{%
\expandafter\newcommand\csname #2#1\endcsname{#3}%
\expandafter\gdef\csname #2#1FC\endcsname{\FlashCard[#3]{#4}}%
}
\newenvironment{Table}
{\begin{tcbraster}[%
raster height=\textwidth,
raster width=\linewidth,
raster columns=2,
raster rows=3,
size=fbox,
sharp corners,
halign=flush center,
valign=center,
boxrule=2pt, % line width
raster column skip=-2pt, % negative line width
raster row skip=-2pt, % negative line width
colframe=Red,
colback=White,
]}
{\end{tcbraster}}
\begin{document}
\begin{enumerate}
\item \DeclareWord{kare}{\ruby{彼}{かれ}}{he}%
\DeclareWord{samui}{\ruby{寒}{さむ}い}{cold}%
\kare は\samui です。\\
\textcolor{red}{He is cold.}
\Table
\kareFC
\samuiFC
\endTable
\item \DeclareWord{jikan}{\ruby{時}{じ}\ruby{間}{かん}}{time}%
\DeclareWord{kichou}{\ruby{貴}{き}\ruby{重}{ちょう}}{precious}%
\DeclareWord{kenmei}{\ruby{賢}{けん}\ruby{明}{めい}}{wise}%
\DeclareWord{tsukau}{\ruby{使}{つか}う}{to use (N1)}%
\jikan は\kichou なので、\kenmei にそれを\ruby{使}{つか}います。\\
\textcolor{red}{As time is precious, use it wisely.}
\Table
\jikanFC
\kichouFC
\kenmeiFC
\tsukauFC
\endTable
\end{enumerate}
\end{document}
Problems
To make the input file as simple as possible, I think I don't need to write
..............
\Table
\kareFC
\samuiFC
\endTable
..............
\Table
\jikanFC
\kichouFC
\kenmeiFC
\tsukauFC
\endTable
..............
I mean that creating the table should be done automatically. How to do this?


\currentwordtableautomatically done at the end of each\item. Could you make it possible? Thank you. – kiss my armpit Oct 18 '15 at 07:24\let\old@item=\item\def\item#1{\old@item{#1 \currentwordtable}}to the preamble will automatically call\currentwordtableas the last command in the content of the\item. This will only work if you enclose the contents of the\itemin braces (e.g., for the first\item:\item{ \DeclareWord{kare}{$\alpha$}{he}%and\textcolor{red}{He is cold.}}. – Guho Oct 18 '15 at 07:52