\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{class/nitreport}[2024/11/14 NIT Report Class]

\LoadClass[
    a4paper,12pt
]{ltjsreport}

\RequirePackage[no-math,deluxe,expert,haranoaji]{luatexja-preset}
\RequirePackage{luatexja-fontspec}
\RequirePackage[utf8]{luainputenc}
\RequirePackage{luacode}
\RequirePackage[T1]{fontenc}
\RequirePackage{babel}

\RequirePackage[
    a4paper,
    total={180mm, 270mm},
    left=15mm,
    right=15mm,
    top=20mm,
    headheight=10mm,
    headsep=5mm,
    marginparwidth=25mm,
    footnotesep=5mm,
    footskip=7.5mm,
    bottom=20mm
]{geometry}

\RequirePackage[unicode, colorlinks=true, allcolors=blue]{hyperref}
\urlstyle{same}

\RequirePackage{amsmath, amssymb, amsthm}
\RequirePackage{mathtools}

\RequirePackage[dvipdfm]{graphicx}
\RequirePackage{wrapfig}
\RequirePackage{here}
\graphicspath{{./assets}}

\RequirePackage[hang,small,bf]{caption}
\RequirePackage[subrefformat=parens]{subcaption}
\captionsetup{compatibility=false}

\RequirePackage{fontspec}
\setmainfont{TeX Gyre Pagella Regular}
% IPA Fonts
\newjfontfamily{\ipamincho}{IPAMincho}
\newjfontfamily{\ipagothic}{IPAGothic}
\setmainjfont{IPAMincho}
\setsansjfont{IPAGothic}

\setmonofont{0xProtoNerdFontMono}[
        Path=./assets/fonts/,
        Extension=.ttf,
        UprightFont=*-Regular
]
\newcommand{\zeroxproto}{\ttfamily}

\setsansfont{LiberationSans}[
        Path=./assets/fonts/,
        Extension=.ttf,
        UprightFont=*-Regular
]
\newcommand{\liberationsans}{\fontspec{LiberationSans}}

\RequirePackage{enumitem}
\RequirePackage{tabularray}
\RequirePackage{tabularx}
\RequirePackage{framed}

\RequirePackage{listings}
\RequirePackage{xcolor}

\definecolor{draculabg}{RGB}{40,42,54}
\definecolor{draculafg}{RGB}{248,248,242}
\definecolor{draculacomment}{RGB}{98,114,164}
\definecolor{draculacurrentline}{RGB}{68, 71, 90}
\definecolor{draculaorange}{RGB}{255,184,108}
\definecolor{draculacyan}{RGB}{139,244,253}
\definecolor{draculagreen}{RGB}{80,250,123}

\lstdefinestyle{codestyle}{
    backgroundcolor=\color{draculabg},
    commentstyle=\color{draculacomment},
    keywordstyle={\color{draculaorange}},
    identifierstyle=\color{draculacyan},
    numberstyle=\small\color{draculacurrentline},
    stringstyle=\bfseries\color{draculagreen},
    basicstyle=\ttfamily\normalsize\color{draculafg},
    breakatwhitespace=false,
    breaklines=true,
    captionpos=t,
    keepspaces=true,
    numbers=left,
    numbersep=14pt,
    showspaces=false,
    showstringspaces=true,
    showtabs=false,
    tabsize=4,
    lineskip=-3pt,
    xrightmargin=32pt,
    xleftmargin=32pt,
    frame=single,
    framerule=1pt,
    rulesepcolor=\color{draculacyan},
    framexleftmargin=4pt,
    framexrightmargin=4pt,
    framextopmargin=4pt,
    framexbottommargin=4pt,
    xleftmargin=5px,
    xrightmargin=5px
}

\lstset{style=codestyle}
\renewcommand{\lstlistingname}{コードリスティング}

\usepackage[backend=biber,bibencoding=utf8,firstinits=false,style=numeric-comp,date=short,dateabbrev=false]{biblatex}
\addbibresource{references.bib}

\newcommand{\reporttitle}[1]{
    \def\@title{#1}
    \title{#1}
}

\newcommand{\reportauthor}[1]{
    \def\@author{#1}
    \author{#1}
}

\newcommand{\reportdate}[3]{
    \def\@year{#1}
    \def\@month{#2}
    \def\@day{#3}
    \date{\@year \@month \@day}
}

\newcommand{\schoolname}[1]{\def\@schoolname{#1}}
\newcommand{\studentid}[1]{\def\@studentid{#1}}
\newcommand{\department}[1]{\def\@department{#1}}
\newcommand{\subject}[1]{\def\@subject{#1}}

\newcommand{\compiledTime}{\liberationsans \directlua{tex.sprint("Last Compiled(UN*X Time): " .. tostring(os.time()))}}

\newcommand{\coverpage}{
    \begin{titlepage}
        \thispagestyle{empty}
        \begin{center}
            \vspace*{0.25cm}
            
            \includegraphics[height=5cm]{./assets/school-symbol.png}
            
            \vspace{1cm}

            \Huge
            {\fontspec{IPAMincho} \@schoolname}

            \vspace{2cm}

            \LARGE
            \@title

            \vspace{0.5cm}

            \large
            {\fontspec{IPAMincho} \@department : \@subject}

            \vspace{1cm}

            {\@author ({\fontspec{IPAMincho}\@studentid})}

            \vfill

            {\@year \@month \@day}
        \end{center}
        \begin{flushleft}
            \footnotesize
            Made with \LaTeX{} + vim
        \end{flushleft}
    \end{titlepage}
}

\RequirePackage{fancyhdr}
\pagestyle{fancy}
%\renewcommand{\headwidth}{240mm}
\fancyhf{}
\lhead{\@author}
\chead{\@title　―　\rightmark}
\rhead{\@subject}

\lfoot{\footnotesize Made With \LaTeX{} + vim}
\cfoot{\thepage}
\rfoot{}

