Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have a custom block defined as the following! this comes from the progressbar theme from http://recherche.noiraudes.net/fr/LaTeX.php

\newdimen\lengthone
\newcommand{\defblock}[1][]{
  \defbeamertemplate*{block \ifx#1\@empty\else#1\space\fi begin}{progressbar theme}
  {     
        %\rule{\textwidth}{2pt}
    \lengthone=\textwidth
    \advance\lengthone by -4mm
    \setbox\progressbar@blockbox=\hbox to 1\textwidth\bgroup\vbox\bgroup
        \vskip-0.25\baselineskip
        \raggedright
        \hspace{-2.4mm}
    \begin{minipage}{\lengthone} 
        \ifx\insertblocktitle\@empty
        \else
        {\usebeamerfont{block title}\usebeamercolor[fg]{block title\ifx#1\@empty\else\space#1\fi}\insertblocktitle}\\[-0.3cm]% Just to be "babel-safe" 
        \tikz\draw[fg!20!bg] (0, 0) -- (\lengthone, 0);\par
        %\vspace{-2mm}
        \fi
        \par
        \usebeamerfont{block body\ifx#1\@empty\else\space#1\fi}
        \ifx\insertblocktitle\@empty\else\global\let\itemize=\progressbar@itemize\fi  
        %\vphantom{y}
        }

  \defbeamertemplate*{block \ifx#1\@empty\else#1\space\fi end}{progressbar theme}
  {
    \vphantom{y}
    \global\let\itemize=\progressbar@tempitemize
    \end{minipage}
    \vskip-0.25\baselineskip\egroup\egroup
    \progressbar@boxwidth=\wd\progressbar@blockbox
    %\advance\progressbar@boxwidth by 0.5\baselineskip
    %\advance\progressbar@boxwidth by 5mm
    \progressbar@boxheight=\ht\progressbar@blockbox
    \advance\progressbar@boxheight by \dp\progressbar@blockbox
    {
     \parbox[t]{0cm}{
      \usebeamercolor{block body\ifx#1\@empty\else\space#1\fi}
      \tikz[baseline=(current bounding box.north)]{\draw[draw=fg!20!bg,fill=bg, rounded corners=2pt] (0, 0) rectangle (\progressbar@boxwidth, \progressbar@boxheight);} 
    }
    }
  {
    \parbox[t]{0cm}{
      \vskip0.5\baselineskip
      \hfill{\box\progressbar@blockbox}\hfill
    }
   }
  }
}

\defblock

When I make a frame in beamer with three identical Blocks in a Minipage like this the following comes out, that the first box looks completely wrong and the follwing look right with the right spacing... Does anybody see what can cause this strange effect?

\begin{frame}[t,fragile]
\frametitle{Ball on Curve}
\begin{flushright}
\begin{minipage}[t]{0.7\textwidth}
    \begin{block}{Frage und Ziel}
    \begin{itemize}
        \item<2-> Scheibe als \emph{ungebundenes} System formulieren.
        \item<2-> Scheibe als \emph{ungebundenes} System formulieren.
    \end{itemize}
    \end{block}
\end{minipage}
\end{flushright}
\vspace{-\baselineskip}
\begin{flushright}
\begin{minipage}[t]{0.7\textwidth}
    \begin{block}{Frage und Ziel}
    \begin{itemize}
        \item<2-> Scheibe als \emph{ungebundenes} System formulieren.
        \item<2-> Scheibe als \emph{ungebundenes} System formulieren.
    \end{itemize}
    \end{block}
\end{minipage}
\end{flushright}
\vspace{-\baselineskip}
\begin{flushright}
\begin{minipage}[t]{0.7\textwidth}
    \begin{block}{Frage und Ziel}
    \begin{itemize}
        \item<2-> Scheibe als \emph{ungebundenes} System formulieren.
        \item<2-> Scheibe als \emph{ungebundenes} System formulieren.
    \end{itemize}
    \end{block}
\end{minipage}
\end{flushright}
\end{frame}

enter image description here

share|improve this question
3  
I've no answer, but I noticed a big error in the first block of macros: the tests \ifx#1\@empty are all wrong. It doesn't influence your setting, as you call \defblock without an optional argument, but \defblock[aachen] would result in \defbeamertemplate*{block chen begin} which is clearly unwanted. However, a MWE is needed. –  egreg Jun 17 '12 at 22:33
add comment

1 Answer 1

The problem can be reproduced without all the extra definitions, so it's not dependent on the particular theme:

\documentclass{beamer}

\begin{document}

\begin{frame}[t,fragile]
\frametitle{Ball on Curve}

\begin{flushright}
\begin{minipage}[t]{\textwidth}
    \begin{block}{Frage und Ziel}
    \begin{itemize}
        \item Scheibe als \emph{ungebundenes} System formulieren.
    \end{itemize}
    \end{block}
\end{minipage}
\end{flushright}
\vspace{-\baselineskip}
\begin{flushright}
\begin{minipage}[t]{\textwidth}
    \begin{block}{Frage und Ziel}
    \begin{itemize}
        \item Scheibe als \emph{ungebundenes} System formulieren.
    \end{itemize}
    \end{block}
\end{minipage}
\end{flushright}
\vspace{-\baselineskip}
\begin{flushright}
\begin{minipage}[t]{\textwidth}
    \begin{block}{Frage und Ziel}
    \begin{itemize}
        \item Scheibe als \emph{ungebundenes} System formulieren.
    \end{itemize}
    \end{block}
\end{minipage}
\end{flushright}
\end{frame}

\end{document}

enter image description here

As can be seen, the vertical spacing between the block title and the block body in the first block is less than the corresponding space in the other two blocks. Adding \leavevmode before the first flushright environment (or suppressing the t option for the frame) solves the problem:

\documentclass{beamer}

\begin{document}

\begin{frame}[t,fragile]
\frametitle{Ball on Curve}
\leavevmode
\begin{flushright}
\begin{minipage}[t]{\textwidth}
    \begin{block}{Frage und Ziel}
    \begin{itemize}
        \item Scheibe als \emph{ungebundenes} System formulieren.
    \end{itemize}
    \end{block}
\end{minipage}
\end{flushright}
\vspace{-\baselineskip}
\begin{flushright}
\begin{minipage}[t]{\textwidth}
    \begin{block}{Frage und Ziel}
    \begin{itemize}
        \item Scheibe als \emph{ungebundenes} System formulieren.
    \end{itemize}
    \end{block}
\end{minipage}
\end{flushright}
\vspace{-\baselineskip}
\begin{flushright}
\begin{minipage}[t]{\textwidth}
    \begin{block}{Frage und Ziel}
    \begin{itemize}
        \item Scheibe als \emph{ungebundenes} System formulieren.
    \end{itemize}
    \end{block}
\end{minipage}
\end{flushright}
\end{frame}

\end{document}

enter image description here

share|improve this answer
    
Ohhhh soo good!! Thank you very much!! –  Gabriel Jun 18 '12 at 6:16
    
Bhut why is this command needed? How do we know latex is in vertical or horizontal mode? –  Gabriel Jun 18 '12 at 12:04
    
@Gabriel You have \ifvmode and \ifhmode to test if LaTeX is in vertical or horizontal mode, respectively (See, for example, Can I detect whether LaTeX is in vertical mode? and also this answer); at the beginning of a frame, LaTeX is in vertical mode. By the way, since my answer seems to have solved your problem, please consider accepting it; in case of doubt please see How do you accept an answer?. –  Gonzalo Medina Jun 19 '12 at 0:51
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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