我在这个 MWE 中有一个枚举列表。
\documentclass[]{beamer}
\usetheme{Madrid}
\setbeamertemplate{items}[circle]
\begin{document}
\begin{frame}
\frametitle{Example}
\begin{enumerate}
\item First one
\item Second one
\item Third one
\end{enumerate}
In the above list, 2 and 3 are what more important.
\end{frame}
\end{document}
我希望文本中的“2”和“3”与列表中的相同,即带有白色数字的蓝色实心圆圈。
我该怎么做?谢谢。
答案1
如果外观是唯一重要的因素,那么以下做法即可:
代码
\documentclass[]{beamer}
\usetheme{Madrid}
\setbeamertemplate{items}[circle]
\usepackage{tikz}
\newcommand\mynum[1]{%
\usebeamercolor{enumerate item}%
\tikzset{beameritem/.style={circle,inner sep=0,minimum size=2ex,text=enumerate item.bg,fill=enumerate item.fg,font=\footnotesize}}%
\tikz[baseline=(n.base)]\node(n)[beameritem]{#1};%
}
\begin{document}
\begin{frame}
\frametitle{Example}
\begin{enumerate}
\item First one
\item Second one
\item Third one
\end{enumerate}
In the above list, \mynum{2} and \mynum{3} are what more important.
\end{frame}
\end{document}
输出
答案2
这几乎是相同的答案,但安全地引用标签名称而不是项目编号(即,当项目顺序发生变化时,引用仍然正确)。
\documentclass[]{beamer}
\usetheme{Warsaw}
\setbeamertemplate{items}[circle]
\usepackage{tikz}
\newcommand*\itemref[1]{%
\tikz[baseline=(char.base)]{%
\node[circle, fill=enumerate item.fg, inner sep=.6pt] (char) {\scriptsize\color{white}\ref{#1}};}}
\begin{document}
(Compile twice to solve the cross references).
\begin{frame}
\frametitle{Example}
\begin{enumerate}
\item \label{one} First one
\item \label{two} Second one
\item Last minuted included item without importance
\item \label{three} Third one
\end{enumerate}
In the above list, \itemref{one}, \itemref{two} and \itemref{three} are the more important.
\end{frame}
\end{document}
答案3
为了完整起见,我认为最好的解决方案是@Markus 和@Fran 的组合。带有模板标记的项目标签的参考:
\documentclass[]{beamer}
\usetheme{Warsaw}
\setbeamertemplate{items}[circle]
\usepackage{tikz}
\newcommand\itemref[1]{{\renewcommand{\insertenumlabel}{\ref{#1}}%
\usebeamertemplate{enumerate item}}}
\begin{document}
(Compile twice to solve the cross references).
\begin{frame}
\frametitle{Example}
\begin{enumerate}
\item \label{one} First one
\item \label{two} Second one
\item Last minuted included item without importance
\item \label{three} Third one
\end{enumerate}
In the above list, \itemref{one}, \itemref{two} and \itemref{three} are the more important.
\end{frame}
\end{document}
答案4
使用此代码:
\newcommand*\circled[1]{\tikz[baseline=(char.base)]{\node[shape=circle,draw,inner sep=2pt,fill=blue] (char) {#1};}}
\circled{\color{white} 3}
你会得到这个: