How can I make a fancy box around equations like the one in the left?
I tried many time on my own but nothing satisfactory obtained!
[Tex/LaTex] beamer box around equations
beamergraphics
Related Solutions
You can redefine the title page
template and introduce the necessary modifications for the layout; this redefinition is needed since both the title and the subtitle are, by deafult, inside the same beamercolorbox
so simply redefining the title
beamer color would produce a box around both title and subtitle (which is not wanted here):
\documentclass{beamer}
\title{TITLE}
\titlegraphic{\includegraphics[height=4cm]{cat}}
\subtitle{\textbf{Subtitle}}
\author{Author}
\setbeamercolor{title}{bg=orange,fg=white}
\makeatletter
\setbeamertemplate{title page}
{
\vbox{}
\vfill
\begin{centering}
\begin{beamercolorbox}[sep=8pt,center]{title}
\usebeamerfont{title}\inserttitle
\end{beamercolorbox}
\setbeamercolor{title}{bg=white,fg=structure}
\begin{beamercolorbox}[sep=8pt,center]{title}
{\usebeamercolor[fg]{titlegraphic}\inserttitlegraphic\par}
\ifx\insertsubtitle\@empty%
\else%
\vskip0.25em%
{\usebeamerfont{subtitle}\usebeamercolor[fg]{subtitle}\insertsubtitle\par}%
\fi%
\end{beamercolorbox}%
\vskip1em\par
\begin{beamercolorbox}[sep=8pt,center]{author}
\usebeamerfont{author}\insertauthor
\end{beamercolorbox}
\vskip-1em\par % change here
\begin{beamercolorbox}[sep=8pt,center]{institute}
\usebeamerfont{institute}\insertinstitute
\end{beamercolorbox}
\begin{beamercolorbox}[sep=8pt,center]{date}
\usebeamerfont{date}\insertdate
\end{beamercolorbox}\vskip0.5em
\end{centering}
\vfill
}
\makeatother
\begin{document}
\maketitle
\end{document}
Notice that now there's no need to use \title[TITLE]{TITLE\includegraphics{...}}
but now you can simply use \title{TITLE}
and \titlegraphic{\includegraphics[]{}}`. Of course, feel free to make the necessary adjutments according to your particular needs (yo can play with the lengths in the \vskip commands to adjust vertical spacing).
As requested in a comment, to have a colored box around only the subtitle, the necessary modifications are the following:
\documentclass{beamer}
\title{TITLE}
\titlegraphic{\includegraphics[height=4cm]{cat}}
\subtitle{\textbf{Subtitle}}
\author{Author}
\makeatletter
\setbeamertemplate{title page}
{
\vbox{}
\vfill
\begin{centering}
\begin{beamercolorbox}[sep=8pt,center]{title}
\usebeamerfont{title}\inserttitle
\end{beamercolorbox}
{\usebeamercolor[fg]{titlegraphic}\inserttitlegraphic\par}
\ifx\insertsubtitle\@empty%
\else%
\vskip0.25em%
\setbeamercolor{title}{bg=orange,fg=white}
\begin{beamercolorbox}[sep=8pt,center]{title}
{\usebeamerfont{subtitle}\usebeamercolor[fg]{subtitle}\insertsubtitle\par}%
\fi%
\end{beamercolorbox}%
\vskip1em\par
\begin{beamercolorbox}[sep=8pt,center]{author}
\usebeamerfont{author}\insertauthor
\end{beamercolorbox}
\vskip-1em\par % change here
\begin{beamercolorbox}[sep=8pt,center]{institute}
\usebeamerfont{institute}\insertinstitute
\end{beamercolorbox}
\begin{beamercolorbox}[sep=8pt,center]{date}
\usebeamerfont{date}\insertdate
\end{beamercolorbox}\vskip0.5em
\end{centering}
\vfill
}
\makeatother
\begin{document}
\maketitle
\end{document}
With a new request, here's the code to change at will the width of the box used for the subtitle; change the length used for \subtitwd
(initially set to 4cm
) according to your needs:
\documentclass{beamer}
\newlength\subtitwd
\setlength\subtitwd{4cm}% change the width here
\makeatletter
\setbeamertemplate{title page}
{
\vbox{}
\vfill
\begin{centering}
\begin{beamercolorbox}[sep=8pt,center]{title}
\usebeamerfont{title}\inserttitle
\end{beamercolorbox}
{\usebeamercolor[fg]{titlegraphic}\inserttitlegraphic\par}
\ifx\insertsubtitle\@empty%
\else%
\vskip0.25em%
\setbeamercolor{title}{bg=orange,fg=white}
\vbox{%
\hfill\begin{beamercolorbox}[wd=\subtitwd,sep=8pt,center]{title}
{\usebeamerfont{subtitle}\usebeamercolor[fg]{subtitle}\insertsubtitle\par}%
\end{beamercolorbox}\hfill\null%
}%
\fi%
\vskip1em\par
\begin{beamercolorbox}[sep=8pt,center]{author}
\usebeamerfont{author}\insertauthor
\end{beamercolorbox}
\vskip-1em\par % change here
\begin{beamercolorbox}[sep=8pt,center]{institute}
\usebeamerfont{institute}\insertinstitute
\end{beamercolorbox}
\begin{beamercolorbox}[sep=8pt,center]{date}
\usebeamerfont{date}\insertdate
\end{beamercolorbox}\vskip0.5em
\end{centering}
\vfill
}
\makeatother
\title{TITLE}
\titlegraphic{\includegraphics[height=4cm]{cat}}
\subtitle{\textbf{Subtitle}}
\author{Author}
\begin{document}
\maketitle
\end{document}
Here's one possibility, placing marks and then using the marks to draw the boxes and the arrow:
\documentclass{beamer}
\usepackage{algorithm,algpseudocode}
\usepackage{tikz}
\usetikzlibrary{arrows,calc,intersections}
\usepackage{xcolor}
\makeatletter
\newcommand\tikzmark[1]{%
\tikz[overlay,remember picture,baseline] \coordinate (#1);}
\begin{document}
\begin{frame}
\begin{algorithm}[H]
\begin{algorithmic}
\State\tikzmark{start1} $y \leftarrow 1$
% Start box 1
\If{$n < 0$}
\State $X \leftarrow 1 / x$
\State $N \leftarrow -n$
\Else
\State $X \leftarrow x$
\State $N \leftarrow n$
\EndIf\tikzmark{end1}
%End box 1
%Start box 2
\Statex\vskip-2.2ex
\tikzmark{start2}\While{$N \neq 0$}
\If{$N$ is even}
\State $X \leftarrow X \times X$
\State $N \leftarrow N / 2$
\Else[$N$ is odd]
\State $y \leftarrow y \times X$
\State $N \leftarrow N - 1$
\EndIf
\EndWhile\tikzmark{end2}
% End box 2
\end{algorithmic}
\end{algorithm}
\begin{tikzpicture}[remember picture,overlay]
\draw[orange] ( $ (start1) + (-2pt,-2pt) $ ) rectangle ( $ (end1) + (1.3,-2pt) $ );
\draw[orange] ( $ (start2) + (-2pt,-2pt) $ ) rectangle ( $ (end2) + (1.8,-2pt) $ );
\draw[orange,-latex] let \p1=(start1), \p2=(end1), \p3=(start2), \p4=(end2)
in ( $ (\x2,0.5*\y1+0.5*\y2) + (1.3,0) $ ) to[out=0,in=0] ( $ (\x4,0.5*\y3+0.5*\y4) + (1.8,0) $ );
\end{tikzpicture}
\end{frame}
\end{document}
Best Answer
Here are some options with
empheq
andtcolorbox
adopting code from this answer.