\usepackage{expl3,etoolbox,ifthen,xstring}
\usepackage{xltxtra,mflogo,texnames}
\usepackage[zihao=5]{ctex}
\ctexset{today=old}
\let\kaiti=\kaishu
\usepackage{xeCJKfntef}

\usepackage{xcolor}
\definecolor{gbsteelblue}{RGB}{70,130,180}
\definecolor{gborange}{RGB}{255,138,88}
\definecolor{gbblue}{RGB}{23,74,117}
\definecolor{gbforestgreen}{RGB}{21,122,81}
\definecolor{gbyellow}{RGB}{255,185,88}
\definecolor{gbgrey}{RGB}{200,200,200}

%一些字符串格式化命令
\newcommand*{\verbatimfont}{\ttfamily}
\newrobustcmd*{\cnt}[1]{\mbox{\verbatimfont#1}}
\newrobustcmd*{\bibfield}[1]{\mbox{\verbatimfont#1}}
\newrobustcmd*{\opt}[1]{\mbox{\verbatimfont#1}}
\newrobustcmd*{\prm}[1]{%
  \ifblank{#1}
    {}
    {\mbox{%
       \ensuremath\langle
       \normalfont\textit{#1}%
       \ensuremath\rangle}}}

\usepackage[paperwidth=210mm,paperheight=290mm,left=20mm,right=20mm,top=25mm, bottom=15mm,showcrop
]{geometry}%定义版面showframe,

\usepackage[colorlinks=true,%
pdfstartview=FitH,allcolors=blue]{hyperref}  %书签功能，选项去掉链接红色方框
%linkcolor=gbblue,anchorcolor=gbblue,citecolor=gbblue
%linkcolor=black,linkcolor=green,blue,red,cyan, magenta,
%yellow, black, gray,white, darkgray, lightgray, brown,
%lime, olive, orange, red,purple, teal, violet.
%CJKbookmarks,bookmarksnumbered=true,
\usepackage{titleref} %标题引用


%\usepackage[unit=cm,type=lowerleft,showframe=true,hshift=2cm,vshift=1.5cm]{fgruler}


\usepackage{titlesec}
%\titlespacing*{hcommandi}{hlefti}{hbefore-sepi}{hafter-sepi}[hright-sepi]
\titlespacing*{\section}{0pt}{\baselineskip}{0.5\baselineskip}
\titlespacing*{\subsection}{0pt}{0.5\baselineskip}{0.5\baselineskip}
\titlespacing*{\subsubsection}{0pt}{0.5\baselineskip}{0pt}
\titlespacing{\paragraph}{2em}{0.5\baselineskip}{1em}

\setlength{\bibitemsep}{1pt}
%\defbibheading{bibliography}[\bibname]{%
%%\phantomsection%解决链接指引出错的问题，相当于加入了一个引导点
%%\addcontentsline{toc}{subsection}{#1}
%	\centering\subsubsection*{#1}}%

%自定义下划红线和背景颜色
\usepackage{ulem}
\newcommand\yellowback{\bgroup\markoverwith
{\textcolor{yellow}{\rule[-0.5ex]{2pt}{2.5ex}}}\ULon}
\newcommand\reduline{\bgroup\markoverwith
{\textcolor{red}{\rule[-0.5ex]{2pt}{0.4pt}}}\ULon}

\usepackage{subfigure}
\usepackage[subfigure]{tocloft} %注意其与titletoc共用时分页会有问题
\usepackage{ccaption}
\captiondelim{. } %图序图题中间的间隔符号
\captionnamefont{\zihao{-5}\heiti} %图序样式
\captiontitlefont{\zihao{-5}} %图题样式
\captionwidth{0.8\linewidth} %标题宽度
\changecaptionwidth
\captionstyle{\centering} %\captionstyle{<style>} style are: \centering, \raggedleft or \raggedright
%\precaption{\rule{\linewidth}{0.4pt}\par}
%\postcaption{\vspace{-1cm}}
\setlength{\belowcaptionskip}{2pt}%设置caption上下间距
\setlength{\abovecaptionskip}{0pt}
%\setlength{\abovelegendskip}{0pt} %设置legend上下间距
%\setlength{\belowlegendskip}{0pt}
%新的浮动体设置
\newcommand{\listegcodename}{\centerline{示~~例}}%listegcodename，新环境目录的标题
\newcommand{\egcodename}{例}%egcodename，新环境标题的图序
\newfloatlist{egcode}{loc}{\listegcodename}{\egcodename}%loc，写入条目的文件的扩展名
\newfixedcaption{\codecaption}{egcode}%egcode，环境名

%目录命令
\setlength{\cftbeforetoctitleskip}{\baselineskip}
\setlength{\cftaftertoctitleskip}{0.5\baselineskip}
\setlength{\cftbeforeloftitleskip}{\baselineskip}
\setlength{\cftafterloftitleskip}{0.5\baselineskip}
\setlength{\cftbeforelottitleskip}{\baselineskip}
\setlength{\cftafterlottitleskip}{0.5\baselineskip}
\setlength{\cftbeforeloctitleskip}{\baselineskip}
\setlength{\cftafterloctitleskip}{0.5\baselineskip}
%\renewcommand\contentsname{\hfill 目~~ 录 \hfill \hspace{1cm}} %用这一句也是一样的。
\renewcommand{\cfttoctitlefont}{\zihao{-3}\heiti}
\renewcommand{\cftaftertoctitle}{}
\renewcommand{\cftloftitlefont}{\zihao{-3}\heiti}
\renewcommand{\cftafterloftitle}{}
\renewcommand{\cftlottitlefont}{\zihao{-3}\heiti}
\renewcommand{\cftafterlottitle}{}
\renewcommand{\cftloctitlefont}{\zihao{-3}\heiti}
\renewcommand{\cftafterloctitle}{}
\renewcommand{\contentsname}{\centerline{目~~录}}
\renewcommand{\listfigurename}{\centerline{图~~片}}
\renewcommand{\listtablename}{\centerline{表~~格}}
\renewcommand{\cftsecfont}{\zihao{5}\heiti} %条目样式
\renewcommand{\cftsubsecfont}{\zihao{5}\fangsong} %条目样式
\renewcommand{\cftsubsubsecfont}{\zihao{-5}\songti} %条目样式
%−−−−−−−−−−设置egcode条目样式−−−−−−−−−−−−−−−−−−−−−−
%\renewcommand{\cftegcodeleader}{\leaders\hbox to 1em{\hss.\hss}\hfill}
\setlength{\cftbeforeegcodeskip}{0.1ex} %条目前的间距
\setlength{\cftegcodeindent}{0em} %条目缩进
\setlength{\cftegcodenumwidth}{2.5em} %条目标签宽度
\renewcommand{\cftegcodefont}{\color{blue}\fangsong} %条目样式
\renewcommand{\cftegcodepresnum}{例}
\renewcommand{\cftegcodeaftersnum}{.}
\renewcommand{\cftegcodeaftersnumb}{~}
%\cftsetindents{egcode}{0em}{3em}
%\renewcommand{\cftegcodepagefont}{\bfseries}
%−−−−−−−−−−设置figure条目样式−−−−−−−−−−−−−−−−−−−−−−
%\newcommand{\cftfigfill}{\renewcommand{\cftdot}{$\diamond$}\cftdotfill{\cftdotsep}}
\setlength{\cftbeforefigskip}{0.1ex} %条目前的间距
\setlength{\cftfigindent}{0em} %条目缩进
\setlength{\cftfignumwidth}{2.5em} %条目标签宽度
\renewcommand{\cftfigfont}{\color{blue}\fangsong} %条目样式
\renewcommand{\cftfigpresnum}{图} %条目数字前的内容
\renewcommand{\cftfigaftersnum}{.} %条目数字后的内容
\renewcommand{\cftfigaftersnumb}{~} %条目数字后的第二个内容
%\renewcommand{\cftfigdotsep}{\cftdotsep} %连接符之间的宽度
%\renewcommand{\cftfigleader}{\bfseries\cftfigfill} %连接符粘连团
%\renewcommand{\cftfigpagefont}{\color{red}\zihao{-5}$\diamond$\itshape} %页码的样式
%\renewcommand{\cftfigafterpnum}{\color{red}$\diamond$} %页码后内容
%−−−−−−−−−−设置table条目样式−−−−−−−−−−−−−−−−−−−−−−
%\newcommand{\cfttabfill}{\renewcommand{\cftdot}{$\infty$}\cftdotfill{\cftdotsep}}
\setlength{\cftbeforetabskip}{0.1ex} %条目前的间距
\setlength{\cfttabindent}{0em} %条目缩进
\setlength{\cfttabnumwidth}{2.5em} %条目标签宽度
\renewcommand{\cfttabfont}{\color{blue}\fangsong} %条目样式
\renewcommand{\cfttabpresnum}{表} %条目数字前的内容
\renewcommand{\cfttabaftersnum}{.} %条目数字后的内容
\renewcommand{\cfttabaftersnumb}{~} %条目数字后的第二个内容
%\renewcommand{\cfttabdotsep}{\cftdotsep} %连接符之间的宽度
%\renewcommand{\cfttableader}{\bfseries\cfttabfill} %连接符粘连团
%\renewcommand{\cfttabpagefont}{\color{red}\zihao{-5}$\infty$\itshape} %页码的样式
%\renewcommand{\cfttabafterpnum}{\color{red}$\infty$} %页码后内容

\usepackage{listings}
\usepackage{tikz,pgf}
\usetikzlibrary{calc}
\colorlet{examplefill}{yellow!80!black}
\definecolor{graphicbackground}{rgb}{0.96,0.96,0.8}
\definecolor{codebackground}{rgb}{0.9,0.9,1}


\newenvironment{example}[3][代码]%
{\list{}{\begingroup\codecaption{#2}\label{#3}\endgroup
\setlength{\topsep}{0pt}
\setlength{\partopsep}{0pt}
\setlength{\itemsep}{0pt}
\setlength{\parsep}{0pt}
\setlength{\leftmargin}{0pt}%
\setlength{\itemindent}{0pt}%
%\renewcommand*{\makelabel}[1]{\hss\llap{\footnotesize\color{orange}\bfseries##1}}
}\item[\footnotesize\color{gbblue}\bfseries#1]\relax}
{\endlist}


\lstnewenvironment{texlist}%
{\lstset{% general command to set parameter(s)
%name=#1,
%label=#2,
%caption=\lstname,
linewidth=\linewidth,
breaklines=true,
%showspaces=true,
extendedchars=false,
columns=fullflexible,%flexible,
aboveskip=2pt,
boxpos=t,
rulesep=0pt,
frame=tb,
framesep=0pt,
rulecolor=\color{gbblue},
fontadjust=true,
language=[LaTeX]TeX,
%backgroundcolor=\color{yellow}, %背景颜色
numbers=left,
numberstyle=\tiny\color{gbblue},
basicstyle=\footnotesize\ttfamily, % print whole listing small
keywordstyle=\color{blue}\bfseries,%\underbar,
% underlined bold black keywords
identifierstyle=, % nothing happens
commentstyle=\color{green!50!black}, % white comments
stringstyle=\ttfamily, % typewriter type for strings
showstringspaces=false}% no special string spaces
}
{}

\usepackage[listings,theorems,most]{tcolorbox}
\tcbuselibrary{breakable}
\newcounter{myprop}\def\themyprop{\arabic{myprop}}
%序号如果带章节的话可以改为比如:\thesection.\arabic{myprop}
\tcbmaketheorem{property}{方法}
{enhanced jigsaw,breakable,pad at break*=1mm,left=2em,boxsep=0pt,
 colback=black!5,colframe=gborange,coltitle=gborange,
 theorem style=plain,fonttitle=\bfseries,arc=0mm,
%separator sign={\ $\blacktriangleright$},breakable,
%theorem style=plain,fonttitle=\bfseries\upshape, fontupper=\slshape,boxrule=0mm,arc=0mm, %
%coltitle=black,colback=green!50!yellow!15!white,colframe=blue!50,%
%description delimiters={}{},
%terminator sign={\ }
}{myprop}{pp}
%最后一个必须参数是prefix用来做label比如这里是pp:加上给出的标签名

\newtcbtheorem[]{refentry}{条目类型}
{breakable,pad at break*=1mm,enhanced jigsaw,left=2em,boxsep=0pt,
 colback=yellow!10!white,boxrule=0pt,frame hidden,
 borderline west={1.5mm}{-2mm}{gbforestgreen},
separator sign={\ $\blacktriangleright$},terminator sign={\ },
theorem style=plain,fonttitle=\bfseries,coltitle=gbforestgreen
%fontupper=\normalsize,boxrule=0mm,arc=0mm,breakable,
%coltitle=green!35!black,colbacktitle=green!15!white,
%colback=green!50!yellow!15!white,terminator sign={\ }
}{rfeg}
%最后一个必须参数是prefix用来做label比如这里是eg:加上给出的标签名
\newcommand{\bibliofmt}[1]{\medskip\textcolor{gbforestgreen}{\heiti#1}}

\newcommand{\titleformanual}[1]{\def\biaotiudf{#1}}
\newcommand{\authorformanual}[1]{\def\zuozheudf{#1}}
\newcommand{\dateformanual}[1]{\def\riqiudf{#1}}
%\ifthenelse{\equal{\youwuudf}{\temp}}{true}{false}
\def\temp{}
\newcommand{\titleandauthor}{
\begin{center}
{\renewcommand{\thefootnote}{\fnsymbol{footnote}}\setlength{\baselineskip}{30pt}\heiti{\zihao{-2}{\biaotiudf}}\par}
%注意这里\par要放在花括号内才有效
\vspace*{0.3cm}
{\renewcommand{\thefootnote}{\arabic{footnote}}\kaishu{\zihao{4}{\zuozheudf}}\par}
\vspace*{0.2cm}
{\songti{\zihao{-4}{\riqiudf}}\par}
\end{center}
}

\renewcommand{\thefootnote}{\textcircled{\tiny\arabic{footnote}}}

%--------------列表环境---------------------------------------------
\usepackage[inline]{enumitem} %重设list环境
\setlist[enumerate]{label=\bfseries\textcolor{gbblue}{(\arabic*)},topsep=2pt,partopsep=0pt,parsep=0pt,%
align=left,leftmargin=0em,itemsep=0.5em,labelwidth=0.1em,itemindent=2.6em,listparindent=2em}%label=$\triangleright$,itemindent=1em
\setlist[itemize]{topsep=2pt,partopsep=0pt,parsep=0pt,%
leftmargin=3em,itemindent=0em}
\setlist[description]{font=\bfseries\textcolor{gbblue},align=right,topsep=5pt,partopsep=0pt,parsep=0pt,%
itemsep=0pt,leftmargin=2em,itemindent=0em}%注意，font或format中的最后一个命令自动提取标签为其参数


\usepackage{longtable}

\usepackage{amssymb}
\newcommand{\HandRight}{$\bigstar$}
\newcommand{\zhongdian}[1]{\textcolor{gbblue}{\HandRight\heiti#1}}
\newcommand{\pz}[1]{%定义pz为旁注命令
\marginpar[\flushright\youyuan\color{gbblue}\footnotesize #1]{\youyuan\color{gbblue}\small #1}}
\newcommand{\PZ}[1]{%定义pz为旁注命令
\marginpar[\flushright\youyuan\color{gbblue}\footnotesize  #1]{\youyuan\color{gbblue}\small #1}}
\newcommand{\qd}[1]{%定义qd为强调命令
\begin{quote}
  \fangsong\color{gbblue}#1%blue!50!black
\end{quote}}
\newcommand{\QD}[1]{%定义qd为强调命令
\begin{quote}
  \fangsong\color{gbblue}#1
\end{quote}}
\newcommand{\bc}[1]{%定义补充信息
{\kaiti\color{gbblue}#1}} %orange，brown，purple，teal，gbblue，olive，cyan
\newcommand{\BC}[1]{%定义补充信息
{\kaiti\color{gbblue}#1}}
\newcommand{\zd}[1]{%定义补充信息
{\heiti\color{gbblue}#1}} %orange，brown，purple，teal，gbblue，olive，cyan
\newcommand{\ZD}[1]{%定义补充信息
{\heiti\color{gbblue}#1}}




\newenvironment*{marglist}
{\list{}{\setlength{\topsep}{0pt}
\setlength{\partopsep}{0pt}
\setlength{\itemsep}{0pt}
\setlength{\parsep}{0pt}
\setlength{\leftmargin}{0pt}%
\setlength{\itemindent}{0pt}%
\renewcommand*{\makelabel}[1]{\hss\llap{\footnotesize\color{orange}\bfseries##1}}}}
{\endlist}

\makeatletter
\newcommand{\updateinfo}[2][\@empty]{%
\par\small\addvspace{2ex plus 1ex}%
\noindent{\color{gbblue}\rule{\linewidth}{2pt}}
\vskip -\parskip
\ifx\@empty#1 \begin{marglist} \item #2\end{marglist}
\else \begin{marglist} \item[#1] #2\end{marglist} \fi}
\makeatother

\usepackage{filecontents}
\begin{filecontents}{example/egspecialchar.bib}
@Inproceedings{ref-replace-char,
  Title                    = {Cognitive Radio and Cooperative Strategies for Power Saving in Multi-Standard Wireless Devices},
  Address                  = {Florence, Italy},
  Author                   = {Rodriguez, J. and P. Marques and A. Radwan and K. Moessner and R. Tafazolli and others},
  Booktitle                = {Future % Network & Mobile # Summit 2010},
  Date                     = {June 2010}
}

@Online{olnoauthorcn,
  Title                    = {如何在LaTeX写作中管理参考文献?},
  Date                     = {2016-08-12},
  Url                      = {http://www.latexstudio.net/archives/7131}
}

@Online{Allianceurlonly,
  Url                      = {www.wimedia.org}
}

@Online{olnoauthoren,
  Title                    = {Dublin Core metadata element set: version 1.1},
  Url                      = {http://dublincore.org},
  Urldate                  = {2014-06-11},
  Year                     = {2012-06-14}
}
\end{filecontents}


