1

I have just started lerning Latex. So, it is possible that the following doubt is very easy.

I have to do a presentation with Beamer. I know that there exist specific comands to theorems, definitions, examples... I wonder if it is possible to modify those environments and change its default color. That is can I use the Theorem environment in such a way that the color of the block is green instead of blue? In the following example I wanto to change the color of the block to red.

\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usepackage{amsfonts}
\usepackage{amsmath, amsthm, amssymb}
\usepackage{enumerate}
\usepackage{graphicx}
\usepackage[english]{babel}
\usetheme{madrid}
\begin{document}
\begin{frame}{Test}
\begin{theorem}[Pythagoras]
  $a^+b^2=c^2$
\end{theorem}
\end{frame}
\end{document}

enter image description here

Thanks in advance.

1
\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usepackage{amsfonts}
\usepackage{amsmath, amsthm, amssymb}
\usepackage{enumerate}
\usepackage{graphicx}
\usepackage[spanish]{babel}
\usetheme{madrid}

\AtBeginEnvironment{theorem}{%
  \setbeamercolor{block title}{use=example text,fg=white,bg=example text.fg!75!black}
  \setbeamercolor{block body}{parent=normal text,use=block title example,bg=block title example.bg!10!bg}
}

\begin{document}
\begin{frame}{Test}
\begin{theorem}[Pythagoras]
  $a^+b^2=c^2$
\end{theorem}
\end{frame}
\end{document}

enter image description here


For a yellow colored "Teorema" block, please see the following MWE:

\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usepackage{amsfonts}
\usepackage{amsmath, amsthm, amssymb}
\usepackage{enumerate}
\usepackage{graphicx}
\usepackage[spanish]{babel}
\usetheme{madrid}

\newtheorem{theo}{Teorema}
\AtBeginEnvironment{theo}{%
  \setbeamercolor{block title}{use=example text,fg=black,bg=yellow!75!black}
  \setbeamercolor{block body}{parent=normal text,use=block title example,bg=yellow!10}
}

\begin{document}
\begin{frame}{Test}
\begin{theo}[Pythagoras]
  $a^+b^2=c^2$
\end{theo}
\end{frame}
\end{document}

enter image description here

  • Thanks, but I have a doubt. How could I change the color to yellow? I don't see where is the specific command to change the color – mathlife Jun 16 at 16:28
  • @mathlife texdoc xcolor or osl.ugr.es/CTAN/macros/latex/contrib/xcolor/xcolor.pdf – Rmano Jun 16 at 16:31
  • Finally, my last doubt: How can I change in that environment the word "Theorem" by "Teorema"? – mathlife Jun 16 at 16:50
  • @mathlife: I have edited my answer according to your requests. – leandriis Jun 16 at 16:58
  • @leandriis A lot of thanks!!!!!!! – mathlife Jun 16 at 17:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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