From f8729c63a9d707c8bbe9453ff60e6b393eaa6b70 Mon Sep 17 00:00:00 2001 From: EthanDeng Date: Sun, 2 Feb 2020 12:44:08 +0800 Subject: [PATCH] update titlepage --- elegantbook-cn.tex | 87 ++++++++--------- elegantbook-en.tex | 7 +- elegantbook.cls | 235 ++++++++++++++++++++++----------------------- 3 files changed, 154 insertions(+), 175 deletions(-) diff --git a/elegantbook-cn.tex b/elegantbook-cn.tex index 569b299..e3e98c1 100644 --- a/elegantbook-cn.tex +++ b/elegantbook-cn.tex @@ -7,6 +7,7 @@ \institute{Elegant\LaTeX{} Program} \date{\today} \version{3.10*} +\bioinfo{自定义}{信息} \extrainfo{Victory won\rq t come to us unless we go to it. --- M. Moore} @@ -189,46 +190,43 @@ Hellow \end{lstlisting} \begin{table}[htbp] -\caption{ElegantBook 模板中的颜色主题\label{tab:color thm}} -\centering -\begin{tabular}{ccccccc} -\toprule - & \textcolor{structure1}{green} - & \textcolor{structure2}{cyan} - & \textcolor{structure3}{blue} - & \textcolor{structure4}{gray} - & \textcolor{structure5}{black} - & 主要使用的环境\\ -\midrule -structure & \makecell{{\color{structure1}\rule{1cm}{1cm}}} - & \makecell{{\color{structure2}\rule{1cm}{1cm}}} - & \makecell{{\color{structure3}\rule{1cm}{1cm}}} - & \makecell{{\color{structure4}\rule{1cm}{1cm}}} - & \makecell{{\color{structure5}\rule{1cm}{1cm}}} - & chapter \ section \ subsection \\ - -main & \makecell{{\color{main1}\rule{1cm}{1cm}}} - & \makecell{{\color{main2}\rule{1cm}{1cm}}} - & \makecell{{\color{main3}\rule{1cm}{1cm}}} - & \makecell{{\color{main4}\rule{1cm}{1cm}}} - & \makecell{{\color{main5}\rule{1cm}{1cm}}} - & definition \ exercise \ problem \\ - -second & \makecell{{\color{second1}\rule{1cm}{1cm}}} - & \makecell{{\color{second2}\rule{1cm}{1cm}}} - & \makecell{{\color{second3}\rule{1cm}{1cm}}} - & \makecell{{\color{second4}\rule{1cm}{1cm}}} - & \makecell{{\color{second5}\rule{1cm}{1cm}}} - & theorem \ lemma \ corollary\\ - -third & \makecell{{\color{third1}\rule{1cm}{1cm}}} - & \makecell{{\color{third2}\rule{1cm}{1cm}}} - & \makecell{{\color{third3}\rule{1cm}{1cm}}} - & \makecell{{\color{third4}\rule{1cm}{1cm}}} - & \makecell{{\color{third5}\rule{1cm}{1cm}}} - & proposition\\ -\bottomrule -\end{tabular} + \caption{ElegantBook 模板中的颜色主题\label{tab:color thm}} + \centering + \begin{tabular}{ccccccc} + \toprule + & \textcolor{structure1}{green} + & \textcolor{structure2}{cyan} + & \textcolor{structure3}{blue} + & \textcolor{structure4}{gray} + & \textcolor{structure5}{black} + & 主要使用的环境\\ + \midrule + structure & \makecell{{\color{structure1}\rule{1cm}{1cm}}} + & \makecell{{\color{structure2}\rule{1cm}{1cm}}} + & \makecell{{\color{structure3}\rule{1cm}{1cm}}} + & \makecell{{\color{structure4}\rule{1cm}{1cm}}} + & \makecell{{\color{structure5}\rule{1cm}{1cm}}} + & chapter \ section \ subsection \\ + main & \makecell{{\color{main1}\rule{1cm}{1cm}}} + & \makecell{{\color{main2}\rule{1cm}{1cm}}} + & \makecell{{\color{main3}\rule{1cm}{1cm}}} + & \makecell{{\color{main4}\rule{1cm}{1cm}}} + & \makecell{{\color{main5}\rule{1cm}{1cm}}} + & definition \ exercise \ problem \\ + second & \makecell{{\color{second1}\rule{1cm}{1cm}}} + & \makecell{{\color{second2}\rule{1cm}{1cm}}} + & \makecell{{\color{second3}\rule{1cm}{1cm}}} + & \makecell{{\color{second4}\rule{1cm}{1cm}}} + & \makecell{{\color{second5}\rule{1cm}{1cm}}} + & theorem \ lemma \ corollary\\ + third & \makecell{{\color{third1}\rule{1cm}{1cm}}} + & \makecell{{\color{third2}\rule{1cm}{1cm}}} + & \makecell{{\color{third3}\rule{1cm}{1cm}}} + & \makecell{{\color{third4}\rule{1cm}{1cm}}} + & \makecell{{\color{third5}\rule{1cm}{1cm}}} + & proposition\\ + \bottomrule + \end{tabular} \end{table} 如果需要自定义颜色的话请选择 \lstinline{nocolor} 选项或者使用 \lstinline{color=none},然后在导言区定义 structurecolor、main、second、third 颜色,具体方法如下: @@ -278,15 +276,6 @@ The content of theorem. \end{theorem} \end{lstlisting} -\begin{lstlisting}{Python} ->> 'www0'>='W123' - -ans = - - 1×4 logical 数组 - - 1 1 1 0 -\end{lstlisting} 第一个必选项 \lstinline{theorem name} 是定理的名字,第二个必选项 \lstinline{label} 是交叉引用时所用到的标签,交叉引用的方法为 \verb|\ref{thm:label}|。请注意,交叉引用时必须加上前缀 \lstinline{thm:}。 diff --git a/elegantbook-en.tex b/elegantbook-en.tex index 0c25e59..d9e3d32 100644 --- a/elegantbook-en.tex +++ b/elegantbook-en.tex @@ -7,6 +7,7 @@ \institute{Elegant\LaTeX{} Program} \date{\today} \version{3.10*} +\bioinfo{Bio}{Information} \extrainfo{Victory won\rq t come to us unless we go to it. } @@ -687,16 +688,14 @@ This appendix covers some of the basic mathematics used in econometrics. We brie \date{\today} % extra info \version{1.00} -\extrainfo{Victory won\rq t come to us unless we go to it. --- M. Moore} -\logo{logo.png} -\cover{cover.jpg} \begin{document} \maketitle +\frontmatter \tableofcontents + \mainmatter -\hypersetup{pageanchor=true} % add preface chapter here if needed \chapter{Example Chapter Title} The content of chapter one. diff --git a/elegantbook.cls b/elegantbook.cls index cfd473b..c3d1e70 100644 --- a/elegantbook.cls +++ b/elegantbook.cls @@ -55,7 +55,7 @@ \DeclareStringOption[apalike]{bibstyle} -\DeclareVoidOption{newtxmath}{\ekv{math=newtx}} +\DeclareVoidOption{newtx}{\ekv{math=newtx}} \DeclareVoidOption{mtpro2}{\ekv{math=mtpro2}} \DeclareVoidOption{cm}{\ekv{math=cm}} @@ -115,7 +115,7 @@ \setcounter{tocdepth}{1} \PassOptionsToPackage{no-math}{fontspec} -\RequirePackage{amsmath,mathrsfs,amsfonts,amssymb} + \ifdefstring{\ELEGANT@lang}{cn}{ \RequirePackage[UTF8, scheme=plain]{ctex} @@ -233,26 +233,33 @@ \ifdefstring{\ELEGANT@titlestyle}{hang}{\def\style{hang}}{\relax} \ifdefstring{\ELEGANT@titlestyle}{display}{\def\style{display}}{\relax} +% reference: +% https://tex.stackexchange.com/questions/58506/how-to-make-a-new-command-similar-to-author +% https://pastebin.com/C8W4axzV +\newcommand{\email}[1]{\gdef\@email{\href{mailto:#1}{\nolinkurl{#1}}}} +\def\@email{\@latex@warning@no@line{No \noexpand\email given}} -\newtoks\email -\newtoks\version -\newtoks\institute -\newtoks\subtitle +\global\let\@title\@empty +\global\let\@author\@empty +\global\let\@date\@empty +\newcommand{\subtitle}[1]{\gdef\@subtitle{#1}} +\newcommand{\institute}[1]{\gdef\@institute{#1}} +\newcommand{\version}[1]{\gdef\@version{#1}} +\newcommand{\extrainfo}[1]{\gdef\@extrainfo{#1}} + +\RequirePackage{mwe} +\newcommand{\logo}[1]{\gdef\@logo{#1}} +\newcommand{\cover}[1]{\gdef\@cover{#1}} \RequirePackage[\ELEGANT@cite,sort&compress]{natbib} \setlength{\bibsep}{0.0pt} \def\bibfont{\footnotesize} - - \RequirePackage{enumerate} % list/itemize/enumerate setting \RequirePackage[shortlabels,inline]{enumitem} \setlist{nolistsep} -% caption settings -\RequirePackage{caption} -\captionsetup{labelfont = bf} \RequirePackage[font=small,labelfont={bf,color=structurecolor}]{caption} \captionsetup[table]{skip=3pt} \captionsetup[figure]{skip=3pt} @@ -279,6 +286,7 @@ \RequirePackage{graphicx} %\RequirePackage{enumerate} +\RequirePackage{amsmath,mathrsfs,amsfonts,amssymb} \RequirePackage{booktabs} \RequirePackage{multicol,multirow} @@ -325,6 +333,7 @@ \newcommand{\propertyname}{性质} \newcommand{\introductionname}{内容提要} \newcommand{\problemsetname}{习题} + \newcommand\bioinfo[2]{\gdef\@bioinfo{\textit{#1}:#2}} }{\relax} \ifdefstring{\ELEGANT@lang}{en}{ \setlength\parindent{2em} @@ -355,6 +364,7 @@ \newcommand{\propertyname}{Property} \newcommand{\introductionname}{Introduction} \newcommand{\problemsetname}{Exercise} + \newcommand\bioinfo[2]{\gdef\@bioinfo{\textbf{#1}: #2}} }{\relax} \RequirePackage{xpatch} @@ -399,8 +409,7 @@ pdfborder={0 0 0}, linktocpage } -\let\email\relax -\newcommand\email[1]{\href{mailto:#1}{\nolinkurl{#1}}} + %% 章节设置 \RequirePackage[center,pagestyles]{titlesec} @@ -412,27 +421,22 @@ \titleformat{\chapter}[\style]{\bfseries} {\filcenter\LARGE\enspace\bfseries{\color{structurecolor}\IfAppendix{\appendixname}{\chaptername}\enspace}}{1pt}{\bfseries\color{structurecolor}\LARGE\filcenter}[\ifdefstring{\ELEGANT@base}{hide}{}{\filcenter\base{structurecolor}{88}}] -\titleformat{\section}[hang]{\bfseries} -{\Large\bfseries{\color{structurecolor}\thesection}\enspace}{1pt}{\color{structurecolor}\Large\bfseries\filright} - +\titleformat{\section}[hang]{\bfseries}{ + \Large\bfseries{\color{structurecolor}\thesection}\enspace}{1pt}{% + \color{structurecolor}\Large\bfseries\filright} \titleformat{\subsection}[hang]{\bfseries}{ - \large\bfseries\color{structurecolor}\thesubsection\enspace}{1pt}{\color{structurecolor}\large\bfseries\filright} - -\titleformat{\subsubsection}[hang]{\bfseries} -{\large\bfseries\color{structurecolor}\thesubsubsection\enspace}{1pt}{\color{structurecolor}\large\bfseries\filright} + \large\bfseries\color{structurecolor}\thesubsection\enspace}{1pt}{% + \color{structurecolor}\large\bfseries\filright} +\titleformat{\subsubsection}[hang]{\bfseries}{ + \large\bfseries\color{structurecolor}\thesubsubsection\enspace}{1pt}{% + \color{structurecolor}\large\bfseries\filright} \titlespacing{\chapter}{0pt}{-20pt}{1.3\baselineskip} %\titlespacing{\subsection}{0pt}{0.5\baselineskip}{-\baselineskip} - - %%define the note and proof environment \RequirePackage{pifont,manfnt,bbding} -% list/itemize/enumerate setting -\RequirePackage[shortlabels]{enumitem} -\setlist{nolistsep} - \RequirePackage[many]{tcolorbox} @@ -486,20 +490,13 @@ \node[anchor=south east, outer sep=0pt] at (\linewidth-width,0) { \textcolor{third}{$\spadesuit$}};}},} -\newtcbtheorem[auto counter,number within=chapter]{definition}{\definitionname}{defstyle}{def} - -\newtcbtheorem[auto counter,number within=chapter]{theorem}{\theoremname}{thmstyle}{thm} - -\newtcbtheorem[auto counter,number within=chapter]{postulate}{\postulatename}{thmstyle}{pos} - -\newtcbtheorem[auto counter,number within=chapter]{axiom}{\axiomname}{thmstyle}{axi} - -\newtcbtheorem[auto counter,number within=chapter]{proposition}{\propositionname}{propstyle}{pro} - -\newtcbtheorem[auto counter,number within=chapter]{corollary}{\corollaryname}{thmstyle}{cor} - -\newtcbtheorem[auto counter,number within=chapter]{lemma}{\lemmaname}{thmstyle}{lem} - + \newtcbtheorem[auto counter,number within=chapter]{definition}{\definitionname}{defstyle}{def} + \newtcbtheorem[auto counter,number within=chapter]{theorem}{\theoremname}{thmstyle}{thm} + \newtcbtheorem[auto counter,number within=chapter]{postulate}{\postulatename}{thmstyle}{pos} + \newtcbtheorem[auto counter,number within=chapter]{axiom}{\axiomname}{thmstyle}{axi} + \newtcbtheorem[auto counter,number within=chapter]{proposition}{\propositionname}{propstyle}{pro} + \newtcbtheorem[auto counter,number within=chapter]{corollary}{\corollaryname}{thmstyle}{cor} + \newtcbtheorem[auto counter,number within=chapter]{lemma}{\lemmaname}{thmstyle}{lem} }{\relax} \ifdefstring{\ELEGANT@mode}{simple}{ @@ -511,56 +508,53 @@ % declare a new theorem style \newtheoremstyle{edefstyle}{3pt}{3pt}{\itshape}{}{ - \bfseries\color{main}}{}{0.5em}{ - \thmname{#1} \thmnumber{#2} \thmnote{(#3)}} - % -------------------------------------------------% + \bfseries\color{main}}{}{0.5em}{\thmname{#1} \thmnumber{#2} \thmnote{(#3)}} \newtheoremstyle{ethmstyle}{3pt}{3pt}{\itshape}{}{ - \bfseries\color{second}}{}{.5em}{ - \thmname{#1} \thmnumber{#2} \thmnote{(#3)}} - % -------------------------------------------------% + \bfseries\color{second}}{}{0.5em}{\thmname{#1} \thmnumber{#2} \thmnote{(#3)}} \newtheoremstyle{eprostyle}{3pt}{3pt}{\itshape}{}{ - \bfseries\color{third}}{}{.5em}{ - \thmname{#1} \thmnumber{#2} \thmnote{(#3)}} + \bfseries\color{third}}{}{0.5em}{\thmname{#1} \thmnumber{#2} \thmnote{(#3)}} -\theoremstyle{edefstyle} -\newtheorem{edefinition}{\definitionname }[chapter] -\theoremstyle{ethmstyle} -\newtheorem{etheorem}{\theoremname }[chapter] -\newtheorem{elemma}{\lemmaname }[chapter] -\newtheorem{ecorollary}{\corollaryname }[chapter] -\newtheorem{epostulate}{\postulatename }[chapter] -\newtheorem{eaxiom}{\axiomname }[chapter] -\theoremstyle{eprostyle} -\newtheorem{eproposition}{\propositionname }[chapter] + \theoremstyle{edefstyle} % definition style -\newenvironment{theorem}[2] - {\ifstrempty{#1}{\etheorem}{\etheorem[#1]}\ifstrempty{#2}{}{\label{thm:#2}}} - {\endetheorem} + \newtheorem{edefinition}{\definitionname}[chapter] + \newenvironment{definition}[2]{ + \ifstrempty{#1}{\edefinition}{\edefinition[#1]}\ifstrempty{#2}{}{\label{def:#2}}}{ + \endedefinition} -\newenvironment{definition}[2] - {\ifstrempty{#1}{\edefinition}{\edefinition[#1]}\ifstrempty{#2}{}{\label{def:#2}}} - {\endedefinition} -\newenvironment{lemma}[2] - {\ifstrempty{#1}{\elemma}{\elemma[#1]}\ifstrempty{#2}{}{\label{lem:#2}}} - {\endelemma} + \theoremstyle{ethmstyle} %theorem style + + \newtheorem{etheorem}{\theoremname}[chapter] + \newenvironment{theorem}[2]{ + \ignorespaces\ifstrempty{#1}{\etheorem}{\etheorem[#1]}\ifstrempty{#2}{}{\label{thm:#2}}}{ + \endetheorem} -\newenvironment{corollary}[2] - {\ifstrempty{#1}{\ecorollary}{\ecorollary[#1]}\ifstrempty{#2}{}{\label{cor:#2}}} - {\endecorollary} + \newtheorem{elemma}{\lemmaname}[chapter] + \newenvironment{lemma}[2]{ + \ignorespaces\ifstrempty{#1}{\elemma}{\elemma[#1]}\ifstrempty{#2}{}{\label{lem:#2}}}{ + \endelemma} + + \newtheorem{ecorollary}{\corollaryname}[chapter] + \newenvironment{corollary}[2]{ + \ignorespaces\ifstrempty{#1}{\ecorollary}{\ecorollary[#1]}\ifstrempty{#2}{}{\label{cor:#2}}}{ + \endecorollary} + + \newtheorem{epostulate}{\postulatename}[chapter] + \newenvironment{postulate}[2]{ + \ifstrempty{#1}{\epostulate}{\epostulate[#1]}\ifstrempty{#2}{}{\label{pos:#2}}}{ + \endepostulate} + + \newtheorem{eaxiom}{\axiomname}[chapter] + \newenvironment{axiom}[2]{ + \ifstrempty{#1}{\eaxiom}{\eaxiom[#1]}\ifstrempty{#2}{}{\label{axi:#2}}}{ + \endaxiom} -\newenvironment{postulate}[2] - {\ifstrempty{#1}{\epostulate}{\epostulate[#1]}\ifstrempty{#2}{}{\label{pos:#2}}} - {\endepostulate} - -\newenvironment{axiom}[2] - {\ifstrempty{#1}{\eaxiom}{\eaxiom[#1]}\ifstrempty{#2}{}{\label{axi:#2}}} - {\endaxiom} - -\newenvironment{proposition}[2] - {\ifstrempty{#1}{\eproposition}{\eproposition[#1]}\ifstrempty{#2}{}{\label{pro:#2}}} - {\endeproposition} + \theoremstyle{eprostyle} + \newtheorem{eproposition}{\propositionname}[chapter] + \newenvironment{proposition}[2]{ + \ifstrempty{#1}{\eproposition}{\eproposition[#1]}\ifstrempty{#2}{}{\label{pro:#2}}}{ + \endeproposition} }{\relax} % main(green-def): example exercise problem solution @@ -648,7 +642,7 @@ \RequirePackage{adforn} \newenvironment{problemset}[1][\chaptername~\medskip~\problemsetname]{ \begin{center} - \addcontentsline{toc}{section}{\texorpdfstring{\chaptername\medskip\problemsetname}{\problemsetname}} + \phantomsection\addcontentsline{toc}{section}{\texorpdfstring{\chaptername\medskip\problemsetname}{\problemsetname}} \textcolor{structurecolor}{\Large\bfseries\adftripleflourishleft~#1~\adftripleflourishright} \end{center} \begin{enumerate}}{ @@ -702,31 +696,6 @@ \renewcommand{\sectionmark}[1]{\markright{\thesection\, #1}{} } \renewcommand{\chaptermark}[1]{\markboth{\chaptername \, #1\,}{}} -%%封面 -\newcommand*{\extrainfo}[1]{\def\@extrainfo{#1}} - -\def\IfEmpty#1{% - \edef\1{\the#1} - \ifx\1\empty -} -\def \ifempty#1{\def\temp{#1} \ifx\temp\empty } - -\newcommand*{\logo}[1]{ - \def\@logo{\includegraphics[width=4.2cm]{#1} - } -} -\ifdefstring{\ELEGANT@device}{normal}{ -\newcommand*{\cover}[1]{ - \def\@cover{\includegraphics[width=\linewidth]{#1} - } -}}{\relax} - -\ifdefstring{\ELEGANT@device}{pad}{ -\newcommand*{\cover}[1]{ - \def\@cover{\includegraphics[trim=0 26bp 0 26bp,clip=true, width=\linewidth]{#1} - } -}}{\relax} - \renewcommand{\baselinestretch}{1.35} \renewcommand*{\maketitle}{% @@ -734,51 +703,73 @@ \begin{titlepage} \newgeometry{margin = 0in} \parindent=0pt - \@cover + \ifdefstring{\ELEGANT@device}{normal}{ + \ifcsname @cover\endcsname + \includegraphics[width=\linewidth]{\@cover} + \else + \includegraphics[width=\linewidth]{example-image} + \fi + }{\relax} + \ifdefstring{\ELEGANT@device}{pad}{ + \ifcsname @cover\endcsname + \includegraphics[trim=0 26bp 0 26bp,clip=true, width=\linewidth]{\@cover} + \else + \includegraphics[trim=0 26bp 0 26bp,clip=true, width=\linewidth]{example-image} + \fi + }{\relax} \setlength{\fboxsep}{0pt} \colorbox{second}{\makebox[\linewidth][c]{\shortstack[c]{\vspace{0.5in}}}} \vfill \vskip-2ex \hspace{2em} \parbox{0.8\textwidth}{ - \bfseries\Huge \@title\par - } + \bfseries\Huge + \ifcsname @title\endcsname \@title \fi + \par} \vfill \vspace{-1.0cm} \setstretch{2.5} \hspace{2.5em} \begin{minipage}[c]{0.67\linewidth} - {\color{darkgray}\bfseries\Large \the\subtitle\\[2ex]} + {\color{darkgray}\bfseries\Large + \ifcsname @subtitle\endcsname\@subtitle\\[2ex]\fi} \color{gray}\normalsize {\renewcommand{\arraystretch}{0.618} - \begin{tabular}{l} - \authorname \@author \\ - \institutename \the\institute\\ - \datename \@date\\ - \versionname \the\version\\ + \begin{tabular}{l} + % \ifcsname @author\endcsname \authorname \@author\\\fi + \ifx\@author\empty\else\authorname\@author\\ \fi + \ifcsname @institute\endcsname \institutename \@institute\\ \fi + % \ifcsname @date\endcsname \@date\\\fi + \ifx\@date\empty\else\datename\@date \\ \fi + \ifcsname @version\endcsname \versionname \@version\\ \fi + \ifcsname @bioinfo\endcsname \@bioinfo\\ \fi \end{tabular}} \end{minipage} \begin{minipage}[c]{0.27\linewidth} \begin{tikzpicture}[remember picture,overlay] \begin{pgfonlayer}{background} - \node[opacity=0.8,anchor=south east,outer sep=0pt,inner sep=0pt] at ($(current page.south east) +(-0.8in,1.5in)$) {\@logo}; + \node[opacity=0.8, + anchor=south east, + outer sep=0pt, + inner sep=0pt] at ($(current page.south east) +(-0.8in,1.5in)$) { + \ifcsname @logo\endcsname\includegraphics[width=4.2cm]{\@logo}\fi}; \end{pgfonlayer} \end{tikzpicture} \end{minipage} \vfill \begin{center} - \setstretch{1.3} - \parbox[t]{0.7\textwidth}{\centering \itshape \@extrainfo} + \setstretch{1.3} + \parbox[t]{0.7\textwidth}{\centering \itshape + \ifcsname @extrainfo\endcsname\@extrainfo\fi} \end{center} \vfill \end{titlepage} \restoregeometry -\thispagestyle{empty} -} +\thispagestyle{empty}} -\RequirePackage{listings} +\RequirePackage{listings} \renewcommand{\ttdefault}{cmtt} \lstdefinestyle{mystyle}{ basicstyle=%