Change kanji table design

This commit is contained in:
Oystein Kristoffer Tveit 2020-05-28 22:03:03 +02:00
parent c2850517c4
commit 5da70a3184
3 changed files with 28 additions and 5 deletions

View File

@ -9,22 +9,29 @@ function kanjiTable(kanjiArray) {
const sideLength = Math.ceil(Math.sqrt(kanjiArray.length)); const sideLength = Math.ceil(Math.sqrt(kanjiArray.length));
let tableString = ''; let tableString = '';
let numberRow = [...Array(xLength).keys()];
numberRow = numberRow.map((number) => (number + 1).toString());
numberRow = numberRow.map((number) => `{\\large ${number}}`);
numberRow = [' ', ...numberRow];
tableString += `${numberRow.join(' & ')} \\\\\n\\hline\n\\endhead\n`;
for (let y_index = 0; y_index < yLength; y_index++) { for (let y_index = 0; y_index < yLength; y_index++) {
const lineArray = new Array; const lineArray = new Array;
lineArray.push(`{\\large ${y_index*16}}`); lineArray.push(`{\\large ${y_index*xLength}}`);
for (let x_index = 0; x_index < xLength; x_index++) { for (let x_index = 0; x_index < xLength; x_index++) {
const indexNumber = y_index * xLength + x_index; const indexNumber = y_index * xLength + x_index;
lineArray.push(kanjiArray[indexNumber] ? kanjiArray[indexNumber] : ''); lineArray.push(kanjiArray[indexNumber] ? kanjiArray[indexNumber] : '');
} }
tableString += `${lineArray.join(' & ')} \\\\\n` tableString += `${lineArray.join(' & ')} \\\\\n`;
} }
return `\\begin{longtable}{ ${'c '.repeat(xLength+1)}} return `\\begin{kanjiTable}{ ${'l | ' + 'l '.repeat(xLength)}}
${tableString}\\end{longtable}` ${tableString}\\end{kanjiTable}`
} }
exports.kanjiTable = kanjiTable; exports.kanjiTable = kanjiTable;

View File

@ -1,5 +1,5 @@
\usepackage[table]{xcolor}
\usepackage[most]{tcolorbox} \usepackage[most]{tcolorbox}
\usepackage{xcolor}
\usepackage{anyfontsize} \usepackage{anyfontsize}
\usepackage{tikz} \usepackage{tikz}
@ -22,6 +22,18 @@
\break \break
} }
% ---------------------------------------------------------------------------- %
% Kanji Table %
% ---------------------------------------------------------------------------- %
\newenvironment{kanjiTable}[1]
{
\begin{longtable}{#1}
}
{
\end{longtable}
}
% ---------------------------------------------------------------------------- % % ---------------------------------------------------------------------------- %
% Header line % % Header line %
% ---------------------------------------------------------------------------- % % ---------------------------------------------------------------------------- %

View File

@ -37,6 +37,10 @@
\input{./title/titlepage.tex} \input{./title/titlepage.tex}
% Kanji table settings that should not affect the titlepage
\renewcommand{\arraystretch}{2}
\rowcolors{1}{white}{myGreen!30}
\break \break
\tableofcontents \tableofcontents