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

\LoadClass[
    a4paper,12pt
]{ltjsreport}

\RequirePackage[utf8]{luainputenc}
\RequirePackage{luacode}
\RequirePackage{babel}

\RequirePackage[
    a4paper,
    total={180mm, 270mm},
    left=15mm,
    right=15mm,
    top=30mm,
    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}

% ============================== FONT CONFIG ==================================

\RequirePackage{luatexja-fontspec}
\RequirePackage[T1]{fontenc}
\RequirePackage{fontspec}
\newjfontfamily{\notoserifjp}{NotoSerifJP}[
        Path=../assets/fonts/,
        Extension=.ttf,
        UprightFont=*-Regular,
        BoldFont=*-Bold,
        ScaleAgain=1.2,
        CJKShape=JIS1990,
        CharacterWidth=Full
]
\newjfontfamily{\notosansjp}{NotoSansJP}[
        Path=../assets/fonts/,
        Extension=.ttf,
        UprightFont=*-Regular,
        BoldFont=*-Bold,
        ScaleAgain=1.2,
        CJKShape=JIS1990,
        CharacterWidth=Full
]
\newfontfamily{\notoserif}{NotoSerif}[
        ScaleAgain=\Cjascale,
        Path=../assets/fonts/,
        Extension=.ttf,
        UprightFont=*-Regular,
        BoldFont=*-Bold,
        ItalicFont=*-Italic,
        BoldItalicFont=*-BoldItalic
]
\newfontfamily{\notosans}{NotoSans}[
        ScaleAgain=\Cjascale,
        Path=../assets/fonts/,
        Extension=.ttf,
        UprightFont=*-Regular,
        BoldFont=*-Bold,
        ItalicFont=*-Italic,
        BoldItalicFont=*-BoldItalic
]
\setmainfont{NotoSerif}
\setsansfont{NotoSans}
\setmainjfont{NotoSerifJP}
\setsansjfont{NotoSansJP}
\newcommand{\serif}{\notoserif\notoserifjp}
\newcommand{\sans}{\notosans\notosansjp}

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

% =========================== FONT CONFIG (END) ===============================

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

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

% =============================== LISTINGS CONFIG =============================

\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}{\fontspec{NotoSerifJP} コードリスティング}

% ============================ LISTINGS CONFIG (END) ==========================

\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}{\serif \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
            {\serif \@schoolname}

            \vspace{2cm}

            \LARGE
            \@title

            \vspace{0.5cm}

            \large
            {\serif \@department : \@subject}

            \vspace{1cm}

            {\serif \@author ({\@studentid})}

            \vfill

            {\serif \@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{}

