加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
beamerthemebaoding.sty 32.61 KB
一键复制 编辑 原始数据 按行查看 历史
Peng Fei 提交于 2023-07-24 23:57 . complete
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{beamerthemebaoding}[2023/07/06 v0.2 Baoding Beamer theme]
\RequirePackage{pgfopts}
\newcommand{\bdset}[1]{\pgfkeys{/bd/.cd,#1}}
\RequirePackage{etoolbox}
%\RequirePackage{expl3}
\RequirePackage{xparse}
\RequirePackage{tikz}
\usetikzlibrary{%
calc,%coordinate calculation
arrows.meta,shapes.geometric,shapes.misc,%shapes
positioning,matrix,trees,fit,%node placement
fill.image,shadings,fadings,backgrounds,%visual effect
overlay-beamer-styles
}
\RequirePackage{tcolorbox}
\tcbuselibrary{skins}%for enhanced skin
\RequirePackage{fontawesome5}%for interstring icons
\RequirePackage{pgfornament-han}%for ornament decorations
%plotting library
\RequirePackage{pgfplots}
\pgfplotsset{compat=1.18}
%graphics library
\RequirePackage{graphicx}
\RequirePackage{wrapstuff}
%for testing
\RequirePackage{lipsum,zhlipsum}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%1.颜色定义
\makeatletter
%1.1背景色定义
\definecolor{qilin}{RGB}{18,38,79}%骐驎
\definecolor{bicheng}{RGB}{18,80,123}%碧城
\definecolor{yuebai}{RGB}{212,229,239}%月白
\definecolor{shangong}{RGB}{245,243,242}%山巩
\colorlet{bd@color@b1}{qilin}
\colorlet{bd@color@b2}{bicheng}
\colorlet{bd@color@b3}{yuebai}
\colorlet{bd@color@b4}{shangong}
\newcommand{\bdcolorbgone}{bd@color@b1}
\newcommand{\bdcolorbgtwo}{bd@color@b2}
\newcommand{\bdcolorbgthree}{bd@color@b3}
\newcommand{\bdcolorbgfour}{bd@color@b4}
%1.2文字色定义
\definecolor{qingming}{RGB}{50,113,174}%青冥
\definecolor{taxian}{RGB}{21,29,41}%獭见
\definecolor{luoshenzhu}{RGB}{210,57,24}%洛神珠
\definecolor{erlv}{RGB}{93,163,157}%二绿
\colorlet{bd@color@structure}{qingming}
\colorlet{bd@color@normal@text}{taxian}
\colorlet{bd@color@alerted@text}{luoshenzhu}
\colorlet{bd@color@example@text}{erlv}
\newcommand{\bdcolorstructure}{bd@color@structure}
\newcommand{\bdcolornormal}{bd@color@normal@text}
\newcommand{\bdcoloralerted}{bd@color@alerted@text}
\newcommand{\bdcolorexample}{bd@color@example@text}
%1.3数学色定义
\definecolor{qunqing}{RGB}{46,89,167}%群青
\definecolor{facui}{RGB}{016,139,150}%法翠
\definecolor{zhengqing}{RGB}{108,168,175}%正青
\definecolor{shaorong}{RGB}{237,109,061}%苕荣
\colorlet{bd@color@math@definition}{qunqing}
\colorlet{bd@color@math@theorem}{facui}
\colorlet{bd@color@math@example}{zhengqing}
\colorlet{bd@color@math@proof}{shaorong}
\newcommand{\bdcolormathdefinition}{bd@color@math@definition}
\newcommand{\bdcolormaththeorem}{bd@color@math@theorem}
\newcommand{\bdcolormathexample}{bd@color@math@example}
\newcommand{\bdcolormathproof}{bd@color@math@proof}
%1.4其它颜色定义
\colorlet{bd@color@mask}{qilin}
\colorlet{bd@color@border}{lightgray}
\newcommand{\bdcolormask}{bd@color@mask}
\newcommand{\bdcolorborder}{bd@color@border}
%1.5 beamer颜色定义
\setbeamercolor*{palette primary}{fg=bd@color@b1}
\setbeamercolor*{palette secondary}{fg=bd@color@b2}
\setbeamercolor*{palette tertiary}{fg=bd@color@b3}
\setbeamercolor*{palette quaternary}{fg=bd@color@b4}
%
\setbeamercolor{structure}{fg=\bdcolorstructure, bg=\bdcolorbgfour}
\setbeamercolor{normal text}{fg=bd@color@normal@text}
\setbeamercolor{alterted text}{fg=bd@color@altered@text}
\setbeamercolor{example text}{fg=bd@color@example@text}
%
\setbeamercolor{titlelike}{parent=structure}
\makeatother
%2.字体定义
\makeatletter
%一级标题
\setCJKfamilyfont{bd@font@heading}{锐字真言体免费商用 常规}
\newcommand{\bdfontheading}{\CJKfamily{bd@font@heading}}
%二级标题
\setCJKfamilyfont{bd@font@subheading}{问藏书房}
\newcommand{\bdfontsubheading}{\CJKfamily{bd@font@subheading}}
%书法字体
\setCJKfamilyfont{bd@font@cal}{SJxingkai-C Regular}
\newcommand{\bdfontcal}{\CJKfamily{bd@font@cal}}
%英文引用字体
\newfontfamily{\bdfontenquote}{Monotype Corsiva}
\makeatother
%3.图片定义
\makeatletter
\newcommand{\bd@image@title}{}
\newcommand{\bd@image@toc}{}
\newcommand{\bd@image@section}{}
\newcommand{\bd@image@logo}{}
\pgfkeys{
/bd/image/title/.code={%
\renewcommand{\bd@image@title}{#1}%
},%
/bd/image/toc/.code={%
\renewcommand{\bd@image@toc}{#1}%
},%
/bd/image/section/.code={%
\renewcommand{\bd@image@section}{#1}%
},%
/bd/image/logo/.code={%
\renewcommand{\bd@image@logo}{#1}%
},%
}
\makeatother
%4.总体页面设置
\makeatletter
\newcommand{\bd@sep}{ \hskip1em\structure{\textbar}\hskip1em }
\AtBeginDocument{%
{%
\pgfdeclareverticalshading{bd@shading@in@headfoot}{\paperwidth}{%
color(0.0ex)=(black!30!\bdcolorbgone);%
color(0.8ex)=(black!20!\bdcolorbgone);%
color(1.0ex)=(\bdcolorbgone);%
color(1.2ex)=(white!10!\bdcolorbgone);%
color(2.0ex)=(white!20!\bdcolorbgone)%
}%
}%
}
%4.1 背景色与背景图
\setbeamercolor{background canvas}{fg=black, bg=\bdcolorbgfour}
\setbeamercolor{background}{parent=background canvas}
\pgfkeys{%
/bd/draft/.code={%
\setbeamertemplate{background}[grid][step=1cm,color=\bdcolorborder]%
},%
}
%4.2 水平边距
\setbeamersize{text margin left=1em,text margin right=1em}
%4.3取消导航按钮
\setbeamertemplate{navigation symbols}{}
%4.4 headline
\setbeamertemplate{headline}
{%
\leavevmode%
\pgfuseshading{bd@shading@in@headfoot}%
\vskip-3ex%
\tcbox[empty,size=minimal,nobeforeafter,colupper=white,%
%show bounding box
]{%
\hspace*{3.5ex} \insertshorttitle %
\ifx\insertsection\empty\else\bd@sep\insertsection\fi%
\ifx\insertsubsection\empty\else\bd@sep\insertsubsection\fi%
\ifx\insertsubsubsection\empty\else\bd@sep\insertsubsubsection\fi%
}%
\vskip0pt%
}
%4.5 footline
\setbeamertemplate{footline}
{%
\leavevmode%
\pgfuseshading{bd@shading@in@headfoot}%
\vskip-3ex%
\begin{tcolorbox}[%
empty,size=minimal,nobeforeafter,colupper=white,width=\paperwidth,%
%show bounding box,
]%
\hspace*{3.5ex} \insertshortauthor{} \bd@sep \insertshortinstitute \bd@sep \insertshortdate%
\hfill%
\insertframenumber{} / \inserttotalframenumber \hspace*{3.5ex} %前面的空格是必须的,去掉会使3.5ex空格失效
\end{tcolorbox}%
\vskip0pt%
}
%4.6 titleline
\setbeamertemplate{frametitle}
{%
\leavevmode%
\begin{tikzpicture}[remember picture, overlay]%
\node[anchor=north west,text=\bdcolorstructure] (frame title) at ([yshift=-1.4ex]current page.north west) {\insertframetitle};%
\ifx\insertframesubtitle\@empty%
%
\else{%
\node[anchor=south west,text=\bdcolorstructure!80,font=\footnotesize] at ([xshift=-3mm]frame title.south east) {(\insertframesubtitle)};
}%
\fi%
\path[fill stretch image=\bd@image@logo] ([xshift=-.5cm]frame title.center-|current page.north east) circle[radius=.39cm];
\draw[color=\bdcolorbgone, line width=.5pt] (frame title.south west)--+(20cm,0);%
\end{tikzpicture}%
\vskip0pt%
}
\makeatother
%5.定制页面
%5.0 思维导图
\makeatletter
\colorlet{central-concept-color}{\bdcoloralerted}
\colorlet{normal-concept-color}{gray!20}
\colorlet{annotation-concept-color}{\bdcolorstructure}
\tikzset{
central concept/.style={
rounded rectangle,
rounded rectangle arc length=90,
inner sep=5pt,
fill=central-concept-color,
text=white,
font=\bfseries\small,
},
normal concept/.style={
rounded rectangle,
rounded rectangle arc length=150,
inner sep=3pt,
fill=normal-concept-color,
text=\bdcolorbgone,
font=\zihao{7},
align=left,
},
annotation concept/.style={
rounded rectangle,
rounded rectangle arc length=90,
inner sep=2pt,
fill=annotation-concept-color,
text=white,
font=\tiny,
align=left,
},
node distance=2ex,
mind map/.style={
root/.style={central concept},
every child node/.style={normal concept},
grow'=east,growth parent anchor=east,anchor=west,
level distance=1cm,
level 1/.style={level distance=2cm,sibling distance=1.8cm},
level 2/.style={level distance=1.5cm,sibling distance=8mm},
level 3/.style={level distance=1.2cm,sibling distance=6mm},
level 4/.style={level distance=1cm,sibling distance=6mm},
edge from parent path={[draw=white](\tikzparentnode)to[out=0,in=180](\tikzchildnode)},
},
}
%5.1 定制封面页
\setbeamertemplate{title page}
{%
\begin{tikzpicture}[remember picture, overlay]%
%背景图片
\path[fill=\bdcolormask, fill stretch image=\bd@image@title, fill image opacity=.5] (current page.south west) rectangle (current page.north east);%
%标题与小标题
\node[anchor=south,text=white,font=\Huge\bdfontheading] (title) at ([yshift=2ex]current page.center) {\inserttitle};%
\node[anchor=north,text=white,font=\small\bdfontsubheading] (subtitle) at([yshift=-1ex]title.south) {\insertsubtitle};%
%logo
\path[fill stretch image=\bd@image@logo, fill image opacity=.2] ([yshift=2cm]current page.south) circle[radius=1cm];%
%机构、作者、日期
\begin{scope}[text=white,font=\footnotesize\yahei]%
\node[below=of title,yshift=-3em,xshift=12em] (institute) {\insertinstitute};%
\node[anchor=north east] (author) at ([yshift=-1ex]institute.south east) {\insertauthor};%
\node[anchor=north east] (date) at ([yshift=-.4ex]author.south east) {\insertdate};%
\end{scope}%
\end{tikzpicture}%
}
%5.2 定制目录页
\RequirePackage{multicol}
\newcommand{\tocpage}
{%
\begin{frame}[plain]%
\setbeamercolor{section in toc}{fg=white}%
\setbeamerfont{section in toc}{size=\large}%
\setbeamertemplate{section in toc}[square]%
%
\begin{tikzpicture}[remember picture, overlay, node distance=5mm]%
%背景图片
\path[fill=\bdcolormask, fill stretch image=\bd@image@toc, fill image opacity=.5] (current page.south west) rectangle (current page.north east);%
%目录标题
\node[text=white,font=\huge\bdfontheading] (toc title) at([yshift=-1cm] current page.north){\hspace{1.2cm}};%
%目录内容
\node[below=of toc title.south,anchor=north, text width=.6\textwidth]{%
\begin{multicols}{2}%
\tableofcontents[sectionstyle=show,subsectionstyle=hide,subsubsectionstyle=hide]%
\end{multicols}%
};%
\end{tikzpicture}%
\end{frame}%
}
%5.3 定制转场页
\defbeamertemplate{section in toc}{bdsecpage}{%
\leavevmode%
\tcbox[arc=0mm,colframe=\bdcolorbgfour,colback=\bdcolorbgfour,colupper=\bdcolorbgone,fontupper=\huge\bdfontheading]{\inserttocsection}%
\par%
}
\defbeamertemplate{subsection in toc}{bdsecpage}{%
\leavevmode%
\tcbox[empty,size=fbox,nobeforeafter,colupper=\bdcolorbgfour,fontupper=\small\bdfontsubheading]{\inserttocsubsection}%
\par%
}
\setbeamertemplate{section in toc}[bdsecpage]%
\setbeamertemplate{subsection in toc}[bdsecpage]%
\setbeamertemplate{section page}{%
%背景图
\tikz[remember picture, overlay]%
\path[fill=bd@color@mask, fill stretch image=\bd@image@section, fill image opacity=.5]%
(current page.south west) rectangle (current page.north east);%
%本节目录
\tikz[remember picture, overlay]%
\node[anchor=north east] at ([xshift=3cm]current page.60) {%
\begin{minipage}{5cm}%
\flushright%
\tableofcontents[sectionstyle=show/hide,subsectionstyle=show/show/hide,subsubsectionstyle=hide]%
\end{minipage}%
};%
}
\AtBeginSection[]
{%
\begin{frame}[plain]%
\sectionpage%
\end{frame}%
}
%5.4 定制subsection转场页
\newcommand{\defaultsubsectionmindmap}{%
\tikz[remember picture, overlay]%
\node[central concept] at (0,0){%
\insertsubsection%
};%
}
\newcommand{\subsectionmindmap}{\defaultsubsectionmindmap}
\newcommand{\restoresubsectionmindmap}{\renewcommand{\subsectionmindmap}{\defaultsubsectionmindmap}}
\newcommand{\setsubsectionmindmap}[1]{%
\renewcommand{\subsectionmindmap}{#1}%
}
\setbeamertemplate{subsection page}{%
\tikz[remember picture, overlay]%
\path[fill=\bdcolormask!50!black, fill stretch image=\bd@image@section, fill image opacity=.4]%
(current page.south west) rectangle (current page.north east);%
\tikz[remember picture, overlay]%
\node at (current page.center){%
\subsectionmindmap%
};%
}
\newif\ifshowsubsection
\pgfkeys{
/bd/show subsection/.is if=showsubsection,
/bd/show subsection/.default=false,
}
\AtBeginSubsection[]
{%
\ifshowsubsection%
\begin{frame}[plain]%
\subsectionpage%
\end{frame}%
\restoresubsectionmindmap%
\fi%
}
%5.5 定制突显页
\newcommand{\standoutpage}[1]{%
\begin{frame}[plain]%
\begin{tikzpicture}[remember picture, overlay]%
\fill[\bdcolormask, fill opacity=.9] (current page.south west) rectangle (current page.north east);%
%
\node[text=white,font=\Huge\bdfontcal,scale=1.5] at (current page.center){#1};%
\end{tikzpicture}%
\end{frame}%
}
\makeatother
%6. 局部结构
%6.1 块
\setbeamertemplate{blocks}[rounded]
%normal block
\setbeamercolor{block title}{parent=normal text, bg=\bdcolorbgthree}
\setbeamerfont{block title}{series=\bfseries}
\setbeamercolor{block body}{parent=normal text, bg=\bdcolorbgthree}
%alerted block
\setbeamercolor{block title alerted}{parent=alerted text, bg=\bdcolorbgthree}
\setbeamerfont{block title alerted}{series=\bfseries}
\setbeamercolor{block body alerted}{parent=alerted text, bg=\bdcolorbgthree}
%example block
\setbeamercolor{block title example}{parent=example text, bg=\bdcolorbgthree}
\setbeamerfont{block title example}{series=\bfseries}
\setbeamercolor{block body example}{parent=example text, bg=\bdcolorbgthree}
%6.2 条目
\setbeamertemplate{items}[square]
%6.3题注
\setbeamercolor{caption}{}
\setbeamercolor{caption name}{parent=structure}
%7.自定义命令和环境
%7.1定义居中环境
\NewDocumentEnvironment{centeredminipage}{O{\textwidth}}{\bgroup\begin{center}\begin{minipage}{#1}}{\end{minipage}\end{center}\egroup}
%7.2整页背景图片命令
\NewDocumentCommand{\bdfillbgimage}{m}{%
\begin{tikzpicture}[remember picture, overlay]%
\path[fill stretch image=#1] (current page.south west) rectangle (current page.north east);%
\end{tikzpicture}%
}
%7.3居中带边框的列表环境
\tcbset{
dashed frame/.style={
enhanced,size=small,
colframe=\bdcolorbgfour,
%drop lifted shadow=lightgray,
borderline={1pt}{0pt}{\bdcolorborder,dashed}
}
}
\NewDocumentEnvironment{listbox}{O{itemize} !O{}}{%
\begin{tcolorbox}[dashed frame, #2]\begin{#1}%
}{%
\end{#1}\end{tcolorbox}%
}
%7.4pdf文档显示环境
\tcbset{
pdf document/.style={
enhanced,size=small,
colframe=\bdcolorborder,
drop fuzzy shadow=lightgray
}
}
\NewDocumentCommand{\pdfview}{m !O{page=1} !O{}}{%
\bgroup\begin{tcolorbox}[pdf document, #3]%
\href[pdfnewwindow=true]{run:#1}{\includegraphics[width=\textwidth,#2]{#1}}%
\end{tcolorbox}\egroup%
}
%7.5任务清单环境
\tcbuselibrary{raster}
\NewDocumentEnvironment{bdtaskboard}{ O{} !O{} !O{}}{%
\begin{tcboxedraster}[%
raster columns=2, raster equal height,#1,%
raster halign=center,%
raster force size=false,%
raster every box/.style={%
size=small, enhanced,%
colframe=white,colback=white,%
drop fuzzy shadow,%
valign lower=bottom,%
width=.5\textwidth,%
#2,%
}%
]{%
colframe=white,colback=\bdcolorbgthree,%
width=.8\textwidth,%
before=\begin{center},%
after=\end{center},%
#3,%
}%
}{\end{tcboxedraster}}%
%
\newcounter{bdtask}
\setcounter{bdtask}{0}
\newcommand{\bdtask}{\tcbox[verbatim,size=small,colframe=white,colback=\bdcolorstructure,colupper=white,fontupper=\bfseries]{任务~\stepcounter{bdtask}\thebdtask}}
%
\NewDocumentCommand \bdtaskcard { v v v }{%
\begin{tcolorbox}%
\bdtask\par%
%
\textbf{#1}\par%
%
{\color{gray}\scriptsize #2}%
%
\tcblower%
%
\tcbox[verbatim,size=small,colframe=white,colback=\bdcolorbgthree!90!black,colupper=white,fontupper=\footnotesize]{\faClock[regular] #3}%
\end{tcolorbox}%
}
%7.6便签盒子
\usetikzlibrary{patterns}
\NewTColorBox{bdtips}{}{
enhanced,
before=\begin{center},after=\end{center},
text width=.25\textwidth,
height=.5\textheight,
boxrule=0pt,toprule=5mm, top=0pt,bottom=0pt, arc=0pt,
colback=\bdcolorbgthree,colframe=\bdcolorbgtwo,
drop lifted shadow,
frame style={pattern=crosshatch dots light steel blue},
overlay={%
\fill[shading=ball, ball color=\bdcolorbgtwo,opacity=.5] ([yshift=-2.5mm]frame.north) circle[radius=2mm];
}
}
%8.代码盒子
%\pgfkeys{/bd/has source code/.code={\input{./template/code/sourcecode.code.tex}}}
\begin{tcbwritetemp}
\tcbuselibrary{minted}%
%8.0代码片段盒子
\DeclareTotalTCBox{\cmdbox}{ s v }{verbatim,size=fbox,colupper=white,colback=\bdcolorbgone!90,colframe=\bdcolorbgthree,fontupper=\footnotesize}{%
\IfBooleanT{#1}{\textcolor{\bdcoloralerted}{\ttfamily\bfseries > }}%
\mintinline{winbatch}{#2}%
}
%8.1通用代码盒子
\tcbset{%
source code/.style={%
enhanced,size=small,%
before=\begin{center},after=\end{center},%
colback=\bdcolorbgfour,colframe=\bdcolorborder!50,colbacktitle=\bdcolorborder!40,coltitle=\bdcolornormal!70,%
boxrule=0.2mm,leftrule=5mm,arc=0mm,%
halign upper=flush center,%
before lower=\begin{center},after lower=\end{center}, fontlower=\scriptsize,%
}%
}%
\DeclareTCBListing{sourcecode}{s m !O{} !O{}}{%
source code,%
IfBooleanT={#1}{listing only},%
listing engine=minted,
minted language=#2,%
minted style=friendly,%
default minted options={fontsize=\scriptsize,breaklines,autogobble,linenos},%
IfEmptyF={#3}{minted options={fontsize=\scriptsize,breaklines,autogobble,linenos, #3}},%
#4,%
}%
%8.2外部代码盒子
\DeclareTCBInputListing{\inputsourcecode}{s m O{} O{} m}{%
source code,%
IfBooleanT={#1}{listing only},%
listing engine=minted,
minted language=#2,%
minted style=friendly,%
default minted options={fontsize=\scriptsize,breaklines,autogobble,linenos},%
IfEmptyF={#3}{minted options={fontsize=\scriptsize,breaklines,autogobble,linenos, #3}},%
#4,%
listing file={#5},%
}%
%8.3pythontex盒子
\RequirePackage[prettyprinter=pygments,pygopt={style=friendly}]{pythontex}%
\setpythontexfv{fontsize=\scriptsize,numbers=left}%
%
\setpythontexcontext{textwidth=\the\textwidth, textheight=\the\textheight}%
\begin{pythontexcustomcode}[begin]{pylab}
plt.style.use('seaborn')
tex_fonts = {
# Use LaTeX to write all text
"text.usetex": True,
"font.family": "serif",
# Use 10pt font in plots, to match 10pt font in document
"axes.labelsize": 10,
"font.size": 10,
# Make the legend/label fonts a little smaller
"legend.fontsize": 8,
"xtick.labelsize": 8,
"ytick.labelsize": 8
}
plt.rcParams.update(tex_fonts)
def before():
fig_width_pt = pytex.context['textwidth']
fig_width_in = pytex.pt_to_in(fig_width_pt)
fig_height_in = fig_width_in * 0.618#golden_ratio = (5**.5 - 1) / 2
fig,ax = plt.subplots(1, 1, figsize=(fig_width_in,fig_height_in))
def after():
fname = ''.join([pytex.family, pytex.session, pytex.restart,'.pdf'])
fig = gcf()
fig.savefig(fname)
print(r'\includegraphics{'+fname+r'}')
pytex.before=before
pytex.after = after
\end{pythontexcustomcode}
\end{tcbwritetemp}
\pgfkeys{/bd/has source code/.code={\tcbusetemp}}
%9.数学盒子
\RequirePackage{amsmath,amssymb}
\RequirePackage{unicode-math}
\RequirePackage{nicematrix}
\RequirePackage{varwidth}
\tcbuselibrary{skins,theorems,breakable}
\makeatletter
\newcommand\bdmathcolor{\bdcolormaththeorem}
\newcommand\bdmathsymbol{\clubsuit}
\tcbset{
math env type/.is choice,
math env type/definition/.code={%
\renewcommand\bdmathcolor{\bdcolormathdefinition}%
\renewcommand\bdmathsymbol{\spadesuit}%
},
math env type/theorem/.code={%
\renewcommand\bdmathcolor{\bdcolormaththeorem}%
\renewcommand\bdmathsymbol{\clubsuit}%
},
math env type/lemma/.code={%
\renewcommand\bdmathcolor{\bdcolormaththeorem}%
\renewcommand\bdmathsymbol{\clubsuit}%
},
math env type/corollary/.code={%
\renewcommand\bdmathcolor{\bdcolormaththeorem}%
\renewcommand\bdmathsymbol{\clubsuit}%
},
math env type/proposition/.code={%
\renewcommand\bdmathcolor{\bdcolormaththeorem}%
\renewcommand\bdmathsymbol{\clubsuit}%
},
math env type/property/.code={%
\renewcommand\bdmathcolor{\bdcolormaththeorem}%
\renewcommand\bdmathsymbol{\clubsuit}%
},
math env type/example/.code={%
\renewcommand\bdmathcolor{\bdcolormathexample}%
\renewcommand\bdmathsymbol{\diamondsuit}%
},
math env type/proof/.code={%
\renewcommand\bdmathcolor{\bdcolormathproof}%
\renewcommand\bdmathsymbol{\heartsuit}%
},
math env type/solution/.code={%
\renewcommand\bdmathcolor{\bdcolormathproof}%
\renewcommand\bdmathsymbol{\heartsuit}%
},
math common/.style={
enhanced,breakable,
frame empty,
lower separated=false,
%
colframe=\bdmathcolor,
colback=\bdmathcolor!8,
fontupper=\kaishu,
%
borderline={0.3mm}{0mm}{\bdmathcolor!20!white},
borderline={0.3mm}{0mm}{\bdmathcolor,dashed},
%
coltitle=\bdmathcolor!50!black,
colbacktitle=\bdmathcolor!15!white,
fonttitle=\bfseries,
attach boxed title to top center={yshift=-2mm},
boxed title style={boxrule=0.5pt},varwidth boxed title,
%
before skip=5pt,after skip=5pt,
top=6pt,bottom=3pt,left=3pt,right=3pt,boxsep=0pt,
%
separator sign colon,
description delimiters parenthesis,
%
overlay unbroken and last={
\node[anchor=south east, outer sep=0pt] at (\linewidth-width,0) {$\textcolor{\bdmathcolor!50}{\bdmathsymbol}$};
},
},
first env/.style={
no overlay,
borderline south={0.5mm}{-0.1mm}{white},
borderline south={0.1mm}{0mm}{\bdmathcolor!20},
sharp corners=south,
},
middle env/.style={
notitle,no overlay,
borderline horizontal={0.4mm}{0mm}{white},
borderline horizontal={0.1mm}{0mm}{\bdmathcolor!20},
sharp corners=all,
finish={\ifx\tcbcounter\empty\else\addtocounter{\tcbcounter}{-1}\fi},
},
last env/.style={
notitle,
borderline north={0.5mm}{-0.1mm}{white},
borderline north={0.1mm}{0mm}{\bdmathcolor!20},
sharp corners=north,
finish={\ifx\tcbcounter\empty\else\addtocounter{\tcbcounter}{-1}\fi},
},
}
\DeclareTcbTheorem[auto counter, number within=section]{definition}{定义}{%
math env type=definition,%
math common,%
}{def}%
\DeclareTcbTheorem[auto counter, number within=section]{theorem}{定理}{%
math env type=theorem,%
math common,%
}{thm}%
\DeclareTcbTheorem[auto counter, number within=subsection, number freestyle={\noexpand\thesection.\noexpand\thesubsection.\noexpand\arabic{\tcbcounter}}]{lemma}{引理}{%
math env type=theorem,%
math common,%
}{lem}%
\DeclareTcbTheorem[auto counter, number within=subsection, number freestyle={\noexpand\thesection.\noexpand\thesubsection.\noexpand\arabic{\tcbcounter}}]{corollary}{推论}{%
math env type=theorem,%
math common,%
}{cor}%
\DeclareTcbTheorem[auto counter, number within=section]{proposition}{命题}{%
math env type=theorem,%
math common,%
}{pps}%
\DeclareTcbTheorem[auto counter, number within=section]{property}{性质}{%
math env type=theorem,%
math common,%
}{ppt}%
\DeclareTcbTheorem[auto counter, number within=subsection, number freestyle={\noexpand\thesection.\noexpand\thesubsection.\noexpand\arabic{\tcbcounter}}]{example}{例题}{%
math env type=example,%
math common,%
}{exm}%
\DeclareTcbTheorem[no counter]{proof}{证明}{%
math env type=proof,%
math common,%
}{pro}%
\DeclareTcbTheorem[no counter]{solution}{解答}{%
math env type=proof,%
math common,%
}{slt}%
\makeatother
%表格环境定制
\RequirePackage{tabularray}
%k-v 3列表格
\makeatletter
\newcommand*{\K}[1]{\texttt{#1}}
\newcommand*{\V}[1]{\texttt{#1}}
\newcommand*{\None}{$\times$}
\NewTblrEnviron{spectblr}
\SetTblrOuter[spectblr]{long}
\SetTblrInner[spectblr]{%
hlines = {white},%
colsep = 5pt,%
row{odd} = {bd@color@b3!90!gray}, row{even} = {bd@color@b4!95!black},%
row{1} = {fg=white, bg=bd@color@b1, font=\bfseries\sffamily,halign=c},%
rowhead = 1,%
}
\makeatother
%专有名称
\usepackage{hologo}
\def\pgfname{\textsc{pgf}}
\def\tikzname{Ti\emph{k}Z}
\newcommand\PGFPlots{\textsc{pgfplots}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%hacking code borrowed from %
%https://tex.stackexchange.com/questions/262864/badly-aligned-two-column-beamer-toc?noredirect=1%
%to fixing the multicos toc miss-alignment bug. %
% %
\makeatletter %
\def\beamer@tableofcontents[#1]{% %
\def\beamer@toc@cs{show}% %
\def\beamer@toc@os{show}% %
\def\beamer@toc@css{show}% %
\def\beamer@toc@oss{show}% %
\def\beamer@toc@ooss{show}% %
\def\beamer@toc@csss{show}% %
\def\beamer@toc@osss{show}% %
\def\beamer@toc@oosss{show}% %
\def\beamer@toc@ooosss{show}% %
\beamer@showpartnumber=\c@part% %
\beamer@pausesectionsfalse% %
\beamer@pausesubsectionsfalse% %
\def\beamer@tocsections{<*>}% %
\setkeys{beamertoc}{firstsection=1}% %
\setkeys{beamertoc}{#1}% %
%\vspace*{-.5em} %
{\makeatletter% %
\pause[0]% %
\@input{\jobname.toc}% %
\vfill}% %
} %
\makeatother %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\ProcessPgfOptions{/bd}
%结束
\endinput
% %8.代码盒子定制
% \makeatletter
% %8.1程序代码风格
% \tcbuselibrary{listings}
% \tcbset{
% program code/.style={
% enhanced,size=small,
% colback=\bdcolorbgfour,colframe=\bdcolorborder,
% boxrule=0.2mm,leftrule=0.7mm,arc=0mm,
% }
% }
% %8.2 LaTeX代码盒子
% \DeclareTCBListing{latexbox}{ s !O{} !O{} }{%
% program code,%
% %IfEmptyTF={#2}{width=\textwidth}{width=#2},%
% before=\begin{center},after=\end{center},%
% IfBooleanT={#1}{listing only},%
% halign upper=flush center,%
% listing options={style=tcblatex,texcsstyle=*\structure,
% moretexcs={includegraphics},
% basicstyle=\scriptsize\bdfontcode,emphstyle=\color{bd@color@alerted@text}, #2},%
% before lower=\begin{center},after lower=\end{center}, fontlower=\scriptsize,%
% #3,%
% }
% %8.3 TikZ代码盒子
% %导入aobs-tikz库,为tikz添加Beamer overlay功能
% \usetikzlibrary{overlay-beamer-styles}
% %添加fading的overlay功能
% \tikzset{
% background fade/.style={path fading=#1},
% background fade/.default={fade out},
% background default fade/.style={
% background fade/.default={#1},
% },
% fade on/.style={alt=#1{}{background fade}},
% }
% %定义tikz的listing style
% \definecolor{bd@color@tikz@kw}{HTML}{859900}
% \lstdefinestyle{bdtcbtikz}{
% language=[LaTeX]TeX,
% %classoffset=0,
% texcsstyle=*\structure,
% moretexcs={tikzset,pic,node,coordinate,path,draw,fill,foreach},
% moretexcs={definecolor},
% basicstyle=\scriptsize\bdfontcode,
% morekeywords={tikzpicture,scope},
% keywordstyle={\color{bd@color@tikz@kw}\bfseries},
% emphstyle=\color{bd@color@alerted@text},
% }
% %定义tikz代码盒子
% %\DeclareTCBListing{bdtikzbox}{ s O{\textwidth} !O{} !O{} }{%
% \DeclareTCBListing{tikzbox}{ !s !O{} !O{} }{%
% program code,%
% %IfEmptyTF={#2}{width=\textwidth,text width=\textwidth}{width=#2,text width=#2},%
% before=\begin{center},after=\end{center},%
% IfBooleanT={#1}{listing only},%
% halign upper=flush center,%
% listing options={style=bdtcbtikz, #2},%
% before lower=\begin{center},after lower=\end{center}, fontlower=\scriptsize,%
% listing outside text,%
% #3,%
% }
% %8.3Python代码盒子
% %源代码字体
% \RequirePackage{textcomp}
% %\RequirePackage{sourcecodepro}
% %\newcommand{\bdfontcode}{\soucecodepro}
% \newfontfamily{\bdfontcode}{Source Code Pro}
% \makeatletter
% \definecolor{bd@color@python@background}{HTML}{F8F8F8}
% \definecolor{bd@color@python@corekeyword}{HTML}{008000}
% \definecolor{bd@color@python@builtins}{HTML}{008000}
% \definecolor{bd@color@python@decorator}{HTML}{AA22FF}
% \definecolor{bd@color@python@comment}{HTML}{3D7B7B}
% \definecolor{bd@color@python@string}{HTML}{BA2121}
% \definecolor{bd@color@python@digit}{HTML}{666666}
% \definecolor{bd@color@python@emph}{HTML}{0000FF}
% \newcommand\digitstyle{\color{bd@color@python@digit}}
% \newcommand{\ProcessDigit}[1]
% {%
% \ifnum\lst@mode=\lst@Pmode\relax%
% {\digitstyle #1}%
% \else
% #1%
% \fi
% }
% \lstdefinestyle{bdtcbpython}{%
% % core keywords
% keywordstyle={\color{bd@color@python@corekeyword}\bfseries},
% %builtins
% keywordstyle={[2]\color{bd@color@python@builtins}}, % built-ins
% alsoletter={@},
% morekeywords=[3]{@staticmethod},
% keywordstyle={[3]\color{bd@color@python@decorator}},%
% %background color
% %backgroundcolor=\color{bd@color@python@background},%
% %basic style
% basicstyle=\footnotesize\bdfontcode, % size of the fonts for the code
% stringstyle=\color{bd@color@python@string},%
% commentstyle=\color{bd@color@python@comment}\itshape,%
% emphstyle=\color{bd@color@python@emph},
% emphstyle={[2]\color{bd@color@python@emph}\bfseries},
% upquote=true, % requires textcomp
% literate=
% {0}{{{\ProcessDigit{0}}}}1
% {1}{{{\ProcessDigit{1}}}}1
% {2}{{{\ProcessDigit{2}}}}1
% {3}{{{\ProcessDigit{3}}}}1
% {4}{{{\ProcessDigit{4}}}}1
% {5}{{{\ProcessDigit{5}}}}1
% {6}{{{\ProcessDigit{6}}}}1
% {7}{{{\ProcessDigit{7}}}}1
% {8}{{{\ProcessDigit{8}}}}1
% {9}{{{\ProcessDigit{9}}}}1
% {<=}{{\(\leq\)}}1,
% numberstyle=\scriptsize\color{lightgray},
% breakatwhitespace=false,
% breaklines=true,
% captionpos=b,
% keepspaces=true,
% numbers=left,
% numbersep=5pt,
% showspaces=false,
% showstringspaces=false,
% showtabs=false,
% tabsize=4,
% }
% \makeatother
% \NewTCBListing{pythonbox}{ !O{} !O{} }{%
% program code,%
% left=5mm,%
% %IfEmptyTF={#1}{width=\textwidth}{width=#1},%
% before=\begin{center},after=\end{center},%
% listing options={language=Python,style=bdtcbpython, #1},%
% listing only,%
% #2,%
% }
% %8.4Python可视化环境
%\setpythontexfv{fontfamily=Source Code Pro}
%\fvset{font=\bdfontcode}
% \makeatother
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化