This commit is contained in:
EthanDeng
2019-01-15 15:14:16 +08:00
parent 2866196be5
commit 1d6daabb30
7 changed files with 333 additions and 355 deletions

View File

@@ -5,11 +5,11 @@
%% This work may be distributed and/or modified freely
%% available at https://ddswhu.me/resource/
% %
%% Last Modification 2018-12-02
%% Last Modification 2018-12-06
%%%%%%%%%%%%%%%%%%%%%
% % !Mode:: "TeX:UTF-8"
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{elegantbook}[2014/01/20 v2.30 ElegantBook document class]
\ProvidesClass{elegantbook}[2018/12/06 v3.00 ElegantBook document class]
\RequirePackage{kvoptions}
\RequirePackage{etoolbox}
@@ -23,9 +23,10 @@
\DeclareVoidOption{cyan}{\ekv{color = cyan}}
\DeclareVoidOption{blue}{\ekv{color = blue}}
\DeclareVoidOption{nocolor}{\ekv{color = none}}
% ----- Math option -----
\DeclareBoolOption[true]{mathpazo}
\DeclareComplementaryOption{mtpro}{mathpazo}
\newcommand\mailto[1]{\href{mailto:#1}{\nolinkurl{#1}}}
% ----- Title Style -----
\DeclareStringOption[hang]{titlestyle}[hang]
% ----- backward compatibility
@@ -38,6 +39,17 @@
% \ProcessOptions*\relax
\LoadClass[12pt,a4paper,openany]{book}
% font setting for text and math
\RequirePackage[T1]{fontenc}
\RequirePackage{newtxtext}
\RequirePackage{newtxmath}
\RequirePackage[scale=0.85]{newtxtt}
\RequirePackage{type1cm}
\usepackage[UTF8,space=auto,scheme=plain]{ctex}
\usepackage{indentfirst}
\setlength\parindent{2em}
% ----- Handle Colors -----
%%
@@ -46,29 +58,28 @@
\definecolor{main}{RGB}{0,120,2}%
\definecolor{second}{RGB}{230,90,7}%
\definecolor{third}{RGB}{0,160,152}%
% \base{greenbase.pdf}%
}{\relax}
\ifdefstring{\ELEGANT@color}{cyan}{
\definecolor{main}{RGB}{0,175,152}%
\definecolor{second}{RGB}{239,126,30}%
\definecolor{third}{RGB}{120,8,13}%
% \base{cyanbase.pdf}%
}{\relax}
\ifdefstring{\ELEGANT@color}{blue}{
\definecolor{main}{RGB}{20,50,104}%
\definecolor{second}{RGB}{180,50,131}%
\definecolor{third}{RGB}{7,127,128}%
% \base{bluebase.pdf}%
}{\relax}
\definecolor{winered}{rgb}{0.5,0,0}
\AtBeginDocument{
\input{base.tex}
}
\providecommand{\base}{
\begin{tikzpicture}[scale=0.3]
\begin{tikzpicture}[scale=0.2]
\triz{0}{0}
\ellz{128}
\intz{149}
@@ -80,13 +91,6 @@
%\newcommand*{\base}{
%}
% ----- Handle Math option -----
\ifELEGANT@mathpazo
\RequirePackage{mathpazo}
\newcommand{\mbf}{\mathbf}
\else
\AtBeginDocument{\usepackage{mtpro2}}
\fi
% ----- Title Style -----
\ifdefstring{\ELEGANT@titlestyle}{hang}{\def\style{hang}}{\relax}
\ifdefstring{\ELEGANT@titlestyle}{display}{\def\style{display}}{\relax}
@@ -100,6 +104,31 @@
%%
%%
\renewcommand{\contentsname}{\hspace{2em}}
\renewcommand{\figurename}{}
\renewcommand{\tablename}{}
\renewcommand{\partname}{}
\renewcommand{\listfigurename}{\bfseries }
\renewcommand{\listtablename}{\bfseries }
\renewcommand{\bibname}{\bfseries }
\renewcommand{\appendixname}{\bfseries \hspace{2em}}
\renewcommand{\indexname}{\bfseries \hspace{2em}}
% more pretty font
\linespread{1.3}
\RequirePackage{microtype}
\RequirePackage{booktabs}
\RequirePackage{multicol}
\RequirePackage{xcolor}
\RequirePackage{graphicx}
\RequirePackage{fancyvrb}
\graphicspath{{image/}{figure/}{fig/}{img/}}
%%
\RequirePackage{graphicx}
\RequirePackage{enumerate}
@@ -112,7 +141,7 @@
\newcommand*{\myquote}[1]{\def\@myquote{#1}}
\newcommand*{\logo}[1]{
\def\@logo{\includegraphics[width=0.5\textwidth]{#1}
\def\@logo{\includegraphics[width=0.3\textwidth]{#1}
}
}
@@ -138,14 +167,15 @@
\hypersetup{
breaklinks,
unicode,
unicode,
bookmarksnumbered=true,
bookmarksopen=true,
pdfsubject=\@author \@title Book,
pdfkeywords={ElegantBook},
pdfcreator={XeLaTeX with ElegantBook class},
colorlinks,
linkcolor=main,
linkcolor=main,
citecolor=winered,
plainpages=false,
pdfstartview=FitH,
pdfborder={0 0 0},
@@ -165,194 +195,111 @@
%%
\RequirePackage[center,pagestyles]{titlesec}
\renewcommand{\chaptername}{ \thechapter }
\renewcommand{\chaptername}{ \thechapter\;}
\titleformat{\chapter}[\style]{\bfseries}
{\filcenter\LARGE\enspace\bfseries{\color{main}\chaptername}\enspace}{1pt}{\bfseries\color{main}\LARGE\filcenter}[\filcenter\base]
\titleformat{\section}[hang]{\sffamily}
\titleformat{\section}[hang]{\bfseries}
{\hspace{-2.45em}\Large\bfseries{\color{main}\thesection}\enspace}{1pt}{\color{main}\Large\bfseries\filright}
\titleformat{\subsection}[hang]{\sffamily}
\titleformat{\subsection}[hang]{\bfseries}
{\large\bfseries\color{main}\thesubsection\enspace}{1pt}{\color{main}\large\bfseries\filright}
\titlespacing{\chapter}{0pt}{0pt}{1.5\baselineskip}
%\titlespacing{\subsection}{0pt}{0.5\baselineskip}{-\baselineskip}
%%
\renewcommand{\contentsname}{\hspace{2em}}
\renewcommand{\figurename}{}
\renewcommand{\tablename}{}
\renewcommand{\partname}{}
\renewcommand{\listfigurename}{\bfseries }
\renewcommand{\listtablename}{\bfseries }
\renewcommand{\bibname}{\bfseries }
\renewcommand{\appendixname}{\bfseries \hspace{2em}}
\renewcommand{\indexname}{\bfseries \hspace{2em}}
\RequirePackage{caption}
\captionsetup{labelfont = bf}
%%
\RequirePackage{fontenc}
\RequirePackage[no-math,cm-default]{fontspec}
\defaultfontfeatures{Mapping=tex-text}
\RequirePackage{xunicode}
\RequirePackage{xltxtra}
\setmainfont[Ligatures=TeX]{Times New Roman} % (\textrm)
\setsansfont{Arial} % (\textsf)
\setmonofont{Courier New}%Palatino Linotype
%--%
\RequirePackage{xeCJK}
\setCJKmainfont[BoldFont={},ItalicFont={}]{}%_GBK Adobe Song Std L
\setCJKsansfont[BoldFont={},ItalicFont={}]{}
\setCJKmonofont{}
\XeTeXlinebreaklocale "zh"
\XeTeXlinebreakskip = 0pt plus 1pt
% list/itemize/enumerate setting
\RequirePackage[shortlabels]{enumitem}
\setlist{nolistsep}
% caption settings
\RequirePackage[font=small,labelfont={bf}]{caption}
\captionsetup[table]{skip=3pt}
\captionsetup[figure]{skip=3pt}
%% \\
\RequirePackage{environ}
\RequirePackage{tikz}
\usetikzlibrary{shapes,decorations}
\definecolor{bule}{RGB}{18,29,57}
\definecolor{bablue}{RGB}{248,248,248}
%define the style of tikz etheoremsty
\tikzstyle{etheoremsty}
=[draw=main, fill=blue!10,very thick,rectangle,
rounded corners, inner sep=10pt, inner ysep=20pt]
\tikzstyle{etheoremstytitle}
=[fill=main, text=blue!10]
\tikzstyle{edefinitionsty}
=[draw=second, fill=yellow!20,very thick,rectangle,
rounded corners, inner sep=10pt, inner ysep=20pt,
text=black,fill opacity=0.9]
\tikzstyle{edefinitionstytitle}
=[fill=second, text=white]
\tikzstyle{epropositionositionsty}
=[draw=third, fill=bablue,very thick,rectangle,
rounded corners, inner sep=10pt, inner ysep=20pt,
text=black,fill opacity=0.9]
\tikzstyle{epropositionositionstytitle}
=[fill=third, text=white]
%%define the "etheorem" environment
\newcounter{etheorem}[chapter]
\renewcommand{\theetheorem}{\thechapter.\arabic{etheorem}}
\NewEnviron{etheorem}[1][{}]{%
\begin{figure}[!htb]
\noindent\centering
\begin{tikzpicture}
\node[etheoremsty] (box){
\begin{minipage}{0.93\columnwidth}
\sffamily\refstepcounter{etheorem}\BODY
\end{minipage}};
\node[etheoremstytitle,right=10pt] at (box.north west){
\bf\textsf{Theorem \theetheorem\; #1}};
\node[etheoremstytitle, rounded corners] at (box.east) {$\clubsuit$};
\end{tikzpicture}
\end{figure}}
%%define the "elemma" environment
\newcounter{elemma}[chapter]
\renewcommand{\theelemma}{\thechapter.\arabic{elemma}}
\NewEnviron{elemma}[1][{}]{%
\begin{figure}[!htb]
\noindent\centering
\begin{tikzpicture}
\node[etheoremsty] (box){
\begin{minipage}{0.93\columnwidth}
\sffamily\refstepcounter{elemma}\BODY
\end{minipage}};
\node[etheoremstytitle,right=10pt] at (box.north west){
\bf\textsf{Lemma \theelemma\; #1}};
\node[etheoremstytitle, rounded corners] at (box.east) {$\clubsuit$};
\end{tikzpicture}
\end{figure}}
%%define the "ecorollary" environment
\newcounter{ecorollary}[chapter]
\renewcommand{\theecorollary}{\thechapter.\arabic{ecorollary}}
\NewEnviron{ecorollary}[1][{}]{%
\begin{figure}[!htb]
\noindent\centering
\begin{tikzpicture}
\node[etheoremsty] (box){
\begin{minipage}{0.93\columnwidth}
\sffamily\refstepcounter{ecorollary}\BODY
\end{minipage}};
\node[etheoremstytitle,right=10pt] at (box.north west){
\bf\textsf{Corollary \theecorollary\; #1}};
\node[etheoremstytitle, rounded corners] at (box.east) {$\clubsuit$};
\end{tikzpicture}
\end{figure}}
%% define the "proposition" environment
\newcounter{eproposition}[chapter]
\renewcommand{\theeproposition}{\thechapter.\arabic{eproposition}}
\NewEnviron{eproposition}[1][{}]{%
\begin{figure}[!htb]\noindent\centering
\begin{tikzpicture}
\node[epropositionositionsty] (box){
\begin{minipage}{0.93\columnwidth}
\sffamily\refstepcounter{eproposition}\BODY
\end{minipage}};
\node[epropositionositionstytitle,right=10pt] at (box.north west){
\bf\textsf{Proposition \theeproposition\; #1}};
\node[epropositionositionstytitle, rounded corners] at (box.east) {$\spadesuit$};
\end{tikzpicture}
\end{figure}}
%%define the "edefinition" environment
\newcounter{edefinition}[chapter]
\renewcommand{\theedefinition}{\thechapter.\arabic{edefinition}}
\NewEnviron{edefinition}[1][{}]{%
\begin{figure}[!htb]\noindent\centering
\begin{tikzpicture}
\node [edefinitionsty] (dbox){\begin{minipage}{0.93\textwidth}\itshape\refstepcounter{edefinition}\BODY\end{minipage}};
\node[edefinitionstytitle, right=10pt] at (dbox.north west) {\bf\textsf{Definition \theedefinition\; #1}};
\node[edefinitionstytitle, rounded corners] at (dbox.east) {$\heartsuit$};
\end{tikzpicture}
\end{figure}}
\RequirePackage[most]{tcolorbox}
\tcbset{
common/.style={
fontupper=\kaishu,
lower separated=false,
coltitle=white,
colback=gray!10,
fonttitle=\bfseries,
enhanced,
breakable,
top=8pt,
before skip=8pt,
attach boxed title to top left={yshift=-0.11in,xshift=0.15in},
boxed title style={boxrule=0pt,colframe=white,arc=0pt,outer arc=0pt},
},
defstyle/.style={
common,
colframe=main,
colbacktitle=main,
overlay unbroken and last={\node[anchor=south east, outer sep=6pt] at (\textwidth-width,0) {\textcolor{main}{$\clubsuit$}}; }
},
thmstyle/.style={
common,
colframe=second,
colbacktitle=second,
overlay unbroken and last={\node[anchor=south east, outer sep=6pt] at (\textwidth-width,0) {\textcolor{second}{$\heartsuit$}}; }
},
propstyle/.style={
common,
colframe=third,
colbacktitle=third,
overlay unbroken and last={\node[anchor=south east, outer sep=6pt] at (\textwidth-width,0) {\textcolor{third}{$\spadesuit$}}; }
},
}
\newtcbtheorem[auto counter,number within=chapter]{definition}{Definition}{defstyle}{def}
\newtcbtheorem[auto counter,number within=chapter]{theorem}{Theorem}{thmstyle}{thm}
\newtcbtheorem[auto counter,number within=chapter]{proposition}{Proposition}{propstyle}{prop}
\newtcbtheorem[auto counter,number within=chapter]{corollary}{Corollary}{thmstyle}{cor}
\newtcbtheorem[auto counter,number within=chapter]{lemma}{Lemma}{thmstyle}{lemma}
%% Example with counter
\newcounter{example}[chapter]
\renewcommand{\theexample}{\thechapter.\arabic{example}}
\newenvironment{example}{\par\noindent\textbf{Example\,\stepcounter{example}\theexample: }\color{black!90}}{\par}
\newenvironment{example}{\par\noindent\textbf{Example\,\refstepcounter{example}\theexample: }\color{black!90}}{\par}
%% Exercise with counter
\newcounter{exercise}[chapter]
\renewcommand{\theexercise}{\thechapter.\arabic{exercise}}
\newenvironment{exercise}{\par\noindent{\makebox[0pt][r]{\color{main}\ding{50}\;\;}}\textbf{Exercise\,\stepcounter{exercise}\theexercise: }}{\par}
\newenvironment{exercise}{\par\noindent\textbf{Exercise\,\refstepcounter{exercise}\theexercise: }}{\par}
%%define the note and eproof environment
%%define the note and proof environment
\RequirePackage{pifont,manfnt}
\newenvironment{note}{\par\itshape\noindent{\makebox[0pt][r]{\scriptsize\color{red!90}\textdbend\quad}\textbf{Note:}}}{\par}
\newenvironment{proof}{\par\noindent\textbf{Proof:}\color{black!90}\small}{\hfill$\Box$\quad\par}
\newenvironment{remark}{\par\itshape\noindent{\makebox[0pt][r]{\color{red!90}\ding{96}\quad}\textbf{Remarks:}}}{\par}
\newenvironment{remark}{\noindent\textbf{Remarks:}}{\par}
\newenvironment{assumption}{\par\noindent\textbf{Assumptions:}}{\par}
\newenvironment{conclusion}{\par\noindent\textbf{Conclusions:}}{\par}
\newenvironment{solution}{\par\noindent\textbf{Solution:}}{\par}
\newenvironment{property}{\par\noindent\textbf{Properties:}}{\par}
\newenvironment{assumption}{\par\noindent\textbf{Assumptions: }\color{black!90}}{\par}
\newenvironment{conclusion}{\par\noindent\textbf{Conclusions: }}{\par}
\newenvironment{property}{\par\noindent\textbf{Properties: }}{\par}
\newenvironment{eproof}{\par\noindent{\makebox[0pt][r]{\color{main}\ding{43}\;\;}\textbf{Proof:}}\color{black!90}\small}{\hfill$\Box$\quad\par}
\newenvironment{solution}{\par\noindent{\makebox[0pt][r]{\color{main}\ding{46}\;\;}\textbf{Solution:}}\small}{\hfill$\Box$\quad\par}
\newenvironment{custom}[1]{\par\noindent{\makebox[0pt][r]{\color{main}\ding{34}\;\;}\textbf{#1:}}\small}{\par}
%
\RequirePackage{fancyhdr}
@@ -371,16 +318,23 @@
%\let\origdoublepage\cleardoublepage
%\newcommand{\clearemptydoublepage}{%
% \clearpage
% {\pagestyle{empty}\origdoublepage}%
%}
%\let\cleardoublepage\clearemptydoublepage
%\RequirePackage{nextpage}
%\cleartooddpage[\thispagestyle{empty}]
%\cleartoevenpage[\thispagestyle{empty}]
\DeclareSymbolFont{cmlargesymbols}{OMX}{cmex}{m}{n}
\DeclareMathSymbol{\intop}{\mathop}{cmlargesymbols}{"5A}
\def\int{\intop\nolimits}
\DeclareMathSymbol{\ointop}{\mathop}{cmlargesymbols}{"49}
\def\oint{\ointop\nolimits}
\DeclareMathSymbol{\sumop}{\mathop}{cmlargesymbols}{"58}
\let\sum\sumop
\DeclareMathSymbol{\prodop}{\mathop}{cmlargesymbols}{"59}
\let\prod\prodop
\newcommand\figref[1]{\textbf{Figure}~\ref{#1}}
\newcommand\tabref[1]{\textbf{Table}~\ref{#1}}
%%
\def\maketitle{%
@@ -402,7 +356,7 @@
\end{figure}
\begin{center}
\begin{minipage}{0.65\textwidth}
\Eindent\color{bule}\@myquote
\indent\centering\color{bule}\@myquote
\end{minipage}
\end{center}
\vfill
@@ -423,33 +377,8 @@
}
%%
%----/-----
%----CJK
%\f@size = pt/pt
%\p@ = 1pt
\def\elegant@CJKChar@size{\hskip \f@size \p@}
%----
% = + =
\newdimen\elegant@CJKChar@size@dimen
\settowidth\elegant@CJKChar@size@dimen{\elegant@CJKChar@size\CJKglue}
%----
%
\newcommand{\CJKsetfontspace}{%
%
\settowidth\elegant@CJKChar@size@dimen{\elegant@CJKChar@size\CJKglue}%
%
%0
\ifdim\parindent=0pt%
\relax%
\else%
\parindent2\elegant@CJKChar@size@dimen%
\fi%
}
\newcommand{\Eindent}{\CJKsetfontspace\parindent2\elegant@CJKChar@size@dimen}
\newcommand{\Enoindent}{\parident\z@}
%----
\AtBeginDocument{\Eindent}
\RequirePackage{natbib}
\setlength{\bibsep}{0.0pt}
\def\bibfont{\footnotesize}