kanji-sheets/kanjiLib.tex

209 lines
4.9 KiB
TeX

\usepackage[most]{tcolorbox}
\usepackage{xcolor}
\usepackage{anyfontsize}
\usepackage{tikz}
\definecolor{myGreen}{RGB}{72, 194, 78}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\jlptSection}[1]{
\section*{\uppercase{#1}}
\resizebox{\textwidth}{!}{
\input{./data/tables/#1.tex}
}
\localtableofcontents
\break
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\taughtIn}[1]{
Taught in: #1 \newline
}
\newcommand{\jlptLevel}[1]{
JLPT Level: #1 \newline
}
\newcommand{\strokeCount}[1]{
Stroke count: #1 \newline
}
\newcommand{\kanji}[1]{
\begin{center}
\resizebox{\textwidth}{!}{
\begin{tikzpicture}
\fill[rounded corners=2pt, fill=myGreen, draw=black] (0,0) rectangle (1,1);
\draw (0.5,0.23) node[white, anchor=base, scale=2]{#1};
\end{tikzpicture}
}
\phantomsection
\addcontentsline{toc}{subsection}{#1}
\end{center}
}
\newcommand{\radicalHeader}[1]{
\begin{center}
\resizebox{.4\textwidth}{!}{
\begin{tikzpicture}
\draw[thick] (0,0) rectangle (1,1);
\draw (0.5,0.23) node[anchor=base, scale=2]{#1};
\end{tikzpicture}
}
\end{center}
}
\newcommand{\kanjiPageHeader}[5]{
\begin{minipage}{0.3\textwidth}
\begin{flushleft}
\taughtIn{#2}
\jlptLevel{#3}
\strokeCount{#4}
\end{flushleft}
\end{minipage} \hfill
\begin{minipage}{0.3\textwidth}
\kanji{#1}
\end{minipage} \hfill
\begin{minipage}{0.3\textwidth}
\begin{flushright}
\radicalHeader{#5}
\end{flushright}
\end{minipage}
\vspace{1cm}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newtcolorbox{meaningBox}{
enhanced,
colback=black!20,
left=15pt,
right=15pt,
top=15pt,
bottom=15pt,
width=\textwidth,
hbox,
capture=minipage
}
\newcommand{\kanjiMeaning}[1]{
\begin{center}
\begin{meaningBox}
\Large #1
\end{meaningBox}
\end{center}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newtcolorbox{kunyomiBox}{
enhanced,
attach boxed title to top left={yshift=-12pt,xshift=10pt},
colback=blue!20,
colframe=blue!60,
left=15pt,
right=15pt,
top=15pt,
bottom=5pt,
title={\fontsize{15}{20}\textcolor{white}{\textbf{訓読み}}},
colbacktitle=blue!60,
width=\textwidth
}
\newcommand{\kunyomi}[1]{
\begin{kunyomiBox}
\fontsize{15}{20}
#1
\end{kunyomiBox}
}
\newtcolorbox{onyomiBox}{
enhanced,
attach boxed title to top left={yshift=-12pt,xshift=10pt},
colback=red!20,
colframe=red!60,
left=15pt,
right=15pt,
top=15pt,
bottom=5pt,
title={\fontsize{15}{20}\textcolor{white}{\textbf{音読み}}},
colbacktitle=red!60,
width=\textwidth,
}
\newcommand{\onyomi}[1]{
\begin{onyomiBox}
\fontsize{15}{20}
\textbf{\textcolor{myGreen!80!black}{#1}}
\end{onyomiBox}
\vspace{0.5cm}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newCJKfontfamily\drawingKanji{Choumei}
\newCJKfontfamily\drawingFirstKanji{KanjiStrokeOrders}
\newcommand{\kanjiRow}[1]{
\resizebox{\textwidth}{!}{
\begin{tikzpicture}[font=\drawingKanji, anchor=base]
\clip (-0.1,-0.1) rectangle (14.1,6.1);
% 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 (0.95,4.42) node[scale=5, font=\drawingFirstKanji]{#1};
\draw (3,4.3) node[scale=5, opacity=.2, inner sep=0pt]{#1};
\draw (5,4.3) node[scale=5, opacity=.15]{#1};
\draw (7,4.3) node[scale=5, opacity=.12]{#1};
\draw (9,4.3) node[scale=5, opacity=.08]{#1};
\draw (11,4.3) node[scale=5, opacity=.04]{#1};
% Small characters
\draw (0.5,1.15) node[scale=2]{#1};
\draw (0.5,0.15) node[scale=2, opacity=.3]{#1};
\draw (1.5,1.15) node[scale=2, opacity=.2]{#1};
\draw (1.5,0.15) node[scale=2, opacity=.15]{#1};
\draw (2.5,1.15) node[scale=2, opacity=.1]{#1};
\draw (2.5,0.15) node[scale=2, opacity=.05]{#1};
\end{tikzpicture}
}
}