1

I have a figure which is coming out of the block environment in a beamer presentation: The problem

I found this thread and defined a varblock environment, where I set the width to be a little larger. But the resulting block grows only to the right and therefore is not centered in the frame. I would like to center this block, or shift it and its contents to the left.

Varblock

I tried using \hspace and \begin{center}\begin{minipage}{blockwidth} <new block environment> \end{minipage}\end{center}, but in both cases the varblock environment rescaled (shifted?) and went bigger than the frame.

Also, when using the varblock, my images are for some reason shifted to the right (see the intersection of right-most circle with frame end). This effect is reduced if \setbeamertemplate{blocks}[rounded] is removed from the code, but I need it.

Using block Using varblock

How to center the varblock and prevent it from shifting my images to the right? Alternatively, how to shift the varblock and its contents to the letf?

MWE with usual block and varblock follows:

\documentclass{beamer}
\usepackage{tikz} 

\newenvironment<>{varblock}[2][.9\textwidth]{%
  \setlength{\textwidth}{#1}
  \begin{actionenv}#3%
    \def\insertblocktitle{#2}%
    \par%
    \usebeamertemplate{block begin}}
  {\par%
    \usebeamertemplate{block end}%
  \end{actionenv}}
  

\usecolortheme{orchid}
\setbeamertemplate{blocks}[rounded]

\begin{document}

%%%%%%%% Usual Block Environment
\begin{frame}{Title}
 \begin{block}{Proof}
    \begin{minipage}[b]{0.55\linewidth}             
        \begin{itemize}
            \item some text
        \end{itemize}
    \end{minipage}
    \begin{minipage}[b]{0.35\linewidth}
        \begin{figure}
            \centering
            \begin{tikzpicture}                    
                %draw first slide circles
                \only<1>{
                    \draw (95:1.5) circle (1cm);
                    \draw (0:1.5) circle (1cm);
                    \draw (-180:1.5) circle (1cm);
                }
                %draw second slide circles
                \only<2>{
                    \draw[red] (0,0) circle (1cm);
                    \draw (95:2) circle (1cm);
                    \draw (0:2) circle (1cm);
                    \draw (-180:2) circle (1cm);
                }
            \end{tikzpicture}
        \end{figure}
    \end{minipage}
 \end{block}
\end{frame}

%%%%%%%% Adjustable Block Environment
\begin{frame}{Title}
 \begin{varblock}[1.05\linewidth]{Proof}
    \begin{minipage}[b]{0.55\linewidth}             
        \begin{itemize}
            \item some text
        \end{itemize}
    \end{minipage}
    \begin{minipage}[b]{0.35\linewidth}
        \begin{figure}
            \centering
            \begin{tikzpicture}                    
                %draw first slide circles
                \only<1>{
                    \draw (95:1.5) circle (1cm);
                    \draw (0:1.5) circle (1cm);
                    \draw (-180:1.5) circle (1cm);
                }
                %draw second slide circles
                \only<2>{
                    \draw[red] (0,0) circle (1cm);
                    \draw (95:2) circle (1cm);
                    \draw (0:2) circle (1cm);
                    \draw (-180:2) circle (1cm);
                }
            \end{tikzpicture}
        \end{figure}
    \end{minipage}
 \end{varblock}
\end{frame}
\end{document}

Thanks in advance!

1 Answer 1

1

You can use the adjustbox package for that. If your tikzpicture exeeds the chosen max width of the adjustbox, then it is shrinked to the max width. Therefore the circles have different radii in the adjustable block.

MWE based on your code

 \documentclass{beamer}
    \usepackage{tikz, adjustbox} 
    
    \newenvironment<>{varblock}[2][.9\textwidth]{%
      \setlength{\textwidth}{#1}
      \begin{actionenv}#3%
        \def\insertblocktitle{#2}%
        \par%
        \usebeamertemplate{block begin}}
      {\par%
        \usebeamertemplate{block end}%
      \end{actionenv}}
      
    
    \usecolortheme{orchid}
    \setbeamertemplate{blocks}[rounded]
    
    \begin{document}
    
    %%%%%%%% Usual Block Environment
    \begin{frame}{Block Environment}
     \begin{block}{Proof}
     \begin{minipage}[b]{0.39\linewidth}             
            \begin{itemize}
                \item some text
            \end{itemize}
        \end{minipage}  
        \hfill
        \begin{adjustbox}{valign=b, max width=0.59\linewidth}
                \begin{tikzpicture}                    
                    %draw first slide circles
                    \only<1>{
                        \draw (95:1.5) circle (1cm);
                        \draw (0:1.5) circle (1cm);
                        \draw (-180:1.5) circle (1cm);
                    }
                    %draw second slide circles
                    \only<2>{
                        \draw[red] (0,0) circle (1cm);
                        \draw (95:2) circle (1cm);
                        \draw (0:2) circle (1cm);
                        \draw (-180:2) circle (1cm);
                    }
                \end{tikzpicture}
        \end{adjustbox}
     \end{block}
    \end{frame}
    
    %%%%%%%% Adjustable Block Environment
    \begin{frame}{Adjustable Block Environment}
     \begin{varblock}[0.85\linewidth]{Proof}
        \begin{minipage}[b]{0.39\linewidth}             
            \begin{itemize}
                \item some text
            \end{itemize}
        \end{minipage}
        \hfill
        \begin{adjustbox}{valign=b, max width=0.59\linewidth}
                \begin{tikzpicture}                    
                    %draw first slide circles
                    \only<1>{
                        \draw (95:1.5) circle (1cm);
                        \draw (0:1.5) circle (1cm);
                        \draw (-180:1.5) circle (1cm);
                    }
                    %draw second slide circles
                    \only<2>{
                        \draw[red] (0,0) circle (1cm);
                        \draw (95:2) circle (1cm);
                        \draw (0:2) circle (1cm);
                        \draw (-180:2) circle (1cm);
                    }
                \end{tikzpicture}
        \end{adjustbox}
     \end{varblock}
    \end{frame}
    
    \end{document}

enter image description here enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .