115 lines
4.2 KiB
TeX
115 lines
4.2 KiB
TeX
\RequirePackage{tikz}
|
|
\RequirePackage{tikzpagenodes}
|
|
|
|
\usetikzlibrary{calc,tikzmark}
|
|
|
|
|
|
\newtheorem{main}{XXX}[section]
|
|
|
|
\makeatletter
|
|
\newcommand{\checkmarkpage}[4]% #1 = tikzmark label, #2 = less, #3 = equal, #4 = greater
|
|
{\@ifundefined{save@pt@#1}{#2}{%
|
|
\edef\markid{\csname save@pt@#1\endcsname}%
|
|
\edef\markpage{\csname save@pg@\markid\endcsname}%
|
|
\ifnum\thepage<\markpage\relax #2%
|
|
\else
|
|
\ifnum\thepage=\markpage\relax #3%
|
|
\else #4%
|
|
\fi
|
|
\fi}%
|
|
}
|
|
\makeatother
|
|
|
|
\newcommand{\drawoutline}[3]{%
|
|
\checkmarkpage{begin#1\csname theoutlinedone#1\endcsname}{}%
|
|
{\begin{tikzpicture}[remember picture, overlay]
|
|
\path ({pic cs:begin#1\csname theoutlinedone#1\endcsname}-| current page text area.west)
|
|
++(0pt,\ht\strutbox) coordinate (A#1);
|
|
\checkmarkpage{end#1\csname theoutlinedone#1\endcsname}%
|
|
{\path (current page text area.south west) ++(0pt,-\dp\strutbox) coordinate(B#1);
|
|
\path (current page text area.south east) ++(0pt,-\dp\strutbox) coordinate(C#1);}%
|
|
{\path ({pic cs:end#1\csname theoutlinedone#1\endcsname}-| current page text area.west) ++(0pt,-\dp\strutbox) coordinate(B#1);
|
|
\path ({pic cs:end#1\csname theoutlinedone#1\endcsname}-| current page text area.east) ++(0pt,-\dp\strutbox) coordinate(C#1);}%
|
|
{}% this should not happen
|
|
\fill[#2] ($(A#1) + (-3pt,0pt)$) rectangle ($(B#1) + (-4.5pt,0pt)$);
|
|
\fill[#3] ($(A#1) + (-3pt,0pt)$) rectangle ($(C#1) + (3pt,0pt)$);
|
|
\end{tikzpicture}}%
|
|
{\begin{tikzpicture}[remember picture, overlay]
|
|
\coordinate (A#1) at (current page text area.north west);
|
|
\checkmarkpage{end#1\csname theoutlinedone#1\endcsname}%
|
|
{\path (current page text area.south west) ++(0pt,-\dp\strutbox) coordinate(B#1);
|
|
\path (current page text area.south east) ++(0pt,-\dp\strutbox) coordinate(C#1);}%
|
|
{\path ({pic cs:end#1\csname theoutlinedone#1\endcsname}-| current page text area.west) ++(0pt,-\dp\strutbox) coordinate(B#1);
|
|
\path ({pic cs:end#1\csname theoutlinedone#1\endcsname}-| current page text area.east) ++(0pt,-\dp\strutbox) coordinate(C#1);}%
|
|
{}% this should not happen
|
|
\fill[#2] ($(A#1) + (-3pt,0pt)$) rectangle ($(B#1) + (-4.5pt,0pt)$);
|
|
\fill[#3] ($(A#1) + (-3pt,0pt)$) rectangle ($(C#1) + (3pt,0pt)$);
|
|
\end{tikzpicture}}%
|
|
\checkmarkpage{end#1\csname theoutlinedone#1\endcsname}{}%
|
|
{\stepcounter{outlinedone#1}\drawoutline{#1}{#2}{#3}}%
|
|
{}% this should not happen
|
|
}
|
|
|
|
\def\cthBODYFONT{\itshape}
|
|
\def\cthHEADFONT{\bfseries}
|
|
|
|
\makeatletter
|
|
\newcommand{\colortheoremstyle}[1]{%
|
|
\ifthenelse{\equal{#1}{plain}}%
|
|
{%
|
|
\def\cthBODYFONT{\itshape}%
|
|
\def\cthHEADFONT{\bfseries}%
|
|
}{%
|
|
\ifthenelse{\equal{#1}{definition}}%
|
|
{%
|
|
\def\cthBODYFONT{\normalfont}%
|
|
\def\cthHEADFONT{\bfseries}%
|
|
}{%
|
|
\def\cthBODYFONT{\itshape}%
|
|
\def\cthHEADFONT{\itshape}%
|
|
}%
|
|
}%
|
|
}%
|
|
\makeatother
|
|
|
|
\newcommand\newctheorem[4][white]{%
|
|
\newcounter{outlineid#2}%
|
|
\newcounter{outlinedone#2}%
|
|
\newcounter{outlinefinal#2}%
|
|
\AddToHook{shipout/background}{
|
|
\drawoutline{#2}{#4}{#1}
|
|
}%
|
|
\makeatletter
|
|
\expandafter\let\csname color@th@BODYFONT@#2\endcsname\cthBODYFONT%
|
|
\expandafter\let\csname color@th@HEADFONT@#2\endcsname\cthHEADFONT%
|
|
\newtheoremstyle{thmcolor#2}
|
|
{\topsep} % ABOVESPACE
|
|
{\topsep} % BELOWSPACE
|
|
{\csname color@th@BODYFONT@#2\endcsname} % BODYFONT
|
|
{0pt} % INDENT (empty value is the same as 0pt)
|
|
{\csname color@th@HEADFONT@#2\endcsname\color{#4}} % HEADFONT
|
|
{.}
|
|
{5pt plus 1pt minus 1pt}
|
|
{}
|
|
\makeatother
|
|
\theoremstyle{thmcolor#2}%
|
|
\newtheorem{i#2}[main]{%
|
|
\stepcounter{outlinefinal#2}%
|
|
\tikzmark{begin#2\csname theoutlineid#2\endcsname}#3%
|
|
}%
|
|
\newenvironment{#2}[1][]%
|
|
{\begingroup%
|
|
\def\finalaqui{%
|
|
\tikzmark{end#2\csname theoutlineid#2\endcsname}%
|
|
\stepcounter{outlineid#2}\ignorespaces}%
|
|
\begin{i#2}[##1]}%
|
|
{%
|
|
\ifnum\csname theoutlinefinal#2\endcsname>\csname theoutlineid#2\endcsname%
|
|
\tikzmark{end#2\csname theoutlineid#2\endcsname}%
|
|
\stepcounter{outlineid#2}\ignorespaces%
|
|
\fi\end{i#2}%
|
|
\endgroup%
|
|
}%
|
|
}%
|
|
|