% Edited to replace RLJ with RL in Big Worlds for the camera ready submission

% RLC rlj.sty Version 2026.1

% This style file was adapted from previous style files in the following reverse-chronological order:
% Adapted by Marlos C. Machado and Philip Thomas for RLJ/RLC 2026
% Adapted by Philip Thomas and Glen Berseth for RLJ/RLC 2024
% Adapted by Hugo Larochelle and Fabian Pedregosa for TMLR
% Adapted by ICLR, borrowing from JMLR.

% Last edited, October 2026 by Marlos C. Machado and Philip Thomas
%   - Implemented several changes for RLJ/RLC 2026

% First, include the packages we require
\RequirePackage{fancyhdr}   % For modifying the header
\RequirePackage{natbib}     % For formatting references
\RequirePackage{enumitem}   % For removing the indentetion in an enumerate block
\RequirePackage[T1]{fontenc}% T1 font encoding for hyphenation and accents
\RequirePackage{times}      % Set the font to times new roman
\RequirePackage{ragged2e}   % For justifying text on the title page
\RequirePackage{tcolorbox}  % For the colored box on the title page
\RequirePackage{hyperref}   % For hyperlinks (e.g., clicking references)
\RequirePackage{xcolor}     % For setting the color of links and boxes
\RequirePackage{lineno}     % For line numbers when in-submission
\RequirePackage{amsmath}    % <- after lineno
\RequirePackage{etoolbox}   % <- for \cspreto, \csappto, used in amsmath + lineno fix

% Slightly increase header height to avoid fancyhdr warning
\setlength{\headheight}{12.1001pt}

% modification to natbib citations
\setcitestyle{authoryear,round,citesep={;},aysep={,},yysep={;}}

% Make the links a blue color so that they are visually identifiable in digital forms.
\definecolor{dark-blue}{rgb}{0,0,0.7}
\hypersetup{
    colorlinks, linkcolor={dark-blue},
    citecolor={dark-blue}, urlcolor={dark-blue}
}

% Default max portion of a page for a float (e.g., figure) is 50%. Change to 95% to allow large figures.
\renewcommand{\topfraction}{0.95}

% Default minimum fraction of page that must be occupied by text is 20%. Change to 5% to help with float placement.
\renewcommand{\textfraction}{0.05}

% Create a conditional flag called '@accepted' and set its default value to 'false'
\newif\if@accepted\@acceptedfalse

% Define an option 'accepted' that sets the '@accepted' flag to 'true'
\DeclareOption{accepted}{%
    \@acceptedtrue
}

% Create another conditional flag called '@preprint' and set its default value to 'false'
\newif\if@preprint\@preprintfalse

% Define an option 'preprint' that sets both '@preprint' and '@accepted' flags to 'true'
% The 'preprint' option can be used to create a version ready for preprint uploads (e.g., to arXiv)
\DeclareOption{preprint}{
  \@preprinttrue
  \@acceptedtrue
}

% If an unrecognized option is passed to the 'rlj' package, issue a warning message.
\DeclareOption*{\PackageWarning{rlj}{Unknown ‘\CurrentOption’}}

% Process all the options that were passed to the 'rlj' package.
% This applies the declared options ('accepted', 'preprint', etc.) or triggers the fallback warning for unknown options.
\ProcessOptions\relax

\newcommand{\@camerareadyvenue}{RLC 2026 workshop on RL In Big Worlds}

