Graphics, Figures & Tablesmodify \part of Beamer

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
vita001
Posts: 17
Joined: Sun Mar 20, 2011 1:04 am

modify \part of Beamer

Post by vita001 »

Hi, the "/part" and "/frame{/partpage}" together will produce a page which has a long colorbox containing the text. I want to modify it such that the colorbox is just enough to contain the text. How can I achieve this? Is there a way to locate the definition of latex commands in the packages? If I can find a definition of the command, I probably can figure many modifications by myself. However, It seems that latex has a huge amount of packages and I don't know a way to do it. Thanks.

Code: Select all

    \part{testing}
    \frame{\partpage}
 
Last edited by vita001 on Sun Mar 20, 2011 2:08 am, edited 3 times in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

User avatar
Stefan Kottwitz
Site Admin
Posts: 10348
Joined: Mon Mar 10, 2008 9:44 pm

Re: modify /part of Beamer

Post by Stefan Kottwitz »

Hi vita001,

welcome to the board!

Which beamer theme do you use? Perhaps post a compilable minimal example for demonstration. Not all themes use color boxes for part pages, some use boxes of different width.

And please use the backslash \ for writing LaTeX commands, not a slash /. It would be nice if you would edit your post regarding this.

Stefan
LaTeX.org admin
vita001
Posts: 17
Joined: Sun Mar 20, 2011 1:04 am

modify \part of Beamer

Post by vita001 »

The following is a small example Which gives me a long blue box. I want the blue colorbox smaller---just big enough to embed the "testing"

Code: Select all

\documentclass[compress]{beamer}
\mode<presentation> {
 \usetheme{Warsaw}
  \usefonttheme[onlymath]{serif}
  \setbeamercovered{transparent}

  \setbeamertemplate{headline}[default]
  \setbeamertemplate{footline}{

  \leavevmode%

  \hbox{%

  \begin{beamercolorbox}[wd=.5\paperwidth,ht=2.25ex,dp=1ex,center]{author in head/foot}%

    \usebeamerfont{author in head/foot}\insertshortauthor

  \end{beamercolorbox}%

  \begin{beamercolorbox}[wd=.5\paperwidth,ht=2.25ex,dp=1ex,right]{date in head/foot}% 
  \end{beamercolorbox}}%

  \vskip0pt%
}
}
\usepackage[english]{babel}
\usepackage[latin1]{inputenc}
\usepackage{times}
\usepackage[T1]{fontenc}
\usepackage{mathptmx}
\usepackage{helvet}
\usepackage{courier}
\usepackage[font=small,labelfont=bf]{caption}
\usepackage{subfigure}
\usepackage{fancybox}
\usepackage{slashbox} %%for slash in tables
\setbeamertemplate{navigation symbols}{}
\begin{document}
\part{testing}
\frame{\partpage}
\end{document}
User avatar
Stefan Kottwitz
Site Admin
Posts: 10348
Joined: Mon Mar 10, 2008 9:44 pm

modify \part of Beamer

Post by Stefan Kottwitz »

Warsaw uses a rounder inner theme.

In beamerinnerthemedefault.sty you will find this definition for the default part page:

Code: Select all

