Fix table newpages

This commit is contained in:
Oystein Kristoffer Tveit 2020-05-27 16:54:57 +02:00
parent 2cb332339e
commit 86e2c54a9f
3 changed files with 35 additions and 27 deletions

View File

@ -1,5 +1,10 @@
/**
* Turns an array of kanji into a tabular for a chapter overview
* @param {string[]} kanjiArray A list of kanji to put into the table
* @returns {string} A tex tabular.
*/
function kanjiTable(kanjiArray) { function kanjiTable(kanjiArray) {
const xLength = 15; const xLength = 16;
const yLength = Math.ceil(kanjiArray.length/xLength); const yLength = Math.ceil(kanjiArray.length/xLength);
const sideLength = Math.ceil(Math.sqrt(kanjiArray.length)); const sideLength = Math.ceil(Math.sqrt(kanjiArray.length));
@ -8,6 +13,8 @@ function kanjiTable(kanjiArray) {
const lineArray = new Array; const lineArray = new Array;
lineArray.push(`{\\large ${y_index*16}}`);
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] : '');
@ -16,8 +23,8 @@ function kanjiTable(kanjiArray) {
tableString += `${lineArray.join(' & ')} \\\\\n` tableString += `${lineArray.join(' & ')} \\\\\n`
} }
return `\\begin{tabular}{ ${'c '.repeat(xLength)}} return `\\begin{longtable}{ ${'c '.repeat(xLength+1)}}
${tableString}\\end{tabular}` ${tableString}\\end{longtable}`
} }
exports.kanjiTable = kanjiTable; exports.kanjiTable = kanjiTable;

View File

@ -12,9 +12,10 @@
\newcommand{\jlptSection}[1]{ \newcommand{\jlptSection}[1]{
\section*{\uppercase{#1}} \section*{\uppercase{#1}}
\resizebox{\textwidth}{!}{ \begin{center}
\fontsize{16}{16}
\input{./data/tables/#1.tex} \input{./data/tables/#1.tex}
} \end{center}
\localtableofcontents \localtableofcontents

View File

@ -20,7 +20,7 @@
\setlength{\parskip}{0.5em} \setlength{\parskip}{0.5em}
\setlength{\parindent}{0pt} \setlength{\parindent}{0pt}
\usepackage{longtable} %N1 table is too long. \usepackage{longtable} % For multipage tables
%Japanese typesetting and fonts %Japanese typesetting and fonts
\usepackage[japanese]{babel} \usepackage[japanese]{babel}