这是该主题的延续显示编号的问题和答案。
我继续给背景上色,然后把问题和答案放在方框里,使用框架包裹。
\documentclass{beamer}
\setbeamercovered{transparent=0}
\setbeamercolor{background canvas}{bg=lime!20}
\usepackage{xcolor}
\usepackage{transparent}
\usepackage[framemethod=TikZ]{mdframed}
\mdfdefinestyle{QueFrame}{%
linecolor = blue!30,
outerlinewidth = 2pt,
roundcorner = 10pt,
leftmargin = 10pt,
rightmargin = 80pt,
innertopmargin = \baselineskip,
innerbottommargin = \baselineskip,
innerrightmargin = 20pt,
innerleftmargin = 20pt,
backgroundcolor = red!20!white
}
\mdfdefinestyle{AnsFrame}{
linecolor = red!30,
outerlinewidth = 2pt,
roundcorner = 10pt,
leftmargin = 80pt,
rightmargin = 10pt,
innertopmargin = \baselineskip,
innerbottommargin = \baselineskip,
innerrightmargin = 20pt,
innerleftmargin = 20pt,
backgroundcolor = blue!20!white
}
\newcounter{num}
\setcounter{num}{0}
\newcommand<>\Que[1]{
\leavevmode\par
\stepcounter{num}
\noindent
\begin{mdframed}[style=QueFrame]
\hbox{
{\color{blue}\transparent{0.3}\Huge Q{\huge\thenum}} --- #1}
\end{mdframed}
}
\newcommand<>\Ans[2][]{
\leavevmode\par
\noindent
\begin{flushright}
\begin{mdframed}[style=AnsFrame]
\textbf{#1} #2 --- {\Huge\color{blue}\transparent{0.3} A}
\end{mdframed}
\end{flushright}
}
\resetcounteronoverlays{num}
\begin{mdframed}[style=QueFrame]
\inserttitle{\huge\color{blue} Questions and Answer}
\end{mdframed}
\begin{mdframed}[style=AnsFrame]
\insertauthor{\Large\color{blue} Edy Wihardjo}
\end{mdframed}
\date{}
\begin{document}
\frame{\titlepage}
\setbeamercolor{background canvas}{bg=green!20}
\begin{frame}
\Que{What is \LaTeX{}?}
\pause
\Ans{\LaTeX{} is a document preparation system and document markup language!}
\end{frame}
\begin{frame}
\Que{Why I should use \LaTeX?}
\pause
\Ans{\LaTeX{} provides very high quality. \LaTeX{} is free and Open Source!}
\end{frame}
\end{document}
第一个问题
如何设置标题位于页面的中间?
我添加了一个命令:
\begin{frame}
\vspace{15pt}
\titlepage
\end{frame}
但不起作用。
第二个问题
在显示答案之前,有一个空白的文本框。
答案1
对于第一个问题,我重新定义了title page
模板,只包含标题和作者。对于第二个问题,你可以\only
使用\pause
:
\documentclass{beamer}
\setbeamercovered{transparent=0}
\setbeamercolor{background canvas}{bg=lime!20}
\usepackage{xcolor}
\usepackage{transparent}
\usepackage[framemethod=TikZ]{mdframed}
\mdfdefinestyle{QueFrame}{%
linecolor = blue!30,
outerlinewidth = 2pt,
roundcorner = 10pt,
leftmargin = 10pt,
rightmargin = 80pt,
innertopmargin = \baselineskip,
innerbottommargin = \baselineskip,
innerrightmargin = 20pt,
innerleftmargin = 20pt,
backgroundcolor = red!20!white
}
\mdfdefinestyle{AnsFrame}{
linecolor = red!30,
outerlinewidth = 2pt,
roundcorner = 10pt,
leftmargin = 80pt,
rightmargin = 10pt,
innertopmargin = \baselineskip,
innerbottommargin = \baselineskip,
innerrightmargin = 20pt,
innerleftmargin = 20pt,
backgroundcolor = blue!20!white
}
\newcounter{num}
\newcommand<>\Que[1]{
\leavevmode\par
\stepcounter{num}
\noindent
\begin{mdframed}[style=QueFrame]
\hbox{
{\color{blue}\transparent{0.3}\Huge Q{\huge\thenum}} --- #1}
\end{mdframed}
}
\newcommand<>\Ans[2][]{
\leavevmode\par
\noindent
\begin{flushright}
\begin{mdframed}[style=AnsFrame]
\textbf{#1} #2 --- {\Huge\color{blue}\transparent{0.3} A}
\end{mdframed}
\end{flushright}
}
\resetcounteronoverlays{num}
\makeatletter
\defbeamertemplate*{title page}{cendefault}[1][]
{
\vbox{}
\vfill
\begingroup
\centering
\begin{beamercolorbox}[sep=8pt,center,#1]{title}
\usebeamerfont{title}\inserttitle\par%
\ifx\insertsubtitle\@empty%
\else%
\vskip0.25em%
{\usebeamerfont{subtitle}\usebeamercolor[fg]{subtitle}\insertsubtitle\par}%
\fi%
\end{beamercolorbox}%
\vskip1em\par
\begin{beamercolorbox}[sep=8pt,center,#1]{author}
\usebeamerfont{author}\insertauthor
\end{beamercolorbox}
% \begin{beamercolorbox}[sep=8pt,center,#1]{institute}
% \usebeamerfont{institute}\insertinstitute
% \end{beamercolorbox}
% \begin{beamercolorbox}[sep=8pt,center,#1]{date}
% \usebeamerfont{date}\insertdate
% \end{beamercolorbox}\vskip0.5em
% {\usebeamercolor[fg]{titlegraphic}\inserttitlegraphic\par}
\endgroup
\vfill
}
\makeatother
\setbeamertemplate{title page}[cendefault][center]
\title{The title}
\author{The Author}
\date{}
\begin{document}
\frame{\titlepage}
\setbeamercolor{background canvas}{bg=green!20}
\begin{frame}
\begin{overlayarea}{\textwidth}{.8\textheight}
\Que{What is \LaTeX{}?}
\only<2>{\Ans{\LaTeX{} is a document preparation system and document markup language!}}
\end{overlayarea}
\end{frame}
\begin{frame}
\begin{overlayarea}{\textwidth}{.8\textheight}
\Que{Why I should use \LaTeX?}
\pause
\only<2>{\Ans{\LaTeX{} provides very high quality. \LaTeX{} is free and Open Source!}}
\end{overlayarea}
\end{frame}
\end{document}
我将您的问题和答案封闭在一个overlayarea
环境中,以保持问题固定并防止在呈现答案时向上跳动。
答案2
问题在于\Que
和的定义\Ans
:
\newcommand<>\Que[1]{
\leavevmode\par
\stepcounter{num}
\noindent
\begin{mdframed}[style=QueFrame]
\hbox{
{\color{blue}\transparent{0.3}\Huge Q{\huge\thenum}} --- #1}
\end{mdframed}
}
\newcommand<>\Ans[2][]{
\leavevmode\par
\noindent
\begin{flushright}
\begin{mdframed}[style=AnsFrame]
\textbf{#1} #2 --- {\Huge\color{blue}\transparent{0.3} A}
\end{mdframed}
\end{flushright}
}
您正在定义覆盖感知命令,但未明确使用覆盖规范。将定义更改为:
\newcommand<>\Que[1]{
\leavevmode\par
\stepcounter{num}
\noindent
\only#2{\begin{mdframed}[style=QueFrame]
\hbox{
{\color{blue}\transparent{0.3}\Huge Q{\huge\thenum}} --- #1}
\end{mdframed}}
}
\newcommand<>\Ans[2][]{
\leavevmode\par
\noindent
\begin{flushright}
\only#3{\begin{mdframed}[style=AnsFrame]
\textbf{#1} #2 --- {\Huge\color{blue}\transparent{0.3} A}
\end{mdframed}}
\end{flushright}
}
允许使用:
\begin{frame}
\Que<1->{What is \LaTeX{}?}
\Ans<2->{\LaTeX{} is a document preparation system and document markup language!}
\end{frame}
\begin{frame}
\Que<1->{Why I should use \LaTeX?}
\Ans<2->{\LaTeX{} provides very high quality. \LaTeX{} is free and Open Source!}
\end{frame}
完整示例:
\documentclass{beamer}
\usepackage{lmodern}
\setbeamercovered{transparent=0}
\setbeamercolor{background canvas}{bg=lime!20}
\usepackage{transparent}
\usepackage[framemethod=TikZ]{mdframed}
\mdfdefinestyle{QueFrame}{%
linecolor = blue!30,
outerlinewidth = 2pt,
roundcorner = 10pt,
leftmargin = 10pt,
rightmargin = 80pt,
innertopmargin = \baselineskip,
innerbottommargin = \baselineskip,
innerrightmargin = 20pt,
innerleftmargin = 20pt,
backgroundcolor = red!20!white
}
\mdfdefinestyle{AnsFrame}{
linecolor = red!30,
outerlinewidth = 2pt,
roundcorner = 10pt,
leftmargin = 80pt,
rightmargin = 10pt,
innertopmargin = \baselineskip,
innerbottommargin = \baselineskip,
innerrightmargin = 20pt,
innerleftmargin = 20pt,
backgroundcolor = blue!20!white
}
\newcounter{num}
\setcounter{num}{0}
\newcommand<>\Que[1]{
\leavevmode\par
\stepcounter{num}
\noindent
\only#2{\begin{mdframed}[style=QueFrame]
\hbox{
{\color{blue}\transparent{0.3}\Huge Q{\huge\thenum}} --- #1}
\end{mdframed}}
}
\newcommand<>\Ans[2][]{
\leavevmode\par
\noindent
\begin{flushright}
\only#3{\begin{mdframed}[style=AnsFrame]
\textbf{#1} #2 --- {\Huge\color{blue}\transparent{0.3} A}
\end{mdframed}}
\end{flushright}
}
\resetcounteronoverlays{num}
\begin{document}
\frame{\titlepage}
\setbeamercolor{background canvas}{bg=green!20}
\begin{frame}
\Que<1->{What is \LaTeX{}?}
\Ans<2->{\LaTeX{} is a document preparation system and document markup language!}
\end{frame}
\begin{frame}
\Que<1->{Why I should use \LaTeX?}
\Ans<2->{\LaTeX{} provides very high quality. \LaTeX{} is free and Open Source!}
\end{frame}
\end{document}
结果:
答案3
基于贡萨洛·梅迪纳答案,我做了一些调整:
标题
\usebeamerfont{title}
%\inserttitle\par % disabled
\begin{mdframed}[style=QueFrame]
\inserttitle{\huge\color{blue} Questions and Answer}
\end{mdframed}
作者
\usebeamerfont{author}
%\insertauthor % disabled
\begin{mdframed}[style=AnsFrame]
\insertauthor{\Large\color{blue} Edy Wihardjo}
\end{mdframed}
和
%\title{The title} % disabled
%\author{The Author} % disabled
这就是我要的
前
后