在beamer中,如何強迫「enumerate」和「itemize」標籤位於它們所提到的環境內?

在beamer中,如何強迫「enumerate」和「itemize」標籤位於它們所提到的環境內?

下圖中,有一個使用mdframedpackage.json 定義的自訂框架。很明顯,枚舉超出了框框。

在此輸入影像描述

當使用普通類排版類似內容時,標籤會進入mdframed環境內部。

在此輸入影像描述

我希望獲得相同的輸出,但標籤自訂除外,但標籤縮排與其上方以“what”開頭的文字對齊。

微量元素

\documentclass[aspectratio=169, xcolor={x11names}]{beamer}


\usecolortheme{rose}

\useoutertheme[]{split}

\useinnertheme{inmargin}
% BEGIN_FOLD

    \setbeamersize{text margin left=2mm, text margin right=2mm}

    \newlength{\sidebarWidth}
    \setlength{\sidebarWidth}{0.1\paperwidth}

    \setbeamersize{sidebar width left=\sidebarWidth, sidebar width right=0cm}

% END_FOLD

\usefonttheme{structurebold}



% ==========================================================================
% BEGIN_FOLD


% ========== Package editing packages ==========
\usepackage{etoolbox}
% BEGIN_FOLD

    \AtBeginEnvironment{enumerate}{\centering}
    \BeforeBeginEnvironment{multicols}{\centering}

% END_FOLD
\usepackage{xpatch}

% ========== Figures and tables locations packages ==========
\usepackage{adjustbox}


% ========== Page, margins and paragraph layout packages packages ==========
\usepackage{ragged2e}

% ========== Graphics packages ==========
\usepackage{graphicx}

% ========== Font encoding packages ==========
\usepackage[T1]{fontenc}
\usepackage{fontspec}

% ========== Equations and math packages ==========
\usepackage{amsmath}
\usepackage{amssymb, amsfonts}
\usepackage{mathtools}

% ========== Framing packages ==========
\usepackage{mdframed}
% BEGIN_FOLD

    % ===== Begin skipbelow patch =====
    \makeatletter
    \xpatchcmd{\endmdframed}
    {\aftergroup\endmdf@trivlist\color@endgroup}
    {\endmdf@trivlist\color@endgroup\@doendpe}
    {}{}
    \makeatother
    % ===== End skipbelow patch =====

    % ===== Frames templates =====
    \newcommand{\frameMultipleChoiceQuiz}{Example Frame}
    \global \mdfdefinestyle{\frameMultipleChoiceQuiz}{
        % Line
        linecolor=DodgerBlue1, linewidth=0.5mm,
        topline=false, bottomline=false, rightline=false,
        skipabove=0.2\baselineskip, skipbelow=0.1\baselineskip,
        innertopmargin=0.5\baselineskip, innerbottommargin=0.5\baselineskip, innerleftmargin=2mm, innerrightmargin=0.01\textwidth,
        %
        % Frame
        frametitlerule=false, frametitlerulewidth=0.2mm
        frametitlefont=\normalsize\bfseries, frametitlealignment=\justifying,
        frametitleaboveskip=1.76mm, frametitlebelowskip=0mm,
        nobreak=false, needspace=3\baselineskip
    }

% END_FOLD


\usepackage{multicol}

% END_FOLD


\begin{document}


\begin{frame}{Showing Contents Gradually}

    \begin{columns}

        \column[c]{0.4\textwidth}


        \begin{mdframed}[style=\frameMultipleChoiceQuiz]

            What is $\sqrt{x^{2}}$?

            \begin{enumerate}
                \item $X$
                \item $-X$ 
                \item $\left| X \right|$ \onslide<2->{\textbf{correct answer}}
                \item Undefined
            \end{enumerate}

        \end{mdframed}


        \column[c]{0.5\textwidth}
        \onslide<3>{
            \includegraphics[width=\textwidth]{example-image-a}
        }

        \onslide<3>{Comment on the image}


    \end{columns}

\end{frame}


\end{document}

答案1

