summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/semtex/semtex.sty
blob: f7d979205d173059373716a84a419f8a4691a08f (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
\RequirePackage{xparse}
\ProvidesExplPackage{semtex}{2020/09/10}{0.2}{}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%																%
%		semtex -- for documents stripped of SemanTeX markup		%
%		https://ctan.org/pkg/semantex							%
%		(C) 2020 Sebastian Ørsted								%
%       sorsted@gmail.com										%
%																%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Bullets:

\box_if_exist:NF \g__semantex_bullet_box
{
	\box_new:N \g__semantex_bullet_box
	\hbox_set:Nn \g__semantex_bullet_box { $\cdot$ }
	\box_scale:Nnn \g__semantex_bullet_box {1.2} {1.2}
	\tl_set:Nn\g_semantex_bullet
	{
		\box_move_up:nn{-0.25ex}{\box_use:N \g__semantex_bullet_box}
	}

	\tl_set:Nn\g_semantex_double_bullet{\g_semantex_bullet \g_semantex_bullet}
	
	\tl_set_eq:NN\SemantexBullet \g_semantex_bullet
	
	\tl_set_eq:NN \SemantexDoubleBullet \g_semantex_double_bullet
}

% Parentheses:

\cs_set:Npn\SemantexLeft { \mathopen{}\mathclose\bgroup\left }

\cs_set:Npn\SemantexRight { \aftergroup\egroup\right }

\tl_set:Nn\SemantexDelimiterSize{}

\DeclareDocumentCommand\SemantexParentheses { mmmm }
{
	\str_case:nnF { #1 } % This is where \big,\Big, etc. go.
	{
		{ normal } {
			\group_begin:
			\tl_clear:N \SemantexDelimiterSize
			\str_if_eq:nnF { #2 } { . } { \mathopen #2 }
			#4
			\str_if_eq:nnF { #3 } { . } { \mathclose #3 }
			\group_end:
		}
		{ auto } {
			\group_begin:
			\tl_set_eq:NN \SemantexDelimiterSize \middle
			\SemantexLeft #2
			#4
			\SemantexRight #3
			\group_end:
		}
		{ * } {
			\group_begin:
			\tl_set_eq:NN \SemantexDelimiterSize \middle
			\SemantexLeft #2
			#4
			\SemantexRight #3
			\group_end:
		}
	}
	{
		\group_begin:
		\tl_set_eq:NN\SemantexDelimiterSize #1
		\mathopen #1 #2
		#4
		\mathclose #1 #3
		\group_end:
	}
}

\DeclareDocumentCommand\SemantexNoParentheses { m }
{
	\group_begin:
	\tl_clear:N\SemantexDelimiterSize
	#1
	\group_end:
}