%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% LaTeX Style Document for CEEA-ACEG Conference Proceedings
%%%
%%% Written by John McLeod (jmcleod7@uwo.ca), Fall 2026
%%% Corrections added by Julie Vale (jvale@uoguelph.ca), Fall 2026
%%%
%%% All authors submitting documents in LaTeX assume personal
%%% responsibility for ensuring that their paper adheres to 
%%% the require formatting for the CEEA-ACEG Conference Proceedings
%%% 
%%% All efforts have been made to create a style that does conform
%%% to these reqiurements, but using this style does not necessarily
%%% guarantee that a paper will have the appropriate formatting
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\ProvidesPackage{CEEA_ACEG_Conf_Proc}[2026/10/12 by John McLeod]

% seems like href-ul is loading ulem by stealth (?) and 
% on some systems (like Overleaf) this causes journal titles to be 
% underlined in the bibliography, which is wrong; and also messing up 
% line breaks
% this seems to fix it
\PassOptionsToPackage{normalem}{ulem}


% set up page with appropriate margins and separation between columns
\RequirePackage[twocolumn,columnsep=0.3125in,left=0.84in,right=0.84in,top=1in,bottom=1in,footskip=14pt]{geometry}

% this package will force floats (figures, tables) to be positioned 
% exactly where they occur in the source code
% this makes placing figures and tables after they are referenced in 
% the text the author's responsibility
\RequirePackage{float}

% this package will make the two columns on the last page as even as possible
\RequirePackage{flushend}

% this package is used to check if file is compiled with XeLaTeX/LuaLaTeX or regular LaTeX
\RequirePackage{iftex}
% use the checks from the above package
\ifXeTeX
	% if we are using XeLaTeX then we can use Times New Roman and Arial fonts directly
	% note that on some systems small caps may not be available in Times New Roman!
	\RequirePackage{fontspec}
	\setmainfont{Times New Roman}
	\setsansfont{Arial}
\else\ifLuaTeX
	% if we are using LuaLaTeX then we can use Times New Roman and Arial fonts directly
	% note that on some systems small caps may not be available in Times New Roman!
	\RequirePackage{fontspec}
	\setmainfont{Times New Roman}
	\setsansfont{Arial}
\else
	% with regular LaTeX use open-source fonts
	% I can't see any difference between these ones ant Times New Roman/Arial
	\RequirePackage{newtxtext,newtxmath} 
	\RequirePackage{helvet}
\fi\fi

% this package is used to define MS Word's "Blue Gray Accent 1" colour that is used for the 
% work license text in the footer of the first page
\RequirePackage{xcolor}
\definecolor{Word_BlueGray_1}{HTML}{4F81BD}

% this package makes URLs blue or black and creates internal links (all black, according
% to these options) to figures and references
\ifbluelinks
	\RequirePackage[colorlinks=true,urlcolor=blue,linkcolor=black,citecolor=black]
{hyperref}
\else
	\RequirePackage[colorlinks=true,urlcolor=black,linkcolor=black,citecolor=black]
{hyperref}
\fi
% this package underlines the URLs if necessary
\ifullinks
	\RequirePackage{href-ul}
\else
	\RequirePackage{ulem}
\fi

% this package is used to format the title
\RequirePackage{titling}
% make the title bold, small-caps, 18 pt size, with some magic spacing numbers to position
% it properly according to the CEEA-ACEG MS Word template
\pretitle{\vspace{-12pt}\begin{center}\fontsize{18}{22}\selectfont\bfseries\scshape}
\posttitle{\par\end{center}\vspace{7pt}}
% this is use to avoid displaying a date
\predate{}
\date{}
% this is used to push the main text block a skootch lower after the author affiliations to match the
% CEEA-ACEG MS Word template
\postdate{\vspace{2pt}}

