我打算构建与以下代码完全相同的项目,但每次出现时在圆圈和字体中填充不同的颜色(例如,第一个为红色,白色为“1”,第二个为绿色,棕色为“2”)。我该怎么做?谢谢。
\documentclass[10pt,xcolor={dvipsnames,table}]{beamer}
\mode<article> % only for the article version
{
\usepackage{fullpage}
\usepackage{hyperref}
}
\mode<presentation>
{
%\setbeamertemplate{background canvas}[vertical shading][bottom=red!10,top=blue!10]
\setbeamercovered{transparent}
\usefonttheme{serif}
\usecolortheme{crane}
}
\usepackage{tikz}
\setbeamercovered{dynamic}
\setbeamertemplate{items}[circle]
\usetikzlibrary{tikzmark}
\newcommand{\itemnum}[1]{%
\setcounter{enumi}{#1}\usebeamertemplate{enumerate item}%
}
\begin{document}
\begin{frame}
These are my items~{\itemnum{1}} and~{\itemnum{2}} ...
\end{frame}
\end{document}
答案1
由于模板enumerate item
使用了的颜色设置,item projected
您可以使用它来调整圆圈(bg
)和文本(fg
)的颜色。
我已经添加\unskip
并\unbreak
调整水平间距(我认为之前的空间太多)并抑制换行。
代码
\documentclass[10pt,xcolor={dvipsnames,table}]{beamer}
\mode<article>{ % only for the article version
\usepackage{fullpage}
\usepackage{hyperref}
}
\mode<presentation>{
%\setbeamertemplate{background canvas}[vertical shading][bottom=red!10,top=blue!10]
\setbeamercovered{transparent}
\usefonttheme{serif}
\usecolortheme{crane}
}
\setbeamercovered{dynamic}
\setbeamertemplate{items}[circle]
\newcommand{\itemnum}[2][]{{% extra {} to keep changes local
\setbeamercolor{item projected}{#1}%
\setcounter{enumi}{#2}%
\unskip\nobreak % no linebreak and no space before it
\usebeamertemplate{enumerate item}%
}}
\begin{document}
\begin{frame}
These are my items \itemnum[bg=red, fg=white]{1}
and \itemnum[fg=brown, bg=green]{2} \dots
\end{frame}
\end{document}
输出
答案2
您已经得到了问题的完美答案,但作为替代方案:这里有一个使用circledsteps
包的解决方案
\documentclass[10pt,xcolor={dvipsnames,table}]{beamer}
\mode<article> % only for the article version
{
\usepackage{fullpage}
\usepackage{hyperref}
}
\mode<presentation>
{
%\setbeamertemplate{background canvas}[vertical shading][bottom=red!10,top=blue!10]
\setbeamercovered{transparent}
\usefonttheme{serif}
\usecolortheme{crane}
}
\usepackage{tikz}
\setbeamercovered{dynamic}
\usepackage{circledsteps}
\setbeamertemplate{items}[circle]
\usetikzlibrary{tikzmark}
\newcommand{\itemnum}[1]{%
\setcounter{enumi}{#1}\usebeamertemplate{enumerate item}%
}
\begin{document}
\begin{frame}
These are my items~{\footnotesize\Circled[inner color=white,fill color=red,outer color=red]{1}} and~{\footnotesize\Circled[inner color=lightgray,fill color=green,outer color=green]{2}} ...
\end{frame}
\end{document}