% Welcome to Karunya's thesis class file!
% May your references resolve, your tables align, and your \end{document} compile on the first try.

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{karunya-thesis}[2026/02/17 Karunya PhD Thesis Class]
\LoadClass[12pt,a4paper,oneside]{book}
\usepackage[a4paper, left=3.5cm, right=2cm, top=3cm, bottom=2.5cm]{geometry}
\usepackage{times}
\usepackage{graphicx}
\usepackage{amsmath,amssymb}
\usepackage{caption}
\usepackage{subcaption}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage{float}
\usepackage{array, booktabs, multirow}
\usepackage{lipsum}
\usepackage{ragged2e}
\usepackage{tabularx}
% -------------------------------
% Global caption formatting
% -------------------------------
\usepackage{caption}
% Force captions to fit within full text width, not just figure width
\captionsetup{
    width=\textwidth,            % wrap to text width
    justification=justified,     % full justification
    singlelinecheck=false,       % left-align even single-line captions
    font=normal,                  % font size for captions
    labelfont=bf                 % bold Figure/Table label
}

\usepackage{setspace}
\onehalfspacing
\setlength{\parskip}{0.5em}
\setlength{\parindent}{0pt}
\setlength{\headheight}{15pt}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\rhead{\thepage}
\renewcommand{\headrulewidth}{0pt}

\usepackage{titlesec}
\titleformat{\chapter}[block]
{\bfseries\centering\fontsize{16}{18}\selectfont}
{CHAPTER \thechapter}{0pt}{\\ \MakeUppercase}
\titlespacing*{\chapter}{0pt}{18pt plus 4pt minus 2pt}{12pt plus 2pt minus 2pt}

\titleformat{\section}[block]
{\bfseries\fontsize{13}{15}\selectfont}
{\thesection}{1em}{\MakeUppercase}

\titleformat{\subsection}[block]
{\bfseries\fontsize{13}{15}\selectfont}
{\thesubsection}{1em}{}

\usepackage{hyperref}
\hypersetup{colorlinks=true, linkcolor=black, citecolor=blue, urlcolor=blue}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}
% -------------------------------
% TOC: Make CHAPTER titles UPPERCASE in Table of Contents
% -------------------------------
\makeatletter
\renewcommand*\l@chapter[2]{%
  \ifnum \c@tocdepth >\m@ne
    \addpenalty{-\@highpenalty}%
    \vskip 1.0em \@plus\p@
    \setlength\@tempdima{1.5em}%
    \begingroup
      \parindent \z@ \rightskip \@pnumwidth
      \parfillskip -\@pnumwidth
      \leavevmode \bfseries
      \advance\leftskip\@tempdima
      \hskip -\leftskip
      \MakeUppercase{#1}\nobreak\hfil
      \nobreak\hb@xt@\@pnumwidth{\hss #2}\par
      \penalty\@highpenalty
    \endgroup
  \fi}
\makeatother


\fancypagestyle{plainroman}
{
  \fancyhf{} % clear all headers and footers
  \fancyhead[R]{\thepage} % Roman page number on top right
  \renewcommand{\headrulewidth}{0pt} % no header line
  \renewcommand{\footrulewidth}{0pt} % no footer line
}

\usepackage{enumitem}

% Packages for tables and special formats
\usepackage{booktabs} % Professional looking tables
\usepackage[table]{xcolor} % Coloring for table cells
\usepackage{lscape} % Allow landscape pages (wide tables)
\usepackage{longtable} % Tables that span multiple pages


% ----------------------------------------------------------------
% Acknowledgements (for internal template credits only)
% ----------------------------------------------------------------
% This LaTeX thesis template was compiled and customized
% by Dr. Tony Jose (Office of Research & Consultancy),
% for the Ph.D. scholars of 
% Karunya Institute of Technology and Sciences, Coimbatore, India.
%
% With sincere thanks to:
% - The LaTeX community and contributors on TeX Stack Exchange
% - Developers of the biblatex, fancyhdr, geometry, and related packages
% - Overleaf, for democratizing LaTeX and providing a collaborative platform
% - ChatGPT (by OpenAI), for assistance in formatting, writing macros,
%   and generally making LaTeX a less lonely experience.
% ----------------------------------------------------------------