summaryrefslogtreecommitdiff
path: root/language/korean/kotex-oblivoir/tex/memhangul-common/oblivoir-misc.sty
blob: d55aa9001563a50d107e2fe50583297dfb1a6ca1 (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
%% file oblivoir-misc.sty
%% part of oblivoir class
%%
%% (c) 2022 Kangsoo Kim 
%%
%% 2022-03-01, 03-06
%%
\ProvidesPackage{oblivoir-misc}[2022/03/06 version0.2]

\RequirePackage{etoolbox}

%%% tikz pagenode
%%% see http://www.ktug.org/xe/index.php?mid=KTUG_QnA_board&document_srl=253542

\AtEndPreamble{%
\@ifpackageloaded{pgf}{%
\newcommand\setpagenode{%
    \expandafter\def\csname pgf@sh@ns@current page\endcsname{rectangle}%
    \strictpagecheck%
    \checkoddpage%
    \ifoddpage%
        \expandafter\def\csname pgf@sh@np@current page\endcsname{%
          \def\southwest{\pgfpoint{\stockwidth-\paperwidth-\trimedge}%
                                  {\stockheight-\trimtop-\paperheight}}%
          \def\northeast{\pgfpoint{\stockwidth-\trimedge}{\stockheight-\trimtop}}%
        }%
    \else
        \expandafter\def\csname pgf@sh@np@current page\endcsname{%
          \def\southwest{\pgfpoint{\trimedge}{\stockheight-\trimtop-\paperheight}}%
          \def\northeast{\pgfpoint{\trimedge+\paperwidth}{\stockheight-\trimtop}}%
        }%
    \fi
    \expandafter\def\csname pgf@sh@nt@current page\endcsname{{1}{0}{0}{1}{0pt}{0pt}}%
    \expandafter\def\csname pgf@sh@pi@current page\endcsname{pgfpageorigin}}

\pgfkeys{/tikz/overlay/.add code={}{\setpagenode}}
\fi
}{}
}

%%% \texthl
%%% from oblivoir-patch2.sty, 2021
%%% \texthl command
%%% highlighs text in XeTeX
%%%	 * now, in mathmode it doesn't work.
%%%. * now, lualatex is not supported.
%%% 
%%% \obhlcolor, \obhlheight, \obhlraisedim can be redefined by user.
\ExplSyntaxOn
\bool_new:N \g_ulemloaded_bool
\bool_new:N \g_xcolorloaded_bool
\dim_new:N \obhlraisedim
\dim_new:N \obhlheight
\AtEndPreamble{
	\@ifpackageloaded{color}
		{ \bool_set_true:N \g_xcolorloaded_bool }
		{ 
		  \@ifpackageloaded{xcolor}
			{ \bool_set_true:N \g_xcolorloaded_bool }	
			{ \bool_set_false:N \g_xcolorloaded_bool }
		}
	\@ifpackageloaded{ulem}
		{ \bool_set_true:N \g_ulemloaded_bool }
		{ \bool_set_false:N \g_ulemloaded_bool 
		  \let\UL@protected\protected
		}
  \sys_if_engine_luatex:TF {
    \cs_if_exist:NF \obhlcolor { \def\obhlcolor{yellow!80} }
    \dim_set:Nn \obhlraisedim { -.1\baselineskip }
    \dim_set:Nn \obhlheight { 1.01em }
    \NewDocumentCommand\texthl{}{
      \bool_if:NTF \g_ulemloaded_bool
      {
      	\msg_error:nn { texthl } { Do~not~use~ulem~with~luatexko. }
	  }
	  {
	    \hbox_set:Nn \l_tmpa_box { \color{\obhlcolor}\rule{1pt}{\obhlheight} }
    	\markoverwith{ 
	  	  \box_move_up:nn { \obhlraisedim } { \box_use:N \l_tmpa_box }
	    }
      }
    }
  }{
%  \sys_if_engine_xetex:TF {
        \bool_if:nTF 
        {
        	\g_ulemloaded_bool
        	&&
        	\g_xcolorloaded_bool
        }
        {
        	\cs_if_exist:NF \obhlcolor
        	{
        		\def\obhlcolor{yellow!80}
        	}
        	\dim_set:Nn \obhlraisedim { -.1\baselineskip }
        	\dim_set:Nn \obhlheight { 1.01em }
            \UL@protected\def \texthl 
            {
                \bgroup
                \hbox_set:Nn \l_tmpa_box {\color{\obhlcolor}\rule{1pt}{\obhlheight}}
                \box_set_ht:Nn \l_tmpa_box { \c_zero_dim }
                \box_set_dp:Nn \l_tmpa_box { \c_zero_dim }
                \markoverwith{%
                	\kern-.1pt
                	\box_move_up:nn { \obhlraisedim } { \box_use:N \l_tmpa_box }
                }\ULon
            }
        }
        {
        	\def\texthl {
        		\msg_error:nn { texthl } { ulem~and~(x)color~required.}
        	}
        }
%	}
%	{
%		\msg_error:nn { texthl } { pdftex~not~supported }
%	}
  }
}
\ExplSyntaxOff

\endinput