\defbeamertemplate*{part page}{default}[1][]
{
  \begin{centering}
    {\usebeamerfont{part name}\usebeamercolor[fg]{part name}
    \partname~\insertromanpartnumber}
    \vskip1em\par
    \begin{beamercolorbox}[sep=8pt,center,#1]{part title}
      \usebeamerfont{part title}\insertpart\par
    \end{beamercolorbox}
  \end{centering}
}
In beamerinnerthemerounded.sty:

Code: Select all

\setbeamertemplate{part page}[default][colsep=-4bp,rounded=true,
shadow=\beamer@themerounded@shadow]
We can see, options to the template are given to the box. So we can specify a width. You could write in your preamble:

Code: Select all

\makeatletter
\setbeamertemplate{part page}[default][colsep=-4bp,rounded=true,
  shadow=\beamer@themerounded@shadow,wd=0.4\textwidth]
\makeatother
Stefan
LaTeX.org admin
vita001
Posts: 17
Joined: Sun Mar 20, 2011 1:04 am

modify \part of Beamer

Post by vita001 »

I try your suggestion but the box is not centered any more.

Code: Select all

\documentclass[compress]{beamer}
\mode<presentation> {
 \usetheme{Warsaw}
  \usefonttheme[onlymath]{serif}
  \setbeamercovered{transparent}

  \setbeamertemplate{headline}[default]
  \setbeamertemplate{footline}{

  \leavevmode%

  \hbox{%

  \begin{beamercolorbox}[wd=.5\paperwidth,ht=2.25ex,dp=1ex,center]{author in head/foot}%

    \usebeamerfont{author in head/foot}\insertshortauthor

  \end{beamercolorbox}%

  \begin{beamercolorbox}[wd=.5\paperwidth,ht=2.25ex,dp=1ex,right]{date in head/foot}% 
  \end{beamercolorbox}}%

  \vskip0pt%
}
}
\makeatletter
\setbeamertemplate{part page}[default][colsep=-4bp,rounded=true,
  shadow=\beamer@themerounded@shadow,wd=0.4\textwidth]
\makeatother

\usepackage[english]{babel}
\usepackage[latin1]{inputenc}
\usepackage{times}
\usepackage[T1]{fontenc}
\usepackage{mathptmx}
\usepackage{helvet}
\usepackage{courier}
\usepackage[font=small,labelfont=bf]{caption}
\usepackage{subfigure}
\usepackage{fancybox}
\usepackage{slashbox} %%for slash in tables
\setbeamertemplate{navigation symbols}{}
\begin{document}
\part{testing}
\frame{\partpage}
\end{document}
vita001
Posts: 17
Joined: Sun Mar 20, 2011 1:04 am

modify \part of Beamer

Post by vita001 »

I've found the solution:

Code: Select all

\usepackage[english]{babel}
\usepackage[latin1]{inputenc}
\usepackage{times}
\usepackage[T1]{fontenc}
\usepackage{mathptmx}
\usepackage{helvet}
\usepackage{courier}
\usepackage[font=small,labelfont=bf]{caption}
\usepackage{subfigure}
\usepackage{fancybox}
\usepackage{slashbox} %%for slash in tables
\setbeamertemplate{navigation symbols}{}
\begin{document}
\part{testing}
\frame{\partpage}
\part{testing2}
\begin{frame}
  \begin{centering}
    {\usebeamerfont{part name}\usebeamercolor[fg]{part name}
    \partname~\insertromanpartnumber}
    \vskip1em\par
    \hfill\hfill
    \begin{beamercolorbox}[sep=8pt,colsep=-4bp,rounded=true,wd=0.4\textwidth,center,shadow]{part title}
      \usebeamerfont{part title}\insertpart\par
    \end{beamercolorbox}
    \hfill\hfill
  \end{centering}
\end{frame}
\end{document}
However, I want to re-define the \partpage, such that I can pass in the width of the colorbox as a parameter at each partpage. How can I do that?
User avatar
Stefan Kottwitz
Site Admin
Posts: 10348
Joined: Mon Mar 10, 2008 9:44 pm

modify \part of Beamer

Post by Stefan Kottwitz »

You could use \settowidth to adjust the box to the title width instead of specifying it manually.

Stefan
LaTeX.org admin
vita001
Posts: 17
Joined: Sun Mar 20, 2011 1:04 am

modify \part of Beamer

Post by vita001 »

\settowidth{\gnat}{text}'
The `\settowidth' command sets the value of a `length' command equal
to the width of the `text' argument.
That's the definition I get, but I still don't know how to use it. What is \gnat? and how can I insert it into the \partpage command?

What I want to do is to re-define the \partpage command only once in the preamble, and then I can do \partpage as usual in the other part? But I don't know how. The copy-paste approach is error-prone. Thanks
User avatar
Stefan Kottwitz
Site Admin
Posts: 10348
Joined: Mon Mar 10, 2008 9:44 pm

modify \part of Beamer

Post by Stefan Kottwitz »

For your preamble:

Code: Select all

\newlength{\gnat}% create a length
\defbeamertemplate*{part page}{my part}[1][]
{
  \begin{centering}
    {\usebeamerfont{part name}\usebeamercolor[fg]{part name}
    \partname~\insertromanpartnumber}
    \vskip1em\par
    \settowidth{\gnat}{\insertpart}% set the length matching to the title
    \addtolength{\gnat}{2em}% raise the length  a bit
    \hfill
    %now we use that length
    \begin{beamercolorbox}[sep=8pt,center,wd=\gnat,#1]{part title}
      \usebeamerfont{part title}\insertpart\par
    \end{beamercolorbox}
    \hfill
  \end{centering}
}
\makeatletter
\setbeamertemplate{part page}[my part][colsep=-4bp,rounded=true,
  shadow=\beamer@themerounded@shadow]
\makeatother
Stefan
LaTeX.org admin
vita001
Posts: 17
Joined: Sun Mar 20, 2011 1:04 am

modify \part of Beamer

Post by vita001 »

I am almost there.
It seems that \settowidth{} will decide to break the line somewhere. I try to use \mbox{} to force the break at some place. However, this seems cause \settowidth{} not working correctly.
In the following code, the colorbox in the first partpage has the desire margin. But for some reason the colorbox in the second partpage has a much bigger margin.

Code: Select all

\documentclass[compress]{beamer}
\mode<presentation> {
 \usetheme{Warsaw}
  \usefonttheme[onlymath]{serif}
  \setbeamercovered{transparent}
  \setbeamertemplate{headline}[default]
  \setbeamertemplate{footline}[default]
}
\makeatletter
\setbeamertemplate{part page}[default][colsep=-4bp,rounded=true,
  shadow=\beamer@themerounded@shadow,wd=0.4\textwidth]
\makeatother

\usepackage[english]{babel}
\usepackage[latin1]{inputenc}
\usepackage{times}
\usepackage[T1]{fontenc}
\usepackage{mathptmx}
\usepackage{helvet}
\usepackage{courier}
\usepackage[font=small,labelfont=bf]{caption}
\usepackage{subfigure}
\usepackage{fancybox}
\usepackage{slashbox} %%for slash in tables
\setbeamertemplate{navigation symbols}{}
\newlength{\gnat}% create a length
\defbeamertemplate*{part page}{my part}[1][]
{
  \begin{centering}
    \settowidth{\gnat}{\insertpart}% set the length matching to the title
    \addtolength{\gnat}{4em}% raise the length  a bit
    \hfill
    %now we use that length
    \begin{beamercolorbox}[sep=8pt,center,wd=\gnat,#1]{part title}
      \usebeamerfont{part title}\insertpart\par
    \end{beamercolorbox}
    \hfill
  \end{centering}
}
\makeatletter
\setbeamertemplate{part page}[my part][colsep=-4bp,rounded=true,
  shadow=\beamer@themerounded@shadow]
\makeatother
\begin{document}
\part{Margin is OK.}
\frame{\partpage}
\part{\mbox{Break here} \mbox{Margin is wrong}} 
\frame{\partpage}
\end{document}
Post Reply