summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/zennote/zennote.sty
blob: 2bb39f0d4969424982b17eb3937e6a63ba539953 (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
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{zennote}[2023/01/10 Version 1.0.0]

\RequirePackage[most]{tcolorbox}

\newcounter{notenumber}
\setcounter{notenumber}{1}
\counterwithin{equation}{notenumber}
\counterwithin{figure}{notenumber}
\counterwithin{table}{notenumber}
\AtBeginDocument{\counterwithin{lstlisting}{notenumber}}
\ExplSyntaxOn
\keys_define:nn{titlebox}{
    top-left.tl_set:N = \l_titlebox_topleft_tl,
    top-right.tl_set:N = \l_titlebox_topright_tl,
    bottom-left.tl_set:N = \l_titlebox_bottomleft_tl,
    bottom-right.tl_set:N = \l_titlebox_bottomright_tl,
    notenumber.code:n = {\setcounter{notenumber}{#1}},
    topic.tl_set:N = \l_titlebox_topic_tl,
    type.tl_set:N = \l_titlebox_type_tl,
}

\NewDocumentCommand{\titlebox}{m}{
    \group_begin:
    \keys_set:nn{titlebox}{#1}
    \begin{center}
    \framebox{
    \vbox{\vspace{2mm}
    \hbox to .98\textwidth {\hspace*{2mm}\tl_use:N \l_titlebox_topleft_tl
    \hfill \tl_use:N \l_titlebox_topright_tl\hspace*{2mm}} 
        \vspace{4mm}
        \hbox to .98\textwidth { \large\hfill \tl_use:N \l_titlebox_type_tl{~}\thenotenumber\c_colon_str {~} \tl_use:N \l_titlebox_topic_tl  \hfill}
        \vspace{2mm}
        \hbox to .98\textwidth {\hspace*{2mm}\tl_use:N \l_titlebox_bottomleft_tl \hfill \tl_use:N \l_titlebox_bottomright_tl\hspace*{2mm}}
    \vspace{2mm}}
    }
    \end{center}
    \group_end:
}

\tl_new:N \l_noteframe_style_tl

\tl_const:Nn \c_noteframe_style_zero_tl {}
\tl_const:Nn \c_noteframe_style_one_tl {
    borderline~west={3pt}{0pt}{\l_noteframe_color_tl!85!black}
}
\tl_const:Nn \c_noteframe_style_two_tl {
    borderline~west={3pt}{0pt}{\l_noteframe_color_tl!85!black},
    borderline~east={3pt}{0pt}{\l_noteframe_color_tl!85!black}
}

\keys_define:nn{noteframe}{
    color.tl_set:N = \l_noteframe_color_tl,
    style.tl_set:N = \l_noteframe_style_tl,
    title.tl_set:N = \l_noteframe_title_tl,
}

\keys_set:nn{noteframe}{
    color = {cyan},
    style = {one},
    title = {}
}

\NewDocumentEnvironment{noteframe}{O{}+b}{
    \group_begin:

    \keys_set:nn{noteframe}{#1}
    \use:x {
    \exp_not:n{\begin{tcolorbox}}[
        enhanced,
        boxrule=0pt,
        frame~hidden,
        \exp_not:v {c_noteframe_style_ \l_noteframe_style_tl _tl},
        colback=\tl_use:N \l_noteframe_color_tl!10!white,
        sharp~corners
    ]
    \exp_not:n{
        \tl_if_empty:NTF\l_noteframe_title_tl{}{
          \textbf{\Large \textcolor{\tl_use:N \l_noteframe_color_tl!85!black}{\tl_use:N \l_noteframe_title_tl}\\\vspace*{-2mm}\\ }  
        }
    #2
    \end{tcolorbox}  
    }
    \group_end:
    } 
}{
    
}

\ExplSyntaxOff

\pagestyle{plain}

\endinput