% From mitthesis package
% Documentation: https://ctan.org/pkg/mitthesis

\ProvidesFile{mydesign.tex}[2026/11/19 v1.08 Typographic design options for mitthesis]

% ==> You can change this file however you want. The content below is only for illustration! <==


%%%%%%%%%  Change page margins  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 
%% The following tells the geometry package to use a two-sided layout with a 1 cm binding
%%   offset on the inner edge (left on odd pages, right on even pages) and 1 inch margins
%%   all around. Because the margins are fixed, \textwidth is reduced by the full 1 cm
%%   (from 6.5 in to about 6.1 in on letter paper). The 0.7 cm reduction in the geometry
%%   manual (Sec. 8.2) applies only when margins are not set and the default scale=0.7 is used.
%%
%% \newgeometry must be hooked to the end of \begin{document}; if used directly in the
%%   preamble, it is overridden when geometry applies its settings at \begin{document}.
%%   \restoregeometry will return to the mitthesis defaults:
%%
%% mitthesis defaults: [top=1in,bottom=1in,left=1in,right=1in,marginparwidth=50pt,headsep=12pt,footskip=0.5in]

% \AddToHook{begindocument/end}{%
%   \newgeometry{twoside,bindingoffset=1cm,margin=1in,marginparwidth=50pt,headsep=12pt,footskip=0.5in}%
% }


%%%%%%%%%%  Color support  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Color package: xcolor.
%% Change this if you prefer something else

\RequirePackage[dvipsnames,svgnames,x11names]{xcolor}

%% xcolor defines a broad set of color names that can be invoked in your document (see xcolor documentation).
%% Can add option [table] to xcolor to use color in tables


%%%%%%%%%%  Hyperlink and line number colors  %%%%%%%%%%%%%%

\AtBeginDocument{%
    % Using color names from xcolor package
    \hypersetup{
    	linkcolor=Blue3,
    	citecolor=Blue3,
    	urlcolor=violet,
    	filecolor=red,
    %	anchorcolor=yellow,%  not all pdf viewers recognize this key (Firefox does); hyperref issues a warning, which can be ignored
    %	colorscheme=phelype,% overrides link, cite, url, file colors with a preset scheme (requires \DocumentMetadata)
    	}
    %
    \ifmitthesis@lineno
	    \renewcommand{\linenumberfont}{\sffamily\mdseries\tiny\color{violet}}% line numbers will be sans-serif, medium weight, tiny, and violet
    \fi
}

