我正在尝试在 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}