AUTh Report LaTeX/XeLaTeX class
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

645 rindas
17 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. \RequirePackage{iftex}
  12. \RequirePackage{xkeyval}
  13. % Options
  14. % ===============================================
  15. % Default options
  16. \newcommand{\auth@mainlanguage}{english} % Default main language
  17. \newcommand{\auth@languages}{none} % Default list of additional languages
  18. \def\auth@short{no} % Default value for the "short" option
  19. \newcommand{\none}{none} % For comparison checks
  20. % Language append tool for option process
  21. \newcommand{\authSetupLanguageOption}[1]{%
  22. \ifx\auth@languages\none
  23. \gdef\auth@languages{#1}%
  24. \else
  25. \edef\auth@languages{\auth@languages, #1}%
  26. \fi
  27. }
  28. %
  29. % Set the default language of the document which affects:
  30. % - hyphenations
  31. % - Localization (section, dates, etc...)
  32. %
  33. % Usage: mainlang=<language>
  34. % Default: english
  35. %
  36. % example: \documentclass[mainlang=greek]{AUThReport}
  37. %
  38. \DeclareOptionX{mainlang}{
  39. \def\auth@mainlanguage{#1}
  40. }
  41. \ProcessOptionsX\relax
  42. %
  43. % Add hyphenation and typesetting support for other languages
  44. % Currently supports: english, greek, german, french
  45. %
  46. % Usage: <language>
  47. %
  48. % example: \documentclass[english, greek]{AUThReport}
  49. %
  50. \DeclareOption{english}{\authSetupLanguageOption{english}}
  51. \DeclareOption{greek}{\authSetupLanguageOption{greek}}
  52. \DeclareOption{french}{\authSetupLanguageOption{french}}
  53. \DeclareOption{german}{\authSetupLanguageOption{german}}
  54. %
  55. % Requests a shorter title for the document
  56. %
  57. % Usage: short
  58. % Default: no short
  59. %
  60. % example: \documentclass[short]{AUThReport}
  61. %
  62. \DeclareOption{short}{\def\auth@short{yes}}
  63. % Pass all other options to article
  64. \DeclareOption*{%
  65. \PassOptionsToClass{\CurrentOption}{article}%
  66. }
  67. \ProcessOptions\relax
  68. \LoadClass{article}
  69. % Requirements
  70. % ===============================================
  71. % Font packages
  72. \ifPDFTeX
  73. \RequirePackage[LGR, T1]{fontenc} % ToDo: find a way to dynamicaly select encoding based on languages
  74. \RequirePackage[utf8]{inputenc}
  75. \RequirePackage{lmodern}
  76. \else
  77. \RequirePackage{fontspec}
  78. \fi
  79. % Language packages
  80. \ifPDFTeX
  81. % Postponed to Pre-Begin hook
  82. % \usepackage{babel}
  83. \else
  84. \RequirePackage{polyglossia}%
  85. \fi
  86. \RequirePackage{xargs} % Commands
  87. \RequirePackage{geometry} % Layout
  88. \RequirePackage{fancyhdr}
  89. \RequirePackage{graphicx} % Figures
  90. \RequirePackage{tikz}
  91. % Format packages
  92. \RequirePackage[hang, small,labelfont=bf,up,textfont=it,up]{caption} % Custom captions under/above floats in tables or figures
  93. %\RequirePackage{caption}
  94. \RequirePackage[nobottomtitles]{titlesec}
  95. \RequirePackage{titling}
  96. \RequirePackage[bottom]{footmisc} % Place footnotes always as much to the bottom as possible.
  97. \RequirePackage{hyperref} % Various
  98. \RequirePackage[ddmmyyyy]{datetime}
  99. \RequirePackage{enumitem}
  100. \RequirePackage{multicol}
  101. % Local Tools
  102. % ===============================================
  103. % Tool to check equality
  104. \newcommand{\isequal}[2]{ \pdf@strcmp{#1}{#2} }
  105. % syntactic suggar for horizaontal rule
  106. \newcommand{\Hrule}[1]{ \rule{\linewidth}{#1} }
  107. % Dispatch between the right author(s) caption text for document title
  108. \newcommand{\authAuthorTitleText}{%
  109. \ifnum \isequal{\auth@mainlanguage}{greek}=0
  110. \ifdefined \auth@coauthorName Συντάκτες\else Συντάκτης\fi
  111. \else
  112. \ifdefined \auth@coauthorName Authors\else Author\fi
  113. \fi
  114. }
  115. % Dispatch between the right instructor(s) caption text for document title
  116. \newcommand{\authInstructorTitleText}{%
  117. \ifnum \isequal{\auth@mainlanguage}{greek}=0
  118. \ifdefined \auth@coinstructorName Διδάσκοντες\else Διδάσκων\fi
  119. \else
  120. \ifdefined \auth@coinstructorName Instructors\else Instructor\fi
  121. \fi
  122. }
  123. % Handle the language command for email href for document title
  124. \newcommand{\authMailText}[1]{%
  125. \ifnum \isequal{\auth@mainlanguage}{greek}=0
  126. \href{mailto:#1}{\eng{#1}}
  127. \else
  128. \href{mailto:#1}{#1}
  129. \fi
  130. }
  131. % Language
  132. % ===============================================
  133. %
  134. % Language setup functionality to use at the end of class.
  135. %
  136. % It uses either babel to register the languages(pdflatex) or
  137. % polyglossia (already included) to setup default and other languages
  138. %
  139. \newcommand{\authSetupLanguageEnv}{%
  140. \ifPDFTeX
  141. \ifnum \isequal{\auth@languages}{none}=0
  142. \usepackage[\auth@mainlanguage]{babel}
  143. \else
  144. \usepackage[\auth@languages, main=\auth@mainlanguage]{babel}
  145. \fi
  146. \else
  147. % Set main language
  148. \setdefaultlanguage{\auth@mainlanguage}%
  149. % Set other languages
  150. \@for\auth@lang:=\auth@languages\do{%
  151. \setotherlanguage{\auth@lang}
  152. }%
  153. \fi
  154. }
  155. % Theme
  156. % ===============================================
  157. % Layout
  158. % =====================================================
  159. % Page core layout settings (include head and foot)
  160. % A4 will result to:
  161. % Top margin: 12mm
  162. % Bottom margin: 11mm
  163. % Head hight: 14mm
  164. % Foot skip: 15mm
  165. % Left margin: 15mm
  166. % Right margin: 12mm
  167. \newcommand{\authTopMargin}{12mm}
  168. \newcommand{\authBottomMargin}{12mm}
  169. \newcommand{\authHeadHeight}{10mm}
  170. \newcommand{\authFootSkip}{10mm}
  171. \newcommand{\authLeftMargin}{15mm}
  172. \newcommand{\authRightMargin}{15mm}
  173. %
  174. % Sets page layout. (include head and foot)
  175. \newcommand*{\authSetPageLayout}{%
  176. \newgeometry{%
  177. includeheadfoot,
  178. top= \authTopMargin,
  179. bottom= \authBottomMargin,
  180. headheight= \authHeadHeight,
  181. footskip= \authFootSkip,
  182. lmargin= \authLeftMargin,
  183. rmargin= \authRightMargin
  184. }
  185. }
  186. % Fonts
  187. % =====================================================
  188. %
  189. % Setup fonts (computer modern)
  190. %
  191. \newcommand{\authSetupFontEnv}{%
  192. \ifPDFTeX
  193. % PDFLaTeX fonts
  194. \else
  195. % \setmainfont{CMU-Serif-Roman}[%
  196. %% Path=~/texmf/tex/latex/local/AUThReport/cmu/,
  197. % ItalicFont = CMU-Serif-Italic,
  198. % BoldFont = CMU-Serif-Bold,
  199. % BoldItalicFont= CMU-Serif-BoldItalic
  200. % ]
  201. % \setsansfont{CMU-Sans-Medium}[%
  202. %% Path=~/texmf/tex/latex/local/AUThReport/cmu/,
  203. % ItalicFont = CMU-Sans-Oblique,
  204. % BoldFont = CMU-Sans-Bold,
  205. % BoldItalicFont= CMU-Sans-BoldOblique
  206. % ]
  207. % %\setsansfont{CMU-Concrete-Roman}[%
  208. % % Path=~/texmf/tex/latex/local/AUThReport/cmu/,
  209. % % ItalicFont = CMU-Concrete-Italic,
  210. % % BoldFont = CMU-Concrete-Bold,
  211. % % BoldItalicFont= CMU-Concrete-BoldItalic
  212. % %]
  213. % \setmonofont{CMU-Typewriter-Regular}[%
  214. %% Path=~/texmf/tex/latex/local/AUThReport/cmu/,
  215. % ItalicFont = CMU-Typewriter-Oblique,
  216. % BoldFont = CMU-Typewriter-Bold,
  217. % BoldItalicFont= CMU-Typewriter-Oblique
  218. % ]
  219. % \typeout{[DEBUG] set fonts}
  220. \setmainfont{CMU Serif}
  221. \setsansfont{CMU Sans Serif}
  222. \setmonofont{CMU Typewriter Text}
  223. % \setmonofont{Courier New}
  224. \fi
  225. }
  226. % Header and Footer
  227. % =====================================================
  228. %
  229. % Clear footer command
  230. %
  231. \newcommand*{\authSetFooterEmpty}{%
  232. % Clear styles
  233. \fancyfoot{}
  234. \renewcommand{\footrulewidth}{0pt}
  235. }
  236. %
  237. % Setup footer according to theme
  238. %
  239. \newcommand*{\authSetFooter}{%
  240. % Clear styles
  241. \fancyfoot{}
  242. \fancyfoot[C]{\thepage}
  243. \renewcommand{\footrulewidth}{0pt}
  244. \pagenumbering{arabic}
  245. }
  246. %
  247. % Clear header command
  248. %
  249. \newcommand{\authSetHeaderEmpty}{
  250. % Clear styles
  251. \fancyhead{}
  252. \renewcommand{\headrulewidth}{0pt}
  253. }
  254. %
  255. % Setup header according to theme
  256. %
  257. \newcommand{\authSetHeader}{
  258. % Clear styles
  259. \fancyhead{}
  260. \fancyhead[L]{\auth@className}
  261. \fancyhead[R]{\auth@docTitle}
  262. \renewcommand{\headrulewidth}{0.5pt}
  263. }
  264. %
  265. % Page styles
  266. %
  267. % Plain: the main style of the document (including TOC if any)
  268. \fancypagestyle{plain}{%
  269. \authSetFooter
  270. \authSetHeader
  271. }
  272. % authTitlePageStyle: The style for the title page
  273. \fancypagestyle{authTitlePageStyle}{%
  274. % Style for Title page
  275. \authSetHeaderEmpty
  276. \ifnum \isequal{\auth@short}{no}=0
  277. \authSetFooterEmpty
  278. \else
  279. \authSetFooter
  280. \fi
  281. }
  282. % Page content look and feel style
  283. \newcommand{\authPageStyle}{%
  284. \renewcommand{\bottomtitlespace}{0.12\textheight}
  285. % Change the look of the section and subsection titles
  286. \titleformat{\section}[block]{\large\scshape}{\thesection.}{1em}{}
  287. \titleformat{\subsection}[block]{\large}{\thesubsection.}{1em}{}
  288. \titleformat{\subsubsection}[block]{\normalsize}{\thesubsubsection.}{1em}{}
  289. %\setlist[itemize]{noitemsep} % Make itemize lists more compact
  290. \setlist[itemize]{topsep=6pt, partopsep=0pt, itemsep=3pt, parsep=3pt}
  291. % Set paragraph identation and skip
  292. \setlength{\parindent}{0pt}
  293. \setlength{\parskip}{0.3em}
  294. }
  295. % Setup theme
  296. % =====================================================
  297. \AtEndOfClass{%
  298. \hypersetup{
  299. colorlinks=true,
  300. linkcolor=red, % Internal links, those generated by cross-referenced elements
  301. filecolor=blue, % Links to local files
  302. urlcolor=blue % Links to web sites
  303. }
  304. % Language and fonts
  305. \ifPDFTeX
  306. \authSetupLanguageEnv % Before fonts
  307. \authSetupFontEnv
  308. \else
  309. \authSetupFontEnv
  310. \authSetupLanguageEnv % After fonts
  311. \fi
  312. \typeout{[AUThReport] Main language: \auth@mainlanguage}
  313. \typeout{[AUThReport] Other languages: \auth@languages}
  314. \typeout{[AUThReport] Short title: \auth@short}
  315. }
  316. \AtBeginDocument{%
  317. % Page layout (check above for the geometry setup)
  318. \authSetPageLayout
  319. %hyphenation settiongs
  320. \lefthyphenmin=2 % minimum characters before
  321. \righthyphenmin=2 % minimum characters after
  322. % ToDo:
  323. % Something wrong is going on with fancy header for LaTeX
  324. % In greek (main) the text are in the wrong language configurations
  325. % Header - Footer
  326. \pagestyle{plain}
  327. \thispagestyle{authTitlePageStyle}
  328. % Page styles and formating
  329. \authPageStyle
  330. \normalsize
  331. } % End \AtBeginDocument
  332. % Public environments/commands
  333. % =====================================================
  334. % Common fields
  335. % =====================================================
  336. \newcommand*{\AuthorName}[1]{\def\auth@authorName{#1}}
  337. \newcommand*{\AuthorMail}[1]{\def\auth@authorMail{#1}}
  338. \newcommand*{\AuthorAEM}[1]{\def\auth@authorAEM{#1}}
  339. \newcommand*{\CoAuthorName}[1]{\def\auth@coauthorName{#1}}
  340. \newcommand*{\CoAuthorMail}[1]{\def\auth@coauthorMail{#1}}
  341. \newcommand*{\CoAuthorAEM}[1]{\def\auth@coauthorAEM{#1}}
  342. \newcommand*{\WorkGroup}[1]{\def\auth@workGroup{#1}}
  343. \newcommand*{\DocTitle}[1]{\def\auth@docTitle{#1}}
  344. \newcommand*{\DocSubTitle}[1]{\def\auth@docSubTitle{#1}}
  345. \newcommand*{\Department}[1]{\def\auth@department{#1}}
  346. \newcommand*{\ClassName}[1]{\def\auth@className{#1}}
  347. \newcommand*{\InstructorName}[1]{\def\auth@instructorName{#1}}
  348. \newcommand*{\InstructorMail}[1]{\def\auth@instructorMail{#1}}
  349. \newcommand*{\CoInstructorName}[1]{\def\auth@coinstructorName{#1}}
  350. \newcommand*{\CoInstructorMail}[1]{\def\auth@coinstructorMail{#1}}
  351. \newcommand*{\CurrentDate}[1]{\def\auth@date{#1}}
  352. % Language manipulation commands
  353. % =====================================================
  354. % \eng{}
  355. % syntactic suggar for english text inside greek
  356. % example \eng{A quick brown fox jumpedover the lazy dog}
  357. \newcommand{\eng}[1]{%
  358. \ifPDFTeX
  359. \foreignlanguage{english}{#1}
  360. \else
  361. #1
  362. \fi
  363. }
  364. % \gr{}
  365. % syntactic suggar for greek text inside english
  366. % example \gr{Άσπρη πέτρα ξέξασπρη κι απτον ήλιο ξεξασπρότερη}
  367. \newcommand{\gr}[1]{%
  368. \ifPDFTeX
  369. \foreignlanguage{greek}{#1}
  370. \else
  371. #1
  372. \fi
  373. }
  374. % \setEnglish
  375. % Selects english for the rest of the text
  376. \newcommand{\setEnglish}{%
  377. \ifPDFTeX \selectlanguage{english} \fi
  378. }
  379. % \setGreek
  380. % Selects greek for the rest of the text
  381. \newcommand{\setGreek}{%
  382. \ifPDFTeX \selectlanguage{greek} \fi
  383. }
  384. % Content commands
  385. % =====================================================
  386. %
  387. %
  388. %
  389. \newcommand{\authInsertAuthsInstructors}{%
  390. \center
  391. \noindent
  392. % Authors
  393. \hspace*{0.05\textwidth}
  394. \begin{minipage}[t]{0.35\textwidth}
  395. \begin{flushleft}
  396. \large
  397. \ifdefined \auth@workGroup \emph{\textsc{\auth@workGroup}} \\[2ex]\fi
  398. \emph{\authAuthorTitleText:} \\
  399. \auth@authorName\hspace{1ex}[\auth@authorAEM] \\[0.35ex]
  400. \normalsize \authMailText{\auth@authorMail} \\[2ex]
  401. \large
  402. \ifdefined \auth@coauthorName
  403. \auth@coauthorName\hspace{1ex}[\auth@coauthorAEM] \\[0.35ex]
  404. \normalsize \authMailText{\auth@coauthorMail} \\[2ex]
  405. \fi
  406. \end{flushleft}
  407. \end{minipage}
  408. \hfill
  409. % Instructors
  410. \begin{minipage}[t]{0.35\textwidth}
  411. \begin{flushright}
  412. \large
  413. \emph{\authInstructorTitleText:} \\
  414. \auth@instructorName \\[0.35ex]
  415. \normalsize \authMailText{\auth@instructorMail} \\[2ex]
  416. \large
  417. \ifdefined \auth@coinstructorName
  418. \auth@coinstructorName \\[0.35ex]
  419. \normalsize \authMailText{\auth@coinstructorMail} \\[2ex]
  420. \fi
  421. \end{flushright}
  422. \end{minipage}
  423. \hspace*{0.05\textwidth}
  424. }
  425. % \FirstPage
  426. \newcommand{\authTitlePage}[3]{%
  427. \begin{titlepage}
  428. % Logo
  429. \begin{figure}
  430. \begin{flushleft}
  431. \vspace{-1cm}
  432. \includegraphics[width=5cm]{img/auth_logogr.png}
  433. \end{flushleft}
  434. \end{figure}
  435. \ifnum \isequal{#1}{none}=0 \else
  436. \begin{tikzpicture}[remember picture, overlay]
  437. \node[anchor=center, opacity=0.25] at ([yshift=#3] current page.center) {
  438. \includegraphics[width=#2]{#1}
  439. };
  440. \end{tikzpicture}
  441. \fi
  442. % Titles
  443. \center
  444. \textbf{} \\[1cm] % vertical space
  445. \textsc{\Large \auth@department} \\[0.5cm] % Department
  446. \textsc{\Large \auth@className} \\[4.0cm] % Class/Course name
  447. \begin{flushleft}
  448. {\huge \bfseries \auth@docTitle} \\[0.4cm] % Document/Assignement Title
  449. {\LARGE \bfseries \auth@docSubTitle} \\[0.1cm] % Document/Assignement Sub-Title
  450. \Hrule{0.2mm} \\ % -------
  451. \end{flushleft}
  452. \vfill
  453. % Authors-Instructors
  454. \authInsertAuthsInstructors \\
  455. \vspace{1.5cm}
  456. {\large \auth@date} \\ % date
  457. \end{titlepage}
  458. \newpage
  459. }
  460. % \TitleHeader
  461. \newcommand{\authTitleHeader}{%
  462. \begin{center} % Center everything on the page
  463. % Logo
  464. \noindent
  465. \begin{figure}
  466. \vspace{-1.5cm}
  467. \center
  468. \includegraphics[width=5cm]{img/auth_logogr.png}
  469. \end{figure}
  470. % Titles
  471. \textsc{\Large \auth@department} \\[0.4cm] % Department
  472. \textsc{\Large \auth@className} \\[0.8cm] % Class/Course name
  473. {\Large \bfseries \auth@docTitle} \\[0.2cm] % Document/Assignement Title
  474. {\large \bfseries \auth@docSubTitle} \\[0.2cm] % Document/Assignement Sub-Title
  475. {\large \auth@date} \\[0.4cm] % date
  476. % Authors-Instructors
  477. \authInsertAuthsInstructors
  478. \end{center}
  479. }
  480. %
  481. % Inserts titles, author(s), instructor(s) as a first page or header
  482. %
  483. % [1]: Optional background image
  484. % [2]: Optional width of the image (if argument 1 is used)
  485. % [3]: Optional y shift for image positioning (if argument 1 is used)
  486. %
  487. % examples:
  488. % - \InsertFigure
  489. % - \InsertFigure[myBackgroung]
  490. % - \InsertFigure[myBackgroung][0.9\textwidth][2cm]
  491. %
  492. \newcommandx{\InsertTitle}[3][1=none, 2=\textwidth, 3=0mm]{%
  493. \ifnum \isequal{\auth@short}{no}=0
  494. \authTitlePage{#1}{#2}{#3}
  495. \else
  496. \authTitleHeader
  497. \fi
  498. }
  499. %
  500. % \InsertFigure{}{}{}{}{}
  501. %
  502. % [1]: Position specifier
  503. % [2]: scale
  504. % [3]: Label
  505. % [4]: Figure file
  506. % [5]: Caption text
  507. % example: \InsertFigure{!h}{0.8}{fig:lala}{lala.png}{\eng{Makes lala}}
  508. %
  509. % ToDo:
  510. % Something iswrong with InserFigures in general. In LaTeX the combination
  511. % titlepage and begin{figure} creates problems.
  512. %
  513. \newcommand{\InsertFigure}[5]{
  514. \begin{figure}[#1]
  515. \captionsetup{
  516. format=plain, % Plain format
  517. labelfont={bf,up}, % Bold and upright for label
  518. textfont={it,up}, % Italic and upright for text
  519. justification=centering,
  520. singlelinecheck=false
  521. }
  522. \centering
  523. \includegraphics[width=#2\textwidth]{#4}
  524. \caption{#5}
  525. \label{#3}
  526. \end{figure}
  527. }
  528. %
  529. % \WrapFigure{}{}{}{}
  530. %
  531. % [1]: scale
  532. % [2]: place left or right r,l,R,L
  533. % [3]: Label
  534. % [4]: Figure file
  535. % [5]: Caption text
  536. % example: \WrapFigure{0.8}{r}{fig:lala}{lala.png}{\eng{Makes lala}}
  537. \newcommand{\WrapFigure}[5]{
  538. \begin{wrapfigure}{#2}{#1\textwidth}
  539. \vspace{-20pt}
  540. \begin{center}
  541. \captionsetup{
  542. format=plain, % Plain format
  543. labelfont={bf,up}, % Bold and upright for label
  544. textfont={it,up}, % Italic and upright for text
  545. justification=centering,
  546. singlelinecheck=false
  547. }
  548. \includegraphics[width=#1\textwidth]{#4}
  549. \caption{#5}
  550. \label{#3}
  551. \end{center}
  552. \vspace{-20pt}
  553. \end{wrapfigure}
  554. }