Change kanji table design
This commit is contained in:
parent
c2850517c4
commit
5da70a3184
|
@ -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;
|
14
kanjiLib.tex
14
kanjiLib.tex
|
@ -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 %
|
||||||
% ---------------------------------------------------------------------------- %
|
% ---------------------------------------------------------------------------- %
|
||||||
|
|
Loading…
Reference in New Issue