%%%%%%%%%  Caption support  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% These commands make caption label bold, with an \enspace (~1/2\quad) separating label from text; the hook command is empty.
\IfFormatAtLeastTF{2025/11/01}
{
    %% If your latex format is at least 2025/11/01, you should use this approach:
    \NewSocketPlug{caption/label}{plug-bold-quad}{\textbf{#1:}\enspace} % This strictly addresses the caption label, not caption text.
    \AssignSocketPlug{caption/label}{plug-bold-quad}
    %
    % \AddToHook{cmd/@makecaption/before}{\relax} % Contents of second argument would style the entire caption, but label socket above can override it in the label.
    %
    %% in case caption or subcaption is loaded in preamble, include this hook.
    \AddToHook{package/caption/after}{
        \DeclareCaptionLabelSeparator{colonenspace}{:\enspace}
        \captionsetup{labelfont=bf,labelsep=colonenspace}
    }
}{
    %% For older formats, use the caption package. See documentation of caption package for details.
    \RequirePackage{caption}
    \DeclareCaptionLabelSeparator{colonenspace}{:\enspace}
    \captionsetup{labelfont=bf,labelsep=colonenspace} % change to boldface label with separator ":\enspace"
}


%%%%%%%%%  Customize titles and section headings  %%%%%%%%%%

%% The following commands add \raggedright to section headings (compare to report.cls), and end paragraph titles with "." when
%%     the title does not already end with a punctuation mark.

%% Use new LaTeX template mechanism for newer formats: 
%%     https://mirrors.ctan.org/macros/latex/required/latex-lab/latex-lab-sec-template.pdf
%% For older formats see:
%%     https://latexref.xyz/dev/latex2e.html#g_t_005c_0040startsection

%% This macro adds a period unless the word before it already ends in punctuation. 
%%   If the title ends in an abbreviation after a capital letter, write U.S\@. to avoid a doubled period. 
%%   This macro is similar to \@addpunct{.} from the amsgen package.
\protected\def\mitthesis@addperiod{\ifhmode\ifnum\spacefactor>\@m\else.\fi\fi}


\IfFormatAtLeastTF{2026/11/01}
  { % using template mechanism
   \EditInstance{heading}{section}{
     heading-decls = \normalfont\Large\bfseries\raggedright,
     %
     %% a few further examples (see latex-lab-sec-template.pdf for details)
     %
     % number-format=\fbox{\color{red}\theheading},               % puts a red section number in a box.
     % title-decls =\sffamily,                                    % makes the section title text sans serif (can overwrite heading-decls)
     % heading-format=\colorbox{yellow}{\parbox{\linewidth}{#1}}, % puts full-width yellow background behind the whole section title
    }
   \EditInstance{heading}{subsection}{
     heading-decls = \normalfont\large\bfseries\raggedright,
    }
   \EditInstance{heading}{subsubsection}{
     heading-decls = \normalfont\normalsize\bfseries\raggedright,
    }
   \EditInstance{headformat}{paragraph}{ %title followed by period; text is bold by default. 
     order = { title, separator-c},
     separator-c = \mitthesis@addperiod,
   }
   \EditInstance{heading}{subparagraph}{
     before-vspace = 0.5\baselineskip,  % reduce white page above heading
     after-hspace  = 0.5em,             % reduce space after heading
     number-format = #1,
   }
   \EditInstance{headformat}{subparagraph}{ % title followed by period; text is bold by default.
     order = { title, separator-c},
     separator-c = \mitthesis@addperiod,
   }
  }{ % old way
    \renewcommand\section{\@startsection {section}{1}{\z@}%
                                       {-3.5ex \@plus -1ex \@minus -.2ex}%
                                       {2.3ex \@plus.2ex}%
                                       {\normalfont\Large\bfseries\raggedright}}% <--- added \raggedright
    \renewcommand\subsection{\@startsection{subsection}{2}{\z@}%
                                       {-3.25ex\@plus -1ex \@minus -.2ex}%
                                       {1.5ex \@plus .2ex}%
                                       {\normalfont\large\bfseries\raggedright}}% <--- added \raggedright
    \renewcommand\subsubsection{\@startsection{subsubsection}{3}{\z@}%
                                       {-3.25ex\@plus -1ex \@minus -.2ex}%
                                       {1.5ex \@plus .2ex}%
                                       {\normalfont\normalsize\bfseries\raggedright}}% <--- added \raggedright
    %    \renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}%
    %                                    {3.25ex \@plus1ex \@minus.2ex}%
    %                                    {-1em}%
    %                                    {\normalfont\normalsize\bfseries}}
    \renewcommand\subparagraph{\@startsection{subparagraph}{5}{\parindent}%
                                       {3.25ex \@plus1ex \@minus .2ex}%
                                       {-0.5em}%                           % <--- changed from -1em to -0.5em
                                       {\normalfont\normalsize\bfseries}}
    % 
    % now get periods after \paragraph and \subparagraph titles
    %
    \NewCommandCopy \mitthesis@paragraph \paragraph
    \RenewDocumentCommand \paragraph { s O{#3} m }
     {%
        \IfBooleanTF {#1}
          { \mitthesis@paragraph*      {#3\mitthesis@addperiod} }
          { \mitthesis@paragraph[#2]   {#3\mitthesis@addperiod} }%
    }
    %
    \NewCommandCopy \mitthesis@subparagraph \subparagraph
    \RenewDocumentCommand \paragraph { s O{#3} m }
     {%
        \IfBooleanTF {#1}
          { \mitthesis@subparagraph*      {#3\mitthesis@addperiod} }
          { \mitthesis@subparagraph[#2]   {#3\mitthesis@addperiod} }%
    }
  }


%% to change chapter headings, you can use these commands (as shown, they change the color to Red4 from xcolor's x11names option).

%\IfFormatAtLeastTF{2026/11/01} % need to use new LaTeX template mechanism for newer formats
%  {
%   \EditInstance{heading}{chapter}{
%     heading-decls = \raggedright \parindent0pt \bfseries \huge\color{Red4},
%     title-decls = \Huge\color{Red4},
%    }
%%   \EditInstance{headformat}{chapter}{
%%   }
%  }{
%    \patchcmd{\@makechapterhead}{\Huge}{\color{Red4}\Huge}
%        {}{\ClassWarning{\ClassName}{Patch of \string\@makechapterhead\space failed}}
%    \patchcmd{\@makechapterhead}{\huge}{\color{Red4}\huge}{}{}
%    \patchcmd{\@makeschapterhead}{\Huge}{\color{Red4}\Huge}{}{} % for UNnumbered chapter names
%  }


%%% Automatic bold math in section headings
%%
%% For fonts with a predefined bold font, you can insert \mathversion{bold} into heading commands. 
%%     The predefined fontsets for which a bold math version exists: 
%%           pdflatex only:        Computer Modern (CM-super), fira-newtxsf, newtx, newtx-sans-text
%%           lualatex or pdflatex: Lucida
%%     Other math fonts with a complete bold version include XITS and KpMath. Some fonts, such as Lete Sans Math, 
%%     include a partial bold math version, which is often all that is needed for headings.
%%
%%     NB: All math fonts include bold characters. For a bold math font, the _entire_ font is bold weight.


%% if you want \subsubsection to be numbered, change 2 to 3 in the following (** not recommended **)
%  \setcounter{secnumdepth}{2}


%%%%%%%%%%  Customize list environments  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 
%% Lists can be customized in recent LaTeX formats _without_ loading the enumitem package. 
%% For examples and explanation, see this document:
%%
%%   https://mirrors.ctan.org/macros/latex/required/latex-lab/latex-lab-enumitem.pdf
%%
%% Also relevant to list formatting is the template implementation of lists and block environments: blocks-doc.pdf
%%


%%%%%%%%%  Start first paragraph of each section with \textreferencemark in the margin  %%%%%%%%%%%%

%% This example is entirely frivolous, but it's included to give a sense of how powerful LaTeX's hook mechanism can be.
%% You could alternatively print a counter, say, the section number.  NB: This example is not rigorously tested!
%%    See: lthooks-doc.pdf for more information

%\newcommand*{\docname}{document}
%
%\AddToHook{cmd/section/after}{%
%  \AddToHookNext{para/begin}{%
%    \ifnum\value{subsection}=0                             % don't add symbol if a subsection directly follows section heading
%      \ifx\@currenvir\docname                              % don't add, e.g., if a list directly follows section heading
%        \llap{\textcolor{teal}{\textreferencemark}\quad}%  % \llap contents are typeset left of current position (so in the margin)
%      \fi
%    \fi
%  }%
%}

