Template_Specification/source/_static/jmk_spec.sty
2024-06-17 13:50:08 -03:00

216 lines
No EOL
12 KiB
TeX

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% jmk_spec.sty
%
% LaTeX package for Sphinx override template
%
% © Jeff MacKinnon
% code by E. A. Farina latex.guru
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{jmk_spec}[2024/04/16 v1.1 LaTeX package for Sphinx override template]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Useful packages
\RequirePackage{tikz}
\RequirePackage[table]{xcolor}
\RequirePackage{tabularx}
\RequirePackage{xstring}
\RequirePackage{anyfontsize}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Colors
\definecolor{JMKblue}{HTML}{004360}%{17365d}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Layout
\newlength{\MARmar}\setlength{\MARmar}{1in}
\newlength{\MARlef}\setlength{\MARlef}{\MARmar}
\newlength{\MARrig}\setlength{\MARrig}{\MARmar}
\newlength{\MARtop}\setlength{\MARtop}{1.75\MARmar}
\newlength{\MARbot}\setlength{\MARbot}{\MARmar}
\@ifpackageloaded{geometry}{}{\RequirePackage{geometry}}
\geometry{letterpaper,portrait,left=\MARlef,right=\MARrig,top=\MARtop,bottom=\MARbot,headheight=14.5pt}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Language
%\RequirePackage[english]{babel}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Font
\usepackage[scaled]{helvet}
\usepackage[T1]{fontenc}
\renewcommand{\familydefault}{\sfdefault}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Tokens
\newcommand{\dbclient}{}\newcommand{\client}[1]{\renewcommand{\dbclient}{#1}}
\newcommand{\dbrevision}{}\newcommand{\revision}[1]{\renewcommand{\dbrevision}{#1}}
\newcommand{\dbsubtitle}{}\newcommand{\subtitle}[1]{\renewcommand{\dbsubtitle}{#1}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Page style
\RequirePackage{fancyhdr}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\newcommand{\headfoot}{\fancyhf{}\fancyhead[C]{\begin{tikzpicture}[remember picture,overlay,inner sep=0pt,outer sep=0pt]
%\node at (current page.center) {\includegraphics[width=\paperwidth,page=2]{TEST.pdf}};
% HEAD
\coordinate (TOPl) at ([shift={(\MARlef+100pt,0pt)}]current page.north west);
\coordinate (TOPr) at ([shift={(-\MARrig-100pt,0pt)}]current page.north east);
% Logo
\node[anchor=west] (LOGO) at ([shift={(\MARlef,-0.5\MARtop)}]current page.north west) {\includegraphics[height=55pt]{JMKEngineering-Logo_blue.jpg}};
% Left
% Title
\node[anchor=north west,font=\fontsize{10pt}{12pt}\selectfont] at (TOPl|-LOGO.north) {\bfseries\Chaptername};
% Client
\node[anchor=west,font=\fontsize{10pt}{12pt}\selectfont] at (TOPl|-LOGO.east) {CLIENT: \strut\dbclient};
% Project
\node[anchor=south west,font=\fontsize{10pt}{12pt}\selectfont] at (TOPl|-LOGO.south) {\strut Project Num: \version};
% Right
% Date
\node[anchor=north west,font=\fontsize{10pt}{12pt}\selectfont] (REV) at (TOPr|-LOGO.north) {\strut\@date};
% Revision
\node[anchor=west,font=\fontsize{10pt}{12pt}\selectfont] at (TOPr|-LOGO.center) {\strut Rev: \strut\dbrevision};
% Page
\node[anchor=south west,font=\fontsize{10pt}{12pt}\selectfont] at (TOPr|-LOGO.south) {\StrBefore[1]{\Chaptername}{\sphinxhyphen{}}[\ChapterSpecNum]\strut Page \ChapterSpecNum~--~\thepage};
% FOOT
% Copyright
\node[anchor=center,font=\fontsize{10pt}{12pt}\selectfont,align=left] at ([shift={(0pt,0.5\MARbot)}]current page.south) {JMK Engineering Inc.};
% LAYOUT
%\draw ([shift={(\MARlef,\MARbot)}]current page.south west) rectangle ([shift={(-\MARrig,-\MARtop)}]current page.north east);
%\draw[|<->|] (current page.west)--++(0:\MARlef) node[midway,above] {\strut 1~in};
%\draw[|<->|] (current page.east)--++(180:\MARrig) node[midway,above] {\strut 1~in};
%\draw[|<->|] (current page.south)--++(90:\MARbot) node[midway,right] {\strut 1~in};
%\draw[|<->|] (current page.north)--++(270:\MARtop) node[midway,right] {\strut 1.5~in};
\end{tikzpicture}}}
\fancypagestyle{plain}{\headfoot}
\fancypagestyle{normal}{\headfoot}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Headings
%\RequirePackage[Bjornstrup]{fncychap}% Loaded by conf.py but remove by Elio
%\RequirePackage[explicit]{titlesec}
\let\Chaptermark\chaptermark
\def\chaptermark#1{\def\Chaptername{#1}\Chaptermark{#1}}
%
\def\FONTchapter{\Large\bfseries\color{JMKblue}}
\titleformat{\chapter}[hang]{\FONTchapter}{}{0pt}{}[]
\titleformat{name=\chapter,numberless}[hang]{\FONTchapter}{}{0pt}{}[]
\titlespacing*{\chapter}{0pt}{-3\baselineskip}{\baselineskip}
%
\def\FONTsection{\large\bfseries\color{JMKblue}}
\titleformat{\section}[hang]{\FONTsection}{}{0pt}{}[]
\titleformat{name=\section,numberless}[hang]{\FONTsection}{}{0pt}{}[]
\titlespacing*{\section}{0pt}{\baselineskip}{0pt}
%
\def\FONTsubsection{\bfseries\color{JMKblue}}
\titleformat{\subsection}[hang]{\FONTsubsection}{}{0pt}{}[]
\titleformat{name=\subsection,numberless}[hang]{\FONTsubsection}{}{0pt}{}[]
\titlespacing*{\subsection}{0pt}{\baselineskip}{0pt}
%
\def\FONTsubsubsection{\itshape\color{JMKblue}}
\titleformat{\subsubsection}[hang]{\FONTsubsubsection}{}{0pt}{}[]
\titleformat{name=\subsubsection,numberless}[hang]{\FONTsubsubsection}{}{0pt}{}[]
\titlespacing*{\subsubsection}{0pt}{\baselineskip}{0pt}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Title page
\newcommand{\OLDsphinxmaketitle}{\pagestyle{plain}\pagenumbering{roman}\strut
\vspace{-4\baselineskip}
\begin{center}\fontsize{31pt}{37pt}\bfseries\color{JMKblue}\selectfont
\@title
\end{center}
\vspace{2\baselineskip}
\begin{center}\huge\bfseries\color{JMKblue}
\dbsubtitle
\end{center}
\vfill
\ifnumequal{\therevhis}{0}{}{
\begin{center}\large\bfseries\color{JMKblue}Revision History\end{center}
\begin{tabularx}{\linewidth}{|c|X|l|l|}\hline
\rowcolor{black!10}\bfseries Number & \bfseries Description & \bfseries Date & \bfseries Approved \\\hline
\ifnumgreater{\therevhis}{0}{\csuse{REVnum1} & \csuse{REVdesc1} & \csuse{REVdate1} & \\ \hline}{}
\ifnumgreater{\therevhis}{1}{\csuse{REVnum2} & \csuse{REVdesc2} & \csuse{REVdate2} & \\ \hline}{}
\ifnumgreater{\therevhis}{2}{\csuse{REVnum3} & \csuse{REVdesc3} & \csuse{REVdate3} & \\ \hline}{}
\ifnumgreater{\therevhis}{3}{\csuse{REVnum4} & \csuse{REVdesc4} & \csuse{REVdate4} & \\ \hline}{}
\ifnumgreater{\therevhis}{4}{\csuse{REVnum5} & \csuse{REVdesc5} & \csuse{REVdate5} & \\ \hline}{}
\ifnumgreater{\therevhis}{5}{\csuse{REVnum6} & \csuse{REVdesc6} & \csuse{REVdate6} & \\ \hline}{}
\ifnumgreater{\therevhis}{6}{\csuse{REVnum7} & \csuse{REVdesc7} & \csuse{REVdate7} & \\ \hline}{}
\ifnumgreater{\therevhis}{7}{\csuse{REVnum8} & \csuse{REVdesc8} & \csuse{REVdate8} & \\ \hline}{}
\ifnumgreater{\therevhis}{8}{\csuse{REVnum9} & \csuse{REVdesc9} & \csuse{REVdate9} & \\ \hline}{}
\ifnumgreater{\therevhis}{9}{\csuse{REVnum10} & \csuse{REVdesc10} & \csuse{REVdate10} & \\ \hline}{}
\ifnumgreater{\therevhis}{10}{\csuse{REVnum11} & \csuse{REVdesc11} & \csuse{REVdate11} & \\ \hline}{}
\end{tabularx}
}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Intentionally Blank Page
\newcommand{\IBP}{\clearpage\pagestyle{plain}
\strut\par
\vfill
\centerline{\textbf{\sffamily Intentionally Blank Page}}\par
\vfill
\strut
\clearpage
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% End of section
\protected\def\sphinxstylestrong#1{\ifstrequal{#1}{END OF SECTION}{\vskip\baselineskip\centerline{\textbf{#1}}}{\textbf{#1}}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Title page
\renewcommand{\sphinxmaketitle}{\pagestyle{empty}\pagenumbering{roman}\strut
\begin{tikzpicture}[remember picture,overlay,inner sep=0pt,outer sep=0pt]
% Logo
\node[anchor=north west] (LOGO) at ([shift={(125pt,-100pt)}]current page.north west) {\includegraphics[height=72pt]{JMKEngineering-Logo_text.jpg}};
% Title
\node[anchor=north west,text width=\linewidth-125pt,align=flush left,font=\fontsize{34pt}{40pt}\color{JMKblue}\bfseries\selectfont] (TITLE) at ([shift={(0pt,-18pt)}]LOGO.south west) {\@title};
% Project num
\node[anchor=north west,text width=\linewidth-125pt,align=flush left,font=\fontsize{12pt}{14pt}\color{JMKblue}\sffamily\selectfont] (VER) at ([shift={(0pt,-15pt)}]TITLE.south west) {Project Number: \strut\version};
% Left band
\draw[JMKblue,line width=1.2pt] ([shift={(-5pt,10pt)}]LOGO.north west) coordinate (LS) --([yshift=-10pt]LS|-VER.south);
% Date
\node[anchor=south west,text width=\linewidth-125pt,align=flush left,font=\fontsize{14pt}{16pt}\color{JMKblue}\sffamily\selectfont] (DATE) at ([shift={(0pt,100pt)}]TITLE.west|-current page.south) {Issue Date: \strut\@date};
% Revision
\node[anchor=south west,text width=\linewidth-125pt,align=flush left,font=\fontsize{14pt}{16pt}\color{JMKblue}\sffamily\selectfont] (DATE) at ([shift={(0pt,80pt)}]TITLE.west|-current page.south) {Revision: \strut\dbrevision};
\end{tikzpicture}
%\IBP
\clearpage
\pagenumbering{arabic}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Revision history
\newcounter{revhis}
\setcounter{revhis}{0}
\makeatletter
\define@key{rev}{num}{\csdef{REVnum\therevhis}{#1}}
\define@key{rev}{desc}{\csdef{REVdesc\therevhis}{#1}}
\define@key{rev}{date}{\csdef{REVdate\therevhis}{#1}}
\makeatother
\setkeys{rev}{}
\newcommand{\revisionhistory}[1]{\stepcounter{revhis}\setkeys{rev}{#1}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% List of figures and tables
\RequirePackage{float}
\floatstyle{boxed}
\restylefloat{figure}
\restylefloat{table}
\newif\iffigures
\newif\iftables
\makeatletter
\AtEndDocument{%
\if@filesw
\ifnum\value{figure}=\z@ % no figures
\immediate\write\@mainaux {\global\string\figuresfalse}%
\else
\immediate\write\@mainaux {\global\string\figurestrue}%
\fi
\ifnum\value{table}=\z@ % no tables
\immediate\write\@mainaux {\global\string\tablesfalse}%
\else
\immediate\write\@mainaux {\global\string\tablestrue}%
\fi
\fi
}
\makeatother
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Table of contents
\setcounter{tocdepth}{1}
\renewcommand{\sphinxtableofcontents}{}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Hyperref
\hypersetup{hidelinks}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\endinput