summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/projlib/projlib-titlepage.sty
blob: b9b05b7ce157974d4329cefb120a80ada611d799 (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
%%
%% This is file `projlib-titlepage.sty',
%% generated with the docstrip utility.

%% Copyright (C) 2021-2022 by Jinwen XU
%% 
%% This is part of the ProjLib Toolkit.
%% 
%% 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
%% 2005/12/01 or later.
%% 
\NeedsTeXFormat{LaTeX2e}[2020-10-01]
\RequirePackage{l3keys2e}
\ProvidesExplPackage
  {projlib-titlepage}
  {2022/04/03} {}
  {Commands for rendering the title page}

\keys_define:nn { projlib-titlepage }
  {
    , unknown           .code:n             = {}
  }
\ProcessKeysOptions { projlib-titlepage }

\RequirePackage { projlib-paper }

\RequirePackage { tikz }
\ExplSyntaxOff
\usetikzlibrary { calc }
\ExplSyntaxOn

\tl_new:N \l_projlib_titlepage_logo_tl
\tl_new:N \l_projlib_titlepage_title_tl
\tl_new:N \l_projlib_titlepage_subtitle_tl
\tl_new:N \l_projlib_titlepage_author_tl
\tl_new:N \l_projlib_titlepage_date_tl
\tl_new:N \l_projlib_titlepage_style_tl

\NewDocumentCommand \ProjLibTitlePage { O{} m }
  {
    \keys_set:nn { projlib-titlepage-config } { #1 }
    \projlib_titlepage_render:n { #2 }
  }
\ProvideDocumentCommand \TitlePage { O{} m }
  {
    \ProjLibTitlePage [ #1 ] { #2 }
  }

\cs_new_protected:Nn \projlib_titlepage_set_color:nn
  {
    \colorlet { titlepage- #1 } { #2 }
  }

\keys_define:nn { projlib-titlepage-config }
  {
    , logo              .tl_set:N           = \l_projlib_titlepage_logo_tl
    , logo              .initial:n          = { \scalebox { 2 } { \ProjLib } }
    , title             .tl_set:N           = \l_projlib_titlepage_title_tl
    , subtitle          .tl_set:N           = \l_projlib_titlepage_subtitle_tl
    , author            .tl_set:N           = \l_projlib_titlepage_author_tl
    , date              .tl_set:N           = \l_projlib_titlepage_date_tl
    , style             .tl_set:N           = \l_projlib_titlepage_style_tl
    , style             .initial:n          = { default }
    , color             .code:n             = {
                                                \keyval_parse:nnn
                                                  { \use_none:n }
                                                  { \projlib_titlepage_set_color:nn }
                                                  { #1 }
                                              }
    , unknown           .code:n             = {}
  }

\colorlet { titlepage-main } { blue!50!cyan!50!black }
\colorlet { titlepage-back } { blue!50!cyan!10!yellow!30 }

\cs_new_protected:Nn \projlib_titlepage_render:n
  {
    \keys_set:nn { projlib-titlepage-config } { #1 }
    \begin { titlepage }
      \cs_if_exist_use:c { projlib_titlepage_render_with_style_ \l_projlib_titlepage_style_tl : }
    \end   { titlepage }
    \setcounter { page } { 0 }
  }

\cs_new_protected:Nn \projlib_titlepage_render_with_style_default:
  {
    \begin{tikzpicture}[overlay,remember~picture]
      \fill [color=titlepage-main] ($(current~page.south~west)$) rectangle ($(current~page.north~east)+(0,-.3\paperheight)$);
      \fill [color=titlepage-back] ($(current~page.south~west)$) rectangle ($(current~page.north~west)+(.125\paperwidth,-.3\paperheight)$);
      \fill [color=titlepage-main] ($(current~page.north~west)$) rectangle ($(current~page.north~west)+(.125\paperwidth,-.3\paperheight)$);
      \fill [color=titlepage-back] ($(current~page.north~east)$) rectangle ($(current~page.north~west)+(.125\paperwidth,-.3\paperheight)$);
      \node[text~width=.3\paperwidth,text~height=.2\paperheight] at ($(current~page.north~west)+(.32\paperwidth,-.17\paperheight)$) { \l_projlib_titlepage_logo_tl };
      \node[text~width=.4\paperwidth,text~height=.3\paperheight,scale=2.5] at ($(current~page.north~west)+(.67\paperwidth,-.15\paperheight)$) {\textcolor{titlepage-back}{\sffamily\textsc{ \l_projlib_titlepage_title_tl }\\[.5em]\footnotesize{ \l_projlib_titlepage_subtitle_tl }}};
      \node[text~width=.3\paperwidth,text~height=.3\paperheight] at ($(current~page.south)+(.2\paperwidth,.3\paperheight)$) {\color{titlepage-back}\begin{flushright}\fontsize{16pt}{0pt}\selectfont\textsc{ \l_projlib_titlepage_author_tl }\\[1em]\fontsize{12pt}{0pt}\selectfont \l_projlib_titlepage_date_tl \end{flushright} };
    \end{tikzpicture}
  }

\cs_new_protected:Nn \projlib_titlepage_render_with_style_simple:
  {
    \begin{tikzpicture}[overlay,remember~picture]
      \fill[color=titlepage-main] ($(current~page.south~west)$) rectangle ($(current~page.north~east)+(0,-.3\paperheight)$);
      \node[text~width=.3\paperwidth,text~height=.2\paperheight] at ($(current~page.north~west)+(.28\paperwidth,-.15\paperheight)$) { \l_projlib_titlepage_logo_tl };
      \node[text~width=.4\paperwidth,text~height=.3\paperheight,scale=2.5] at ($(current~page.north~west)+(.63\paperwidth,-.15\paperheight)$) {\textcolor{paper}{\sffamily\textsc{ \l_projlib_titlepage_title_tl }\\[.5em]\footnotesize{ \l_projlib_titlepage_subtitle_tl }}};
      \node[text~width=.3\paperwidth,text~height=.3\paperheight] at ($(current~page.south)+(.2\paperwidth,.3\paperheight)$) {\color{paper}\begin{flushright}\fontsize{16pt}{0pt}\selectfont\textsc{ \l_projlib_titlepage_author_tl }\\[1em]\fontsize{12pt}{0pt}\selectfont \l_projlib_titlepage_date_tl \end{flushright} };
    \end{tikzpicture}
  }

\endinput
%%
%% End of file `projlib-titlepage.sty'.