Beamer 对齐编号

Beamer 对齐编号

我正在尝试关注在 beamer 中给出合理环境的解决方案无需justifying在任何地方明确输入。但是,我不确定如何正确编号,因为枚举项应从 1 开始。(我也不知道该如何做这个description字段,但这是一个额外的问题,因为我很少使用它)。我曾天真地尝试添加一个+1项目发生的位置,但没有成功。

在此处输入图片描述

代码/MWE

\documentclass{beamer}
\usepackage{ragged2e}
\usepackage{lipsum}

\makeatletter
\renewcommand{\itemize}[1][]{%
    \beamer@ifempty{#1}{}{\def\beamer@defaultospec{#1}}%
    \ifnum \@itemdepth >2\relax\@toodeep\else
    \advance\@itemdepth\@ne
    \beamer@computepref\@itemdepth% sets \beameritemnestingprefix
    \usebeamerfont{itemize/enumerate \beameritemnestingprefix body}%
    \usebeamercolor[fg]{itemize/enumerate \beameritemnestingprefix body}%
    \usebeamertemplate{itemize/enumerate \beameritemnestingprefix body begin}%
    \list
    {\usebeamertemplate{itemize \beameritemnestingprefix item}}
    {\def\makelabel##1{%
            {%
                \hss\llap{{%
                        \usebeamerfont*{itemize \beameritemnestingprefix item}%
                        \usebeamercolor[fg]{itemize \beameritemnestingprefix item}##1}}%
            }%
        }%
    }
    \fi%
    \beamer@cramped%
    \justifying% NEW
    %\raggedright% ORIGINAL
    \beamer@firstlineitemizeunskip%
}
\makeatother

% My attempt at getting enumerate working. 
\makeatletter
\renewcommand{\enumerate}[1][]{%
    \beamer@ifempty{#1}{}{\def\beamer@defaultospec{#1}}%
    \ifnum \@itemdepth >2\relax\@toodeep\else
    \advance\@itemdepth\@ne
    \beamer@computepref\@itemdepth% sets \beameritemnestingprefix
    \usebeamerfont{itemize/enumerate \beameritemnestingprefix body}%
    \usebeamercolor[fg]{itemize/enumerate \beameritemnestingprefix body}%
    \usebeamertemplate{itemize/enumerate \beameritemnestingprefix body begin}%
    \list
    {\usebeamertemplate{enumerate \beameritemnestingprefix item}}
    {\def\makelabel##1{%
            {%
                \hss\llap{{%
                        \usebeamerfont*{enumerate \beameritemnestingprefix item}%
                        \usebeamercolor[fg]{enumerate \beameritemnestingprefix item}##1}}%
            }%
        }%
    }
    \fi%
    \beamer@cramped%
    \justifying% NEW
    %\raggedright% ORIGINAL
    \beamer@firstlineitemizeunskip%
}
\makeatother

\begin{document}
    \begin{frame}
        \begin{itemize}
            \item \lipsum[66]
        \end{itemize}
        \begin{enumerate}
            \item \lipsum[75]
        \end{enumerate}
        \begin{description}
            \item[Item] \lipsum[66]
        \end{description}
    \end{frame}
\end{document}

答案1

由于枚举和描述有足够的差异,因此基于 itemize 环境“猜测”代码将不起作用 - 但是您可以找到所有定义并beamerbaselocalstructure.sty以与 itemize 相同的方式修改它们:

\documentclass{beamer}
\usepackage{ragged2e}
\usepackage{lipsum}

\makeatletter
\renewcommand{\itemize}[1][]{%
    \beamer@ifempty{#1}{}{\def\beamer@defaultospec{#1}}%
    \ifnum \@itemdepth >2\relax\@toodeep\else
    \advance\@itemdepth\@ne
    \beamer@computepref\@itemdepth% sets \beameritemnestingprefix
    \usebeamerfont{itemize/enumerate \beameritemnestingprefix body}%
    \usebeamercolor[fg]{itemize/enumerate \beameritemnestingprefix body}%
    \usebeamertemplate{itemize/enumerate \beameritemnestingprefix body begin}%
    \list
    {\usebeamertemplate{itemize \beameritemnestingprefix item}}
    {\def\makelabel##1{%
            {%
                \hss\llap{{%
                        \usebeamerfont*{itemize \beameritemnestingprefix item}%
                        \usebeamercolor[fg]{itemize \beameritemnestingprefix item}##1}}%
            }%
        }%
    }
    \fi%
    \beamer@cramped%
    \justifying% NEW
    %\raggedright% ORIGINAL
    \beamer@firstlineitemizeunskip%
}

\def\beamer@enum@{%
  \beamer@computepref\@itemdepth% sets \beameritemnestingprefix
  \usebeamerfont{itemize/enumerate \beameritemnestingprefix body}%
  \usebeamercolor[fg]{itemize/enumerate \beameritemnestingprefix body}%
  \usebeamertemplate{itemize/enumerate \beameritemnestingprefix body begin}%
  \expandafter
    \list
      {\usebeamertemplate{\beamer@enumtempl}}
      {\usecounter\@enumctr%
        \def\makelabel##1{{\hss\llap{{%
                \usebeamerfont*{enumerate \beameritemnestingprefix item}%
                \usebeamercolor[fg]{enumerate \beameritemnestingprefix item}##1}}}}}%
  \beamer@cramped%
  \justifying
%  \raggedright%
  \beamer@firstlineitemizeunskip%
}

\def\@@description{%
  \advance\beamer@descdefault by \labelsep%
  \usebeamerfont{description body}%
  \usebeamercolor[fg]{description body}%
  \usebeamertemplate{description body begin}%
  \list
  {}
  {\labelwidth\beamer@descdefault\leftmargin\beamer@descdefault\let\makelabel\beamer@descriptionitem}%
  \beamer@cramped%
%  \raggedright
\justifying
  \beamer@firstlineitemizeunskip%
}

\makeatother



\begin{document}
    \begin{frame}
        \begin{itemize}
            \item \lipsum[66]
        \end{itemize}
        \begin{enumerate}
            \item \lipsum[75]
        \end{enumerate}
        \begin{description}
            \item[Item] \lipsum[66]
        \end{description}
    \end{frame}
\end{document}

在此处输入图片描述

相关内容