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

AUThReport.cls 14 KiB

2 个月前
2 个月前
2 个月前
2 个月前
2 个月前
2 个月前
2 个月前
2 个月前
2 个月前
2 个月前
2 个月前
2 个月前
2 个月前
2 个月前
2 个月前
2 个月前
2 个月前
2 个月前
2 个月前
2 个月前
2 个月前
2 个月前
2 个月前
2 个月前
2 个月前
2 个月前
2 个月前
2 个月前
2 个月前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526
  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. \setmonofont{CMU Typewriter Text}
  176. % \setmonofont{Courier New}
  177. \fi
  178. }
  179. % Header and Footer
  180. % =====================================================
  181. \newcommand*{\authSetFooterEmpty}{%
  182. % Clear styles
  183. \fancyfoot{}
  184. \renewcommand{\footrulewidth}{0pt}
  185. }
  186. \newcommand*{\authSetFooter}{%
  187. % Clear styles
  188. \fancyfoot{}
  189. \fancyfoot[C]{\thepage}
  190. \renewcommand{\footrulewidth}{0pt}
  191. \pagenumbering{arabic}
  192. }
  193. \newcommand{\authSetHeaderEmpty}{
  194. % Clear styles
  195. \fancyhead{}
  196. \renewcommand{\headrulewidth}{0pt}
  197. }
  198. \newcommand{\authSetHeader}{
  199. % Clear styles
  200. \fancyhead{}
  201. \fancyhead[L]{\auth@className}
  202. \fancyhead[R]{\auth@docTitle}
  203. \renewcommand{\headrulewidth}{0.5pt}
  204. }
  205. %
  206. % Page styles
  207. %
  208. \fancypagestyle{plain}{%
  209. % Style for the main document (including TOC)
  210. \authSetFooter
  211. \authSetHeader
  212. }
  213. \fancypagestyle{authTitlePageStyle}{%
  214. % Style for Title page
  215. \authSetHeaderEmpty
  216. \ifnum \isequal{\auth@short}{no}=0
  217. \authSetFooterEmpty
  218. \else
  219. \authSetFooter
  220. \fi
  221. }
  222. % Common Page style
  223. \newcommand{\authPageStyle}{%
  224. \renewcommand{\bottomtitlespace}{0.12\textheight}
  225. % Change the look of the section and subsection titles
  226. \titleformat{\section}[block]{\large\scshape}{\thesection.}{1em}{}
  227. \titleformat{\subsection}[block]{\large}{\thesubsection.}{1em}{}
  228. \titleformat{\subsubsection}[block]{\normalsize}{\thesubsubsection.}{1em}{}
  229. %\setlist[itemize]{noitemsep} % Make itemize lists more compact
  230. \setlist[itemize]{topsep=6pt, partopsep=0pt, itemsep=3pt, parsep=3pt}
  231. % Set paragraph identation and skip
  232. \setlength{\parindent}{0pt}
  233. \setlength{\parskip}{0.3em}
  234. }
  235. % Setup theme
  236. % =====================================================
  237. \hypersetup{
  238. colorlinks=true,
  239. linkcolor=red, % Internal links, those generated by cross-referenced elements
  240. filecolor=blue, % Links to local files
  241. urlcolor=blue % Links to web sites
  242. }
  243. \AtBeginDocument{%
  244. % Fonts
  245. \authSetupFontEnv
  246. % Language
  247. \authSetupLanguageEnv % After fonts
  248. % Page layout (check above for the geometry setup)
  249. \authSetPageLayout
  250. %hyphenation settiongs
  251. \lefthyphenmin=2 % minimum characters before
  252. \righthyphenmin=2 % minimum characters after
  253. % Header - Footer
  254. \pagestyle{plain}
  255. \thispagestyle{authTitlePageStyle}
  256. % Page styles and formating
  257. \authPageStyle
  258. \normalsize
  259. } % End \AtBeginDocument
  260. % Public environments/commands
  261. % =====================================================
  262. % Common fields
  263. % =====================================================
  264. \newcommand*{\AuthorName}[1]{\def\auth@authorName{#1}}
  265. \newcommand*{\AuthorMail}[1]{\def\auth@authorMail{#1}}
  266. \newcommand*{\AuthorAEM}[1]{\def\auth@authorAEM{#1}}
  267. \newcommand*{\CoAuthorName}[1]{\def\auth@coauthorName{#1}}
  268. \newcommand*{\CoAuthorMail}[1]{\def\auth@coauthorMail{#1}}
  269. \newcommand*{\CoAuthorAEM}[1]{\def\auth@coauthorAEM{#1}}
  270. \newcommand*{\WorkGroup}[1]{\def\auth@workGroup{#1}}
  271. \newcommand*{\DocTitle}[1]{\def\auth@docTitle{#1}}
  272. \newcommand*{\DocSubTitle}[1]{\def\auth@docSubTitle{#1}}
  273. \newcommand*{\Department}[1]{\def\auth@department{#1}}
  274. \newcommand*{\ClassName}[1]{\def\auth@className{#1}}
  275. \newcommand*{\InstructorName}[1]{\def\auth@instructorName{#1}}
  276. \newcommand*{\InstructorMail}[1]{\def\auth@instructorMail{#1}}
  277. \newcommand*{\CoInstructorName}[1]{\def\auth@coinstructorName{#1}}
  278. \newcommand*{\CoInstructorMail}[1]{\def\auth@coinstructorMail{#1}}
  279. \newcommand*{\CurrentDate}[1]{\def\auth@date{#1}}
  280. % Language
  281. % =====================================================
  282. \newcommand{\authSetMainLanguage}[1]{%
  283. \renewcommand{\auth@mainlanguage}{#1}
  284. }
  285. \newcommand{\authSetLanguages}[1]{%
  286. \renewcommand{\auth@languages}{#1}
  287. }
  288. % \eng{}
  289. % syntactic suggar for english text inside greek
  290. % example \eng{A quick brown fox jumpedover the lazy dog}
  291. \newcommand{\eng}[1]{%
  292. \ifPDFTeX
  293. \foreignlanguage{english}{#1}
  294. \else
  295. #1
  296. \fi
  297. }
  298. % \gr{}
  299. % syntactic suggar for greek text inside english
  300. % example \gr{Άσπρη πέτρα ξέξασπρη κι απτον ήλιο ξεξασπρότερη}
  301. \newcommand{\gr}[1]{%
  302. \ifPDFTeX
  303. \foreignlanguage{greek}{#1}
  304. \else
  305. #1
  306. \fi
  307. }
  308. % \setEnglish
  309. % Selects english for the rest of the text
  310. \newcommand{\setEnglish}{%
  311. \ifPDFTeX \selectlanguage{english} \typeout{[DEBUG] set Eng} \else \typeout{[DEBUG] No set Eng}\fi
  312. }
  313. % \setGreek
  314. % Selects greek for the rest of the text
  315. \newcommand{\setGreek}{%
  316. \ifPDFTeX \selectlanguage{greek} \typeout{[DEBUG] set Gre}\else \typeout{[DEBUG] NO set Gre} \fi
  317. }
  318. % Content commands
  319. % =====================================================
  320. \newcommand{\authInsertAuthsInstructors}{%
  321. \center
  322. \noindent
  323. % Authors
  324. \hspace*{0.05\textwidth}
  325. \begin{minipage}[t]{0.35\textwidth}
  326. \begin{flushleft}
  327. \large
  328. \ifdefined \auth@workGroup \emph{\textsc{\auth@workGroup}} \\[2ex]\fi
  329. \emph{\authAuthorTitleText:} \\
  330. \auth@authorName\hspace{1ex}[\auth@authorAEM] \\[0.35ex]
  331. \normalsize \authMailText{\auth@authorMail} \\[2ex]
  332. \large
  333. \ifdefined \auth@coauthorName
  334. \auth@coauthorName\hspace{1ex}[\auth@coauthorAEM] \\[0.35ex]
  335. \normalsize \authMailText{\auth@coauthorMail} \\[2ex]
  336. \fi
  337. \end{flushleft}
  338. \end{minipage}
  339. \hfill
  340. % Instructors
  341. \begin{minipage}[t]{0.35\textwidth}
  342. \begin{flushright}
  343. \large
  344. \emph{\authInstructorTitleText:} \\
  345. \auth@instructorName \\[0.35ex]
  346. \normalsize \authMailText{\auth@instructorMail} \\[2ex]
  347. \large
  348. \ifdefined \auth@coinstructorName
  349. \auth@coinstructorName \\[0.35ex]
  350. \normalsize \authMailText{\auth@coinstructorMail} \\[2ex]
  351. \fi
  352. \end{flushright}
  353. \end{minipage}
  354. \hspace*{0.05\textwidth}
  355. }
  356. % \FirstPage
  357. \newcommand{\authTitlePage}{%
  358. \begin{titlepage}
  359. % Logo
  360. \begin{figure}
  361. \begin{flushleft}
  362. \includegraphics[width=5cm]{img/auth_logogr.png}
  363. \end{flushleft}
  364. \end{figure}
  365. % Titles
  366. \center % Center everything on the page
  367. \textbf{} \\[3.5cm] % vertical space
  368. \textsc{\Large \auth@department} \\[0.5cm] % Department
  369. \textsc{\Large \auth@className} \\[1.5cm] % Class/Course name
  370. \Hrule \\[0.4cm] % -------
  371. {\huge \bfseries \auth@docTitle} \\[0.4cm] % Document/Assignement Title
  372. {\LARGE \bfseries \auth@docSubTitle} \\[0.1cm] % Document/Assignement Sub-Title
  373. \Hrule \\[3.5cm] % -------
  374. % Authors-Instructors
  375. \authInsertAuthsInstructors
  376. \vfill
  377. {\large \auth@date} \\ % date
  378. \end{titlepage}
  379. \newpage
  380. }
  381. % \TitleHeader
  382. \newcommand{\authTitleHeader}{%
  383. \begin{center} % Center everything on the page
  384. % Logo
  385. \noindent
  386. \begin{figure}
  387. \vspace{-0.8cm}
  388. \center
  389. \includegraphics[width=5cm]{img/auth_logogr.png}
  390. \end{figure}
  391. % Titles
  392. \textsc{\Large \auth@department} \\[0.4cm] % Department
  393. \textsc{\Large \auth@className} \\[0.1cm] % Class/Course name
  394. {\Large \bfseries \auth@docTitle} \\[0.2cm] % Document/Assignement Title
  395. {\large \bfseries \auth@docSubTitle} \\[0.2cm] % Document/Assignement Sub-Title
  396. {\large \auth@date} \\[0.4cm] % date
  397. % Authors-Instructors
  398. \authInsertAuthsInstructors
  399. \end{center}
  400. }
  401. \newcommand{\InsertTitle}{%
  402. \ifnum \isequal{\auth@short}{no}=0
  403. \authTitlePage
  404. \else
  405. \authTitleHeader
  406. \fi
  407. }
  408. % \InsertFigure{}{}{}{}{}
  409. % [1]: Position specifier
  410. % [2]: scale
  411. % [3]: Label
  412. % [4]: Figure file
  413. % [5]: Caption text
  414. % example: \InsertFigure{!h}{0.8}{fig:lala}{lala.png}{\eng{Makes lala}}
  415. \newcommand{\InsertFigure}[5]{
  416. \begin{figure}[#1]
  417. \captionsetup{format=plain}
  418. \centering
  419. \includegraphics[width=#2\textwidth]{#4}
  420. \caption{#5}
  421. \label{#3}
  422. \end{figure}
  423. }
  424. % \WrapFigure{}{}{}{}
  425. % [1]: scale
  426. % [2]: place left or right r,l,R,L
  427. % [3]: Label
  428. % [4]: Figure file
  429. % [5]: Caption text
  430. % example: \WrapFigure{0.8}{r}{fig:lala}{lala.png}{\eng{Makes lala}}
  431. \newcommand{\WrapFigure}[5]{
  432. \begin{wrapfigure}{#2}{#1\textwidth}
  433. \vspace{-20pt}
  434. \begin{center}
  435. \captionsetup{format=plain}
  436. \includegraphics[width=#1\textwidth]{#4}
  437. \caption{#5}
  438. \label{#3}
  439. \end{center}
  440. \vspace{-20pt}
  441. \end{wrapfigure}
  442. }