How to set text margin without conflict with block environment? - latex

I want to decrease the margin between the content text and the page edge. I follow the method from: https://tex.stackexchange.com/questions/354022/modifying-the-margins-of-all-slides-in-beamer by using \setbeamersize{text margin left=1.40mm, text margin left=1.40mm}.
However, it will make the block not centered in the slide. Thus, how do I set the text margin without influencing the setting of the block?
Is there another way to set the text margin?
The full scripts as follows:
\documentclass[t]{beamer}
\usetheme{Madrid}
\usecolortheme{beaver}
\usefonttheme{structurebold}
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{multicol}
\title[Short title]{Full Title of the Talk}
\author{JJ XX}
\institute[UCLA]
{
University of California \\
\medskip
\textit{jx#111.com}
}
\date{\today}
% set the text margin
\setbeamersize{text margin left=1.40mm, text margin left=1.40mm}
\settowidth{\leftmargini}{\usebeamertemplate{itemize item}}
\settowidth{\leftmargini}{\usebeamertemplate{enumerate item}}
\addtolength{\leftmargini}{-0.2\labelsep}
\begin{document}
\begin{frame}
\titlepage % Print the title page as the first slide
\end{frame}
\begin{frame}
\frametitle{Contents}
\begin{multicols}{2}
\tableofcontents
\end{multicols}
\end{frame}
\section{blocka}
\begin{frame}
\frametitle{blocka}
\begin{itemize}
\item First
\item Second
\end{itemize}
\begin{exampleblock}{Introduction to Beamer}
Beamer is a class of \LaTeX.
\end{exampleblock}
\end{frame}
\section{blockb}
\begin{frame}
The second example.
\frametitle{blockb}
\begin{block}{Beamer Intro}
New is New.
\end{block}
\end{frame}

The margins of beamer blocks are designed in such a way that the text within the block is still aligned with the surrounding text. If you set the margin independently, this will break this alignment:
\documentclass[t]{beamer}
\usetheme{Madrid}
\usecolortheme{beaver}
\setbeamersize{text margin left=1.40mm, text margin left=1.40mm}
\makeatletter
\setbeamertemplate{block begin}
{%
\par\vskip\medskipamount%
\hfill\begin{minipage}{.98\textwidth}%
\begin{beamerboxesrounded}[upper=block title,lower=block body,shadow=true]%
{\raggedright\usebeamerfont*{block title}\insertblocktitle}%
\raggedright%
\usebeamerfont{block body}%
}
\setbeamertemplate{block end}
{\end{beamerboxesrounded}\end{minipage}\vskip\smallskipamount}
\makeatother
\begin{document}
\begin{frame}
The second example.
\frametitle{blockb}
\begin{block}{Beamer Intro}
New is New.
\end{block}
\end{frame}
\end{document}
Alternatively, you could use the tcolorbox inner theme:
\documentclass[t]{beamer}
\usetheme{Madrid}
\usecolortheme{beaver}
\setbeamersize{text margin left=1.40mm, text margin left=1.40mm}
\useinnertheme{tcolorbox}
\tcbset{
center,
width=\linewidth
}
\begin{document}
\begin{frame}
The second example.
\frametitle{blockb}
\begin{block}{Beamer Intro}
New is New.
\end{block}
\end{frame}
\end{document}

Related

avoiding transparent caption in beamer/latex

I am trying to insert a figure but its caption is transparent in the current page. how to prevent this? many thanks in advance.
\documentclass{beamer}
\usetheme{Ilmenau}
\setbeamercovered{transparent}
\setbeamercolor*{item}{fg=blue}
\usepackage{caption}
\captionsetup{font=scriptsize,labelfont=scriptsize}
\usepackage{hyperref}
\hypersetup{urlcolor=blue}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}
\title{DNA - Computing}
\author{Aleyna Acikyol \& Alina Grahic
}
\begin{document}
\begin{frame}[plain]
\maketitle
\end{frame}
%5 FOTO
\begin{frame}{Probleme heutiger Computer (3)}
%\begin{enumerate}
% \item \textcolor{blue}{Transistoren:}
\begin{itemize}
\item \textcolor{blue}{Transistoren:}
\begin{itemize}
\item kleiner geht nicht
\item Ausgleich mit Multicores /Multiprozessorsysteme
\end{itemize}
\end{itemize}
\pause
\begin{figure}
%\begin{itemize}
\begin{columns}
\column{0.50\linewidth}
\centering
\includegraphics[height=3cm, width=3cm]{./5.jpg}\caption{diverse Datenträger im Privatgebrauch}
\column{0.50\linewidth}
\centering
\includegraphics[height=3cm, width=3cm]{./5.2.jpg}\caption{Data Centre, Cloud}
\end{columns}
%\end{itemize}
\end{figure}
%\end{enumerate}
\end{frame}
\end{document}
It looks like
The caption is transparent because you are using \setbeamercovered{transparent}. You have two options to avoid the transparent caption:
immediately show the images and caption by avoid the \pause in front of them
switching to \setbeamercovered{invisible} either temporarily or for the whole presentation to delay the images and caption to the next overlay:
\documentclass{beamer}
\usetheme{Ilmenau}
\setbeamercovered{transparent}
\setbeamercolor*{item}{fg=blue}
\setbeamerfont{caption}{size=\scriptsize}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}
\title{DNA - Computing}
\author{Aleyna Acikyol \& Alina Grahic
}
\begin{document}
\begin{frame}[plain]
\maketitle
\end{frame}
%5 FOTO
\begin{frame}
\frametitle{Probleme heutiger Computer (3)}
%\begin{enumerate}
% \item \textcolor{blue}{Transistoren:}
\begin{itemize}
\item \textcolor{blue}{Transistoren:}
\begin{itemize}
\item kleiner geht nicht
\item Ausgleich mit Multicores /Multiprozessorsysteme
\end{itemize}
\end{itemize}
{
\setbeamercovered{invisible}
\pause
\begin{figure}
%\begin{itemize}
\begin{columns}
\column{0.50\linewidth}
\centering
\includegraphics[height=3cm, width=3cm]{example-image-duck}\caption{diverse Datenträger im Privatgebrauch}
\column{0.50\linewidth}
\centering
\includegraphics[height=3cm, width=3cm]{example-image-duck}\caption{Data Centre, Cloud}
\end{columns}
%\end{itemize}
\end{figure}
%\end{enumerate}
}
\end{frame}
\end{document}
Some other comments:
you don't need \usepackage{hyperref}, beamer already loads it
I'd be wary to use \hypersetup{urlcolor=blue} with beamer, this can lead to strange alternations to the carefully constructed colour themes of beamer in places one would never expect
If your tex distribution was updated within the last 5 years or so, you don't need \usepackage[utf8]{inputenc}, that's now the default
If you just want to change the font size of the caption, you don't actually need the caption package, beamer has its own mechanism to control the size of captions
Instead of \begin{frame}{...} I would use \frametitle{...}. That's much more flexible and powerful
If you specify both the width and height of your images, they will end up distorted. Please consider adding the keepaspectratio option to avoid this
to avoid manually repeating the same frame title several times ("Probleme heutiger Computer (3)") you could use overlays and add the slide in frame counter to the frametitle

