kanji-sheets/kanjiLib.tex

256 lines
6.9 KiB
TeX
Raw Normal View History

2020-05-28 22:03:03 +02:00
\usepackage[table]{xcolor}
2020-05-28 23:38:36 +02:00
\usepackage[many]{tcolorbox}
2020-05-20 10:19:01 +02:00
\usepackage{anyfontsize}
\usepackage{tikz}
2020-05-28 22:11:12 +02:00
\definecolor{kanjiColor}{RGB}{72, 194, 78}
\colorlet{kunyomiColor}{blue}
\colorlet{onyomiColor}{red}
\colorlet{meaningColor}{black}
2020-05-20 10:19:01 +02:00
2020-05-25 23:03:19 +02:00
% ---------------------------------------------------------------------------- %
2020-06-10 16:48:24 +02:00
% Chapter Introduction %
2020-05-25 23:03:19 +02:00
% ---------------------------------------------------------------------------- %
2020-05-20 10:19:01 +02:00
2021-01-13 16:39:19 +01:00
\newcommand{\tocPiece}[2]{
2020-05-28 23:38:36 +02:00
% For some reason, I'm not able to use \uppercase in order to use
% a single argument. In the end, I found that just using two arguments
% was going to be easier than trying to override the way the LaTeX
% kernel handles this command.
\section{#1}
2020-05-20 10:19:01 +02:00
2020-05-27 16:54:57 +02:00
\begin{center}
\fontsize{16}{16}
2021-01-13 16:39:19 +01:00
\rowcolors{1}{}{kanjiColor!20!white}
2020-05-28 23:38:36 +02:00
\input{./data/tables/#2.tex}
2020-05-27 16:54:57 +02:00
\end{center}
2021-01-13 16:39:19 +01:00
}
2020-05-20 10:19:01 +02:00
2021-01-13 16:39:19 +01:00
\setcounter{secnumdepth}{0}
2020-05-20 10:19:01 +02:00
2021-01-13 16:39:19 +01:00
\newcommand{\chapterIntroduction}[2]{
\tocPiece{#1}{#2}
2020-05-20 10:19:01 +02:00
\break
}
2020-05-28 22:03:03 +02:00
% ---------------------------------------------------------------------------- %
% Kanji Table %
% ---------------------------------------------------------------------------- %
2020-06-09 15:19:20 +02:00
\newenvironment{chapterTabular}[1]
2020-05-28 22:03:03 +02:00
{
\begin{longtable}{#1}
}
{
\end{longtable}
}
2020-05-25 23:03:19 +02:00
% ---------------------------------------------------------------------------- %
% Header line %
% ---------------------------------------------------------------------------- %
2020-05-20 10:19:01 +02:00
\newcommand{\taughtIn}[1]{
2020-06-10 16:48:24 +02:00
#1 \newline
2020-05-20 10:19:01 +02:00
}
\newcommand{\jlptLevel}[1]{
JLPT Level: #1 \newline
}
\newcommand{\strokeCount}[1]{
Stroke count: #1 \newline
}
\newcommand{\kanji}[1]{
\begin{center}
\resizebox{\textwidth}{!}{
\begin{tikzpicture}
2020-05-28 22:11:12 +02:00
\fill[rounded corners=2pt, fill=kanjiColor, draw=black] (0,0) rectangle (1,1);
2020-05-20 10:19:01 +02:00
\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}
}
2020-05-25 23:03:19 +02:00
% ---------------------------------------------------------------------------- %
% Meaning %
% ---------------------------------------------------------------------------- %
2020-05-20 10:19:01 +02:00
2020-05-28 18:46:25 +02:00
\newtcolorbox{meaningBox}{
tcbox width=auto limited,
capture=hbox,
2020-05-20 10:19:01 +02:00
enhanced,
2020-05-28 22:11:12 +02:00
colback=meaningColor!20,
2020-05-20 10:19:01 +02:00
left=15pt,
right=15pt,
top=15pt,
bottom=15pt,
2020-05-28 20:42:17 +02:00
arc=0pt,
outer arc=0pt,
attach boxed title to top center={yshift=-12pt, yshifttext=-6pt},
title={\fontsize{15}{20}\textcolor{white}{\textbf{意味}}},
2020-05-28 22:11:12 +02:00
colbacktitle=meaningColor!60,
2020-05-28 20:42:17 +02:00
boxed title style={arc=0pt, outer arc=0pt}
2020-05-20 10:19:01 +02:00
}
\newcommand{\kanjiMeaning}[1]{
\begin{center}
\begin{meaningBox}
\Large #1
\end{meaningBox}
\end{center}
}
2020-05-25 23:03:19 +02:00
% ---------------------------------------------------------------------------- %
% Kunyomi and Onyomi %
% ---------------------------------------------------------------------------- %
2020-05-20 10:19:01 +02:00
2020-06-11 00:01:44 +02:00
\newcommand{\emphasize}[1]{\textbf{\textcolor{kanjiColor!80!black}{#1}}}
2020-05-20 10:19:01 +02:00
\newtcolorbox{kunyomiBox}{
enhanced,
attach boxed title to top left={yshift=-12pt,xshift=10pt},
2020-05-28 22:11:12 +02:00
colback=kunyomiColor!20,
colframe=kunyomiColor!60,
2020-05-20 10:19:01 +02:00
left=15pt,
right=15pt,
top=15pt,
bottom=5pt,
title={\fontsize{15}{20}\textcolor{white}{\textbf{訓読み}}},
2020-05-28 22:11:12 +02:00
colbacktitle=kunyomiColor!60,
2020-05-20 10:19:01 +02:00
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},
2020-05-28 22:11:12 +02:00
colback=onyomiColor!20,
colframe=onyomiColor!60,
2020-05-20 10:19:01 +02:00
left=15pt,
right=15pt,
top=15pt,
bottom=5pt,
title={\fontsize{15}{20}\textcolor{white}{\textbf{音読み}}},
2020-05-28 22:11:12 +02:00
colbacktitle=onyomiColor!60,
2020-05-20 10:19:01 +02:00
width=\textwidth,
}
\newcommand{\onyomi}[1]{
\begin{onyomiBox}
\fontsize{15}{20}
2020-05-28 22:11:12 +02:00
\textbf{\textcolor{kanjiColor!80!black}{#1}}
2020-05-20 10:19:01 +02:00
\end{onyomiBox}
\vspace{0.5cm}
}
2020-05-25 23:03:19 +02:00
% ---------------------------------------------------------------------------- %
% Kanji Drawing Box %
% ---------------------------------------------------------------------------- %
2020-05-20 10:19:01 +02:00
2020-05-26 23:05:15 +02:00
\newCJKfontfamily\drawingKanji[
Path = {./font/},
Extension = .ttf,
]{Choumei}
\newCJKfontfamily\drawingFirstKanji[
Path = {./font/},
Extension = .ttf,
]{KanjiStrokeOrders}
2020-05-20 10:19:01 +02:00
\newcommand{\kanjiRow}[1]{
\resizebox{\textwidth}{!}{
\begin{tikzpicture}[font=\drawingKanji, anchor=base]
\clip (-0.1,-0.1) rectangle (14.1,6.1);
% Main Frame
2020-05-28 20:42:17 +02:00
\draw[line width=1.6pt] (0, 0) rectangle (14, 6);
2020-05-20 10:19:01 +02:00
% 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}
}
}