# How to customize the margins of minipages in a beamer frame?

I use inmargin for innertheme but sometimes I would like to write two column contents where a certain text extends from the very left to the very right of the page. However, I am still not sure how to control the margins precisely.

I would like to equalize the margin of two minipages by making the clearance of the left box with respect to the left edge of the page equal to the clearance of the right box to the right edge of the page. The output below shows approximately what I want to get except that I want to get it in a more automated fashion rather than by trial and error in adjusting horizontal spaces and widths.

Also, I want beamer to automatically place minipages horizontally in such a way that the margins of both boxes satisfy a pre-determined value. For example setting the margin of the left box with respect to the left side of the paper to 5mm and setting the margin of the right box with respect to the right side of the paper to 10mm. Also, I would like the text to stretch from left to right with a pre-specified and equalized margins to left and right.

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

\usecolortheme{seahorse}
\useoutertheme[]{split}
\useinnertheme{inmargin}
\newlength{\widthTextMarginLeft}
\setlength{\widthTextMarginLeft}{1mm}
\setbeamersize{sidebar width left=3cm, sidebar width right=0cm}
\setbeamersize{text margin left=\widthTextMarginLeft, text margin right=\widthTextMarginLeft}

\usepackage{amsmath}
\usepackage{amssymb, amsfonts}
\usepackage{nccmath}
\usepackage{mathtools}

\usepackage{fvextra}
\let \verb \Verb
\newcommand{\verbup}[1]{{\upshape \verb{#1}}}

\usepackage{cleveref}
% BEGIN_FOLD

% Single equations (non-breakable)
\crefformat{equation}{\mbox{Eq. #2(#1)#3}}
\crefrangeformat{equation}{\mbox{Eqs. #3(#1)#4 to #5(#2)#6}}
\crefmultiformat{equation}{\mbox{Eqs. #2(#1)#3}}{ and #2(#1)#3}{, #2(#1)#3}{ and #2(#1)#3}
\crefrangemultiformat{equation}{\mbox{Eqs. #3(#1)#4 to #5(#2)#6}}{ and #3(#1)#4 to #5(#2)#6}{, #3(#1)#4 to #5(#2)#6}{ and #3(#1)#4 to #5(#2)#6}

% END_FOLD

\usepackage[defaultmathsizes, subdued, italic, LGRgreek, symbolre, symbolmisc]{mathastext}
% BEGIN_FOLD

\MTDeclareVersion[it]{charter}{T1}{bch}{m}{n}
\AtBeginDocument{\MTversion*{charter}}

% END_FOLD

% Customize addding contents to left margin
\makeatletter
\newlength{\widthBeamerLeftMargin}
\setlength{\widthBeamerLeftMargin}{\Gm@lmargin}
\makeatother

\newlength{\widthTextMarginMin}
\setlength{\widthTextMarginMin}{3\widthTextMarginLeft}

% minimum clearance of minipages with respect to the left margin (when using minipages)

\newlength{\widthBeamerLeftMarginX}
\setlength{\widthBeamerLeftMarginX}{\widthBeamerLeftMargin}

% amount of distance we are required to remove to maintain \widthTextMarginMin with respect to the left margin

\newlength{\widthFullSlideText}
\setlength{\widthFullSlideText}{\paperwidth}

% amount of text we need to maintain \widthTextMarginMin for a single minipage extending slidewide

\begin{document}

\begin{frame}{Minipages in beamer}

\centering
\hspace*{-\widthBeamerLeftMargin} {\adjustbox{minipage={\widthFullSlideText}}{When uncovering math contents, it is a good practice to place the \verb{&} and the equation label outside the  \verb{\uncover}}}

\hspace*{-\widthBeamerLeftMarginX}

\begin{align}
S_{L, \thinspace n} &= V_{n} \thinspace I_{L, \thinspace n}^{*}
\label{eq:S_L_i_def}
\\
\intertext{Replacing the current in \cref{eq:S_L_i_def}}
S_{L, \thinspace n} &= V_{n} \left( \frac{V_{n}}{Z_{L, \thinspace n}} \right)^{*}
\\
\intertext{where $Z_{L, \thinspace n}$ is the load impedance at bus $n$. Since \mbox{$\left| V_{n} \right|^{2} = V_{n} V_{n}^{*}$} \vspace{0.3\baselineskip}}
S_{L, \thinspace n}^{*} &= \frac{\left| V_{n} \right|^{2}}{Z_{L, \thinspace n}}
\label{eq:op_imp_S_L_i_def1}
\\
\intertext{where \vspace{0.3\baselineskip}}
S_{L, \thinspace n} &= P_{L, \thinspace n} + j Q_{L, \thinspace n}
\label{eq:op_imp_S_L_i_def2}
\end{align}

\hfill

\begin{align}
Z_{L, \thinspace n} &= \frac{\left| V_{n} \right|^{2}}{S_{L, \thinspace n}^{*}}
\\
Z_{G, \thinspace n} &= -\frac{\left| V_{n} \right|^{2}}{S_{G, \thinspace n}^{*}}
\\
Z_{RES, \thinspace n} &= -\frac{\left| V_{n} \right|^{2}}{S_{RES, \thinspace n}^{*}}
\end{align}

\hspace{\widthTextMarginMin}

\end{frame}

\end{document}


• to remove the sidebar on a specific frame, you could use the same technique as in https://tex.stackexchange.com/a/423246/36296 and change the \hoffset of the page

• for changing the margins mid document, you could hack the \Gm@lmargin and \Gm@rmargin values, but don't forget that you will have to recalculate textwidth etc.

• I would not use an adjustbox for elements that contain text, you risk that the will get scaled and result in a suboptimal choice of font shape

• with the onlytextwidth option beamer columns will automatically placed to fill the whole text width. If the sum of both columns is not enough space will be inserted in the centre. So it is not necessary to try to manually imitated beamers columns mechanism with adjustboxes

• \newcommand{\verbup}[1]{{\upshape \verb{#1}}} looks like a very bad idea

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

\usepackage{amsmath}
\usepackage{amssymb, amsfonts}
\usepackage{nccmath}
\usepackage{mathtools}
\usepackage{cleveref}

\usecolortheme{seahorse}
\useoutertheme{split}
\useinnertheme{inmargin}

\newlength{\widthTextMarginLeft}
\setlength{\widthTextMarginLeft}{1mm}
\setbeamersize{sidebar width left=3cm, sidebar width right=0cm}
\setbeamersize{text margin left=1mm, text margin right=1mm}

\begin{document}

{
\makeatletter
\def\Gm@lmargin{0.5cm}%
\def\Gm@rmargin{0.5cm}%
\textwidth=\dimexpr\paperwidth-\Gm@lmargin-\Gm@rmargin\relax
\hsize\textwidth
\columnwidth\textwidth
\hoffset=\dimexpr-\beamer@leftsidebar+\Gm@lmargin-\widthTextMarginLeft\relax
\makeatother
\begin{frame}
\frametitle{Minipages in beamer}

\rule{\textwidth}{1pt}

\begin{columns}[T,onlytextwidth]

\begin{column}{.48\textwidth}
\rule{\textwidth}{1pt}
\end{column}

\begin{column}{.48\textwidth}
\rule{\textwidth}{1pt}
\end{column}

\end{columns}

\end{frame}
}

\end{document}