Latex: Left alignment for an equation

I have these two definitions:
\documentclass[12pt]{article}
\usepackage{amsmath}
\begin{document}
\begin{flalign*}
&\boldsymbol{R*^\sigma} & \sigma_{superset}(F)&=\sigma_{superset}(F')&\\
&\boldsymbol{R*_{weak}^\sigma} & \sigma_{superset}(F)&=\sigma_{superset}(F')\cap\mathcal{P}(A)&
\end{flalign*}
\end{document}
Compiled, it looks like this:
I want the equations to be aligned by "=" as they are; but also that they are not centered but quite next to the bold symbols. Like, also aligned left.
It should look like this (done with MS Paint):
If you don't mind that all equations will be left aligned, you could use the fleqn option of amsmath:
\documentclass[12pt]{article}
\usepackage[fleqn]{amsmath}
\setlength{\mathindent}{0pt}
\begin{document}
\noindent text
\begin{alignat*}{3}
&\boldsymbol{R*^\sigma} & \sigma_{superset}(F)&=\sigma_{superset}(F')\\
&\boldsymbol{R*_{weak}^\sigma} \quad& \sigma_{superset}(F)&=\sigma_{superset}(F')\cap\mathcal{P}(A)
\end{alignat*}
\end{document}
If you like to keep other equations centred, you could also switch temporarily:
\documentclass[12pt]{article}
\usepackage{amsmath}
\begin{document}
\[
a
\]
{
\makeatletter
\#fleqntrue
\makeatother
\begin{alignat*}{4}
&\boldsymbol{R*^\sigma} & \sigma_{superset}(F)&=\sigma_{superset}(F')\\
&\boldsymbol{R*_{weak}^\sigma} \quad& \sigma_{superset}(F)&=\sigma_{superset}(F')\cap\mathcal{P}(A)
\end{alignat*}
}
\[
a
\]
\end{document}

Switch Overlay Specification in Latex Beamer

I have a beamer document with
\beamerdefaultoverlayspecification{<+->}
in the preamble to make \items appear separately. However, this seems to also make \bibitems
appear separately. How can I switch back to 'normal' within the document, such that all bibitems appear on one slide?
You can change the default overlay specification before the bibliography:
\documentclass{beamer}
\usepackage{biblatex}
\addbibresource{biblatex-examples.bib}
\beamerdefaultoverlayspecification{<+->}
\begin{document}
\begin{frame}
\begin{itemize}
\item content...
\item content...
\end{itemize}
\end{frame}
\beamerdefaultoverlayspecification{}
\begin{frame}
\nocite{knuth:ct,angenendt}
\printbibliography
\end{frame}
\end{document}

citation, tables and equation exceed page width in beamer

I am using Latex for the first time and I am preparing a slide using 'beamer'. What happening is that some of my citations, tables and long equations are exceeding beyond the text width, though it wasn't the problem when the document class was 'article'. My tables aren't long, as one of them has only 3 rows and 6 columns.
The latex codes are
\documentclass[9pt]{beamer}
\mode<presentation> {
\usefonttheme{serif}
\usetheme{Madrid}
\definecolor{BlueGreen}{cmyk}{0.85,0,0.33,0}
\colorlet{beamer#blendedblue}{BlueGreen!120}}
\usepackage{booktabs}
\usepackage{caption}
\hypersetup{pdfnewwindow}
\setbeamertemplate{caption}[numbered]
\setbeamerfont{frametitle}{size=\footnotesize}
\setbeamertemplate{navigation symbols}{}
\setbeamercolor{postit}{bg=violet!110}
\usepackage{ragged2e} %new code
\addtobeamertemplate{block begin}{}{\justifying}
\usepackage{textpos}
\begin{document}
\begin{frame} \frametitle{\textbf{{\Large Objective}}}
\begin{itemize}
\justifying
\item This package gives you easy access to the Lorem Ipsum dummy text; an option is available to separate the paragraphs of the dummy text. This text \cite{kumar2015method}.
\item The long equation is:
\begin{equation}
A(\theta,\alpha) = \dfrac{ A*{-(\alpha*A)}\beta*{(\delta-1)} \left(A* \hspace{1mm}\hspace{1mm}C^{-A Z_{H}} \hspace{1mm}C^{-C^{-A *Z_{H}}} \prod_{i=1}^{m-1} \left( \dfrac{ A \hspace{1mm}C^{-A* Z_{u(i)}} C^{-C^{-A* Z_{u(i)}}}}{1- \frac{1}{C-1} (C^{1-C^{-A Z_{u(i)}}}-1)}\right) \right) }{ \int_{0}^{\infty} C^{-(\alpha *A)}(A^{(\beta-1)} \left( A* \hspace{1mm}\hspace{1mm}C^{-A Z_{H}} \hspace{1mm}C^{-C^{-A Z_{H}}} \prod_{i=1}^{B-1} \left(\dfrac{ A \hspace{1mm}C^{-A Z_{u(i)}} C^{-C^{-A* Z_{u(i)}}}}{1- \frac{1}{C-1} (C^{1-C^{-A* Z_{u(i)}}}-1)}\right) \right) A} .
\end{equation}
\end{itemize}
\end{frame}
\bibliography{ref}
\bibliographystyle{plainnat}
\end{document}
And the contents of the .bib file is:
#article{kumar2015method,
title={This is the title of the article},
author={Kumar, Dinesh and others},
journal={This is Journal},
volume={2},
number={3},
pages={150-180},
year={2015}
}
If you use the plainnat bib style, you should also load the natbib package. This will automatically allow line breaks
you don't need the caption package, beamer provides it's own mechanism to customise captions
you must place the bibliography inside a frame
for the very large equation, I would suggest to replace the fraction with (...) \times (...)^{-1}, this way you can split it over multiple lines. In addition you'll probably want to use a smaller font size and maybe remove all the manual spaces.
\documentclass[9pt]{beamer}
\mode<presentation> {
\usefonttheme{serif}
\usetheme{Madrid}
\definecolor{BlueGreen}{cmyk}{0.85,0,0.33,0}
\makeatletter
\colorlet{beamer#blendedblue}{BlueGreen!120}
\makeatother
}
\usepackage{booktabs}
%\usepackage{caption}
\hypersetup{pdfnewwindow}
\setbeamertemplate{caption}[numbered]
\setbeamerfont{frametitle}{size=\footnotesize}
\setbeamertemplate{navigation symbols}{}
\setbeamercolor{postit}{bg=violet!110}
\usepackage{ragged2e} %new code
\addtobeamertemplate{block begin}{}{\justifying}
\usepackage{natbib}
\usepackage{textpos}
\begin{document}
\begin{frame} \frametitle{\textbf{{\Large Objective}}}
\begin{itemize}
\justifying
\item This package gives you easy access to the Lorem Ipsum dummy text; an option is available to separate the paragraphs of the dummy text. This text \cite{kumar2015method}.
\item The long equation is:
\end{itemize}
\end{frame}
\begin{frame}
\bibliography{ref}
\bibliographystyle{plainnat}
\end{frame}
\end{document}

Latex Beamer: Increase spacing between sections in section navigation bar

I would like to modify my Latex Beamer Template.
Hence, I would like to increase the space between the displayed sections in the section navigation bar. At the moment the are left indented but the sections are way to close together.
I use the following code to generate the headline:
setbeamertemplate{headline}{%
\leavevmode%
\hbox{%
\begin{beamercolorbox}[wd=\paperwidth,ht=3ex,dp=1.125ex]{palette tertiary}%
\insertsectionnavigationhorizontal{\paperwidth}{}{\hskip0pt plus1filll}
\end{beamercolorbox}%
}
}
How can I modify the spacing between the displayed section?
The tipple fill plus1filll you insert after the navigation makes it flush left. If you remove it, the sections will automatically be distributed within the available paper width:
\documentclass{beamer}
\setbeamertemplate{headline}{%
\leavevmode%
\hbox{%
\begin{beamercolorbox}[wd=\paperwidth,ht=3ex,dp=1.125ex]{palette tertiary}%
\insertsectionnavigationhorizontal{\paperwidth}{}{}
\end{beamercolorbox}%
}
}
\begin{document}
\section{title}
\begin{frame}
content...
\end{frame}
\section{title}
\begin{frame}
content...
\end{frame}
\end{document}
If you want to keep the sections flush left and just add some additional space between:
\documentclass{beamer}
\setbeamertemplate{headline}{%
\leavevmode%
\hbox{%
\begin{beamercolorbox}[wd=\paperwidth,ht=3ex,dp=1.125ex]{palette tertiary}%
\insertsectionnavigationhorizontal{\paperwidth}{}{\hskip0pt plus1filll}
\end{beamercolorbox}%
}
}
\setbeamertemplate{section in head/foot}{\insertsectionhead\hspace{0.5cm}}
\begin{document}
\section{title}
\begin{frame}
content...
\end{frame}
\section{title}
\begin{frame}
content...
\end{frame}
\end{document}

Resources