summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/beamer-contrib/themes/beamerthemeconcrete/riemann/beamerthemeriemann.sty
blob: 82f2fed1511c4861c1d80a499a2758ccbfcf94c6 (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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
% -*- coding: utf-8 -*-
% ----------------------------------------------------------------------------
% Author:  Jianrui Lyu <tolvjr@163.com>
% Website: https://github.com/lvjr/concrete
% License: The LaTeX Project Public License 1.3c
% ----------------------------------------------------------------------------

\ProvidesPackage{beamerthemeriemann}[2024-01-19 v2024A Beamer Theme Riemann]

\makeatletter

% compatible with old versions of beamer
\providecommand{\beamer@endinputifotherversion}[1]{}

\RequirePackage{tikz,etoolbox,adjustbox,calc}
\usetikzlibrary{calc}

\mode<presentation>

\setbeamersize{text margin left=8mm,text margin right=8mm}

%% ----------------- background canvas and background ----------------

\newif\ifbackgroundmarkleft
\newif\ifbackgroundmarkright

\newcommand{\insertbackgroundmark}{
  \ifbackgroundmarkleft
    \foreach \x in {1,2,...,11} \draw[line width=0.2mm,markcolor]
        (0,\x*\paperheight/12) ++(0.1mm,-0.5mm) rectangle +(1mm,1mm);
  \fi
  \ifbackgroundmarkright
    \foreach \x in {1,2,...,11} \draw[line width=0.2mm,markcolor]
        (\paperwidth,\x*\paperheight/12) ++(-1.1mm,-0.5mm) rectangle +(1mm,1mm);
  \fi
}

\defbeamertemplate{background}{line}[1][]{%
  \begin{tikzpicture}
    \useasboundingbox (0,0) rectangle (\paperwidth,\paperheight);
    \draw[xstep=\paperwidth,ystep=1mm,color=tcolor,#1] (0,0) grid (\paperwidth,\paperheight);
    \insertbackgroundmark
  \end{tikzpicture}%
}

\defbeamertemplate{background}{linear}{%
  \begin{tikzpicture}
    \useasboundingbox (0,0) rectangle (\paperwidth,\paperheight);
    \draw[pattern=horizontal lines, pattern color=tcolor]
      (0,0) rectangle (\paperwidth,\paperheight);
    \insertbackgroundmark
  \end{tikzpicture}%
}

\defbeamertemplate{background}{lattice}[1][1mm]{%
  \begin{tikzpicture}
    \useasboundingbox (0,0) rectangle (\paperwidth,\paperheight);
    \draw[step=#1,color=tcolor,semithick] (0,0) grid (\paperwidth,\paperheight);
    \insertbackgroundmark
  \end{tikzpicture}%
}

\defbeamertemplate{background}{empty}{
  \begin{tikzpicture}
    \useasboundingbox (0,0) rectangle (\paperwidth,\paperheight);
    \insertbackgroundmark
  \end{tikzpicture}%
}

%% -------------------------- title page -----------------------------

% add \occasion command
\newcommand{\occasion}[1]{\def\insertoccasion{#1}}
\occasion{}

\defbeamertemplate{title page}{banner}{%
  \nointerlineskip
  \begin{adjustbox}{width=\paperwidth,center}%
    \usebeamertemplate{title page content}%
  \end{adjustbox}%
}

% need "text badly ragged" option for correct space skips
% see http://tex.stackexchange.com/a/132748/8956
\defbeamertemplate{title page content}{hexagon}{%
  \begin{tikzpicture}
  \useasboundingbox (0,0) rectangle (\paperwidth,\paperheight);
  \path[draw=dcolor,fill=fcolor,opacity=0.8]
      (0,0) rectangle (\paperwidth,\paperheight);
  \node[text width=0.86\paperwidth,text badly ragged,inner ysep=1.5cm] (main) at (0.5\paperwidth,0.55\paperheight) {%
    \begin{minipage}[c]{0.86\paperwidth}
      \centering
      \usebeamerfont{title}\usebeamercolor[fg]{title}\inserttitle
      \ifx\insertsubtitle\@empty\else
        \\[5pt]\usebeamerfont{subtitle}\usebeamercolor[fg]{subtitle}
        \insertsubtitle
      \fi
    \end{minipage}
  };
  \node[rectangle,inner sep=0pt,minimum size=3mm,fill=dcolor,right] (a) at (0,0.55\paperheight) {};
  \node[rectangle,inner sep=0pt,minimum size=3mm,fill=dcolor,left] (b) at (\paperwidth,0.55\paperheight) {};
  \ifx\insertoccasion\@empty
      \draw[thick,dcolor] (a.north east) -- (main.north west)
                   -- (main.north east) -- (b.north west);
  \else
      \node[text badly ragged] (occasion) at (main.north west -| 0.5\paperwidth,\paperheight) {
          \usebeamerfont{occasion}\usebeamercolor[fg]{occasion}\insertoccasion
      };
      \draw[thick,dcolor] (a.north east) -- (main.north west) -- (occasion.west)
                          (b.north west) -- (main.north east) -- (occasion.east);
  \fi
  \node[text badly ragged] (date) at (main.south west -| 0.5\paperwidth,0) {
      \usebeamerfont{date}\usebeamercolor[fg]{date}\insertdate
  };
  \draw[thick,dcolor] (a.south east) -- (main.south west) -- (date.west)
                      (b.south west) -- (main.south east) -- (date.east);
  \node[below=4mm,text width=0.9\paperwidth,inner xsep=0.05\paperwidth,
        text badly ragged,fill=white,draw=dcolor] at (date.south) {%
      \begin{minipage}[c]{0.9\paperwidth}
          \centering
          \textcolor{accent2}{$\blacksquare$}\hspace{0.2em}%
          \usebeamerfont{institute}\usebeamercolor[fg]{institute}\insertinstitute
          \hspace{1em}\textcolor{accent2}{$\blacksquare$}\hspace{0.2em}%
          \usebeamerfont{author}\usebeamercolor[fg]{author}\insertauthor
      \end{minipage}
  };
  \end{tikzpicture}
}

\defbeamertemplate{title page content}{rectangle}{%
  \begin{tikzpicture}
  \useasboundingbox (0,0) rectangle (\paperwidth,\paperheight);
  \path[draw=dcolor,fill=fcolor,opacity=0.8]
      (0,0) rectangle (\paperwidth,\paperheight);
  \node[text width=0.9\paperwidth,text badly ragged,inner ysep=1.5cm] (main) at (0.5\paperwidth,0.55\paperheight) {%
    \begin{minipage}[c]{0.9\paperwidth}
      \centering
      \usebeamerfont{title}\usebeamercolor[fg]{title}\inserttitle
      \ifx\insertsubtitle\@empty\else
        \\[5pt]\usebeamerfont{subtitle}\usebeamercolor[fg]{subtitle}
        \insertsubtitle
      \fi
    \end{minipage}
  };
  \node[rectangle,inner sep=0pt,outer sep=0pt,minimum size=3mm,fill=dcolor,below right,xshift=2pt]
       (a) at (main.north west -| 0,0) {};
  \node[rectangle,inner sep=0pt,outer sep=0pt,minimum size=3mm,fill=dcolor,below left,xshift=-2pt]
       (b) at (main.north east -| \paperwidth,0) {};
  \node[rectangle,inner sep=0pt,outer sep=0pt,minimum size=3mm,fill=dcolor,above right,xshift=2pt]
       (c) at (main.south west -| 0,0) {};
  \node[rectangle,inner sep=0pt,outer sep=0pt,minimum size=3mm,fill=dcolor,above left,xshift=-2pt]
       (d) at (main.south east -| \paperwidth,0) {};
  \coordinate (mw) at (main.west -| a.west);
  \coordinate (me) at  (main.east -| b.east);
  \draw[thick,dcolor] (a.south east) -- (a.south west) -- (a.north west) -- (a.north east)
                                     -- ++(0,-6mm) -- ++(-3mm,0) -- (mw)
                      (c.north east) -- (c.north west) -- (c.south west) -- (c.south east)
                                     -- ++(0,6mm)  -- ++(-3mm,0) -- (mw)
                      (b.south west) -- (b.south east) -- (b.north east) -- (b.north west)
                                     -- ++(0,-6mm) -- ++(3mm,0)  -- (me)
                      (d.north west) -- (d.north east) -- (d.south east) -- (d.south west)
                                     -- ++(0,6mm)  -- ++(3mm,0)  -- (me);
  \ifx\insertoccasion\@empty
      \draw[thick,dcolor] (a.south east) -- ++(3mm,0) -- ++(0,3mm) -- (main.north)
                          (b.south west) -- ++(-3mm,0) -- ++(0,3mm) -- (main.north);
  \else
      \node[text badly ragged] (occasion) at (main.north west -| 0.5\paperwidth,\paperheight) {
          \usebeamerfont{occasion}\usebeamercolor[fg]{occasion}\insertoccasion
      };
      \draw[thick,dcolor] (a.south east) -- ++(3mm,0) -- ++(0,3mm) -- (occasion.west)
                          (b.south west) -- ++(-3mm,0) -- ++(0,3mm) -- (occasion.east);
  \fi
  \node[text badly ragged] (date) at (main.south west -| 0.5\paperwidth,0) {
      \usebeamerfont{date}\usebeamercolor[fg]{date}\insertdate
  };
  \draw[thick,dcolor] (c.north east) -- ++(3mm,0) -- ++(0,-3mm) -- (date.west)
                      (d.north west) -- ++(-3mm,0) -- ++(0,-3mm) -- (date.east);
  \node[below=4mm,text width=0.9\paperwidth,inner xsep=0.05\paperwidth,
        text badly ragged,fill=white,draw=dcolor] (author) at (date.south) {%
      \begin{minipage}[c]{0.9\paperwidth}
          \centering
          \textcolor{accent2}{$\blacksquare$}\hspace{0.2em}%
          \usebeamerfont{institute}\usebeamercolor[fg]{institute}\insertinstitute
          \hspace{1em}\textcolor{accent2}{$\blacksquare$}\hspace{0.2em}%
          \usebeamerfont{author}\usebeamercolor[fg]{author}\insertauthor
      \end{minipage}
  };
  \end{tikzpicture}
}

\defbeamertemplate{title page content}{polygon}{%
  \begin{tikzpicture}
  \useasboundingbox (0,0) rectangle (\paperwidth,\paperheight);
  \path[draw=dcolor,fill=fcolor,opacity=0.8]
      (0,0) rectangle (\paperwidth,\paperheight);
  \node[text width=0.82\paperwidth,text badly ragged,inner ysep=1.5cm] (main) at (0.5\paperwidth,0.55\paperheight) {%
    \begin{minipage}[c]{0.82\paperwidth}
      \centering
      \usebeamerfont{title}\usebeamercolor[fg]{title}\inserttitle
      \ifx\insertsubtitle\@empty\else
        \\[5pt]\usebeamerfont{subtitle}\usebeamercolor[fg]{subtitle}
        \insertsubtitle
      \fi
    \end{minipage}
  };
  \node[rectangle,inner sep=0pt,outer sep=0pt,minimum size=3mm,fill=dcolor,right,yshift=12pt]
       (a) at (main.north west -| 0,0) {};
  \node[rectangle,inner sep=0pt,outer sep=0pt,minimum size=3mm,fill=dcolor,left,yshift=12pt]
       (b) at (main.north east -| \paperwidth,0) {};
  \node[rectangle,inner sep=0pt,outer sep=0pt,minimum size=3mm,fill=dcolor,right,yshift=-12pt]
       (c) at (main.south west -| 0,0) {};
  \node[rectangle,inner sep=0pt,outer sep=0pt,minimum size=3mm,fill=dcolor,left,yshift=-12pt]
       (d) at (main.south east -| \paperwidth,0) {};
  \draw[thick,dcolor] (a.south east) -- (main.west) -- (c.north east)
                      (b.south west) -- (main.east) -- (d.north west);
  \ifx\insertoccasion\@empty
      \draw[thick,dcolor] (a.south east) -- (main.north west) -- (main.north east) -- (b.south west);
  \else
      \node[text badly ragged] (occasion) at (main.north west -| 0.5\paperwidth,\paperheight) {
          \usebeamerfont{occasion}\usebeamercolor[fg]{occasion}\insertoccasion
      };
      \draw[thick,dcolor] (a.south east) -- (main.north west) -- (occasion.west)
                          (b.south west) -- (main.north east) -- (occasion.east);
  \fi
  \node[text badly ragged] (date) at (main.south west -| 0.5\paperwidth,0) {
      \usebeamerfont{date}\usebeamercolor[fg]{date}\insertdate
  };
  \draw[thick,dcolor] (c.north east) -- (main.south west) -- (date.west)
                      (d.north west) -- (main.south east) -- (date.east);
  \node[below=4mm,text width=0.9\paperwidth,inner xsep=0.026\paperwidth,
        text badly ragged,fill=white,draw=dcolor] (author) at (date.south) {%
      \begin{minipage}[c]{0.9\paperwidth}
          \centering
          \textcolor{accent2}{$\blacksquare$}\hspace{0.2em}%
          \usebeamerfont{institute}\usebeamercolor[fg]{institute}\insertinstitute
          \hspace{1em}\textcolor{accent2}{$\blacksquare$}\hspace{0.2em}%
          \usebeamerfont{author}\usebeamercolor[fg]{author}\insertauthor
      \end{minipage}
  };
  \path[fill=dcolor] (author.north west) -- (author.north west -| 0,0) -- (author.west)
                         -- (author.south west -| 0,0) -- (author.south west)
                     (author.north east) -- (author.north east -| \paperwidth,0) -- (author.east)
                         -- (author.south east -| \paperwidth,0) -- (author.south east);
  \end{tikzpicture}
}

\defbeamertemplate{title page content}{hypotenuse}{%
  \begin{tikzpicture}
  \useasboundingbox (0,0) rectangle (\paperwidth,\paperheight);
  \path[draw=dcolor,fill=fcolor,opacity=0.8]
      (0,0) rectangle (\paperwidth,\paperheight);
  \node[text width=0.82\paperwidth,text badly ragged,inner ysep=1.5cm] (main) at (0.5\paperwidth,0.55\paperheight) {%
    \begin{minipage}[c]{0.82\paperwidth}
      \centering
      \usebeamerfont{title}\usebeamercolor[fg]{title}\inserttitle
      \ifx\insertsubtitle\@empty\else
        \\[5pt]\usebeamerfont{subtitle}\usebeamercolor[fg]{subtitle}
        \insertsubtitle
      \fi
    \end{minipage}
  };
  \node[rectangle,inner sep=0pt,outer sep=0pt,minimum size=2.7mm,fill=dcolor] (a) at (main.north west) {};
  \node[rectangle,inner sep=0pt,outer sep=0pt,minimum size=2.7mm,fill=dcolor,left] (b) at (main.north -| \paperwidth,0) {};
  \node[rectangle,inner sep=0pt,outer sep=0pt,minimum size=2.7mm,fill=dcolor,right] (c) at (main.south -| 0,0) {};
  \node[rectangle,inner sep=0pt,outer sep=0pt,minimum size=2.7mm,fill=dcolor] (d) at (main.south east) {};
  \draw[thick,dcolor] ($(a.south west)+(0.4pt,0)$) -- ($(c.north east)+(-0.4pt,0)$)
                      ($(b.south west)+(0.4pt,0)$) -- ($(d.north east)+(-0.4pt,0)$);
  \draw[thick,dcolor] ($(a.south east)+(-0.4pt,0)$) -- ($(c.north west)+(0.4pt,0)$)
                      ($(b.south east)+(-0.4pt,0)$) -- ($(d.north west)+(0.4pt,0)$);
  \ifx\insertoccasion\@empty
      \draw[thick,dcolor] (a.north west) -- (b.north east)
                          (a.south west) -- (b.south east);
  \else
      \node[text badly ragged] (occasion) at (main.north west -| 0.5\paperwidth,\paperheight) {
          \usebeamerfont{occasion}\usebeamercolor[fg]{occasion}\insertoccasion
      };
      \draw[thick,dcolor] (a.north west) -- (a.north west -| occasion.north west)
                          (a.south west) -- (a.south west -| occasion.south west)
                          (b.north east) -- (b.north east -| occasion.north east)
                          (b.south east) -- (b.south east -| occasion.south east);
  \fi
  \node[text badly ragged] (date) at (main.south west -| 0.5\paperwidth,0) {
      \usebeamerfont{date}\usebeamercolor[fg]{date}\insertdate
  };
  \draw[thick,dcolor] (c.north west) -- (c.north west -| date.north west)
                      (c.south west) -- (c.south west -| date.south west)
                      (d.north east) -- (d.north east -| date.north east)
                      (d.south east) -- (d.south east -| date.south east);
  \node[below=4mm,text width=0.9\paperwidth,inner xsep=0.015\paperwidth,
        text badly ragged,fill=white,draw=dcolor] (author) at (date.south) {%
      \begin{minipage}[c]{0.9\paperwidth}
          \centering
          \textcolor{accent2}{$\blacksquare$}\hspace{0.2em}%
          \usebeamerfont{institute}\usebeamercolor[fg]{institute}\insertinstitute
          \hspace{1em}\textcolor{accent2}{$\blacksquare$}\hspace{0.2em}%
          \usebeamerfont{author}\usebeamercolor[fg]{author}\insertauthor
      \end{minipage}
  };
  \path[fill=dcolor] (author.north west) -- (author.south west) -- (author.south west -| 0,0)
                     (author.south east) -- (author.north east) -- (author.north west -| \paperwidth,0);
  \end{tikzpicture}
}

% Several safe primes and Blum-Blum-Shub generator
\newcommand{\my@composite}{43921} % 43921=167*263
\newcounter{my@random@seed}
\setcounter{my@random@seed}{43787}
\newcommand{\next@random@seed}{%
  \setcounter{my@random@seed}{\value{my@random@seed}*\value{my@random@seed}}%
  \setcounter{my@random@seed}{\value{my@random@seed}-(\value{my@random@seed}/\my@composite)*\my@composite}%
}

\newlength{\my@title@height}

\defbeamertemplate{title page content}{block}{%
  \begin{tikzpicture}
  \useasboundingbox (0,0) rectangle (\paperwidth,\paperheight);
  \path[draw=dcolor,fill=fcolor,opacity=0.8] (0,0) rectangle (\paperwidth,\paperheight);
  \path[step=4mm,draw=dcolor,ultra thick] (0,0) grid (\paperwidth,\paperheight);
  \foreach \x in {0,1,...,31} \foreach \y in {0,1,...,23} {
    \next@random@seed
    \ifodd\value{my@random@seed}
      \path[draw=dcolor,ultra thick,fill=fcolor2,opacity=0.8] (\x*\paperwidth/32,\y*\paperheight/24) rectangle +(4mm,4mm);
    \fi
  }
  \ifx\insertsubtitle\@empty
    \setlength{\my@title@height}{39.7mm}
  \else
    \setlength{\my@title@height}{47.7mm}
  \fi
  \node[minimum width=0.84\paperwidth,minimum height=\my@title@height,inner xsep=2mm,inner ysep=0mm,
        opacity=0.95,text opacity=1,text badly ragged,fill=fcolor] (main) at (0.5\paperwidth,0.542\paperheight) {%
    \begin{minipage}[c]{0.84\paperwidth}
      \centering
      \usebeamerfont{title}\usebeamercolor[fg]{title}\inserttitle
      \ifx\insertsubtitle\@empty\else
        \\[5pt]\usebeamerfont{subtitle}\usebeamercolor[fg]{subtitle}
        \insertsubtitle
      \fi
    \end{minipage}
  };
  \ifx\insertoccasion\@empty\else
      \node[text badly ragged,fill=fcolor,minimum height=7.8mm,draw=dcolor,very thick]
           (occasion) at (main.north west -| 0.5\paperwidth,\paperheight) {
          \usebeamerfont{occasion}\usebeamercolor[fg]{occasion}\insertoccasion
      };
  \fi
  \node[text badly ragged,fill=fcolor,minimum height=7.8mm,draw=dcolor,very thick]
       (date) at (main.south west -| 0.5\paperwidth,0) {
      \usebeamerfont{date}\usebeamercolor[fg]{date}\insertdate
  };
  \node[below=4mm,minimum width=0.84\paperwidth,minimum height=7.6mm,inner xsep=2mm,inner ysep=0mm,
        opacity=0.85,text opacity=1,text badly ragged,fill=white] at (date.south) {%
      \begin{minipage}[c]{0.84\paperwidth}
          \centering
          \textcolor{accent2}{$\blacksquare$}\hspace{0.2em}%
          \usebeamerfont{institute}\usebeamercolor[fg]{institute}\insertinstitute
          \hspace{0.4em}\textcolor{accent2}{$\blacksquare$}\hspace{0.2em}%
          \usebeamerfont{author}\usebeamercolor[fg]{author}\insertauthor
      \end{minipage}
  };
  \end{tikzpicture}
}

%% ----------------------- section and subsection --------------------

\newcounter{my@pgf@picture@count}

\def\sectionintocskip{0.5pt plus 0.1fill}
\patchcmd{\beamer@sectionintoc}{\vskip1.5em}{\vskip\sectionintocskip}{}{}

\AtBeginSection[]{%
  \begin{frame}%[plain]
    \sectionpage
  \end{frame}%
}

\defbeamertemplate{section name}{simple}{\insertsectionnumber.}

\defbeamertemplate{section name}{chinese}[1][节]{第\CJKnumber{\insertsectionnumber}#1}

\defbeamertemplate{section page}{single}{%
  \centerline{%
    \usebeamerfont{section name}%
    \usebeamercolor[fg]{section name}%
    \usebeamertemplate{section name}%
    \hspace{0.8em}%
    \usebeamerfont{section title}%
    \usebeamercolor[fg]{section title}%
    \insertsection
  }%
}

\defbeamertemplate{section name in toc}{simple}{%
  Section \inserttocsectionnumber
}

\defbeamertemplate{section name in toc}{full}{%
  Section \ifnum\the\beamer@tempcount<10 0\fi\inserttocsectionnumber
}

\defbeamertemplate{section name in toc}{chinese}[1][节]{%
  第\CJKnumber{\inserttocsectionnumber}#1%
}

\newcounter{my@section@from}
\newcounter{my@section@to}

\defbeamertemplate{show sections in toc}{total}{%
  \setcounter{my@section@from}{1}%
  \setcounter{my@section@to}{50}%
}

% show at most five sections
\defbeamertemplate{show sections in toc}{partial}{%
  \setcounter{my@section@from}{\value{section}}%
  \addtocounter{my@section@from}{-2}%
  \setcounter{my@section@to}{\value{section}}%
  \addtocounter{my@section@to}{2}%
  \ifnum\my@totalsectionnumber>0%
    \ifnum\value{my@section@to}>\my@totalsectionnumber
      \setcounter{my@section@to}{\my@totalsectionnumber}%
      \setcounter{my@section@from}{\value{my@section@to}}%
      \addtocounter{my@section@from}{-4}%
    \fi
  \fi
  \ifnum\value{my@section@from}<1\setcounter{my@section@from}{1}%
    \setcounter{my@section@to}{\value{my@section@from}}%
    \addtocounter{my@section@to}{4}%
  \fi
}

% reset pgfid to get correct result with \tikzmark in second run
\defbeamertemplate{section page}{fill}{%
  \usebeamertemplate{show sections in toc}%
  \setcounter{my@pgf@picture@count}{\the\pgf@picture@serial@count}%
  \setlength{\parskip}{5pt minus 1pt}%
  \tableofcontents[sectionstyle=show/shaded,subsectionstyle=hide,
                   sections={\arabic{my@section@from}-\arabic{my@section@to}}]%
  \global\pgf@picture@serial@count=\value{my@pgf@picture@count}%
  \unskip
}

\defbeamertemplate{section in toc}{fill}{%
  \noindent
  \begin{tikzpicture}
  \node[text width=\textwidth,inner xsep=0pt,inner ysep=5pt,text badly ragged,fill=bg] (title) {%
        \hspace{0.28\textwidth}\parbox{0.7\textwidth}{\inserttocsection\vphantom{g}}%
  };
  \path (title.south west) +(2pt,2pt) coordinate (sw)
        (title.north west) +(0.25\textwidth,-2pt) coordinate (ne);
  \path[fill=fg,overlay] (sw) rectangle (ne);
  \node[inner xsep=0pt,text badly ragged,overlay] at ($(sw)!0.5!(ne)$) {%
        \color{bg}\vphantom{g}\usebeamertemplate{section name in toc}%
  };
  \draw[line width=1pt,dcolor,overlay] ($(ne)+(2pt,2pt)$) -- ($(ne |- title.south)+(2pt,0)$);
  \end{tikzpicture}%
  \par
}

\AtBeginSubsection{%
  \begin{frame}%[plain]
    \setlength{\parskip}{0pt}%
    \offinterlineskip
    \subsectionpage
  \end{frame}%
}

\defbeamertemplate{subsection name}{simple}{%
  \insertsectionnumber.\insertsubsectionnumber
}

\defbeamertemplate{subsection page}{single}{%
  \centerline{%
    \usebeamerfont{subsection name}%
    \usebeamercolor[fg]{subsection name}%
    \usebeamertemplate{subsection name}%
    \hspace{0.8em}%
    \usebeamerfont{subsection title}%
    \usebeamercolor[fg]{subsection title}%
    \insertsubsection
  }%
}

\defbeamertemplate{subsection name in toc}{empty}{}

\newcounter{mysubseccnt}
\defbeamertemplate{subsection name in toc}{alphabet}{%
  \setcounter{mysubseccnt}{\inserttocsubsectionnumber}%
  \Alph{mysubseccnt}%
}

\defbeamertemplate{subsection name in toc}{simple}{%
  \inserttocsubsectionnumber
}

\defbeamertemplate{subsection name in toc}{full}{%
  \inserttocsectionnumber.\inserttocsubsectionnumber
}

% reset pgfid to get correct result with \tikzmark in second run
\defbeamertemplate{subsection page}{fill}{%
  \setcounter{my@pgf@picture@count}{\the\pgf@picture@serial@count}%
  \tableofcontents[sectionstyle=show/hide,subsectionstyle=show/shaded/hide]%
  \global\pgf@picture@serial@count=\value{my@pgf@picture@count}%
  \unskip
}

\defbeamertemplate{subsection in toc}{fill}{%
  \vspace{1pt}\noindent%
  \begin{tikzpicture}
  \node[text width=\textwidth,inner xsep=0pt,inner ysep=5pt,text badly ragged,fill=bg] (title) {%
        \hspace{0.28\textwidth}\parbox{0.7\textwidth}{\inserttocsubsection\vphantom{g}}%
  };
  \path (title.south west) +(2pt,2pt) coordinate (sw)
        (title.north west) +(0.25\textwidth,-2pt) coordinate (ne);
  \path[fill=fg,overlay] (sw) rectangle (ne);
  \node[inner xsep=0pt,text badly ragged,overlay] at ($(sw)!0.5!(ne)$) {%
       \color{bg}\vphantom{g}\usebeamertemplate{subsection name in toc}%
  };
  \draw[line width=1pt,dcolor,overlay] ($(ne)+(2pt,2pt)$) -- ($(ne |- title.south)+(2pt,0)$);
  \end{tikzpicture}%
  \par
}

% chinese sections and subsections
\defbeamertemplate{section and subsection}{chinese}[1][节]{%
  \setbeamertemplate{section name in toc}[chinese][#1]%
  \setbeamertemplate{section name}[chinese][#1]%
  \setbeamertemplate{subsection name in toc}[alphabet]%
}

%% ---------------------- headline and footline ----------------------

% fix headline bug in old versions
\@ifclasslater{beamer}{2017/01/23}{}{%
  \patchcmd{\ps@empty}
           {\raise\headheight\box\beamer@tempbox\box\@tempboxa}
           {\raise\headheight\box\beamer@tempbox\raise\headheight\box\@tempboxa}
           {}{}
}

\defbeamertemplate{headline mark}{line}{
  \draw[overlay,color=white,line width=0.8pt] (0,0.5mm) -- (\paperwidth,0.5mm);
}

\defbeamertemplate{headline}{shading}{%
  \begin{tikzpicture}
    \fill[left color=accent2,right color=blue85] (0,0) rectangle (\paperwidth,1mm);
    \usebeamertemplate{headline mark}
  \end{tikzpicture}
}

\defbeamertemplate{headline}{border}{%
  \begin{tikzpicture}
    \path[use as bounding box] (0,0) rectangle (\paperwidth,1mm);
    \fill[left color=accent2,right color=blue85] (0,0) rectangle (\paperwidth,0.8pt);
  \end{tikzpicture}
}

\defbeamertemplate{headline}{phantom}{%
  \begin{tikzpicture}
    \path[use as bounding box] (0,0) rectangle (\paperwidth,1mm);
  \end{tikzpicture}
}

\defbeamertemplate{footline left}{author}{%
  \insertshortauthor
}

\defbeamertemplate{footline center}{title}{%
  \insertshorttitle
}

\defbeamertemplate{footline right}{number}{%
  \Acrobatmenu{GoToPage}{\insertframenumber{}/\inserttotalframenumber}%
}
\defbeamertemplate{footline right}{normal}{%
  \hyperlinkframeendprev{$\vartriangle$}
  \Acrobatmenu{GoToPage}{\insertframenumber{}/\inserttotalframenumber}
  \hyperlinkframestartnext{$\triangledown$}%
}

\defbeamertemplate{footline}{simple}{%
  \hbox{%
  \begin{beamercolorbox}[wd=.2\paperwidth,ht=2.25ex,dp=1ex,left]{footline}%
    \usebeamerfont{footline}\kern\beamer@leftmargin
    \usebeamertemplate{footline left}%
  \end{beamercolorbox}%
  \begin{beamercolorbox}[wd=.6\paperwidth,ht=2.25ex,dp=1ex,center]{footline}%
    \usebeamerfont{footline}\usebeamertemplate{footline center}%
  \end{beamercolorbox}%
  \begin{beamercolorbox}[wd=.2\paperwidth,ht=2.25ex,dp=1ex,right]{footline}%
    \usebeamerfont{footline}\usebeamertemplate{footline right}%
    \kern\beamer@rightmargin
  \end{beamercolorbox}%
  }%
}

\defbeamertemplate{footline separator}{shading}{%
  \begin{tikzpicture}
    \fill[left color=blue85,right color=accent2] (0,0) rectangle (\paperwidth,1pt);
  \end{tikzpicture}
}

\defbeamertemplate{footline}{sectioning}{%
  \usebeamertemplate{footline separator}%
  \hbox{%
  \begin{beamercolorbox}[wd=.8\paperwidth,ht=2.25ex,dp=1ex,left]{footline}%
    \usebeamerfont{footline}\kern\beamer@leftmargin\insertshorttitle
    \ifx\insertsection\@empty\else\qquad$\vartriangleright$\qquad\insertsection\fi
    \ifx\insertsubsection\@empty\else\qquad$\vartriangleright$\qquad\insertsubsection\fi
  \end{beamercolorbox}%
  \begin{beamercolorbox}[wd=.2\paperwidth,ht=2.25ex,dp=1ex,right]{footline}%
     \usebeamerfont{footline}\usebeamertemplate{footline right}%
     \kern\beamer@rightmargin
  \end{beamercolorbox}%
  }%
}

% customize mini frames template to get a section navigation bar

\defbeamertemplate{navigation box}{current}{%
  \usebeamercolor{navigation box}%
  \colorbox{bg}{%
    \rule[-1ex]{0pt}{3.25ex}\color{white}\kern1.4pt\my@navibox\kern1.4pt%
  }%
}

\defbeamertemplate{navigation box}{other}{%
  %\colorbox{white}{%
    \rule[-1ex]{0pt}{3.25ex}\color{black}\kern1.4pt\my@navibox\kern1.4pt%
  %}%
}

\newcommand{\my@navibox@subsection}{$\blacksquare$}
\newcommand{\my@navibox@frame}{$\square$}
\let\my@navibox=\my@navibox@frame

% optional navigation box for some special frame
\newcommand{\my@navibox@frame@opt}{$\boxplus$}
\newcommand{\my@change@navibox}{\let\my@navibox=\my@navibox@frame@opt}
\newcommand{\changenavibox}{%
  \addtocontents{nav}{\protect\headcommand{\protect\my@change@navibox}}%
}

\newcommand{\my@sectionentry@show}[5]{%
  \ifnum\c@section=#1%
    \setbeamertemplate{navigation box}[current]%
  \else
    \setbeamertemplate{navigation box}[other]%
  \fi
  \begingroup
    \def\my@navibox{#1}%
    \hyperlink{Navigation#3}{\usebeamertemplate{navigation box}}%
  \endgroup
}

\newif\ifmy@hidesection

\newcommand{\my@sectionentry@hide}[5]{\my@hidesectiontrue}

\pretocmd{\beamer@setuplinks}{\renewcommand{\beamer@subsectionentry}[5]{}}{}{}
\apptocmd{\beamer@setuplinks}{\global\let\beamer@subsectionentry\mybeamer@subsectionentry}{}{}

\newcommand{\mybeamer@subsectionentry}[5]{\global\let\my@navibox=\my@navibox@subsection}

\newcommand{\my@slideentry@empty}[6]{}

\newcommand{\my@slideentry@section}[6]{%
  \ifmy@hidesection
    \my@hidesectionfalse
  \else
    \ifnum\c@section=#1%
      \setbeamertemplate{navigation box}[other]%
      \ifnum\c@subsection=#2\ifnum\c@subsectionslide=#3%
         \setbeamertemplate{navigation box}[current]%
      \fi\fi
      \beamer@link(#4){\usebeamertemplate{navigation box}}%
    \fi
  \fi
  \global\let\my@navibox=\my@navibox@frame
}

\newcommand{\my@slideentry@subsection}[6]{%
  \ifmy@hidesection
    \my@hidesectionfalse
  \else
    \ifnum\c@section=#1%
      \ifboolexpr{test{\ifnumcomp{\c@subsection}{=}{#2}} or test{\ifnumcomp{#3}{=}{1}}}{%
        \setbeamertemplate{navigation box}[other]%
        \ifnum\c@subsection=#2\ifnum\c@subsectionslide=#3%
           \setbeamertemplate{navigation box}[current]%
        \fi\fi
        \beamer@link(#4){\usebeamertemplate{navigation box}}%
      }{}%
    \fi
  \fi
  \global\let\my@navibox=\my@navibox@frame
}

\AtEndDocument{%
   \immediate\write\@auxout{%
     \noexpand\gdef\noexpand\my@totalsectionnumber{\the\c@section}%
   }%
}

\def\my@totalsectionnumber{0}

\defbeamertemplate{footline navigation}{section}{%
  \setbeamercolor{navigation box}{bg=accent2}%
  \let\sectionentry=\my@sectionentry@hide
  \let\slideentry=\my@slideentry@section
  \dohead
}

\defbeamertemplate{footline navigation}{subsection}{%
  \setbeamercolor{navigation box}{bg=accent2}%
  \let\sectionentry=\my@sectionentry@hide
  \let\slideentry=\my@slideentry@subsection
  \dohead
}

\defbeamertemplate{footline}{navigation}{%
  \usebeamertemplate{footline separator}%
  \begin{beamercolorbox}[wd=\paperwidth,ht=2.25ex,dp=1ex]{footline}%
    \usebeamerfont{footline}%
    \kern\beamer@leftmargin
    \setlength{\fboxsep}{0pt}%
    \setbeamercolor{navigation box}{bg=blue85}%
    \ifnum\my@totalsectionnumber=0%
      \insertshorttitle
    \else
      \let\sectionentry=\my@sectionentry@show
      \let\slideentry=\my@slideentry@empty
      \dohead
    \fi
    \hfill
    \usebeamertemplate{footline navigation}%
    \kern\beamer@rightmargin
  \end{beamercolorbox}%
}

%% ------------------------- frame title -----------------------------

% remove extra vertical space after frametitle
\patchcmd{\endbeamer@frameslide}{\vskip0.25em}{\relax}{}{}

\defbeamertemplate{frametitle}{simple}[1][]
{%
  \nointerlineskip
  \begin{beamercolorbox}[wd=\paperwidth,sep=0pt,leftskip=\beamer@leftmargin,%
                         rightskip=\beamer@rightmargin,#1]{frametitle}
    \usebeamerfont{frametitle}%
    \rule[-3mm]{0pt}{10mm}\insertframetitle\rule[-3mm]{0pt}{10mm}\par
  \end{beamercolorbox}
}

%% ------------------- block and theorem -----------------------------

% allow it to be modified by user
\def\myinserttheoremaddition{\inserttheoremaddition}

\defbeamertemplate{theorem begin}{simple}
{%
  \upshape%\bfseries\inserttheoremheadfont
  {\usebeamercolor[fg]{theoremname}%
  \inserttheoremname\inserttheoremnumber
  \ifx\inserttheoremaddition\@empty\else
    \ \usebeamercolor[fg]{local structure}(\myinserttheoremaddition)%
  \fi%
  %\inserttheorempunctuation
  }%
  \quad\normalfont
}
\defbeamertemplate{theorem end}{simple}{\par}

\defbeamertemplate{proof begin}{simple}
{%
  %\bfseries
  \let\@addpunct=\@gobble
  {\usebeamercolor[fg]{proofname}\insertproofname}%
  \quad\normalfont
}
\defbeamertemplate{proof end}{simple}{\par}

%% ---------------------- enumerate and itemize ----------------------

\expandafter\patchcmd\csname beamer@@tmpop@enumerate item@square\endcsname
         {height1.85ex depth.4ex}{height1.85ex depth.3ex}{}{}
\expandafter\patchcmd\csname beamer@@tmpop@enumerate subitem@square\endcsname
         {height1.85ex depth.4ex}{height1.85ex depth.3ex}{}{}
\expandafter\patchcmd\csname beamer@@tmpop@enumerate subsubitem@square\endcsname
         {height1.85ex depth.4ex}{height1.85ex depth.3ex}{}{}

%% ------------------------ select templates -------------------------

\setbeamertemplate{background canvas}[default]
\setbeamertemplate{background}[line]
\setbeamertemplate{headline}[shading]
\setbeamertemplate{footline}[navigation]
\setbeamertemplate{footline navigation}[section]
\setbeamertemplate{footline separator}[shading]
\setbeamertemplate{footline left}[author]
\setbeamertemplate{footline center}[title]
\setbeamertemplate{footline right}[number]
\setbeamertemplate{title page}[banner]
\setbeamertemplate{title page content}[hexagon]
\setbeamertemplate{section page}[fill]
\setbeamertemplate{show sections in toc}[partial]
\setbeamertemplate{section name}[simple]
\setbeamertemplate{section name in toc}[simple]
\setbeamertemplate{section in toc}[fill]
\setbeamertemplate{section in toc shaded}[default][50]
\setbeamertemplate{subsection page}[fill]
\setbeamertemplate{subsection name}[simple]
\setbeamertemplate{subsection name in toc}[simple]
\setbeamertemplate{subsection in toc}[fill]
\setbeamertemplate{subsection in toc shaded}[default][50]
\setbeamertemplate{theorem begin}[default]
\setbeamertemplate{theorem end}[default]
\setbeamertemplate{proof begin}[default]
\setbeamertemplate{proof end}[default]
\setbeamertemplate{frametitle}[simple]
\setbeamertemplate{navigation symbols}{}
\setbeamertemplate{itemize items}[square]
\setbeamertemplate{enumerate items}[square]

%% --------------------------- font theme ----------------------------

\setbeamerfont{title}{size=\LARGE}
\setbeamerfont{subtitle}{size=\large}
\setbeamerfont{author}{size=\normalsize}
\setbeamerfont{institute}{size=\normalsize}
\setbeamerfont{date}{size=\normalsize}
\setbeamerfont{occasion}{size=\normalsize}
\setbeamerfont{section in toc}{size=\large}
\setbeamerfont{subsection in toc}{size=\large}
\setbeamerfont{frametitle}{size=\large}
\setbeamerfont{block title}{size=\normalsize}
\setbeamerfont{item projected}{size=\footnotesize}
\setbeamerfont{subitem projected}{size=\scriptsize}
\setbeamerfont{subsubitem projected}{size=\tiny}

\usefonttheme{professionalfonts}
%\usepackage{arev}

%% ---------------------------- color theme --------------------------

% always use rgb colors in pdf files
\substitutecolormodel{hsb}{rgb}

\definecolor{red99}{Hsb}{0,0.9,0.9}
\definecolor{yellow5x}{Hsb}{60,0.5,1}
\definecolor{yellow6x}{Hsb}{53,0.6,1}
\definecolor{yellow86}{Hsb}{60,0.8,0.6}
\definecolor{yellow99}{Hsb}{60,0.9,0.9}
\definecolor{cyan95}{Hsb}{180,0.9,0.5}
\definecolor{blue74}{Hsb}{240,0.7,0.4}
\definecolor{blue77}{Hsb}{240,0.7,0.7}
\definecolor{blue85}{Hsb}{230,0.8,0.5}
\definecolor{blue99}{Hsb}{240,0.9,0.9}
\definecolor{magenta88}{Hsb}{300,0.8,0.8}

\colorlet{text1}{black}
\colorlet{back1}{white}
\colorlet{accent1}{blue99}
\colorlet{accent2}{cyan95}
\colorlet{accent3}{red99}
\colorlet{accent4}{yellow86}
\colorlet{accent5}{magenta88}
\colorlet{filler1}{accent1!40!back1}
\colorlet{filler2}{accent2!40!back1}
\colorlet{filler3}{accent3!40!back1}
\colorlet{filler4}{accent4!40!back1}
\colorlet{filler5}{accent5!40!back1}
\colorlet{gray1}{black!20}
\colorlet{gray2}{black!35}
\colorlet{gray3}{black!50}
\colorlet{gray4}{black!65}
\colorlet{gray5}{black!80}
\colorlet{tcolor}{text1!10!back1}
\colorlet{dcolor}{white}
\colorlet{fcolor}{blue77}
\colorlet{fcolor2}{gray3}
\colorlet{markcolor}{gray}

\setbeamercolor{normal text}{bg=white,fg=black}
\setbeamercolor{structure}{fg=blue85}
\setbeamercolor{local structure}{fg=cyan95}
\setbeamercolor{footline}{bg=,fg=black}
\setbeamercolor{title}{fg=yellow99}
\setbeamercolor{subtitle}{fg=white}
\setbeamercolor{author}{fg=black}
\setbeamercolor{institute}{fg=black}
\setbeamercolor{date}{fg=white}
\setbeamercolor{occasion}{fg=white}
\setbeamercolor{section name}{fg=blue85}
\setbeamercolor{section in toc}{fg=yellow6x,bg=blue85}
\setbeamercolor{section in toc shaded}{fg=white,bg=blue74}
\setbeamercolor{subsection name}{parent=section name}
\setbeamercolor{subsection in toc}{fg=yellow5x,bg=accent2}
\setbeamercolor{subsection in toc shaded}{fg=white,bg=accent2!50!black}
\setbeamercolor{frametitle}{parent=structure}
\setbeamercolor{theoremname}{fg=blue77}
\setbeamercolor{proofname}{fg=blue77}
\setbeamercolor{block title}{fg=accent1,bg=gray}
\setbeamercolor{block body}{bg=lightgray}
\setbeamercolor{block title example}{fg=accent2,bg=gray}
\setbeamercolor{block body example}{bg=lightgray}
\setbeamercolor{block title alerted}{fg=accent3,bg=gray}
\setbeamercolor{block body alerted}{bg=lightgray}

%% ----------------------- handout mode ------------------------------

\mode<handout>{
  \setbeamertemplate{background canvas}{}
  \setbeamertemplate{background}[empty]
  \setbeamertemplate{headline}[phantom]
  \setbeamertemplate{footline}[sectioning]
  \setbeamertemplate{section page}[single]
  \setbeamertemplate{subsection page}[single]
  \setbeamerfont{subsection in toc}{size=\large}
  \colorlet{dcolor}{darkgray}
  \colorlet{fcolor}{white}
  \colorlet{fcolor2}{gray1}
  \setbeamercolor{normal text}{fg=black, bg=white}
  \setbeamercolor{title}{fg=blue}
  \setbeamercolor{subtitle}{fg=gray}
  \setbeamercolor{occasion}{fg=black}
  \setbeamercolor{date}{fg=black}
  \setbeamercolor{section in toc}{fg=blue!90!gray,bg=}
  \setbeamercolor{section in toc shaded}{fg=lightgray,bg=}
  \setbeamercolor{subsection in toc}{fg=blue!80!gray}
  \setbeamercolor{subsection in toc shaded}{fg=lightgray}
  \setbeamercolor{frametitle}{fg=blue!70!gray,bg=}
  \setbeamercolor{theoremname}{fg=blue!60!gray}
  \setbeamercolor{proofname}{fg=blue!60!gray}
  \setbeamercolor{footline}{bg=white,fg=black}
}

\mode
<all>

\makeatother