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'm creating a beamerposter style accordingly to my department specification. I would like to create a theme where the definitions of the blocks can vary accordingly to a keyword in the calling of the theme. I'm trying to explain with a MWE The custom style works like this

\ProvidesPackage{beamerthemeMYposter} % this style was created by David Vilar
% Define boolean options
% -----------------
\newif\if@shadowbox
\DeclareOption{shadowbox}{\@shadowboxtrue}
\DeclareOption*{\PackageWarning{beamerthemeMYposter}{Unknown option `\CurrentOption'}}
% process options
% ------------
\ProcessOptions
\mode<presentation>
\usepackage{tikz}       % for drawing the nice rounded boxes 
\usetikzlibrary{arrows,backgrounds}
\newcommand{\makeruleinbox}{{\usebeamercolor[bg]{block alerted title}\centering\hspace*{-0.7cm}\rule{\inboxrule}{0.5cm}}}
\usepackage{ragged2e} 
\newlength{\inboxwd}
\newlength{\iinboxwd}
\newlength{\inboxrule}
\makeatletter  
\makeatother
\usepackage{xcolor}

% Block definition
\setbeamercolor*{block body}{fg=blue,bg=white}
\setbeamerfont{block title}{size=\large,series=\bf}
% conditional block body definition
\if@shadowbox
\setbeamercolor*{block title}{bg=white,fg=red}
\setbeamercolor*{block body}{fg=blue, bg=white}
\setbeamerfont{block title}{size=\large,series=\bf}
\setbeamertemplate{block begin}
{
  \par\vskip\medskipamount
  \begin{beamercolorbox}[colsep*=.5ex,dp={2ex},center]{block title}
    \vskip-0.25cm
    \usebeamerfont{block title}\large\insertblocktitle
    \begin{flushleft}
      \vskip-1cm
      \begin{tikzpicture}[remember picture,overlay]
        \shade [inner color=blue,outer color=white]
        (0,0) rectangle (\textwidth,0.3cm);
      \end{tikzpicture}
    \end{flushleft}
  \end{beamercolorbox}
  {\parskip0pt\par}
  \ifbeamercolorempty[bg]{block title}
  {}
  {\ifbeamercolorempty[bg]{block body}{}{\nointerlineskip\vskip-0.5pt}}
  \usebeamerfont{block body}
  \vskip-0.5cm
  \begin{beamercolorbox}[colsep*=.5ex,vmode]{block body}
    \justifying
  }

  \setbeamertemplate{block end}
  {
  \end{beamercolorbox}
  \vskip\smallskipamount
  }
\else
\setbeamercolor*{block title}{bg=blue,fg=white}
\setbeamertemplate{block begin}{
\vskip.75ex
\begin{beamercolorbox}[leftskip=1cm,colsep*=.75ex]{block title}%
\usebeamerfont*{block title}\insertblocktitle
\end{beamercolorbox}%
{\ifbeamercolorempty[bg]{block body}{}{\nointerlineskip\vskip-0.5pt}}%
\usebeamerfont{block body}%
\begin{beamercolorbox}[colsep*=.75ex,sep=.75ex,vmode]{block body}%
\ifbeamercolorempty[bg]{block body}{\vskip-.25ex}{\vskip-.75ex}\vbox{}%
}
\setbeamertemplate{block end}{
\end{beamercolorbox}
}
\fi

\mode<all>

Then in the document I'm trying to call like that

\documentclass[final]{beamer}
\mode<presentation> {
\usepackage[size=a0,orientation=landscape,debug]{beamerposter}  % e.g. custom size poster
\usetheme[shadowbox]{MYposter}
}
\begin{document}
\begin{frame}{} 
\begin{block}{trial}
\end{block}
\end{frame}
\end{document}

If you try this MWE you can see that there is no way the option shadowbox is considered. I must admit this is my first attempt to use conditional keyword in package creation. Any suggestion is welcomed

share|improve this question

1 Answer 1

up vote 2 down vote accepted

Delete the \makeatletter, \makeatother commands from beamerthemeMYposter.sty:

\ProvidesPackage{beamerthemeMYposter} % this style was created by David Vilar
% Define boolean options
% -----------------
\newif\if@shadowbox
\DeclareOption{shadowbox}{\@shadowboxtrue}
\DeclareOption*{\PackageWarning{beamerthemeMYposter}{Unknown option `\CurrentOption'}}
% process options
% ------------
\ProcessOptions\relax
\mode<presentation>
\usepackage{tikz}       % for drawing the nice rounded boxes 
\usetikzlibrary{arrows,backgrounds}
\newcommand{\makeruleinbox}{{\usebeamercolor[bg]{block alerted title}\centering\hspace*{-0.7cm}\rule{\inboxrule}{0.5cm}}}
\usepackage{ragged2e} 
\newlength{\inboxwd}
\newlength{\iinboxwd}
\newlength{\inboxrule}

\usepackage{xcolor}

% Block definition
\setbeamercolor*{block body}{fg=blue,bg=white}
\setbeamerfont{block title}{size=\large,series=\bf}
% conditional block body definition
\if@shadowbox
\setbeamercolor*{block title}{bg=white,fg=red}
\setbeamercolor*{block body}{fg=blue, bg=white}
\setbeamerfont{block title}{size=\large,series=\bf}
\setbeamertemplate{block begin}
{
  \par\vskip\medskipamount
  \begin{beamercolorbox}[colsep*=.5ex,dp={2ex},center]{block title}
    \vskip-0.25cm
    \usebeamerfont{block title}\large\insertblocktitle
    \begin{flushleft}
      \vskip-1cm
      \begin{tikzpicture}[remember picture,overlay]
        \shade [inner color=blue,outer color=white]
        (0,0) rectangle (\textwidth,0.3cm);
      \end{tikzpicture}
    \end{flushleft}
  \end{beamercolorbox}
  {\parskip0pt\par}
  \ifbeamercolorempty[bg]{block title}
  {}
  {\ifbeamercolorempty[bg]{block body}{}{\nointerlineskip\vskip-0.5pt}}
  \usebeamerfont{block body}
  \vskip-0.5cm
  \begin{beamercolorbox}[colsep*=.5ex,vmode]{block body}
    \justifying
  }

  \setbeamertemplate{block end}
  {
  \end{beamercolorbox}
  \vskip\smallskipamount
  }
\else
\setbeamercolor*{block title}{bg=blue,fg=white}
\setbeamertemplate{block begin}{
\vskip.75ex
\begin{beamercolorbox}[leftskip=1cm,colsep*=.75ex]{block title}%
\usebeamerfont*{block title}\insertblocktitle
\end{beamercolorbox}%
{\ifbeamercolorempty[bg]{block body}{}{\nointerlineskip\vskip-0.5pt}}%
\usebeamerfont{block body}%
\begin{beamercolorbox}[colsep*=.75ex,sep=.75ex,vmode]{block body}%
\ifbeamercolorempty[bg]{block body}{\vskip-.25ex}{\vskip-.75ex}\vbox{}%
}
\setbeamertemplate{block end}{
\end{beamercolorbox}
}
\fi

\mode<all>

When using \ProcessOptions, it's a good idea to use \relax at the end to stop searching for a star.

share|improve this answer
    
Thanks it solved –  Nicola Vianello Sep 27 '12 at 14:36

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.