slides.sty 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. % author Matus Necas, October 2026
  2. % original work by Jan Sumsky <jan.sumsky@gmail.com>, August 2024
  3. %
  4. % Description: High-level slide layout macros for Beamer presentations.
  5. % Provides specialized commands for title slides, table of contents,
  6. % section dividers, single-column, and two-column slide layouts.
  7. \RequirePackage{multicol}
  8. \input{organisation/info.sty} % Import user configurations and colors
  9. % ==============================================================================
  10. % DIMENSIONS CONFIGURATION
  11. % ==============================================================================
  12. \newlength{\uniTitleTopSpace}\setlength{\uniTitleTopSpace}{42pt} % Top spacing for title slides
  13. \newlength{\uniTitleSubtitleGap}\setlength{\uniTitleSubtitleGap}{15pt} % Gap between title and subtitle
  14. \newlength{\uniTitleAuthorGap}\setlength{\uniTitleAuthorGap}{10pt} % Gap before author (standard title)
  15. \newlength{\uniColorAuthorGap}\setlength{\uniColorAuthorGap}{10pt} % Gap before author (colored title)
  16. \newlength{\uniColumnIndent}\setlength{\uniColumnIndent}{0.8em} % Text indentation in columns
  17. \newlength{\uniFootlineRightPad}\setlength{\uniFootlineRightPad}{3mm} % Right padding in footline
  18. \newlength{\uniColumnGap}\setlength{\uniColumnGap}{2em} % Gap between two columns
  19. % ==============================================================================
  20. % STATE SWITCH AND GLOBAL FOOTLINE TOGGLE
  21. % ==============================================================================
  22. \newif\ifuni@onstitle
  23. \uni@onstitlefalse
  24. % ==============================================================================
  25. % HELPER MACRO FOR TWO-COLUMN SLIDE
  26. % ==============================================================================
  27. % #1: Left column width ratio relative to \textwidth (e.g., 0.5)
  28. % #2: Left column content
  29. % #3: Right column content
  30. \newcommand{\uni@renderColumns}[3]{%
  31. \noindent
  32. \begin{minipage}[t]{#1\textwidth}%
  33. \setlength{\fboxsep}{0pt}%
  34. \begin{minipage}[t]{\linewidth}%
  35. #2%
  36. \end{minipage}%
  37. \end{minipage}%
  38. \hspace{\uniColumnGap}%
  39. \begin{minipage}[t]{\dimexpr\textwidth - #1\textwidth - \uniColumnGap\relax}%
  40. \setlength{\fboxsep}{0pt}%
  41. \begin{minipage}[t]{\linewidth}%
  42. #3%
  43. \end{minipage}%
  44. \end{minipage}%
  45. }
  46. % ==============================================================================
  47. % HELPER MACRO FOR TITLE TEXT
  48. % ==============================================================================
  49. % #1: Title formatting, #2: Subtitle formatting, #3: Title text, #4: Subtitle text
  50. \newcommand{\uni@renderTitleText}[4]{%
  51. #1#3%
  52. \def\uni@tempsub{#4}%
  53. \ifx\uni@tempsub\@empty
  54. \else
  55. \vspace{\uniTitleSubtitleGap}%
  56. \par
  57. #2#4%
  58. \fi
  59. }
  60. % ==============================================================================
  61. % TABLE OF CONTENTS SLIDE
  62. % ==============================================================================
  63. % #1: Number of columns (optional, default is 1)
  64. \NewDocumentCommand{\slideTableOfContents}{o}{%
  65. \uni@onstitlefalse
  66. \begin{frame}{%
  67. \contentsname%
  68. }%
  69. \IfValueTF{#1}{%
  70. \ifnum#1>1%
  71. \begin{multicols}{#1}%
  72. \tableofcontents
  73. \end{multicols}%
  74. \else%
  75. \tableofcontents%
  76. \fi%
  77. }{%
  78. \tableofcontents%
  79. }%
  80. \end{frame}%
  81. }
  82. % ==============================================================================
  83. % 2. TITLE SLIDES
  84. % ==============================================================================
  85. % Creates a standard title slide using global Beamer variables (\inserttitle, \insertsubtitle, \insertauthor).
  86. \NewDocumentCommand{\slideTitle}{}{
  87. \uni@onstitletrue
  88. \begin{frame}[c]
  89. \vspace{\uniTitleTopSpace}
  90. \noindent
  91. \begin{minipage}{\textwidth}
  92. \raggedright
  93. \uni@renderTitleText
  94. {\usebeamerfont{title}\usebeamercolor[fg]{title}}
  95. {\usebeamerfont{subtitle}\usebeamercolor[fg]{subtitle}}
  96. {\inserttitle}{\insertsubtitle}%
  97. \vspace{\uniTitleAuthorGap}%
  98. {\usebeamerfont{author}\color{colorText}\insertauthor}%
  99. \end{minipage}
  100. \end{frame}
  101. }
  102. % Creates a colored title slide with custom background canvas and vertical centering matching \slideTitle.
  103. \NewDocumentCommand{\slideTitleColor}{}{
  104. \uni@onstitletrue
  105. {
  106. \usebeamercolor{footline}
  107. \setbeamercolor{background canvas}{bg=footline.bg}
  108. \begin{frame}[c,plain]
  109. \vspace{\uniTitleTopSpace}
  110. \noindent
  111. \begin{minipage}{\textwidth}
  112. \raggedright
  113. \color{footline.fg}%
  114. \uni@renderTitleText
  115. {\usebeamerfont{title}}
  116. {\usebeamerfont{subtitle}}
  117. {\inserttitle}{\insertsubtitle}%
  118. \vspace{\uniTitleAuthorGap}%
  119. {\usebeamerfont{author}\insertauthor}%
  120. \end{minipage}
  121. \end{frame}
  122. }
  123. }
  124. % ==============================================================================
  125. % 3. SECTIONS
  126. % ==============================================================================
  127. % Creates a dedicated section divider slide with vertical centering.
  128. % * : Optional star (captured as #1) to suppress automatic section registration
  129. % #2 : Section title text (+m supports multi-line text with \\)
  130. \NewDocumentCommand{\slideSection}{s +m}{
  131. \uni@onstitlefalse
  132. \IfBooleanF{#1}{\section{#2}}
  133. \begin{frame}
  134. \vfill
  135. \begin{beamercolorbox}[leftskip=\titlelf]{section title}
  136. \usebeamerfont{section title}#2
  137. \end{beamercolorbox}
  138. \vfill
  139. \end{frame}
  140. }
  141. % Creates a dedicated section divider slide with vertical centering and subtitle.
  142. % * : Optional star (captured as #1) to suppress automatic section registration
  143. % #2 : Section title text (+m supports multi-line text with \\)
  144. % #3 : Section subtitle text (+m supports multi-line text with \\)
  145. \NewDocumentCommand{\slideSectionSubtitle}{s +m +m}{
  146. \uni@onstitlefalse
  147. \IfBooleanF{#1}{\section{#2}}
  148. \begin{frame}
  149. \vfill
  150. \begin{beamercolorbox}[leftskip=\titlelf]{section title}
  151. \usebeamerfont{section title}#2%
  152. \IfNoValueF{#3}{%
  153. \par
  154. \vspace{\uniTitleSubtitleGap}%
  155. \usebeamerfont{subtitle}\color{colorText}#3%
  156. }%
  157. \end{beamercolorbox}
  158. \vfill
  159. \end{frame}
  160. }
  161. % ==============================================================================
  162. % 4. SINGLE-COLUMN SLIDES
  163. % ==============================================================================
  164. % Creates a plain single-column slide without a frame title.
  165. % #1: Slide content (+m supports multi-line text, lists, and macros)
  166. \NewDocumentCommand{\slideOneColumnPlain}{+m}{
  167. \uni@onstitlefalse
  168. \begin{frame}
  169. #1
  170. \end{frame}
  171. }
  172. % Creates a standard single-column slide with a frame title and section handling.
  173. % * : Optional star (captured as #1) to suppress automatic section registration
  174. % #2 : Frame and section title (m)
  175. % #3 : Slide content (+m)
  176. \NewDocumentCommand{\slideOneColumn}{s m +m}{
  177. \uni@onstitlefalse
  178. \IfBooleanF{#1}{\section{#2}}
  179. \begin{frame}{#2}
  180. #3
  181. \end{frame}
  182. }
  183. % ==============================================================================
  184. % 5. TWO-COLUMN SLIDES
  185. % ==============================================================================
  186. % Creates a blank two-column slide without a frame title.
  187. % #1: Left column width ratio (e.g., 0.5 for 50%)
  188. % #2: Left column content (+m supports multi-line text and macros)
  189. % #3: Right column content (+m supports multi-line text and macros)
  190. \NewDocumentCommand{\slideTwoColumnsPlain}{m +m +m}{
  191. \uni@onstitlefalse
  192. \begin{frame}
  193. \uni@renderColumns{#1}{#2}{#3}
  194. \end{frame}
  195. }
  196. % Creates a standard two-column slide with a frame title and section handling.
  197. % * : Optional star to suppress automatic section registration
  198. % #1 : Frame and section title (m)
  199. % #2 : Left column width ratio (m)
  200. % #3 : Left column content (+m)
  201. % #4 : Right column content (+m)
  202. \NewDocumentCommand{\slideTwoColumns}{s m m +m +m}{
  203. \uni@onstitlefalse
  204. \IfBooleanF{#1}{\section{#2}}
  205. \begin{frame}{#2}
  206. \uni@renderColumns{#3}{#4}{#5}
  207. \end{frame}
  208. }