% New commands to store emails and affiliations
\newcommand{\emails}[1]{\def\@emails{#1}}
\newcommand{\affiliations}[1]{\def\@affiliations{#1}}
\newcommand{\keywords}[1]{\gdef\@keywords{#1}}  % Define command to store keywords
\newcommand{\summary}[1]{\gdef\@summary{#1}}    % Define command to create summary
\newcommand{\coverPageAuthor}[1]{\def\@coverPageAuthor{#1}} % Define command to store cover page authors without superscripts

% Command to set and store the running title
\newcommand{\setrunningtitle}[1]{
    \def\therunningtitle{#1}  % Store the running title
    \markboth{#1}{}           % Set the running title in the header
}

% Specify the dimensions of each page
\setlength{\paperheight}{11in}
\setlength{\paperwidth}{8.5in}

\oddsidemargin 0.5in            % Set the left margin for odd-numbered pages to 0.5 inches.
\evensidemargin 0.5in           % Set the left margin for even-numbered pages to match the odd-numbered pages (for double-sided documents).
\marginparwidth 0in             % Disable margin notes by setting the margin width to 0.
\topmargin -0.5in               % Set the top margin to -0.5 inches to adjust the vertical position of the text area.
\textheight 9.0 true in         % Define the height of the text area, including footnotes and figures, to be 9 inches.
\textwidth 5.5 true in          % Define the width of the text area to be 5.5 inches.
\widowpenalty=10000             % Prevent single lines (widows) at the top of a page by assigning a high penalty.
\clubpenalty=10000              % Prevent single lines (orphans) at the bottom of a page by assigning a high penalty.
\flushbottom                    % Align the text at the bottom of each page to give pages a consistent length.
\sloppy                         % Allow LaTeX more flexibility in line-breaking to reduce overfull lines (long lines extending into the margins).
\def\addcontentsline#1#2#3{}    % Disable the creation of table of contents entries to save space, as they are not needed for this document.


\definecolor{customBoxColor}{HTML}{F1F4F7}  % Custom color for cover page boxes

\newtcolorbox{custombox}[1][]{%
    colback=customBoxColor,     % Light gray background
    colframe=customBoxColor,    % Light gray border
    boxrule=0.6pt,              % Thin border line
    width=\textwidth,           % Full text width
    fonttitle=\bfseries,        % Bold title
    coltitle=black,             % Title color
    arc=2mm,                    % Subtle rounded corners
    outer arc=2mm,              % Outer border roundness
    boxsep=4pt,                 % Padding inside box
    left=6pt,                   % Padding on left side
    right=6pt,                  % Padding on right side
    toptitle=3pt,               % Space above title
    bottomtitle=3pt,            % Space below title
    title=#1                    % Allow setting the title via parameter
}

% Define a counter to keep track of contributions
\newcounter{contribution}

% Create an empty list to store the contributions
\def\contributionsList{}

% Define a new command '\contribution' that adds a contribution to the list
% Parameters:
% #1 - The contribution description
% #2 - The context associated with the contribution
\newcommand{\contribution}[2]{
    % Append the new contribution to the list, formatting it with bold "Context" label
    \expandafter\def\expandafter\contributionsList\expandafter{\contributionsList
        \item #1\\\textbf{Context:} #2\par
    }
}

% Define a command '\removeSuperscripts' to remove superscripts from text (e.g., author names on the cover page)
% Parameters:
% #1 - The content where superscripts should be removed
\newcommand{\removeSuperscripts}[1]{%
  \begingroup                           % Start a local group to limit the scope of changes
  \renewcommand{\textsuperscript}[1]{}  % Redefine '\textsuperscript' to do nothing, effectively removing superscripts
  #1                                    % Process the provided content without superscripts
  \endgroup                             % End the local group, restoring the original definition of '\textsuperscript'
}

% Define \makeCover to create the title page
\newcommand{\makeCover}{
    % Turn off line numbers
    \nolinenumbers

    % Check if \@coverPageAuthor is defined
    \ifdefined\@coverPageAuthor
        % It is defined, use it
        \def\coverAuthors{
            \begin{minipage}{0.95\textwidth}
                \begin{center}
                    \@coverPageAuthor
                \end{center}
            \end{minipage}
            }
    \else
        % It is not defined - attempt to automatically process the author names, removing superscripts
        \def\coverAuthors{
            \begin{minipage}{0.95\textwidth}
                \begin{center}
                    \removeSuperscripts{\@author}
                \end{center}
            \end{minipage}
            }
    \fi
    
    % Reproduce the start of the title page
    \begin{titlepage}
        %% Set up the header and footer
        \fancyhf{}                                                  % Clear all header and footer fields
        \fancyhead[R]{\textbf{\big |} \textbf{Cover Page}}          % Set the header

        % Set left side of the header based on the conditional options
        \if@accepted
            \if@preprint
                % Preprint: No text on left side
                \fancyhead[L]{}
            \else
                % Accepted
                \fancyhead[L]{\@camerareadyvenue}
            \fi
        \else
            % Under review
            \fancyhead[L]{Under review for RLC 2026, to be published in RLJ}
        \fi
        \thispagestyle{fancy}   % Apply the header and footer
        \setcounter{page}{1}    % Ensure page number starts from 1 after the cover page

        %% Enclose the entire content in a minipage of fixed height
        \centering
        \begin{minipage}[t][\dimexpr\textheight - \topskip]{\textwidth} % We can't just use \textheight for the height since that doesn't fit with the header / any other spacing. Instead we dynamically compute the height the minipage can be.

            % Center content
            \begin{center}
        
            % Print the title
            {\LARGE \bfseries\@title\par}

            \vskip 10pt

            % Print the authors
            \if@accepted
                {\large \textbf{\coverAuthors}}
            \else
                {\large \textbf{Anonymous authors}\\Paper under double-blind review}
            \fi
            \par

            % Print the keywords
            \vskip 10pt
            {\bfseries Keywords:} \@keywords

            % Spacing between keywords and Summary box
            \vskip 20pt
            
            % Summary box
            \begin{custombox}
                \vbox{
                    \setlength{\parindent}{0mm}     % Set paragraph indentation
                    \setlength{\parskip}{4pt}       % Adjust space between paragraphs if needed
    
                    % Print the title for the summary box
                    \begin{center}
                        {\Large\textbf{Summary}}
                        \vskip 0.025in
                    \end{center}
                    
                    \justifying                     % Justify the text (so all lines start/end at the same position)
                    \@summary                       % Print the summary
                }
            \end{custombox}

            % Contributions Box
            \vskip 0.2in
            \begin{custombox}
                \vbox{
                    \setlength{\parindent}{0mm}     % Set paragraph indentation
                    \setlength{\parskip}{1pt}       % Adjust space between paragraphs if needed
    
                    % Print the title for the contribution(s) box
                    \begin{center}
                        {\Large\textbf{Contribution(s)}}
                        \vskip 0.025in
                    \end{center}
    
                    \justifying                     % Justify the contribution text
                    \begin{enumerate}[leftmargin=*] % Adjust list indentation
                        \contributionsList          % Print the contributions
                    \end{enumerate}
                }
            \end{custombox}

            % End the centering of content
            \end{center}
        \end{minipage}
    \end{titlepage}

    % Turn line numbers back on only if appropriate
    \if@accepted
        % Accepted papers: Do not display line numbers
    \else
        \if@preprint
            % Preprint papers: Do not display line numbers
        \else
            % Under submission: Activate line numbers
            \linenumbers
        \fi
    \fi
    
    \setcounter{page}{1}        % Reset the page number to 1 for the following content
}

% Create command for the supplementary materials header/title
\newcommand{\beginSupplementaryMaterials}{
    \clearpage
    \begin{center}
        \textbf{\LARGE Supplementary Materials}\\
        \vspace{0.1cm}
        \emph{The following content was not necessarily subject to peer review.}
    \end{center}
    \vspace{-.5cm}
    \noindent\makebox[\linewidth]{\rule{\textwidth}{0.4pt}}
}

% Turn on the header and footer
\pagestyle{fancy}
\fancyhead{}

\if@accepted
    \if@preprint
        \lhead{}
    \else
        \fancyhf{} % Clear all header and footer fields
        \fancyhead[L]{\ifodd\value{page}\relax \therunningtitle \else \@camerareadyvenue\fi}
        \fancyfoot{}
    \fi
\else
    \if@preprint
            \lhead{}
            \fancyfoot[C]{\thepage} % Add this line to show page numbers centrally
        \else
            \fancyhf{} % Clear all header and footer fields
            \fancyhead[L]{\ifodd\value{page}\relax \therunningtitle \else Under review for RLC 2026, to be published in RLJ 2026\fi}
            \fancyfoot[C]{\thepage}
        \fi
\fi

\def\maketitle{\vbox{\hsize\textwidth
\vskip .15in
{\LARGE \bfseries\@title\par}

\if@accepted
    % Accepted or preprint: Show authors
    \vskip 0.2in
    {\large\textbf{%
        \begingroup
        \let\origsuperscript\textsuperscript
        \renewcommand{\textsuperscript}[1]{\origsuperscript{\normalfont ##1}}%
        \@author
        \endgroup
    }\par} % Author names in bold, superscripts normal font
    \vskip -0.06in
    {\normalsize \ttfamily \@emails\par} % Emails in typewriter font
    \vskip 0.1in
    {\normalsize \@affiliations\par} % Affiliations
\else
    % Submission: Hide authors
    \vskip 0.25in
    \textbf{Anonymous authors}\\Paper under double-blind review\\
\fi
\vskip 0.3in minus 0.1in}}

% Format the abstract
\renewenvironment{abstract}{\vskip.05in\centerline{\large\bf
Abstract}\vspace{-1.5ex}\begin{quote}}{\par\end{quote}\vskip 1ex}

% Change sections, subsections, etc. to have slightly smaller headers and use less whitespace
\def\section{\@startsection {section}{1}{\z@}{-2.0ex plus
    -0.5ex minus -.2ex}{1.5ex plus 0.3ex
minus0.2ex}{\large\bf\raggedright}}
\def\subsection{\@startsection{subsection}{2}{\z@}{-1.8ex plus
-0.5ex minus -.2ex}{0.8ex plus .2ex}{\normalsize\bf\raggedright}}
\def\subsubsection{\@startsection{subsubsection}{3}{\z@}{-1.5ex
plus      -0.5ex minus -.2ex}{0.5ex plus
.2ex}{\normalsize\bf\raggedright}}
\def\paragraph{\@startsection{paragraph}{4}{\z@}{1.5ex plus
0.5ex minus .2ex}{-1em}{\normalsize\bf}}
\def\subparagraph{\@startsection{subparagraph}{5}{\z@}{1.5ex plus
  0.5ex minus .2ex}{-1em}{\normalsize\bf}}
\def\subsubsubsection{\vskip
5pt{\noindent\normalsize\rm\raggedright}}

% Footnotes
\footnotesep 6.65pt %
\skip\footins 9pt plus 4pt minus 2pt
\def\footnoterule{\kern-3pt \hrule width 12pc \kern 2.6pt }
\setcounter{footnote}{0}

% Paragraph spacing and list spacing (to compress and remove whitespace)
% Note some of these have more global impact, so even though enumitem makes them not impact lists,
% they impact paragraph spacing (e.g., topsep).
\parindent 0pt                          % No paragraph indending
\topsep 4pt plus 1pt minus 2pt          % Set space above and below lists (impacts section spacing too)
\parskip .5pc                           % Space between paragraphs (outside of lists)
\setlist{
  topsep=0pt,                           % Space above and below the list
  partopsep=0pt,                        % Extra space added to topsep when the list starts a new paragraph
  itemsep=-2pt,                         % Space between items
  parsep=.5pc,                          % Space between paragraphs within items
  leftmargin=*                          % Aligns the list with the left margin (no indentation)
}

% Handle conditional activation of line numbers:
\if@accepted
  % Accepted papers: Do not display line numbers
\else
  \if@preprint
    % Preprint papers: Do not display line numbers
  \else
    % Under submission: Activate line numbers
    \linenumbers
  \fi
\fi
% Restyle line numbers:
\setlength\linenumbersep{11pt} % Adjust the space between line numbers and text
\renewcommand\linenumberfont{\normalfont\small\sffamily\color{gray}} % Style line numbers

% lineno has conflicts with amsmath. The following code fixes these. Source: https://tex.stackexchange.com/questions/461186/how-to-use-lineno-with-amsmath-align
% Patch 'normal' math environments:
\newcommand*\linenomathpatch[1]{%
  \cspreto{#1}{\linenomath}%
  \cspreto{#1*}{\linenomath}%
  \csappto{end#1}{\endlinenomath}%
  \csappto{end#1*}{\endlinenomath}%
}
\linenomathpatch{equation}
\linenomathpatch{gather}
\linenomathpatch{multline}
\linenomathpatch{align}
\linenomathpatch{alignat}
\linenomathpatch{flalign}
