AUTh Report LaTeX/XeLaTeX class
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

525 řádky
14 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. \ProvidesClass{AUThReport}[2024-12-07 AUTh Report document class]
  10. % Pre-option packages
  11. % Options
  12. % ===============================================
  13. % Declare option for short report version
  14. \DeclareOption{short}{\def\auth@short{yes}}
  15. \def\auth@short{no}
  16. % Pass all other options to article
  17. \DeclareOption*{%
  18. \PassOptionsToClass{\CurrentOption}{article}
  19. }
  20. \ProcessOptions\relax
  21. \LoadClass{article}
  22. % Requirements
  23. % ===============================================
  24. \RequirePackage{iftex}
  25. % Font packages
  26. \ifPDFTeX
  27. \RequirePackage[LGR, T1]{fontenc} % ToDo: find a way to dynamicaly select encoding based on languages
  28. \RequirePackage[utf8]{inputenc}
  29. \RequirePackage{lmodern}
  30. \else
  31. \RequirePackage{fontspec}
  32. \fi
  33. % Language packages
  34. \ifPDFTeX
  35. % Postponed to Pre-Begin hook
  36. % \usepackage{babel}
  37. \else
  38. \typeout{[DEBUG] Polyglossia Included}
  39. \RequirePackage{polyglossia}%
  40. \fi
  41. \RequirePackage{xargs} % Commands
  42. \RequirePackage{geometry} % Layout
  43. \RequirePackage{fancyhdr}
  44. \RequirePackage{graphicx} % Figures
  45. % Format packages
  46. \RequirePackage[hang, small,labelfont=bf,up,textfont=it,up]{caption} % Custom captions under/above floats in tables or figures
  47. \RequirePackage[nobottomtitles]{titlesec}
  48. \RequirePackage{titling}
  49. \RequirePackage[bottom]{footmisc} % Place footnotes always as much to the bottom as possible.
  50. \RequirePackage{hyperref} % Various
  51. \RequirePackage[ddmmyyyy]{datetime}
  52. \RequirePackage{enumitem}
  53. \RequirePackage{multicol}
  54. % Local Tools
  55. % ===============================================
  56. % Tool to check equality
  57. \newcommand{\isequal}[2]{ \pdf@strcmp{#1}{#2} }
  58. % syntactic suggar for horizaontal rule
  59. \newcommand{\Hrule}{ \rule{\linewidth}{0.1mm} }
  60. \newcommand{\authAuthorTitleText}{%
  61. \ifnum \isequal{\auth@mainlanguage}{greek}=0
  62. \ifdefined \auth@coauthorName Συντάκτες\else Συντάκτης\fi
  63. \else
  64. \ifdefined \auth@coauthorName Authors\else Author\fi
  65. \fi
  66. }
  67. \newcommand{\authInstructorTitleText}{%
  68. \ifnum \isequal{\auth@mainlanguage}{greek}=0
  69. \ifdefined \auth@coinstructorName Διδάσκοντες\else Διδάσκων\fi
  70. \else
  71. \ifdefined \auth@coinstructorName Instructors\else Instructor\fi
  72. \fi
  73. }
  74. \newcommand{\authMailText}[1]{%
  75. \ifnum \isequal{\auth@mainlanguage}{greek}=0
  76. \href{mailto:#1}{\eng{#1}}
  77. \else
  78. \href{mailto:#1}{#1}
  79. \fi
  80. }
  81. % Pre-Begin hook
  82. % =====================================================
  83. \newcommand{\authPreBeginHook}{}
  84. \newcommand{\authAddToPreBeginHook}[1]{%
  85. \expandafter\gdef\expandafter\authPreBeginHook\expandafter{\authPreBeginHook#1}%
  86. }
  87. % Language
  88. % ===============================================
  89. % Init language variables
  90. \newcommand{\auth@languages}{english} % Pre-selected language
  91. \newcommand{\auth@mainlanguage}{english} % Pre-selected main language
  92. \newcommand{\authSetupLanguageEnv}{%
  93. \ifPDFTeX
  94. \usepackage[\auth@languages, \auth@mainlanguage]{babel}
  95. \else
  96. % Set main language
  97. \setdefaultlanguage{\auth@mainlanguage}%
  98. \typeout{[DEBUG] setdefaultlanguage \auth@mainlanguage}
  99. % Set other languages
  100. \@for\auth@lang:=\auth@languages\do{%
  101. \setotherlanguage{\auth@lang}
  102. \typeout{[DEBUG] setotherlanguage \auth@lang}
  103. }%
  104. \fi
  105. }
  106. % Hook the babel setup
  107. \authAddToPreBeginHook{%
  108. \authSetupLanguageEnv
  109. }
  110. % Theme
  111. % ===============================================
  112. % Layout
  113. % =====================================================
  114. % Page core layout settings (include head and foot)
  115. % A4 will result to:
  116. % Top margin: 12mm
  117. % Bottom margin: 11mm
  118. % Head hight: 14mm
  119. % Foot skip: 15mm
  120. % Left margin: 15mm
  121. % Right margin: 12mm
  122. \newcommand{\authTopMargin}{12mm}
  123. \newcommand{\authBottomMargin}{12mm}
  124. \newcommand{\authHeadHeight}{10mm}
  125. \newcommand{\authFootSkip}{10mm}
  126. \newcommand{\authLeftMargin}{15mm}
  127. \newcommand{\authRightMargin}{15mm}
  128. %
  129. % Sets page layout. (include head and foot)
  130. \newcommand*{\authSetPageLayout}{%
  131. \newgeometry{%
  132. includeheadfoot,
  133. top= \authTopMargin,
  134. bottom= \authBottomMargin,
  135. headheight= \authHeadHeight,
  136. footskip= \authFootSkip,
  137. lmargin= \authLeftMargin,
  138. rmargin= \authRightMargin
  139. }
  140. }
  141. % Fonts
  142. % =====================================================
  143. %
  144. \newcommand{\authSetupFontEnv}{%
  145. \ifPDFTeX
  146. % PDFLaTeX fonts
  147. \else
  148. % \setmainfont{CMU-Serif-Roman.ttf}[%
  149. % Path=cmu/,
  150. % ItalicFont = CMU-Serif-Italic.ttf,
  151. % BoldFont = CMU-Serif-Bold.ttf,
  152. % BoldItalicFont= CMU-Serif-BoldItalic.ttf
  153. % ]
  154. % \setsansfont{CMU-Sans-Medium.ttf}[%
  155. % Path=cmu/,
  156. % ItalicFont = CMU-Sans-Oblique.ttf,
  157. % BoldFont = CMU-Sans-Bold.ttf,
  158. % BoldItalicFont= CMU-Sans-BoldOblique.ttf
  159. % ]
  160. % %\setsansfont{CMU-Concrete-Roman.ttf}[%
  161. % % Path=cmu/,
  162. % % ItalicFont = CMU-Concrete-Italic.ttf,
  163. % % BoldFont = CMU-Concrete-Bold.ttf,
  164. % % BoldItalicFont= CMU-Concrete-BoldItalic.ttf
  165. % %]
  166. % \setmonofont{CMU-Typewriter-Regular.ttf}[%
  167. % Path=cmu/,
  168. % ItalicFont = CMU-Typewriter-Oblique.ttf,
  169. % BoldFont = CMU-Typewriter-Bold.ttf,
  170. % BoldItalicFont= CMU-Typewriter-Oblique.ttf
  171. % ]
  172. \typeout{[DEBUG] set fonts}
  173. \setmainfont{CMU Serif}
  174. \setsansfont{CMU Sans Serif}
  175. \fi
  176. }
  177. % Header and Footer
  178. % =====================================================
  179. \newcommand*{\authSetFooterEmpty}{%
  180. % Clear styles
  181. \fancyfoot{}
  182. \renewcommand{\footrulewidth}{0pt}
  183. }
  184. \newcommand*{\authSetFooter}{%
  185. % Clear styles
  186. \fancyfoot{}
  187. \fancyfoot[C]{\thepage}
  188. \renewcommand{\footrulewidth}{0pt}
  189. \pagenumbering{arabic}
  190. }
  191. \newcommand{\authSetHeaderEmpty}{
  192. % Clear styles
  193. \fancyhead{}
  194. \renewcommand{\headrulewidth}{0pt}
  195. }
  196. \newcommand{\authSetHeader}{
  197. % Clear styles
  198. \fancyhead{}
  199. \fancyhead[L]{\auth@className}
  200. \fancyhead[R]{\auth@docTitle}
  201. \renewcommand{\headrulewidth}{0.5pt}
  202. }
  203. %
  204. % Page styles
  205. %
  206. \fancypagestyle{plain}{%
  207. % Style for the main document (including TOC)
  208. \authSetFooter
  209. \authSetHeader
  210. }
  211. \fancypagestyle{authTitlePageStyle}{%
  212. % Style for Title page
  213. \authSetHeaderEmpty
  214. \ifnum \isequal{\auth@short}{no}=0
  215. \authSetFooterEmpty
  216. \else
  217. \authSetFooter
  218. \fi
  219. }
  220. % Common Page style
  221. \newcommand{\authPageStyle}{%
  222. \renewcommand{\bottomtitlespace}{0.12\textheight}
  223. % Change the look of the section and subsection titles
  224. \titleformat{\section}[block]{\large\scshape}{\thesection.}{1em}{}
  225. \titleformat{\subsection}[block]{\large}{\thesubsection.}{1em}{}
  226. \titleformat{\subsubsection}[block]{\normalsize}{\thesubsubsection.}{1em}{}
  227. %\setlist[itemize]{noitemsep} % Make itemize lists more compact
  228. \setlist[itemize]{topsep=6pt, partopsep=0pt, itemsep=3pt, parsep=3pt}
  229. % Set paragraph identation and skip
  230. \setlength{\parindent}{0pt}
  231. \setlength{\parskip}{0.3em}
  232. }
  233. % Setup theme
  234. % =====================================================
  235. \hypersetup{
  236. colorlinks=true,
  237. linkcolor=red, % Internal links, those generated by cross-referenced elements
  238. filecolor=blue, % Links to local files
  239. urlcolor=blue % Links to web sites
  240. }
  241. \AtBeginDocument{%
  242. % % Language
  243. % \authSetupLanguageEnv
  244. % Fonts
  245. \authSetupFontEnv
  246. % Page layout (check above for the geometry setup)
  247. \authSetPageLayout
  248. %hyphenation settiongs
  249. \lefthyphenmin=2 % minimum characters before
  250. \righthyphenmin=2 % minimum characters after
  251. % Header - Footer
  252. \pagestyle{plain}
  253. \thispagestyle{authTitlePageStyle}
  254. % Page styles and formating
  255. \authPageStyle
  256. \normalsize
  257. } % End \AtBeginDocument
  258. % Public environments/commands
  259. % =====================================================
  260. % Common fields
  261. % =====================================================
  262. \newcommand*{\AuthorName}[1]{\def\auth@authorName{#1}}
  263. \newcommand*{\AuthorMail}[1]{\def\auth@authorMail{#1}}
  264. \newcommand*{\AuthorAEM}[1]{\def\auth@authorAEM{#1}}
  265. \newcommand*{\CoAuthorName}[1]{\def\auth@coauthorName{#1}}
  266. \newcommand*{\CoAuthorMail}[1]{\def\auth@coauthorMail{#1}}
  267. \newcommand*{\CoAuthorAEM}[1]{\def\auth@coauthorAEM{#1}}
  268. \newcommand*{\WorkGroup}[1]{\def\auth@workGroup{#1}}
  269. \newcommand*{\DocTitle}[1]{\def\auth@docTitle{#1}}
  270. \newcommand*{\DocSubTitle}[1]{\def\auth@docSubTitle{#1}}
  271. \newcommand*{\Department}[1]{\def\auth@department{#1}}
  272. \newcommand*{\ClassName}[1]{\def\auth@className{#1}}
  273. \newcommand*{\InstructorName}[1]{\def\auth@instructorName{#1}}
  274. \newcommand*{\InstructorMail}[1]{\def\auth@instructorMail{#1}}
  275. \newcommand*{\CoInstructorName}[1]{\def\auth@coinstructorName{#1}}
  276. \newcommand*{\CoInstructorMail}[1]{\def\auth@coinstructorMail{#1}}
  277. \newcommand*{\CurrentDate}[1]{\def\auth@date{#1}}
  278. % Language
  279. % =====================================================
  280. \newcommand{\authSetMainLanguage}[1]{%
  281. \renewcommand{\auth@mainlanguage}{#1}
  282. }
  283. \newcommand{\authSetLanguages}[1]{%
  284. \renewcommand{\auth@languages}{#1}
  285. }
  286. % \eng{}
  287. % syntactic suggar for english text inside greek
  288. % example \eng{A quick brown fox jumpedover the lazy dog}
  289. \newcommand{\eng}[1]{%
  290. \ifPDFTeX
  291. \foreignlanguage{english}{#1}
  292. \else
  293. #1
  294. \fi
  295. }
  296. % \gr{}
  297. % syntactic suggar for greek text inside english
  298. % example \gr{Άσπρη πέτρα ξέξασπρη κι απτον ήλιο ξεξασπρότερη}
  299. \newcommand{\gr}[1]{%
  300. \ifPDFTeX
  301. \foreignlanguage{greek}{#1}
  302. \else
  303. #1
  304. \fi
  305. }
  306. % \setEnglish
  307. % Selects english for the rest of the text
  308. \newcommand{\setEnglish}{%
  309. \ifPDFTeX \selectlanguage{english} \typeout{[DEBUG] set Eng} \else \typeout{[DEBUG] No set Eng}\fi
  310. }
  311. % \setGreek
  312. % Selects greek for the rest of the text
  313. \newcommand{\setGreek}{%
  314. \ifPDFTeX \selectlanguage{greek} \typeout{[DEBUG] set Gre}\else \typeout{[DEBUG] NO set Gre} \fi
  315. }
  316. % Content commands
  317. % =====================================================
  318. \newcommand{\authInsertAuthsInstructors}{%
  319. \center
  320. \noindent
  321. % Authors
  322. \hspace*{0.05\textwidth}
  323. \begin{minipage}[t]{0.35\textwidth}
  324. \begin{flushleft}
  325. \large
  326. \ifdefined \auth@workGroup \emph{\textsc{\auth@workGroup}} \\[2ex]\fi
  327. \emph{\authAuthorTitleText:} \\
  328. \auth@authorName\hspace{1ex}[\auth@authorAEM] \\[0.35ex]
  329. \normalsize \authMailText{\auth@authorMail} \\[2ex]
  330. \large
  331. \ifdefined \auth@coauthorName
  332. \auth@coauthorName\hspace{1ex}[\auth@coauthorAEM] \\[0.35ex]
  333. \normalsize \authMailText{\auth@coauthorMail} \\[2ex]
  334. \fi
  335. \end{flushleft}
  336. \end{minipage}
  337. \hfill
  338. % Instructors
  339. \begin{minipage}[t]{0.35\textwidth}
  340. \begin{flushright}
  341. \large
  342. \emph{\authInstructorTitleText:} \\
  343. \auth@instructorName \\[0.35ex]
  344. \normalsize \authMailText{\auth@instructorMail} \\[2ex]
  345. \large
  346. \ifdefined \auth@coinstructorName
  347. \auth@coinstructorName \\[0.35ex]
  348. \normalsize \authMailText{\auth@coinstructorMail} \\[2ex]
  349. \fi
  350. \end{flushright}
  351. \end{minipage}
  352. \hspace*{0.05\textwidth}
  353. }
  354. % \FirstPage
  355. \newcommand{\authTitlePage}{%
  356. \begin{titlepage}
  357. % Logo
  358. \begin{figure}
  359. \begin{flushleft}
  360. \includegraphics[width=5cm]{img/auth_logogr.png}
  361. \end{flushleft}
  362. \end{figure}
  363. % Titles
  364. \center % Center everything on the page
  365. \textbf{} \\[3.5cm] % vertical space
  366. \textsc{\Large \auth@department} \\[0.5cm] % Department
  367. \textsc{\Large \auth@className} \\[1.5cm] % Class/Course name
  368. \Hrule \\[0.4cm] % -------
  369. {\huge \bfseries \auth@docTitle} \\[0.4cm] % Document/Assignement Title
  370. {\LARGE \bfseries \auth@docSubTitle} \\[0.1cm] % Document/Assignement Sub-Title
  371. \Hrule \\[3.5cm] % -------
  372. % Authors-Instructors
  373. \authInsertAuthsInstructors
  374. \vfill
  375. {\large \auth@date} \\ % date
  376. \end{titlepage}
  377. \newpage
  378. }
  379. % \TitleHeader
  380. \newcommand{\authTitleHeader}{%
  381. \begin{center} % Center everything on the page
  382. % Logo
  383. \noindent
  384. \begin{figure}
  385. \vspace{-0.8cm}
  386. \center
  387. \includegraphics[width=5cm]{img/auth_logogr.png}
  388. \end{figure}
  389. % Titles
  390. \textsc{\Large \auth@department} \\[0.4cm] % Department
  391. \textsc{\Large \auth@className} \\[0.1cm] % Class/Course name
  392. {\Large \bfseries \auth@docTitle} \\[0.2cm] % Document/Assignement Title
  393. {\large \bfseries \auth@docSubTitle} \\[0.2cm] % Document/Assignement Sub-Title
  394. {\large \auth@date} \\[0.4cm] % date
  395. % Authors-Instructors
  396. \authInsertAuthsInstructors
  397. \end{center}
  398. }
  399. \newcommand{\InsertTitle}{%
  400. \ifnum \isequal{\auth@short}{no}=0
  401. \authTitlePage
  402. \else
  403. \authTitleHeader
  404. \fi
  405. }
  406. % \InsertFigure{}{}{}{}{}
  407. % [1]: Position specifier
  408. % [2]: scale
  409. % [3]: Label
  410. % [4]: Figure file
  411. % [5]: Caption text
  412. % example: \InsertFigure{!h}{0.8}{fig:lala}{lala.png}{\eng{Makes lala}}
  413. \newcommand{\InsertFigure}[5]{
  414. \begin{figure}[#1]
  415. \captionsetup{format=plain}
  416. \centering
  417. \includegraphics[width=#2\textwidth]{#4}
  418. \caption{#5}
  419. \label{#3}
  420. \end{figure}
  421. }
  422. % \WrapFigure{}{}{}{}
  423. % [1]: scale
  424. % [2]: place left or right r,l,R,L
  425. % [3]: Label
  426. % [4]: Figure file
  427. % [5]: Caption text
  428. % example: \WrapFigure{0.8}{r}{fig:lala}{lala.png}{\eng{Makes lala}}
  429. \newcommand{\WrapFigure}[5]{
  430. \begin{wrapfigure}{#2}{#1\textwidth}
  431. \vspace{-20pt}
  432. \begin{center}
  433. \captionsetup{format=plain}
  434. \includegraphics[width=#1\textwidth]{#4}
  435. \caption{#5}
  436. \label{#3}
  437. \end{center}
  438. \vspace{-20pt}
  439. \end{wrapfigure}
  440. }