0

In the picture below, there is a custom frame defined using mdframed package. It is clear that the enumerations go outside the framed box.

enter image description here

When similar content is typeset with a normal class, the labels go inside mdframed environment.

enter image description here

I would like to get the same output except for label customization except that the label indentation is aligned with the text above it starting with 'what'.

MWE

\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}
0

The idea of the inmargin theme is that elements like the enumerate items are placed in the sidebar, therefore the theme modifies the \leftmargini etc. This can be partially undone as shown in the code below.

Some other points:

  • if your beamer version is reasonable new, you don't need \usepackage{etoolbox}, beamer now already loads this

  • you don't need \usepackage{graphicx} with beamer

  • using multicol with beamer makes little sense, beamer has its own columns mechanism

\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}

enter image description here

  • Thanks for the answer. I am still new to beamer but also an advanced LaTeX user. I think a better variation to your solution is to use \AtBeginEnvironment{mdframed}{\setlength{\leftmargini}{5ex}} which will customize \leftmargini variable only for mdframed. Similar codes can be used for other envitonments where we want to change \leftmargini \leftmarginii and \leftmarginiii – Al-Motasem Aldaoudeyeh Mar 12 at 20:38
  • @Al-MotasemAldaoudeyeh Of course you can make the changes locally if you only want to change certain enumerations – user36296 Mar 12 at 20:39
  • I think you know a lot about beamer and its layouts. Why do not you create a new package similar to geometry but made specifically to provide easy customization for beamer frames layouts and enumeration environments indentations and seperations? – Al-Motasem Aldaoudeyeh Mar 12 at 20:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.