TeX - LaTeX Asked by Mohammad on February 14, 2021
I’m trying to use tikz in beamer as follows but get an error "Undefined control sequence. end{frame}"
My MWE is:
documentclass{beamer}
setbeamercovered{highly dynamic}
%setbeamertemplate{bibliography item}{}
usepackage{lipsum, ragged2e, etoolbox}
usepackage{lmodern}
usepackage{graphicx} % include this line if your document contains figures
%usepackage{natbib} % required for bibliography
usepackage{booktabs} % For formal tables
usepackage{dsfont, color, soul, tikz, amsmath, amssymb, amsfonts, amsthm, graphicx, arydshln, fixmath, mathtools, multirow, boldline, xcolor, colortbl, url, algorithm, algpseudocode, subfig, media9, hyperref, blindtext, import, tcolorbox}
usepackage{caption}
captionsetup[figure]{labelformat=empty}
usetikzlibrary{arrows, fit, matrix, positioning, shapes, backgrounds}
addtobeamertemplate{footnote}{}{vspace{2ex}}
makeatletter
defhrulefill{leavevmodeleadershrule height 2pthfillkernz@}
makeatother
newcommandblfootnote[1]{%
begingroup
renewcommandthefootnote{}footnote{#1}%
addtocounter{footnote}{-1}%
endgroup
}
newcolumntype{L}[1]{>{raggedrightarraybackslash}p{#1}}
newcolumntype{C}[1]{>{centeringarraybackslash}m{#1}}
newcolumntype{R}[1]{>{raggedleftarraybackslash}p{#1}}
usetheme{Madrid}
setbeamercolor{section in head/foot}{parent=palette quaternary}
makeatletter
setbeamertemplate{footline}
{%
vskip-9ex%
% begin{beamercolorbox}{}
% hfillusebeamercolor[fg]{navigation symbols dimmed}%
% insertslidenavigationsymbol
% insertframenavigationsymbol
% insertsubsectionnavigationsymbol
% insertsectionnavigationsymbol
% insertdocnavigationsymbol
% insertbackfindforwardnavigationsymbol
% end{beamercolorbox}%
% begin{beamercolorbox}[ht=3ex,dp=4ex]{section in head/foot}%
% insertnavigation{.9paperwidth}
% end{beamercolorbox}%
leavevmode%
hbox{%
begin{beamercolorbox}[wd=0.9paperwidth,ht=2.25ex,dp=1ex,center]{author in head/foot}%
insertnavigation{.9paperwidth}
% usebeamerfont{author in head/foot}{}
end{beamercolorbox}%
begin{beamercolorbox}[wd=0paperwidth,ht=2.25ex,dp=1ex,center]{title in head/foot}%
usebeamerfont{title in head/foot}{}
end{beamercolorbox}%
begin{beamercolorbox}[wd=.1paperwidth,ht=2.25ex,dp=1ex,center]{date in head/foot}%
insertframenumber{} / inserttotalframenumberhspace*{1ex}
end{beamercolorbox}}%
vskip0pt%
}%
makeatother
%AtBeginSection[]{
% begin{frame}
% vfill
% centering
% begin{beamercolorbox}[sep=8pt,center,shadow=true,rounded=true]{title}
% usebeamerfont{title}insertsectionheadpar%
% end{beamercolorbox}
% vfill
%end{frame}
%}
%makeatother
%setbeamertemplate{footline}
%{
% leavevmode%
% hbox{%
% begin{beamercolorbox}[wd=0.9paperwidth,ht=2.25ex,dp=1ex,center]{author in head/foot}%
% usebeamerfont{author in head/foot}{}
% end{beamercolorbox}%
% begin{beamercolorbox}[wd=0paperwidth,ht=2.25ex,dp=1ex,center]{title in head/foot}%
% usebeamerfont{title in head/foot}{}
% end{beamercolorbox}%
% begin{beamercolorbox}[wd=.1paperwidth,ht=2.25ex,dp=1ex,center]{date in head/foot}%
% insertframenumber{} / inserttotalframenumberhspace*{1ex}
% end{beamercolorbox}}%
% vskip0pt%
%}
%makeatletter
title{My title}
% A subtitle is optional and this may be deleted
%subtitle{Optional Subtitle}
author{Me}
% - Give the names in the same order as the appear in the paper.
% - Use the inst{?} command only if the authors have different
% affiliation.
institute[University] % (optional, but mostly needed)
{
%inst{1}%
Electrical and Computer Engineering Department
vspace{.3cm}
}
date{October 1, 2019}
begin{document}
begin{frame}
begin{equation}
lambda_{max}(W_c) = begin{bmatrix}
begin{tikzpicture}
matrix (m) [
matrix of math nodes,
nodes in empty cells,
minimum width=width("998888"),
] {
1.5678 & 9.1645 & 5.2552 & 3.6413
4.3001 & 1.5605 & 5.2552 & 3.6413
6.0162 & 4.0937 & 1.5561 & 3.6413
10.0278 & 5.6221 & 3.8836 & 1.5504
};
draw (m-2-1.south west) rectangle (m-2-4.north east);
draw (m-1-3.north west) rectangle (m-4-3.south east);
scoped[on background layer]
{
node[fill=gray!30, fit=(m-2-3)(m-2-3) ] {};
}
end{tikzpicture}
end{bmatrix}
end{equation}
end{frame}
end{document}
You need to add fragile
to your frames with tikzpicture
s:
documentclass{beamer}
setbeamercovered{highly dynamic}
%setbeamertemplate{bibliography item}{}
usepackage{lipsum, ragged2e, etoolbox}
usepackage{lmodern}
usepackage{graphicx} % include this line if your document contains figures
%usepackage{natbib} % required for bibliography
usepackage{booktabs} % For formal tables
usepackage{dsfont, color, soul, tikz, amsmath, amssymb, amsfonts, amsthm, graphicx, arydshln, fixmath, mathtools, multirow, boldline, xcolor, colortbl, url, algorithm, algpseudocode, subfig, media9, hyperref, blindtext, import, tcolorbox}
usepackage{caption}
captionsetup[figure]{labelformat=empty}
usetikzlibrary{arrows, fit, matrix, positioning, shapes, backgrounds}
addtobeamertemplate{footnote}{}{vspace{2ex}}
makeatletter
defhrulefill{leavevmodeleadershrule height 2pthfillkernz@}
makeatother
newcommandblfootnote[1]{%
begingroup
renewcommandthefootnote{}footnote{#1}%
addtocounter{footnote}{-1}%
endgroup
}
newcolumntype{L}[1]{>{raggedrightarraybackslash}p{#1}}
newcolumntype{C}[1]{>{centeringarraybackslash}m{#1}}
newcolumntype{R}[1]{>{raggedleftarraybackslash}p{#1}}
usetheme{Madrid}
setbeamercolor{section in head/foot}{parent=palette quaternary}
makeatletter
setbeamertemplate{footline}
{%
vskip-9ex%
% begin{beamercolorbox}{}
% hfillusebeamercolor[fg]{navigation symbols dimmed}%
% insertslidenavigationsymbol
% insertframenavigationsymbol
% insertsubsectionnavigationsymbol
% insertsectionnavigationsymbol
% insertdocnavigationsymbol
% insertbackfindforwardnavigationsymbol
% end{beamercolorbox}%
% begin{beamercolorbox}[ht=3ex,dp=4ex]{section in head/foot}%
% insertnavigation{.9paperwidth}
% end{beamercolorbox}%
leavevmode%
hbox{%
begin{beamercolorbox}[wd=0.9paperwidth,ht=2.25ex,dp=1ex,center]{author in head/foot}%
insertnavigation{.9paperwidth}
% usebeamerfont{author in head/foot}{}
end{beamercolorbox}%
begin{beamercolorbox}[wd=0paperwidth,ht=2.25ex,dp=1ex,center]{title in head/foot}%
usebeamerfont{title in head/foot}{}
end{beamercolorbox}%
begin{beamercolorbox}[wd=.1paperwidth,ht=2.25ex,dp=1ex,center]{date in head/foot}%
insertframenumber{} / inserttotalframenumberhspace*{1ex}
end{beamercolorbox}}%
vskip0pt%
}%
makeatother
%AtBeginSection[]{
% begin{frame}
% vfill
% centering
% begin{beamercolorbox}[sep=8pt,center,shadow=true,rounded=true]{title}
% usebeamerfont{title}insertsectionheadpar%
% end{beamercolorbox}
% vfill
%end{frame}
%}
%makeatother
%setbeamertemplate{footline}
%{
% leavevmode%
% hbox{%
% begin{beamercolorbox}[wd=0.9paperwidth,ht=2.25ex,dp=1ex,center]{author in head/foot}%
% usebeamerfont{author in head/foot}{}
% end{beamercolorbox}%
% begin{beamercolorbox}[wd=0paperwidth,ht=2.25ex,dp=1ex,center]{title in head/foot}%
% usebeamerfont{title in head/foot}{}
% end{beamercolorbox}%
% begin{beamercolorbox}[wd=.1paperwidth,ht=2.25ex,dp=1ex,center]{date in head/foot}%
% insertframenumber{} / inserttotalframenumberhspace*{1ex}
% end{beamercolorbox}}%
% vskip0pt%
%}
%makeatletter
title{My title}
% A subtitle is optional and this may be deleted
%subtitle{Optional Subtitle}
author{Me}
% - Give the names in the same order as the appear in the paper.
% - Use the inst{?} command only if the authors have different
% affiliation.
institute[University] % (optional, but mostly needed)
{
%inst{1}%
Electrical and Computer Engineering Department
vspace{.3cm}
}
date{October 1, 2019}
begin{document}
begin{frame}[fragile] %<--- Add fragile here
begin{equation}
lambda_{max}(W_c) = begin{bmatrix}
begin{tikzpicture}
matrix (m) [
matrix of math nodes,
nodes in empty cells,
minimum width=width("998888"),
] {
1.5678 & 9.1645 & 5.2552 & 3.6413
4.3001 & 1.5605 & 5.2552 & 3.6413
6.0162 & 4.0937 & 1.5561 & 3.6413
10.0278 & 5.6221 & 3.8836 & 1.5504
};
draw (m-2-1.south west) rectangle (m-2-4.north east);
draw (m-1-3.north west) rectangle (m-4-3.south east);
scoped[on background layer]
{
node[fill=gray!30, fit=(m-2-3)(m-2-3) ] {};
}
end{tikzpicture}
end{bmatrix}
end{equation}
end{frame}
end{document}
Correct answer by Luis Turcio on February 14, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP