summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/tuda-ci/tudarules.sty
blob: 226dba858f6312c529662b4ee0cc922132a1ed87 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
%%
%% This is file `tudarules.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% tudarules.dtx  (with options: `package')
%% 
%% it is part of
%% TUDa-CI -- Corporate Design for TU Darmstadt
%% 
%% ----------------------------------------------------------------------------
%% 
%%   Copyright (C) 2018--2025 by Marei Peischl <marei@peitex.de>
%% 
%% ============================================================================
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3c
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%% http://www.latex-project.org/lppl.txt
%% and version 1.3c or later is part of all distributions of LaTeX
%% version 2008/05/04 or later.
%% 
%% This work has the LPPL maintenance status `maintained'.
%% 
%% The Current Maintainer of this work is
%%   Marei Peischl <tuda-ci@peitex.de>
%% 
%% The development repository can be found at
%% https://github.com/tudace/tuda_latex_templates
%% Please use the issue tracker for feedback!
%% 
%% ============================================================================
%% 
\NeedsTeXFormat{LaTeX2e}[2020/10/01]
\ProvidesExplPackage{tudarules}{2025-01-26}{4.00}{Creation of colored bars for the tuda-ci bundle}
\str_if_exist:NF \g_ptxcd_department_str {
  \str_new:N \g_ptxcd_department_str
  \str_gset:Nn \g_ptxcd_department_str {default}
}
\bool_new:N \g_ptxcd_simple_rules_bool
\dim_new:N \g_ptxcd_titlerule_dim
\seq_if_exist:NF \l_ptxcd_tmpa_seq {\seq_new:N \l_ptxcd_tmpa_seq}
\tl_if_exist:NF \l_ptxcd_tmpa_tk {\tl_new:N \l_ptxcd_tmpa_tl}
\cs_new:Nn \ptxcd_rules_set_values:n {
  \seq_set_split:Nnn \l_ptxcd_tmpa_seq {|} {#1}
  \int_step_inline:nnnn {1}  {1} {4} {
    \tl_set:Nn \l_ptxcd_tmpa_tl {c_ptxcd_
      \clist_item:nn {largerule, rulesep, smallrule, logoheight} {##1}
      _dim}
    \dim_if_exist:cT {\l_ptxcd_tmpa_tl} {\cs_undefine:c {\l_ptxcd_tmpa_tl}}
    \dim_const:cn {\l_ptxcd_tmpa_tl} {\seq_item:Nn \l_ptxcd_tmpa_seq {##1}}
  }
  \dim_gset:Nn \g_ptxcd_titlerule_dim {.5\c_ptxcd_smallrule_dim}
}
\keys_define:nn {ptxcd/rules} {
  color .tl_gset:N = \g_ptxcd_rules_color_tl,
  blackrule .meta:n = {color=black},
  paper .choice:,
  paper/dl .code:n = { \ptxcd_rules_set_values:n  { 3.5mm | 1.4mm | 1.2pt | 17  mm | 0.6pt| 10mm | 14mm}},
  paper/a6 .code:n = { \ptxcd_rules_set_values:n  { 3  mm | 1.4mm | 1.2pt | 16.5mm | 0.6pt| 10mm | 15mm}},
  paper/a5 .code:n = { \ptxcd_rules_set_values:n { 3.3mm | 1.4mm | 1.2pt | 19  mm | 0.6pt| 12mm | 16mm}},
  paper/a4 .code:n = { \ptxcd_rules_set_values:n  { 4  mm | 1.4mm | 1.2pt | 22  mm | 0.6pt| 15mm | 20mm}},
  paper/a3 .code:n = { \ptxcd_rules_set_values:n  { 4.5mm | 1.4mm | 1.2pt | 24.5mm | 0.6pt| 15mm | 20mm}},
  paper/a2 .code:n = { \ptxcd_rules_set_values:n  { 8  mm | 2.5mm | 2.2pt | 44.5mm | 1.1pt| 30mm | 35mm}},
  paper/a1 .code:n = { \ptxcd_rules_set_values:n { 10 mm | 3.0mm | 2.8pt | 55.5mm | 1.4pt| 30mm | 35mm}},
  paper/a0 .code:n = { \ptxcd_rules_set_values:n  { 16 mm | 5.2mm | 4.8pt | 80  mm | 2.4pt| 30mm | 35mm}},
  paper/slide .code:n = { \ptxcd_rules_set_values:n  { 2mm | .7mm | .6pt | 11 mm | .3pt| 7.5mm | 10mm}},
  paper/beamer .meta:n = {paper= slide},
  paper/leaflet .meta:n = {paper=a5},
  color .tl_gset:N = \g_ptxcd_rules_default_color_tl,
  color .initial:n = black,
  mode .tl_gset:N = \g_ptxcd_rules_default_mode_tl,
  mode .initial:n = box,
  department .choice:,
  department / default .code:n = \str_gset:Nn \g_ptxcd_department_str {default},
  department / mecheng .code:n = \str_gset:Nn \g_ptxcd_department_str {mecheng},
  department / unknown .code:n = {
      \str_gset:Nx \g_ptxcd_department_str {\l_keys_value_tl}
    },
  mecheng .meta:n = {department=mecheng},
}
\ProcessKeyOptions[ptxcd/rules]
\RequirePackage{tudacolors}
\RequirePackage{xparse}
\bool_new:N  \g_ptxcd_rule_TikZmode_bool
\keys_define:nn {ptxcd/rules} {
  width .dim_gset:N = \l_ptxcd_headrule_width_dim,
  color .tl_gset:N = \l_ptxcd_headrule_color_tl,
  mode .choice:,
  mode / box .code:n = \bool_gset_false:N \g_ptxcd_rule_TikZmode_bool,
  mode / tikz .code:n = \bool_gset_true:N \g_ptxcd_rule_TikZmode_bool,
  mode / TikZ  .code:n = \bool_gset_true:N \g_ptxcd_rule_TikZmode_bool,
}
\cs_if_exist_use:NF \str_case:Vn \str_case:on
\g_ptxcd_department_str {
  {mecheng} {\bool_gset_true:N \g_ptxcd_simple_rules_bool}
}
\cs_new:Nn \__ptxcd_logowidth: {\dim_eval:n {2.2\c_ptxcd_logoheight_dim}}
\cs_new:Nn \__ptxcd_logosep:{\dim_eval:n {0.3\c_ptxcd_logoheight_dim}}
\NewDocumentCommand{\ptxcd_makeheadrule}{som}{
  \keys_set:nn {ptxcd/rules} {
    %TODO maybe package options for default
    width=\textwidth,
  }
  \exp_args:Nnx \keys_set:nn {ptxcd/rules} {
    mode= \g_ptxcd_rules_default_mode_tl,
    color=  \g_ptxcd_rules_default_color_tl
  }
  \IfNoValueF {#2} {\keys_set:nn {ptxcd/rules}{#2}}
  \IfBooleanF {#1} {\box_if_exist:cF {#3_box} {\box_new:c {#3_box}}}
  \bool_if:NTF \g_ptxcd_simple_rules_bool {
    \IfBooleanTF {#1} \use_none:n \hbox_gset:cn
    {#3_box}
    {
      \color{\l_ptxcd_headrule_color_tl}
      \raisebox{-\height}{\rule{\l_ptxcd_headrule_width_dim}{.5\c_ptxcd_largerule_dim}}
    }
  }{
    \bool_if:NTF \g_ptxcd_rule_TikZmode_bool {
      \IfBooleanTF {#1} \use_none:n \hbox_gset:cn
      {#3_box} {
        \begin{tikzpicture}
          \fill[\l_ptxcd_headrule_color_tl](0,\c_ptxcd_rulesep_dim)rectangle++(\l_ptxcd_headrule_width_dim,\c_ptxcd_largerule_dim);
          \fill(0,0)rectangle(\l_ptxcd_headrule_width_dim,-\c_ptxcd_smallrule_dim);
        \end{tikzpicture}
      }
    }{
      \IfBooleanTF {#1} \use_none:n \hbox_gset:cn
      {#3_box}
      {
        \parbox[t]{\l_ptxcd_headrule_width_dim}{
          \setlength{\baselineskip}{\z@}
          \null\par\nointerlineskip
          \textcolor{\l_ptxcd_headrule_color_tl}{\rule{\linewidth}{\c_ptxcd_largerule_dim}}
          \vspace{\c_ptxcd_rulesep_dim}\par\nointerlineskip
          \rule{\linewidth}{\c_ptxcd_smallrule_dim}
        }
      }
    }
  }
  \IfBooleanF {#1} {\cs_set:cpn {#3} {\box_use:c {#3_box}}}
}
\NewDocumentCommand{\ptxcd_makefootrule}{som}{
  \keys_set:nn {ptxcd/rules} {
    width= \textwidth
  }
  \IfNoValueF {#2} {\keys_set:nn {ptxcd/rules}{#2}}
  \IfBooleanF {#1} {\box_new:c {#3_box}}
  \IfBooleanTF {#1} \use_none:n \hbox_gset:cn {#3_box} {
    \raisebox{-\height}{\rule{\l_ptxcd_headrule_width_dim}{\g_ptxcd_titlerule_dim}}
  }
  \IfBooleanF{#1} {\cs_new:cpn {#3} {\box_use:c {#3_box}}}
}
\endinput
%%
%% End of file `tudarules.sty'.