主題的想法inmargin是將枚舉項等元素放置在側邊欄中,因此主題會修改\leftmargini等。

其他一些要點:

  • 如果您的 Beamer 版本相當新,則不需要\usepackage{etoolbox},Beamer 現在已經加載了此版本

  • 你不需要\usepackage{graphicx}使用投影儀

  • 與 Beamer 一起使用multicol沒有什麼意義,Beamer 有自己的列機制

\documentclass[aspectratio=169, xcolor={x11names}]{beamer}


\usecolortheme{rose}

\useoutertheme{split}

\useinnertheme{inmargin}


\setlength\leftmargini{5ex}
\setlength\leftmarginii{7.5ex}
\setlength\leftmarginiii{7.5ex}

% BEGIN_FOLD

    \setbeamersize{text margin left=2mm, text margin right=2mm}

    \newlength{\sidebarWidth}
    \setlength{\sidebarWidth}{0.1\paperwidth}

    \setbeamersize{sidebar width left=\sidebarWidth, sidebar width right=0cm}

% END_FOLD

\usefonttheme{structurebold}



% ==========================================================================
% BEGIN_FOLD


% ========== Package editing packages ==========
%\usepackage{etoolbox}
% BEGIN_FOLD

    \AtBeginEnvironment{enumerate}{\centering}
%    \BeforeBeginEnvironment{multicols}{\centering}

% END_FOLD
\usepackage{xpatch}

% ========== Figures and tables locations packages ==========
\usepackage{adjustbox}


% ========== Page, margins and paragraph layout packages packages ==========
\usepackage{ragged2e}

% ========== Graphics packages ==========
%\usepackage{graphicx}

% ========== Font encoding packages ==========
\usepackage[T1]{fontenc}
\usepackage{fontspec}

% ========== Equations and math packages ==========
\usepackage{amsmath}
\usepackage{amssymb, amsfonts}
\usepackage{mathtools}

% ========== Framing packages ==========
\usepackage{mdframed}
% BEGIN_FOLD

    % ===== Begin skipbelow patch =====
    \makeatletter
    \xpatchcmd{\endmdframed}
    {\aftergroup\endmdf@trivlist\color@endgroup}
    {\endmdf@trivlist\color@endgroup\@doendpe}
    {}{}
    \makeatother
    % ===== End skipbelow patch =====

    % ===== Frames templates =====
    \newcommand{\frameMultipleChoiceQuiz}{Example Frame}
    \global \mdfdefinestyle{\frameMultipleChoiceQuiz}{
        % Line
        linecolor=DodgerBlue1, linewidth=0.5mm,
        topline=false, bottomline=false, rightline=false,
        skipabove=0.2\baselineskip, skipbelow=0.1\baselineskip,
        innertopmargin=0.5\baselineskip, innerbottommargin=0.5\baselineskip, innerleftmargin=2mm, innerrightmargin=0.01\textwidth,
        %
        % Frame
        frametitlerule=false, frametitlerulewidth=0.2mm
        frametitlefont=\normalsize\bfseries, frametitlealignment=\justifying,
        frametitleaboveskip=1.76mm, frametitlebelowskip=0mm,
        nobreak=false, needspace=3\baselineskip
    }

% END_FOLD


%\usepackage{multicol}

% END_FOLD


\begin{document}


\begin{frame}{Showing Contents Gradually}

    \begin{columns}

        \column[c]{0.4\textwidth}


        \begin{mdframed}[style=\frameMultipleChoiceQuiz]

            What is $\sqrt{x^{2}}$?

            \begin{enumerate}
                \item $X$
                \item $-X$ 
                \item $\left| X \right|$ \onslide<2->{\textbf{correct answer}}
                \item Undefined
            \end{enumerate}

        \end{mdframed}


        \column[c]{0.5\textwidth}
        \onslide<3>{
            \includegraphics[width=\textwidth]{example-image-a}
        }

        \onslide<3>{Comment on the image}


    \end{columns}

\end{frame}


\end{document}

在此輸入影像描述

相關內容