# How can I set the inner margins of a Beamer block?

I've worked myself into a rut. A very, very hacky, plain-TeX-y rut.

I'm creating a poster with beamerposter. Content is split logically into block environments, and customization is done through the hooks beamer provides (\addtobeamertemplate). That's where the LaTeX ends.

Here is my code:

\documentclass{beamer}

\usepackage[english]{babel}
\usepackage[orientation=portrait,size=a0]{beamerposter}
\mode<presentation>{%
\usetheme{Frankfurt}%
}

\title[short]{Looonnger!!}
\author{me}
\institute{grubby}
\date{\today}

% needed to stretch out title box cleanly, but likely the root of my problem
\setbeamersize{text margin left = -5pt, text margin right = -5pt}

{}
{\vspace{1ex plus 0.5ex minus 0.5ex} % Pads top of block
% separates paragraphs in a block
\setlength{\parskip}{24pt plus 1pt minus 1pt}
\addtolength{\rightskip}{1em}} %%% that doesn't even work right
{\vspace{2ex plus 0.5ex minus 0.5ex}}% Pads bottom of block
{\vspace{10ex plus 1ex minus 1ex}} % Seperates blocks from each other

{\hspace{2em}} % trying to compensate for the awful hack
{}

\usepackage{mwe}

\begin{document}
\begin{frame}[t]{}
\vspace{-8pt}
\begin{beamercolorbox}{}
\maketitle
\end{beamercolorbox}
\vspace{10ex}

\begin{block}{Block A}
\lipsum

\begin{description}[longest label]
\item[short] Short stuff
\item[long] Longer stuff
\item[longest label] Longest stuff (insert cat)
\end{description}

\begin{itemize}
\item I'd like to change the margins here, as well.
\item The macros \texttt{\textbackslash leftskip} and friends
don't work very well for environment-heavy \LaTeX{} document
classes such as \texttt{beamer}
\item Also, for some reason, using \texttt{\textbackslash verb}
kills \emph{everthing}.
\end{itemize}
\end{block}
\end{frame}
\end{document}


and what it produces:

Note that the bullets/balls for the itemize environment are flush with the left margin. Description environment would do the same thing if it weren't for the explicit customization. All text also goes way too close to either side; amenable through \leftskip but not \rightskip. It's an absolute mess.

My immediate goal is to be able to set the right margin so text doesn't go to close. My 'better' goal is to set inner padding for block contents so that I won't have to set the margins for each environment individually, which will quickly get out of hand. And finally, as I said in a comment in the code, I believe the root of my problem is how I stretch out the title to give it a cleaner look (not just a colored block on a white background), but I'm pretty sure that'd be a separate question.

Briefly, I was aiming for (nothing special) a title whose color spans the entire top of the page and content in blocks where the content is padded by about 2 or 3em to taste.

-
It's a bit hard to know what layout you are aiming for, you have negative margins set so it's not surprising the text goes close to the edge (it presumably could have gone wider) setting of \leftskip and \rightskip by hand just simply isn't supported in latex. LaTeX itself sets those all the time depending on the current justification and/or list structure so any direct setting will either do the wrong thing or get over-written. In general you never set the right margin, you set the left margin and the text length. –  David Carlisle Apr 20 '13 at 15:23
@DavidCarlisle I knew \leftskip and \rightskip were bad ideas from the start, but I didn't think of any other way to do it. I don't find myself ever needing to mess with margins, at least nothing geometry can't handle. I've never done a poster before. :P (Also I didn't think about text length! :D Always learning.) --- Briefly, I was aiming for (nothing special) a title whose color spans the entire top of the page and content in blocks where the content is padded by about 2 or 3em to taste. (I'll edit this in particular into the question.) –  Sean Allred Apr 20 '13 at 19:31

Using \leftskip and \rightskip is doomed to failure when lists are involved.

Say \usepackage{changepage} in the preamble and

\addtobeamertemplate{block begin}
{}
{\vspace{1ex plus 0.5ex minus 0.5ex} % Pads top of block
% separates paragraphs in a block
\setlength{\parskip}{24pt plus 1pt minus 1pt}%
}
\vspace{2ex plus 0.5ex minus 0.5ex}}% Pads bottom of block
{\vspace{10ex plus 1ex minus 1ex}} % Seperates blocks from each other


Remove the \addtobeamertemplate{description item} part.

For \verb you have to declare your frame as fragile:

\begin{frame}[fragile,t]


I'd also avoid doing

\setbeamersize{text margin left = -5pt, text margin right = -5pt}


but it's just me.

-
I'm probably going to get rid of the \setbeamersize{...}, and just deal with the ugliness or find a different theme. I didn't know about changepage though! Thanks! –  Sean Allred Apr 20 '13 at 19:52

This gets closer, I still hacked textwidth to get the title box wider, if I knew more beamer that presumably wouldn't be needed. you get \verbyou have to use [fragile] frame option.I added \verb|$\log$| somewhere to test.

\documentclass{beamer}

\usepackage[english]{babel}
\usepackage[orientation=portrait,size=a0]{beamerposter}
\mode<presentation>{%
\usetheme{Frankfurt}%
}

\title[short]{Looonnger!!}
\author{me}
\institute{grubby}
\date{\today}

% needed to stretch out title box cleanly, but likely the root of my problem
\setbeamersize{text margin left = 15pt, text margin right = 15pt}

{}
{\vspace{1ex plus 0.5ex minus 0.5ex} % Pads top of block
% separates paragraphs in a block
\setlength{\parskip}{24pt plus 1pt minus 1pt}}

{\vspace{2ex plus 0.5ex minus 0.5ex}}% Pads bottom of block
{\vspace{10ex plus 1ex minus 1ex}} % Seperates blocks from each other

\usepackage{mwe}

\begin{document}
\begin{frame}[fragile,t]{}

\vspace{-8pt}
\hspace*{-20pt}%
\begin{beamercolorbox}{}
\maketitle
\end{beamercolorbox}
}
\vspace{10ex}

\begin{block}{Block A}
\lipsum

\begin{description}[longest label]
\item[short] Short stuff
\item[long] Longer stuff
\item[longest label] Longest stuff (insert cat)
\end{description}

\begin{itemize}
\item I'd like to change the margins here, as well.
\item The macros \texttt{\textbackslash leftskip} and friends
don't work very well for environment-heavy \LaTeX{} document
classes such as \texttt{beamer}
\item Also, for some \verb|$\log$| reason, using \texttt{\textbackslash verb}
kills \emph{everthing}.
\end{itemize}
\end{block}
\end{frame}
\end{document}

-
Thanks for the fragile tip, that will definitely come in handy, but the hackiness is part of what I was trying to avoid. Thanks though! –  Sean Allred Apr 20 '13 at 19:50
True but this is far less hacky I just locally set the standard latex parameter textwidth to make the title box wider, and then recenter it with hspace. It's possible the title block has some key interface to that but it would do the same thing. The version in the question is the complete opposite: it globally set negative margins and then had to compensate everywhere. and set primitive tex registers such as left and right skip which breaks latex's typesetting structures as left and right margins and \textwidth \linewidth and \hsize were no longer matching –  David Carlisle Apr 20 '13 at 19:55
You're right, it is by default less hacky through the use of the local group, and solves the problem of the ripple effect from the root cause (the negative margins). I shouldn't have unwittingly sneaked in two questions into one post, because this does help answer the 'how do I avoid this awful hack?' mini-question... :( –  Sean Allred Apr 20 '13 at 20:15