AUTh Report LaTeX/XeLaTeX class
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

418 行
12 KiB

  1. %
  2. % AUTH report class
  3. %
  4. % note: Requires compilation with XeLaTeX or LuaTeX
  5. %
  6. % author: Christos Choutouridis <cchoutou@ece.auth.gr>
  7. %
  8. \NeedsTeXFormat{LaTeX2e}
  9. \ProvidesPackage{AUTHReport}[2024-11-03 AUTH Report document class]
  10. % Options
  11. % ===============================================
  12. % Declare option for short report version
  13. \DeclareOption{short}{\def\auth@short{yes}}
  14. % Declare option for CoAuthor
  15. %\DeclareOption{coauthor}{\def\auth@coauthor{yes}}
  16. % Default option values
  17. \def\auth@short{no}
  18. %\def\auth@coauthor{no}
  19. % Pass all other options to article
  20. \DeclareOption*{%
  21. \PassOptionsToClass{\CurrentOption}{article}
  22. }
  23. \ProcessOptions\relax
  24. \LoadClass{article}
  25. % Requirements
  26. % ===============================================
  27. \RequirePackage{iftex}
  28. \ifPDFTeX
  29. \RequirePackage[utf8]{inputenc}
  30. \RequirePackage[T1]{fontenc}
  31. \else
  32. \RequirePackage{fontspec}
  33. \fi
  34. \RequirePackage{xargs} % Commands
  35. \RequirePackage{geometry} % Layout
  36. \RequirePackage{fancyhdr}
  37. \RequirePackage{graphicx} % Figures
  38. % Format packages
  39. \RequirePackage[hang, small,labelfont=bf,up,textfont=it,up]{caption} % Custom captions under/above floats in tables or figures
  40. \RequirePackage[nobottomtitles]{titlesec}
  41. \RequirePackage{titling}
  42. \RequirePackage[bottom]{footmisc} % Place footnotes always as much to the bottom as possible.
  43. \RequirePackage{hyperref} % Various
  44. \RequirePackage[ddmmyyyy]{datetime}
  45. \RequirePackage{enumitem}
  46. % Local Tools
  47. % ===============================================
  48. % Tool to check equality
  49. \newcommand{\isequal}[2]{ \pdf@strcmp{#1}{#2} }
  50. % syntactic suggar for horizaontal rule
  51. \newcommand{\Hrule}{ \rule{\linewidth}{0.1mm} }
  52. % Theme
  53. % ===============================================
  54. % Layout
  55. % =====================================================
  56. % Page core layout settings (include head and foot)
  57. % A4 will result to:
  58. % Top margin: 12mm
  59. % Bottom margin: 11mm
  60. % Head hight: 14mm
  61. % Foot skip: 15mm
  62. % Left margin: 15mm
  63. % Right margin: 12mm
  64. \newcommand{\authTopMargin}{12mm}
  65. \newcommand{\authBottomMargin}{12mm}
  66. \newcommand{\authHeadHeight}{10mm}
  67. \newcommand{\authFootSkip}{10mm}
  68. \newcommand{\authLeftMargin}{15mm}
  69. \newcommand{\authRightMargin}{15mm}
  70. %
  71. % Sets page layout. (include head and foot)
  72. \newcommand*{\authSetPageLayout}{%
  73. \newgeometry{%
  74. includeheadfoot,
  75. top= \authTopMargin,
  76. bottom= \authBottomMargin,
  77. headheight= \authHeadHeight,
  78. footskip= \authFootSkip,
  79. lmargin= \authLeftMargin,
  80. rmargin= \authRightMargin
  81. }
  82. }
  83. % Fonts
  84. % =====================================================
  85. % [1]: Main(Serif) body font
  86. % [5]: Sans family font
  87. % [6]: Mono family font
  88. %
  89. \newcommand{\authFontEnvSetup}[3]{%
  90. \setmainfont{#1}[SmallCapsFeatures={Letters=SmallCaps}]
  91. \setsansfont{#2}
  92. \setmonofont{#3}
  93. % \newfontface\smallcapsfont{Libertinus Serif}[Letters=SmallCaps]
  94. }
  95. % Header and Footer
  96. % =====================================================
  97. \newcommand*{\authSetFooterEmpty}{%
  98. % Clear styles
  99. \fancyfoot{}
  100. \renewcommand{\footrulewidth}{0pt}
  101. }
  102. \newcommand*{\authSetFooter}{%
  103. % Clear styles
  104. \fancyfoot{}
  105. \fancyfoot[C]{\thepage}
  106. \renewcommand{\footrulewidth}{0pt}
  107. \pagenumbering{arabic}
  108. }
  109. \newcommand{\authSetHeaderEmpty}{
  110. % Clear styles
  111. \fancyhead{}
  112. \renewcommand{\headrulewidth}{0pt}
  113. }
  114. \newcommand{\authSetHeader}{
  115. % Clear styles
  116. \fancyhead{}
  117. \fancyhead[L]{\auth@className}
  118. \fancyhead[R]{\auth@docTitle}
  119. \renewcommand{\headrulewidth}{0.5pt}
  120. }
  121. %
  122. % Page styles
  123. %
  124. \fancypagestyle{plain}{%
  125. % Style for the main document (including TOC)
  126. \authSetFooter
  127. \authSetHeader
  128. }
  129. \fancypagestyle{authTitlePageStyle}{%
  130. % Style for Title page
  131. \authSetHeaderEmpty
  132. \ifnum \isequal{\auth@short}{no}=0
  133. \authSetFooterEmpty
  134. \else
  135. \authSetFooter
  136. \fi
  137. }
  138. % Common Page style
  139. \newcommand{\authPageStyle}{%
  140. \renewcommand{\bottomtitlespace}{0.12\textheight}
  141. % Change the look of the section and subsection titles
  142. \titleformat{\section}[block]{\large\scshape}{\thesection.}{1em}{}
  143. \titleformat{\subsection}[block]{\large}{\thesubsection.}{1em}{}
  144. \titleformat{\subsubsection}[block]{\normalsize}{\thesubsubsection.}{1em}{}
  145. %\setlist[itemize]{noitemsep} % Make itemize lists more compact
  146. \setlist[itemize]{topsep=6pt, partopsep=0pt, itemsep=3pt, parsep=3pt}
  147. % Set paragraph identation and skip
  148. \setlength{\parindent}{0pt}
  149. \setlength{\parskip}{0.3em}
  150. }
  151. % Setup theme
  152. % =====================================================
  153. \hypersetup{
  154. colorlinks=true,
  155. linkcolor=red, % Internal links, those generated by cross-referenced elements
  156. filecolor=blue, % Links to local files
  157. urlcolor=blue % Links to web sites
  158. }
  159. \setlist[itemize]{topsep=0pt, partopsep=0pt, itemsep=3pt, parsep=3pt}
  160. \AtBeginDocument{%
  161. % Page layout (check above for the geometry setup)
  162. \authSetPageLayout
  163. % Fonts
  164. \authFontEnvSetup{CMU Serif}{CMU Sans Serif}{Courier New}
  165. % Header - Footer
  166. \pagestyle{plain}
  167. \thispagestyle{authTitlePageStyle}
  168. % Page styles and formating
  169. \authPageStyle
  170. \normalsize
  171. } % End \AtBeginDocument
  172. % QA document public environments/commands
  173. % =====================================================
  174. % Common fields
  175. % =====================================================
  176. \newcommand*{\AuthorName}[1]{\def\auth@authorName{#1}}
  177. \newcommand*{\AuthorMail}[1]{\def\auth@authorMail{#1}}
  178. \newcommand*{\AuthorAEM}[1]{\def\auth@authorAEM{#1}}
  179. \newcommand*{\CoAuthorName}[1]{\def\auth@coauthorName{#1}}
  180. \newcommand*{\CoAuthorMail}[1]{\def\auth@coauthorMail{#1}}
  181. \newcommand*{\CoAuthorAEM}[1]{\def\auth@coauthorAEM{#1}}
  182. \newcommand*{\WorkGroup}[1]{\def\auth@workGroup{#1}}
  183. \newcommand*{\DocTitle}[1]{\def\auth@docTitle{#1}}
  184. \newcommand*{\DocSubTitle}[1]{\def\auth@docSubTitle{#1}}
  185. \newcommand*{\Department}[1]{\def\auth@department{#1}}
  186. \newcommand*{\ClassName}[1]{\def\auth@className{#1}}
  187. \newcommand*{\InstructorName}[1]{\def\auth@instructorName{#1}}
  188. \newcommand*{\InstructorMail}[1]{\def\auth@instructorMail{#1}}
  189. \newcommand*{\CoInstructorName}[1]{\def\auth@coinstructorName{#1}}
  190. \newcommand*{\CoInstructorMail}[1]{\def\auth@coinstructorMail{#1}}
  191. \newcommand*{\CurrentDate}[1]{\def\auth@date{#1}}
  192. % \FirstPage
  193. \newcommand{\authTitlePage}{%
  194. \begin{titlepage}
  195. % Logo
  196. \begin{figure}
  197. \begin{flushleft}
  198. \includegraphics[width=5cm]{img/auth_logogr.png}
  199. \end{flushleft}
  200. \end{figure}
  201. % Titles
  202. \center % Center everything on the page
  203. \textbf{} \\[3.5cm] % vertical space
  204. \textsc{\Large \auth@department} \\[0.5cm] % Department
  205. \textsc{\Large \auth@className} \\[1.5cm] % Class/Course name
  206. \Hrule \\[0.4cm] % -------
  207. {\huge \bfseries \auth@docTitle} \\[0.4cm] % Document/Assignement Title
  208. {\LARGE \bfseries \auth@docSubTitle} \\[0.1cm] % Document/Assignement Sub-Title
  209. \Hrule \\[3.5cm] % -------
  210. % vertical space
  211. % Authors
  212. \begin{minipage}{0.4\textwidth}
  213. \begin{flushleft}
  214. \large
  215. \ifdefined \auth@workGroup \emph{\textsc{\auth@workGroup}} \\[2ex]\fi
  216. \ifdefined \auth@coauthorName
  217. \emph{Συντάκτες:}
  218. \else
  219. \emph{Συντάκτης:}
  220. \fi \\
  221. \textsc{\auth@authorName} \\
  222. \textsc{AEM:\auth@authorAEM} \\[0.35ex]
  223. \normalsize \href{mailto:\auth@authorMail}{\auth@authorMail} \\[2ex]
  224. \large
  225. \ifdefined \auth@coauthorName
  226. \textsc{\auth@coauthorName} \\
  227. \textsc{AEM:\auth@coauthorAEM} \\[0.35ex]
  228. \normalsize \href{mailto:\auth@coauthorMail}{\auth@coauthorMail} \\[2ex]
  229. \fi
  230. \end{flushleft}
  231. \end{minipage}
  232. \begin{minipage}{0.4\textwidth}
  233. \begin{flushright}
  234. \large
  235. \ifdefined \auth@coinstructorName % Instructor(s)
  236. \emph{Διδάσκοντες:}
  237. \else
  238. \emph{Διδάσκων:}
  239. \fi \\
  240. \textsc{\auth@instructorName} \\[0.35ex]
  241. \normalsize \href{mailto:\auth@instructorMail}{\auth@instructorMail} \\[2ex]
  242. \large
  243. \ifdefined \auth@coinstructorName
  244. \textsc{\auth@coinstructorName} \\[0.35ex]
  245. \normalsize \href{mailto:\auth@coinstructorMail}{\auth@coinstructorMail} \\[2ex]
  246. \fi
  247. \end{flushright}
  248. \end{minipage}
  249. \vfill
  250. {\large \auth@date} \\ % date
  251. \end{titlepage}
  252. \newpage
  253. }
  254. % \TitleHeader
  255. \newcommand{\authTitleHeader}{%
  256. \begin{center} % Center everything on the page
  257. % Logo
  258. \begin{figure}
  259. \center
  260. \includegraphics[width=5cm]{img/auth_logogr.png}
  261. \end{figure}
  262. % Titles
  263. \textsc{\Large \auth@department} \\[0.4cm] % Department
  264. \textsc{\Large \auth@className} \\[0.1cm] % Class/Course name
  265. {\Large \bfseries \auth@docTitle} \\[0.2cm] % Document/Assignement Title
  266. {\large \bfseries \auth@docSubTitle} \\[0.2cm] % Document/Assignement Sub-Title
  267. {\large \auth@date} \\[0.4cm] % date
  268. % Authors
  269. \begin{minipage}{0.4\textwidth}
  270. \begin{flushleft}
  271. \large
  272. \ifdefined \auth@coauthorName
  273. \emph{Συντάκτες:}
  274. \else
  275. \emph{Συντάκτης:}
  276. \fi \\
  277. \textsc{\auth@authorName} \\
  278. \textsc{AEM:\auth@authorAEM} \\[0.35ex]
  279. \normalsize \href{mailto:\auth@authorMail}{\auth@authorMail} \\[2ex]
  280. \large
  281. \ifdefined \auth@coauthorName
  282. \textsc{\auth@coauthorName} \\
  283. \textsc{AEM:\auth@coauthorAEM} \\[0.35ex]
  284. \normalsize \href{mailto:\auth@coauthorMail}{\auth@coauthorMail} \\[2ex]
  285. \fi
  286. \end{flushleft}
  287. \end{minipage}
  288. \begin{minipage}{0.4\textwidth}
  289. \begin{flushright} \large
  290. \large
  291. \ifdefined \auth@coinstructorName % Instructor(s)
  292. \emph{Διδάσκοντες:}
  293. \else
  294. \emph{Διδάσκων:}
  295. \fi \\
  296. \textsc{\auth@instructorName} \\[0.35ex]
  297. \normalsize \href{mailto:\auth@instructorMail}{\auth@instructorMail} \\[2ex]
  298. \large
  299. \ifdefined \auth@coinstructorName
  300. \textsc{\auth@coinstructorName} \\[0.35ex]
  301. \normalsize \href{mailto:\auth@coinstructorMail}{\auth@coinstructorMail} \\[2ex]
  302. \fi
  303. \end{flushright}
  304. \end{minipage}
  305. \end{center}
  306. }
  307. \newcommand{\InsertTitle}{%
  308. \ifnum \isequal{\auth@short}{no}=0
  309. \authTitlePage
  310. \else
  311. \authTitleHeader
  312. \fi
  313. }
  314. % \InsertFigure{}{}{}{}{}
  315. % [1]: Position specifier
  316. % [2]: scale
  317. % [3]: Label
  318. % [4]: Figure file
  319. % [5]: Caption text
  320. % example: \InsertFigure{!h}{0.8}{fig:lala}{lala.png}{\eng{Makes lala}}
  321. \newcommand{\InsertFigure}[5]{
  322. \begin{figure}[#1]
  323. \captionsetup{format=plain}
  324. \centering
  325. \includegraphics[width=#2\textwidth]{#4}
  326. \caption{#5}
  327. \label{#3}
  328. \end{figure}
  329. }
  330. % \WrapFigure{}{}{}{}
  331. % [1]: scale
  332. % [2]: place left or right r,l,R,L
  333. % [3]: Label
  334. % [4]: Figure file
  335. % [5]: Caption text
  336. % example: \WrapFigure{0.8}{r}{fig:lala}{lala.png}{\eng{Makes lala}}
  337. \newcommand{\WrapFigure}[5]{
  338. \begin{wrapfigure}{#2}{#1\textwidth}
  339. \vspace{-20pt}
  340. \begin{center}
  341. \captionsetup{format=plain}
  342. \includegraphics[width=#1\textwidth]{#4}
  343. \caption{#5}
  344. \label{#3}
  345. \end{center}
  346. \vspace{-20pt}
  347. \end{wrapfigure}
  348. }