Presenting a Questions and Answers

This is a continuation of the topic Displaying a Numbered Questions and Answer.

I continue to give color to the background, then putting questions and answers in the boxes using mdframed package.

\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} 

First Problem

How to set the title to be in the middle of the page?

I've added a command:

\begin{frame}     \vspace{15pt}     \titlepage \end{frame} 

but does not work.

Second Problem

Presenting a Questions and Answers

Before displaying the answer, there is an empty text box.

Presenting a Questions and Answers

Replay

For the first problem, I redefined the title page template, to have only title and author. For the second problem. you can use \only instead of \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}

Presenting a Questions and Answers

I enclosed your questions and answers inside an overlayarea environment to keep the questions fixed and preventing from jumping upwards when the answers are presented.

The problem lies in the definitions of \Que and \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}
}

You are defining overlay-aware commands without explicit use of the overlay specifications. Changing the definitions into:

\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}
}

allows to use:

\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}

The complete example:

\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}

The result:

Presenting a Questions and Answers

Based on Gonzalo Medina answers, I did some adjustments:

Title

\usebeamerfont{title}
%\inserttitle\par % disabled
\begin{mdframed}[style=QueFrame]
    \inserttitle{\huge\color{blue} Questions and Answer}
\end{mdframed}

Author

\usebeamerfont{author}
    %\insertauthor % disabled
\begin{mdframed}[style=AnsFrame]
    \insertauthor{\Large\color{blue} Edy Wihardjo}
\end{mdframed}

and

%\title{The title} % disabled
%\author{The Author} % disabled

This is what I want

Before

Presenting a Questions and Answers

After

Presenting a Questions and Answers

Category: beamer Time: 2014-02-03 Views: 0
Tags: beamer

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development

search

Front-end development

Database

development tools

Open Platform

Javascript development

.NET development

cloud computing

server

Copyright (C) avrocks.com, All Rights Reserved.

processed in 0.237 (s). 12 q(s)