我目前复制 PowerPoint 主题我需要使用 tikz 和 beamer。目前唯一缺少的是主题中使用的自定义项目符号(见下文)。
我想复制这种外观,可能使用 tikz。有没有办法获得自定义项目符号而无需修改任何源文件(我希望能够在 ShareLaTeX 中执行此操作)?项目符号应仅用于目录,而不用于enumerate
环境。
答案1
基于“的起点Beamer 目录自定义项目符号“。您必须\bicolor
使用适当的矩形尺寸来自定义命令。
\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\setbeamertemplate{section in toc}[sections numbered]
\setbeamertemplate{subsection in toc}[subsections numbered]
\newcommand*\bicolor[1]{\tikz[baseline=(char.base)]{
\fill[blue!20] (-.5,-.2) rectangle (0,.5);
\fill[blue!10] (0,-.2) rectangle (.5,.5);
\node[color=white] (char) {#1};}}
\setbeamertemplate{section in toc}{%
\usebeamercolor[fg]{enumerate item}%
\makebox[2em][r]{\bfseries\Large\bicolor{\inserttocsectionnumber}}%
\parbox[t]{\dimexpr\linewidth-2em}{\inserttocsection}%
}
\begin{document}
\maketitle
\tableofcontents
\section{First section}
\subsection{First subsection}
\subsection{Second subsection}
\section{Second section}
\subsection{First subsection}
\subsection{Second subsection}
\end{document}
更复杂的版本:
\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\setbeamertemplate{section in toc}[sections numbered]
\setbeamertemplate{subsection in toc}[subsections numbered]
\newcommand*\seccolor[1]{\tikz[baseline=(char.base)]{
\fill[blue!20] (-.5,-.3) rectangle (0,.3);
\fill[blue!10] (0,-.3) rectangle (.5,.3);
\node[color=white] (char) {#1};}}
\newcommand*\subseccolor[1]{\tikz[baseline=(char.base)]{
\fill[red!20] (-.5,-.2) rectangle (0,.2);
\fill[red!10] (0,-.2) rectangle (.5,.2);
\node[color=red] (char) {#1};}}
\setbeamertemplate{section in toc}{%
\usebeamercolor[fg]{enumerate item}%
\makebox[2em][r]{\bfseries\Large\seccolor{\inserttocsectionnumber}}%
\parbox[t]{\dimexpr\linewidth-2em}{\rule{0pt}{.75cm}\inserttocsection}%
}
\setbeamertemplate{subsection in toc}{%
\usebeamercolor[fg]{enumerate item}%
\makebox[2em][r]{\bfseries\subseccolor{\inserttocsectionnumber. \inserttocsubsectionnumber}}%
\parbox[t]{\dimexpr\linewidth-2em}{\rule{0pt}{.5cm}\color{red}\inserttocsubsection}%
}
\begin{document}
\maketitle
\tableofcontents
\section{First section}
\subsection{First subsection}
\subsection{Second subsection}
\section{Second section}
\subsection{First subsection}
\subsection{Second subsection}
\section{Second section}
\subsection{First subsection}
\subsection{Second subsection}
\section{Second section}
\subsection{First subsection}
\subsection{Second subsection}
\section{Second section}
\subsection{First subsection}
\subsection{Second subsection}
\end{document}