GeneralBEAMER colorbox environment with colors as arguments

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
corderin
Posts: 77
Joined: Sun Dec 14, 2008 2:27 pm

BEAMER colorbox environment with colors as arguments

Post by corderin »

Hello, this is my first post. I am trying to implement a new environment for beamer, using beamerboxesrounded, but it does not work. I have made two files, on the first the are no arguments, on the second I tried to pass the colors as arguments and it didn´t work.


\documentclass[xcolor=svgnames]{beamer}


\usetheme{PaloAlto}
\usepackage[ansinew]{inputenc}
\usepackage[spanish]{babel}
\usepackage[T1]{fontenc}
\usepackage{cmbright}
\usepackage{fancybox}

\setbeamercolor{upcol}{fg=black,bg=yellow}
\setbeamercolor{lowcol}{fg=black,bg=yellow!40}

\newenvironment{colorblock}
{
\begin{beamerboxesrounded}[upper=upcol,lower=lowcol,shadow=true]}
{\end{beamerboxesrounded}}

\begin{document}

\begin{frame}
\begin{colorblock}{Title}
Text.
\end{colorblock}
\end{frame}

\end{document}

SO WORKS, BUT WITH THE ARGUMENTS IT DOES NOT WORK. -->

\documentclass[xcolor=svgnames]{beamer}


\usetheme{PaloAlto}
\usepackage[ansinew]{inputenc}
\usepackage[spanish]{babel}
\usepackage[T1]{fontenc}
\usepackage{cmbright}
\usepackage{fancybox}

\setbeamercolor{upcol}{fg=black,bg=yellow}
\setbeamercolor{lowcol}{fg=black,bg=yellow!40}

\newenvironment{colorblock}[2]
{
\begin{beamerboxesrounded}[upper=#1,lower=#2,shadow=true]}
{\end{beamerboxesrounded}}

\begin{document}

\begin{frame}
\begin{colorblock}[upcol,lowcol]{Title}
Text.
\end{colorblock}
\end{frame}

\end{document}

COULD SOMEBODY HELP ME ON THAT MATTER?
THANK YOU.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

phi
Posts: 577
Joined: Tue Oct 21, 2008 8:10 pm

BEAMER colorbox environment with colors as arguments

Post by phi »

the arguments have to be given in curly braces, one pair of braces per argument:

Code: Select all

\begin{colorblock}{upcol}{lowcol}
corderin
Posts: 77
Joined: Sun Dec 14, 2008 2:27 pm

Re: BEAMER colorbox environment with colors as arguments

Post by corderin »

THANK YOU!! But now I want to improve my environment, the item symbol should have the same color as the title background like beamer does with the alertblock. I would like to pass this item color as argument too.
A solution is to write this line \setbeamercolor{item}{fg=yellow,bg=yellow}, but then each item of each colorblock will be yellow, and not of the background color of the correspondly own colorbox.

\documentclass[xcolor=svgnames]{beamer}


\usetheme{PaloAlto}
\usepackage[ansinew]{inputenc}
\usepackage[spanish]{babel}
\usepackage[T1]{fontenc}
\usepackage{cmbright}
\usepackage{fancybox}
%
\setbeamercolor{yellow}{fg=black,bg=yellow}
\setbeamercolor{lightyellow}{fg=black,bg=yellow!40}
\setbeamercolor{block title alerted}{fg=black}

\newenvironment{colorblock}[2]
{
\begin{beamerboxesrounded}[upper=#1,lower=#2,shadow=true]}
{\end{beamerboxesrounded}}


\begin{document}

\begin{frame}
\begin{colorblock}{yellow}{lightyellow}{Title}
\begin{itemize}
\item First
\end{itemize}
\end{colorblock}

\begin{alertblock}{Title}
\begin{itemize}
\item First
\end{itemize}
\end{alertblock}

\end{frame}

\end{document}

DO YOU HAVE A SOLUTION???
corderin
Posts: 77
Joined: Sun Dec 14, 2008 2:27 pm

Re: BEAMER colorbox environment with colors as arguments

Post by corderin »

SOLUTION FOUNDED & IT LOOKS QUITE GOOD

\documentclass[xcolor=svgnames]{beamer}


\usetheme{PaloAlto}
\usepackage[ansinew]{inputenc}
\usepackage[spanish]{babel}
\usepackage[T1]{fontenc}
\usepackage{cmbright}
\usepackage{fancybox}
%
\setbeamercolor{yellow}{fg=black,bg=yellow}
\setbeamercolor{lightyellow}{fg=black,bg=yellow!40}
\setbeamercolor{orange}{fg=black,bg=orange}
\setbeamercolor{lightorange}{fg=black,bg=orange!40}
%\setbeamercolor{item}{fg=yellow,bg=yellow}

\newenvironment{colorblock}[2]
{\setbeamercolor{item}{fg=#1,bg=#1}\begin{beamerboxesrounded}[upper=#1,lower=#2,shadow=true]}
{\end{beamerboxesrounded}}


\begin{document}

\begin{frame}

\begin{colorblock}{yellow}{lightyellow}{Title}
\begin{itemize}
\item First
\end{itemize}
\end{colorblock}
\begin{colorblock}{orange}{lightorange}{Title}
\begin{itemize}
\item First
\end{itemize}
\end{colorblock}

\end{frame}

\end{document}
Post Reply