![在 beamer 中的 itemize 环境中使用文本作为标签](https://linux22.com/image/348001/%E5%9C%A8%20beamer%20%E4%B8%AD%E7%9A%84%20itemize%20%E7%8E%AF%E5%A2%83%E4%B8%AD%E4%BD%BF%E7%94%A8%E6%96%87%E6%9C%AC%E4%BD%9C%E4%B8%BA%E6%A0%87%E7%AD%BE.png)
我正在尝试在 beamer 中的 itemize 环境中使用文本作为标签。
我用过
\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage{enumitem}
\setitemize{%
label=\usebeamerfont*{itemize item}
\usebeamercolor[fg]{itemize item}
\usebeamertemplate{itemize item}
}
\begin{document}
\begin{frame}
\begin{itemize}
\item \makebox[2.75cm][l]{$a$} iff $a$,
\item \makebox[2.75cm][l]{$b+c$} iff $a$,
\item \makebox[2.75cm][l]{$d$} iff $a$
\item \makebox[2.75cm][l]{$e+f$} iff $a$ and a lot of text which takes up multiple lines without correct alignment
\end{itemize}
\vfill
\begin{itemize}
\item[$a$] iff $a$,
\item[$b+c$] iff $a$,
\item[$d$] iff $a$
\item[$e+f$] iff $a$
\end{itemize}
\end{frame}
\end{document}
生产
第一个 itemize 环境中的问题是我需要第二行与上面一行中的“iff $a$ and ...”对齐。
我曾尝试通过在 itemize 环境中使用标签而不是 来实现这一点\makebox
。但如果我这样做,我仍然没有定义标签的宽度,并且我会丢失蓝色的 itemize 项目符号/箭头。
答案1
通常,beamer
与 配合得不好enumitem
,存在很多兼容性问题。这里有一个(不太干净的)解决您问题的方法。不过,它会破坏覆盖选项。
\documentclass{beamer}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage{enumitem}
\setitemize{%
label=\usebeamerfont*{itemize item}
\usebeamercolor[fg]{itemize item}
\usebeamertemplate{itemize item}
}
\makeatletter
\def\Myitemize#1{%
\advance\beamer@descdefault by \labelsep%
\list
{}
{\labelwidth\beamer@descdefault%
\leftmargin\beamer@descdefault%
\let\makelabel\beamer@descriptionitem
\settowidth\labelwidth{\beamer@descriptionitem{#1}}%
\setlength\leftmargin{\labelwidth}%
\addtolength\leftmargin{\labelsep}%
}%
\beamer@cramped%
\raggedright
\beamer@firstlineitemizeunskip%
}
\def\endMyitemize{\ifhmode\unskip\fi\endlist}
\long\def\beamer@descriptionitem#1{%
\def\insertdescriptionitem{#1}%
{\usebeamertemplate**{description item}}\hfil}
\makeatother
\begin{document}
\begin{frame}
\begin{Myitemize}{$\blacktriangleright$ $b+c$} % <= longest label here
\item [$\blacktriangleright$ $a$ ] iff $a$,
\item [$\blacktriangleright$ $b+c$] iff $a$,
\item [$\blacktriangleright$ $d$ ] iff $a$,
\item [$\blacktriangleright$ $e+f$] iff $a$ and a lot of text which takes up multiple lines without correct alignment
\end{Myitemize}
\end{frame}
\end{document}
编辑:
更好的方法是这样的:
\begin{itemize}
\item \makebox[2cm][l]{$a$} iff $a$,
\item \makebox[2cm][l]{$b+c$} iff $a$,
\item \makebox[2cm][l]{$d$} iff $a$,
\item \makebox[2cm][l]{$e+f$} \begin{minipage}[t]{7cm}
iff $a$ and a lot of text which takes up multiple lines without correct alignment, and a lot of text which takes up multiple lines without correct alignment
\end{minipage}
\end{itemize}