Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

FirstQue

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

FirstQueAns

share|improve this question
    
Which title are you referring about in the first question? –  Gonzalo Medina Feb 3 at 15:57
    
I mean, title and author on the title page. I can't put it in the middle vertically. –  Edy Jo Feb 3 at 16:15
add comment

3 Answers

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}

enter image description here

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.

share|improve this answer
    
The second problem has been solved. How to solve the first problem, @Gonzalo Medina? –  Edy Jo Feb 3 at 16:03
    
I mean, title and author on the title page. I can't put it in the middle vertically. –  Edy Jo Feb 3 at 16:12
    
@EdyJo please see my updated answer. I assumed you only want to show the author and the title in the title page. –  Gonzalo Medina Feb 3 at 16:32
add comment

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:

enter image description here

share|improve this answer
    
It also ran well, @Claudio Fiandrino. –  Edy Jo Feb 3 at 16:14
add comment

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

Title Page Before

After

Title Page After

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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