% this package is used to format the authors and affiliations
\RequirePackage{authblk}
% the CEEA-ACEG MS Word template has italicized superscripts for author affiliation
% so we need to hack that
\renewcommand{\textsuperscript}[1]{$^\mathit{#1}$}
% the CEEA-ACEG MS Word template wants author names in 11-pt italic font
\renewcommand{\Authfont}{\fontsize{11}{12}\selectfont\itshape}
% the CEEA-ACEG MS Word template wants author affiliations in 10-pt normal font
\renewcommand{\Affilfont}{\fontsize{10}{11.5}\selectfont\upshape}
% the CEEA-ACEG MS Word template has no extra spacing between the authors and the affiliations
\setlength{\affilsep}{0pt}

% this package is used to format the sections, subsections, and subsubsections
% use option 'compact' to keep spacing between sections tighter than normal
\RequirePackage[compact]{titlesec}
% sections are 11-pt font in small caps, bold, and centred
\titleformat{\section}{\fontsize{11}{11}\selectfont\bfseries}{\thesection.}{1em}{\scshape\filcenter}
% subsections are 11-pt font in bold, and left-justified
\titleformat{\subsection}{\fontsize{11}{11}\selectfont\bfseries}{\thesubsection.}{1em}{}
% subsubsections are 10-pt font in bold and left-justified.
\titleformat{\subsubsubsection}{\fontsize{10}{10}\selectfont\bfseries}{\thesubsection.}{1em}{}
% some magic numbers to make spacing between (sub)section titles and text match the
% CEEA-ACEG MS Word template
\titlespacing{\section}{0pt}{12pt}{6pt}
\titlespacing{\subsection}{0pt}{6pt}{6pt}
\titlespacing{\subsubsection}{0pt}{6pt}{6pt}

% this package is used to add a paragraph indent to the first paragraph of a (sub)section
% this is to match the CEEA-ACEG MS Word template
\RequirePackage{indentfirst}
%\setlength {\parindent}{0.43cm}

% this package is used to format the captions for figures and tables to match the CEEA-ACEG MS 
% Word template
\RequirePackage{caption}
% figures and table should have captions in 9-pt san-serif font
% this will be Arial or open-source Helvetica as specified after line 14 (above)
\DeclareCaptionFont{ceeacaption}{\fontsize{9}{10}\selectfont\sffamily}
% make the main text of the caption to above-defined ceeacaption font, but make the
% label for the caption bold-faced
\captionsetup{font=ceeacaption,labelfont=bf}
% tables need to be on the right, very close to the table (hence using a negative skip distance)
% and positioned at the top of the table
\captionsetup[table]{format=plain,justification=raggedright,position=top,skip=-10pt,singlelinecheck=false}
% magic number to set the spacing between figures/tables and text to match the CEEA-ACEG MS Word template
\setlength\intextsep{6pt}

% this package is required to add graphics (PNG, PDF, etc.) as figures
\RequirePackage{graphicx}
% this package is required for line drawings - probably nobody will use this
% but I am using in in the demo file to make a figure since I do not want to worry
% about having a separate graphic attached
\RequirePackage{tikz}
% some internal libraries for TikZ
\usetikzlibrary{math}
\usetikzlibrary{calc}

\ifusebiber
	% code if user prefers bibLaTeX/Biber
	\RequirePackage[backend=biber,style=ieee,citestyle=numeric-comp]{biblatex}
	\renewcommand*{\bibfont}{\fontsize{9}{10}\selectfont}
	% stop bibLaTeX/Biber from writing URLs and DOIs in typewriter font, and
	% instead use same font as rest of document
	\urlstyle{same}
	% IEEE style wants the word "doi" in lower case, but by default
	% bibLaTeX/Biber puts it in small caps
	\renewcommand*{\mkbibacro}[1]{\MakeLowercase{#1}}
	% bibLaTex/Biber puts URLs in "url" field, so we redefine it as "href"
	% only do this if we want underlined links in the references
	% this is often problematic because long links will stretch outside the margins
	% of the column
	\ifullinks
		\ifulrefs
			\DeclareFieldFormat{url}{\href{#1}{#1}}
		\fi
	\fi
	% this keeps formatting consistent (blue and underlined)
	% BUT because it is underlined it cannot perform line breaks for
	% very long website URLs
	% The best solution is to simply NOT PUT LONG URLs in the references
	% and use DOIs for papers instead
\else
	% code if user prefers bibTeX
	\bibliographystyle{IEEEtran}
	% get rid of title because bibTex does not format it correctly
	\renewcommand{\refname}{}
\fi

% this package is used to identify the last page for the page numbering
\RequirePackage{lastpage}

% dummy command for indicating the paper number
\newcommand{\papernumber}{123}

% this package is used to make the headers and footers match the CEEA-ACEG MS Word template
\RequirePackage{fancyhdr}
% fancyhdr puts a horizontal line across the top by default, this code will kill that
\renewcommand{\headrulewidth}{0pt}
% blank out all default headers and footers
\fancyhf{}
% create a footer on the left that gives paper number and conference details
\fancyfoot[L]{\fontsize{9}{10}\selectfont CEEA-AC\'{E}G27; Paper \papernumber\\Western University, London, Ontario\\ June 14 -- 18, 2027}
% create a footer in the centre that gives the page number "x of y"
\fancyfoot[C]{\fontsize{9}{10}\selectfont\linebreak\linebreak--- \thepage~of~\pageref{LastPage} ---}
% create a footer on the right that indicates paper was peer-reviewed (in a box, and inset from the right margin by 6 pt)
\fancyfoot[R]{\fontsize{9}{10}\selectfont\linebreak\linebreak\fbox{\textbf{Peer reviewed}}\hspace{6pt}}
% create a header on the left that indicates the proceedings name
\fancyhead[L]{\fontsize{9}{10}\selectfont\textit{Conference Proceedings 2027 Canadian Engineering Education Association-Assocation canadienne de l'\'{e}ducation en g\'{e}nie}}
%\fancyfootoffset[L]{12pt}
%\fancyfootoffset[L]{12pt}

% the CEEA-ACEG Word stencil always has the creative commons license blue and underlined
% even though it seems authors can choose whether to have other links blue and/or underlined
% so jump through a few hoops here to manually ensure this link is blue and underlined
% not matter what other options the author has chosen
\ifbluelinks
	\ifullinks
		\newcommand{\ccattrib}{\href{https://creativecommons.org/licenses/by-nc/4.0/}{Creative Commons Attribution-NonCommercial 4.0 International License}}
	\else
		\newcommand{\ccattrib}{\href{https://creativecommons.org/licenses/by-nc/4.0/}{\textcolor{blue}{\uline{Creative Commons Attribution-NonCommercial 4.0 International License}}}}
	\fi
\else
	\ifullinks
		\newcommand{\ccattrib}{\href{https://creativecommons.org/licenses/by-nc/4.0/}{\textcolor{blue}{Creative Commons Attribution-NonCommercial 4.0 International License}}}
	\else
		\newcommand{\ccattrib}{\href{https://creativecommons.org/licenses/by-nc/4.0/}{\textcolor{blue}{\uline{Creative Commons Attribution-NonCommercial 4.0 International License}}}}
	\fi
\fi

% we also need to adjust the headers/footers of the first page (which defaults to 'plain' style,
% so here we are overwriting that style)
% this is basically the same as above but it includes the creative commons license
\fancypagestyle{plain}{%
\fancyhf{}
\fancyfoot[L]{\fontsize{9}{10}\selectfont CEEA-AC\'{E}G27; Paper \papernumber\\Western University, June 14 -- 18, 2027\\\textcolor{Word_BlueGray_1}{\textbf{This work is licensed under a}} \ccattrib{}.}
\fancyfoot[C]{\fontsize{9}{10}\selectfont\linebreak--- \thepage~of~\pageref{LastPage} ---}
\fancyfoot[R]{\fontsize{9}{10}\selectfont\linebreak\fbox{\textbf{Peer reviewed}}\hspace{6pt}}
\fancyhead[L]{\fontsize{9}{10}\selectfont\textit{Conference Proceedings 2027 Canadian Engineering Education Association-Assocation canadienne de l'\'{E}ducation en g\'{e}nie}}
}

% redefine the environment for the abstract to have a 12-pt bold-faced 'Abstract -' 
% followed by the abstract text in 10-pt italic font
% this is to match the CEEA-ACEG MS Word template
\renewenvironment{abstract}{\noindent\fontsize{12}{14}\selectfont\textbf{Abstract --}\fontsize{10}{12}\selectfont\itshape}{\vspace{10pt}}

% create a new environment for acknowledgements
% this starts with 11-pt bold-faced, centered "Acknowledgements" followed by text in normal font
% this is to match the CEEA-ACEG MS Word template
\newenvironment{acknowledgements}{\begin{center}\fontsize{11}{11}\selectfont\bfseries Acknowledgements\label{sec:ack}\end{center}\hspace*{\parindent}\ignorespaces}{\ignorespacesafterend}

% create a new environment for disclosure statement
% this starts with 11-pt bold-faced, centered "Acknowledgements" followed by text in normal font
% this is to match the CEEA-ACEG MS Word template
\newenvironment{disclosure}{\begin{center}\fontsize{11}{11}\selectfont\bfseries Disclosure Statement\label{sec:discl}\end{center}\hspace*{\parindent}\ignorespaces}{\ignorespacesafterend}

% create a new command for indicating paper type, starting with unindented, bold-faced, and italicized
% header "Paper Type:" followed by the paper type text, followed by a magic spacing to help
% match the CEEA-ACEG MS Word template
\newcommand{\papertype}[1]{\noindent \textbf{\textit{Paper Type:}} #1\vspace{10pt}}
% create a new command for indicating keywords, starting with unindented, bold-faced, and italicized
% header "Keywords:" followed by the keywords text, followed by a magic spacing to help
% match the CEEA-ACEG MS Word template
\newcommand{\keywords}[1]{\noindent \textbf{\textit{Keywords:}} #1}

% this package is used for making tables
\RequirePackage{tabularx}
% this code creates centred (K), right-aligned (R), and left-aligned (L) environments
% in tables that allows the column to have a fixed width and long text to go across multiple lines
% this ensures that the tables always span the full column width
\newcommand{\PreserveBackslash}[1]{\let\temp=\\#1\let\\=\temp}
\newcolumntype{K}{>{\centering\arraybackslash}X}
\newcolumntype{R}{>{\raggedleft\arraybackslash}X}
\newcolumntype{L}{>{\raggedright\arraybackslash}X}

% this is used to allow pages to have columns that do not perfectly align at the bottom
% without this, LaTeX will sometimes make eggregious choices in vertical spacing to force bottoms of
% columns to line up
% this is acerbated by the fact that we are preventing LaTeX from deciding where to place figures and
% tables by the use of the 'float' package
\raggedbottom