📄 ctextemp_texpower.sty
字号:
\newcommand{\dumpcolorset}[1]%
{%
\nonnormalwarnings@TP{Dumping color set #1}% Output a warning for every color not in the normal variant.
\replacecolors@TP{#1}{}{}{}% Dump normal variant (hopefully).
\replacecolors@TP{#1}{d}{}{d}% Dump dimmed variant.
\replacecolors@TP{#1}{e}{}{e}% Dump enhanced variant.
}%
% Commands for color variants.
\newcommand{\registervariant@TP}[2]% Remember which variant a color is currently in.
{\expandafter\def\csname cvar@#1@TP\endcsname{#2}}
\newcommand{\register@normalvariant@TP}[1]% Register that a color is now in the normal variant.
{\registervariant@TP{#1}{}}
\newcommand{\currentvariant@TP}[1]% Return the current variant of a color.
{\csname cvar@#1@TP\endcsname}
\newcommand{\ifnormalvariant@TP}[3]% Conditional for checking whether a color is in the normal variant.
{\ifthenelse{\equal{\currentvariant@TP{#1}}{}}{#2}{#3}}
\newcommand{\nonnormalwarnings@TP}[1]% Checks the current variant for every standard color and gives a warning
{% if it's not the normal one.
\def\processme@TP##1%
{%
\ifnormalvariant@TP{##1}{}
{%
\PackageWarning{texpower}
{#1\MessageBreak when color ##1 is in \currentvariant@TP{##1} variant}%
}%
}%
\colors@TP
}
% Default dim level for automatic color dimming.
\newcommand{\dimlevel}{.7}
% \dimcolor[<level>]{<color>} dims the color named <color>. It checks whether an explicit `dimmed' variant d<color>
% exists. If yes, <color> is replaced by d<color>. Otherwise, the dimmed color is calculated by interpolating between
% pagecolor and <color>. The parameter for \colorbetween is given by the optional argument <level> (default:
% \dimlevel).
\newcommand{\dimcolor}[2][\dimlevel]
{%
\ifnormalvariant@TP{#2}% Color in the normal variant?
{% Yes.
\registervariant@TP{#2}{d}% Register dimmed variant.
\ifcolorexists@TP{d#2}% Dedicated dimmed color found?
{\replacecolor{#2}{d#2}}% Yes. use that one.
{\colorbetween[#1]{#2}{pagecolor}{#2}}% No. Dim numerically using \colorbetween.
}%
{}% No. Do nothing.
}
% \dimcolors[<level>] dims all standard colors using \dimcolor. See the description of \dimcolor for details.
\newcommand{\dimcolors}[1][\dimlevel]
{%
\def\processme@TP##1{\dimcolor[#1]{##1}}%
\colors@TP
}%
% Default enhance level for automatic color enhancing.
\newcommand{\enhancelevel}{.5}
% \enhancecolor[<level>]{<color>} enhances the color named <color>. It checks whether an explicit `enhanced' variant
% e<color> exists. If yes, <color> is replaced by e<color>. Otherwise, the enhanced color is calculated by
% `extrapolating' from pagecolor and <color>. The parameter for \colorbetween is given by the optional argument
% <level> (default: \enhancelevel).
\newcommand{\enhancecolor}[2][\enhancelevel]
{%
\ifnormalvariant@TP{#2}% Color in the normal variant?
{%
\registervariant@TP{#2}{e}% Register enhanced variant.
\ifcolorexists@TP{e#2}% Dedicated enhanced color found?
{\replacecolor{#2}{e#2}}% Yes. use that one.
{\colorbetween[-#1]{#2}{pagecolor}{#2}}% No. Enhance numerically using \colorbetween.
}%
{}%
}%
% \enhancecolors[<level>] enhances all standard colors using \enhancecolor. See the description of \enhancecolor for
% details.
\newcommand{\enhancecolors}[1][\enhancelevel]
{%
\def\processme@TP##1{\enhancecolor[#1]{##1}}%
\colors@TP
}%
\newcommand{\replacecolorsbyone@TP}[2]% Replace all colors from the current color set by a single color.
{%
\def\processme@TP##1{\replacecolor{#1##1}{#2}}%
\colors@TP
}
% The color used to make things `vanish'.
\newcommand{\vanishcolor}{pagecolor}
% \vanishcolors replaces all standard colors by \vanishcolor.
\newcommand{\vanishcolors}[1][\vanishcolor]{\replacecolorsbyone@TP{}{#1}}
% TeXPower's predefined color sets and commands to activate them. Redefine in tpcolors.cfg as convenient.
\input{tpcolors.cfg}
% \whitebackground sets the standard colors up for white background.
\newcommand{\whitebackground}%
{%
\usecolorset{whitebg}%
}
% When the whitebackground option (or no background option, but some other color-activating option like colormath) is
% given, \whitebackground is executed automatically.
\ifthenelse{\boolean{whitebackground@TP}}
{\AtEndOfPackage{\whitebackground}}% Execute after texpower.cfg was read (for redefinitions).
{}
% \lightbackground sets the standard colors up for `light' background.
\newcommand{\lightbackground}%
{%
\usecolorset{lightbg}%
}
% When the lightbackground option is given, \lightbackground is executed automatically.
\ifthenelse{\boolean{lightbackground@TP}}{\AtEndOfPackage{\lightbackground}}{}
% \darkbackground sets the standard colors up for `dark' background.
\newcommand{\darkbackground}%
{%
\usecolorset{darkbg}%
}
% Execute \darkbackground automatically if the darkbackground option was given.
\ifthenelse{\boolean{darkbackground@TP}}{\AtEndOfPackage{\darkbackground}}{}
% \blackbackground sets the standard colors up for black background.
\newcommand{\blackbackground}%
{%
\usecolorset{blackbg}%
}
% Execute \blackbackground automatically if the blackbackground option was given.
\ifthenelse{\boolean{blackbackground@TP}}{\AtEndOfPackage{\blackbackground}}{}
\ifthenelse{\boolean{TPcolor}}{\AtEndOfPackage{\color{textcolor}\let\default@color\current@color}}{}
% If TeXPower's color management is active, set page and text color at the beginning of the document.
\ifthenelse{\boolean{TPcolor}}{\AtBeginDocument{\pagecolor{pagecolor}\color{textcolor}}}{}
}% matches \ifthenelse{\boolean{TPcolor}}{% Yes.
{% No; provide dummies.
\let\setcolor@TP=\@gobble%
\newcommand{\@replacecolor@TP}[2][]{}%
\let\addTPcolor=\@gobble
\newcommand{\defineTPcolor}[4][]{}%
\let\usecolorset=\@gobble
\let\dumpcolorset=\@gobble
\newcommand{\dimcolor}[2][]{}
\newcommand{\dimcolors}[1][]{}
\newcommand{\enhancecolor}[2][]{}
\newcommand{\enhancecolors}[1][]{}
\newcommand{\vanishcolors}[1][]{}
}
%-----------------------------------------------------------------------------------------------------------------------
% Implementation of the coloremph option.
\ifthenelse{\boolean{coloremph@TP}}% Should \emph use color?
{% Yes;
\DeclareRobustCommand{\em}% Redefine \em.
{%
\@nomath\em \color{emcolor}% Change color.
\replacecolor{tmp@TP}{emcolor}% Exchange emcolor and altemcolor.
\replacecolor{emcolor}{altemcolor}%
\replacecolor{altemcolor}{tmp@TP}%
}%
}%
{}% No; keep original definition.
%-----------------------------------------------------------------------------------------------------------------------
% Implementation of the colormath option.
% Note that the following code is quite fragile and contains some modifications of LaTeX internals. Thus it is likely to
% cause trouble, especially in conjunction with other packages modifying the LaTeX kernel. The array package is
% supported, but no explicit support of other packages exists. If you experience strange and inexplicable errors while
% the colormath option is active, first of all try switching it off to see whether anything changes.
% The implementation of colormath is likely to change several times before the first beta release, so expect backward
% incompatible changes in behaviour.
\ifthenelse{\boolean{colormath@TP}}% Should we color math?
{% Yes.
\AtBeginDocument
{%
% The most basic magical incantation: Color inline math using \everymath. Beware of side effects of this hack.
\expandafter\everymath\expandafter{\the\everymath\color{mathcolor}}%
% Color displayed math by overloading LaTeX's own math environments. Note that this doesn't work for the TeX
% notation $$, which is deprecated in LaTeX anyway.
% Note further that for the eqnarray and eqnarray* environments, the current implementation places the color change
% command OUTSIDE the math environment (for technical reasons; maybe this can be remedied by a more sophisticated
% implementation), which will almost invariably lead to unwanted extra vertical space before and after equation
% arrays. Currently there is no clean remedy, apart from using amsmath's align environment.
\let\o@dm@TP=\[% Save the original definitions of begin and end macros for
\let\o@enddm@TP=\]% LaTeX's displayed math environments.
\let\o@eqa@TP=\eqnarray%
\let\o@endeqa@TP=\endeqnarray%
\expandafter\let\expandafter\o@eqastar@TP\csname eqnarray*\endcsname%
\expandafter\let\expandafter\o@endeqastar@TP\csname endeqnarray*\endcsname%
\def\[{\o@dm@TP\begingroup\color{mathcolor}}% Redefine the begin and end macros for LaTeX's displayed math
\def\]{\endgroup\o@enddm@TP}% environments, adding the color change commands and an extra
\def\eqnarray{\begingroup\color{mathcolor}\o@eqa@TP}% level of grouping.
\def\endeqnarray{\o@endeqa@TP\endgroup\@ignoretrue}%
\@namedef{eqnarray*}{\begingroup\color{mathcolor}\o@eqastar@TP}
\@namedef{endeqnarray*}{\o@endeqastar@TP\endgroup\@ignoretrue}
\@ifpackageloaded{amsmath}% Amsmath's displayed math environments are covered by the
{% \everymath hack because they are `fake' displayed equations.
\@ifpackagelater{amsmath}{2000/01/15}% As amsmath 1.x redefines the equation environment to be a
{% variant of gather, treating it as a displayed math
\let\o@eq@TP=\equation% environment would lead to problems, so this redefinition is
\let\o@endeq@TP=\endequation% made only if amsmath 1.x is not loaded.
\def\equation{\o@eq@TP\begingroup\color{mathcolor}}%
\def\endequation{\endgroup\everymath{}\o@endeq@TP}%
}%
{}%
}%
{%
\let\o@eq@TP=\equation%
\let\o@endeq@TP=\endequation%
\def\equation{\o@eq@TP\begingroup\color{mathcolor}}%
\def\endequation{\endgroup\everymath{}\o@endeq@TP}%
}%
}% matches \AtBeginDocument{
%
% Sometimes, a math environment is used for something other than displaying math. The macro \origmath will put its
% argument in math mode, but turn off coloring. If another math environemt should be nested inside the argument of
% \origmath, it will be coloured.
\newcommand{\origmath}[1]{{\everymath{}\ensuremath{\everymath{\color{mathcolor}}#1}}}%
%
% We need to redefine some LaTeX macros which internally use math mode, to make sure that not all tabulars and
% parboxes are coloured. Note that this can break packages which mess with tabular themselves.
\renewcommand*\labelitemi{\origmath{\m@th\bullet}}%
\@ifpackageloaded{array}% The array package redefines \@tabular
{%
\def\@tabular{%
\leavevmode
\hbox \bgroup \everymath{}$\everymath{\color{mathcolor}}\col@sep\tabcolsep \let\d@llarbegin\begingroup % $
\let\d@llarend\endgroup
\@tabarray
}%
\@ifpackageloaded{colortbl}
{%
\def\@classz{\@classx
\@tempcnta \count@
\prepnext@tok
\expandafter\CT@extract\the\toks\@tempcnta\columncolor!\@nil
\@addtopreamble{%
\setbox\z@\hbox\bgroup\bgroup
\ifcase \@chnum
\hskip\stretch{.5}\kern\z@
\d@llarbegin
\insert@column
\d@llarend\hskip\stretch{.5}\or
\d@llarbegin \insert@column \d@llarend \hfill \or
\hfill\kern\z@ \d@llarbegin \insert@column \d@llarend \or
\@startvcenter
\@startpbox{\@nextchar}\insert@column \@endpbox $\or % $
\vtop \@startpbox{\@nextchar}\insert@column \@endpbox \or
\vbox \@startpbox{\@nextchar}\insert@column \@endpbox
\fi
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -