7

I would like to have a single slide which has only one image on it. No navigation, no border. Nothing, only the image. If that means that the PDF page has a different size than other pages, that is fine for me.

Currently, my best try looks like this:

enter image description here

Minimal example

I tried to make a \framedgraphiconly command:

\documentclass[hyperref={pdfpagelabels=false},usepdftitle=false]{beamer}
\usetheme{Frankfurt} % see http://deic.uab.es/~iblanes/beamer_gallery/index_by_theme.html as fallback
\usecolortheme{beaver}
\usefonttheme{professionalfonts}
\usepackage{hyperref}
\usepackage[utf8]{inputenc} % this is needed for german umlauts
\usepackage[english]{babel} % this is needed for german umlauts
\usepackage[T1]{fontenc}    % this is needed for correct output of umlauts in pdf
\usepackage{tikz}

\newcommand {\framedgraphiconly}[1] {
    \setbeamertemplate{navigation symbols}{}
    \begin{frame}[plain]
        \begin{center}
            \includegraphics[width=\paperwidth,height=\paperheight,keepaspectratio]{#1}
        \end{center}
        %\begin{tikzpicture}[remember picture,overlay]
            %\node[at=(current page.center)] {
                %\includegraphics[width=\paperwidth,height=\paperheight,keepaspectratio]{#1}
            %};
        %\end{tikzpicture}
    \end{frame}
}

\beamertemplatenavigationsymbolsempty

% Begin:Move navigation from top to bottom
\setbeamertemplate{navigation symbols}{}
\makeatletter
\setbeamertemplate{footline}
{%
  \pgfuseshading{beamer@barshade}%
  \ifbeamer@sb@subsection%
    \vskip-9.75ex%
  \else%
    \vskip-7ex%
  \fi%
  \begin{beamercolorbox}[ignorebg,ht=2.25ex,dp=3.75ex]{section in head/foot}
    \insertnavigation{\paperwidth}
  \end{beamercolorbox}%
  \ifbeamer@sb@subsection%
    \begin{beamercolorbox}[ignorebg,ht=2.125ex,dp=1.125ex,%
      leftskip=.3cm,rightskip=.3cm plus1fil]{subsection in head/foot}
      \usebeamerfont{subsection in head/foot}\insertsubsectionhead
    \end{beamercolorbox}%
  \fi%
}%
\setbeamertemplate{headline}{%
}
\makeatother
% End:Move navigation from top to bottom


\begin{document}

\title{Art in Machine Learning}
\subtitle{\href{https://github.com/MartinThoma/}{github.com/MartinThoma/}}
\author{Martin Thoma}
\date{15. Januar 2016}
\subject{Machine Learning}

\frame{\titlepage}

\section{Examples}
\subsection{Examples}
\framedgraphiconly{0099.jpg}

\section{ML-Basics}
\subsection{ML-Basics}

\begin{frame}{Was ist Machine Learning?}
    \begin{block}{Definition by Tom Mitchell: ML}
        A computer program is said to learn from \textbf{experience} $E$ with
        respect to some class of \textbf{tasks} $T$ and \textbf{performance
        measure} $P$, if its performance at tasks in $T$, as measured by $P$,
        improves with experience $E$.
    \end{block}
\end{frame}

\end{document}

If you want the image, it is on https://github.com/MartinThoma/LaTeX-examples/tree/master/presentations/ImageOnly

Question

How can I get a PDF page of the size of an image exactly? In my example: How can I get rid of the white borders without changing the image / the aspect ratio how the image appears? (And whe is there white space on two sides left?)

Martin Thoma
  • 18,799
  • 1
    center environment adds vertical space so you should get rid of that first – David Carlisle Jan 10 '16 at 22:03
  • 1
    width=\paperwidth,height=\paperheight,keepaspectratio will leave a border on vertical or horizontal edges unless the image has the same aspect ratio as the page. – David Carlisle Jan 10 '16 at 22:04
  • @DavidCarlisle Removing the center environment removed one white border. Should I update the image / text, because that was rather not my main question? – Martin Thoma Jan 10 '16 at 22:06
  • 1
    @DavidCarlisle Yes, this problem with the aspect ratio is my main question. PDF pages seem to be able to have many (arbitrary?) size. Can I somehow make this single frame have the same aspect ratio as the image has? – Martin Thoma Jan 10 '16 at 22:08
  • 1
    So you really want just a single PDF page with different size than the other pages? ... – yo' Jan 10 '16 at 22:10
  • 1
    When you project it, it may be distorted if the aspect ratio is not correct i.e. if the ratio for the projection doesn't match the ratio for the page. I'm not sure about this. Maybe you will just get a border. But I think it will probably stretch it to fit the rectangle. – cfr Jan 10 '16 at 22:14
  • yes but you could fix it in so many ways you could set pffpageheigh and \pdfpagewidth to the image size locally for that page or crop the image to your projection ratio, or just print it big bleeding over the smaller side or ... but as others have noted making the page a different size will cause problems with printing and possibly projection – David Carlisle Jan 10 '16 at 22:19
  • @moose you can't presumably change the aspect ratio of your projector beam. – David Carlisle Jan 10 '16 at 22:21
  • 1
    Instead of changing the image or page size, you could change the background to black for that page only and centre the image. This will look much better through a projector than the white background. See http://tex.stackexchange.com/questions/14796/beamer-blank-black-frame – Andrew Kepert Jan 11 '16 at 00:11
  • @AndrewKepert How do I center the image without the center environment (which adds space at the top)? – Martin Thoma Jan 11 '16 at 08:46
  • @yo' Yes, I would really like to have a single PDF page with a different size than the other pages. At least I want to be able to compare the result Andrews suggestion to just make the background black. – Martin Thoma Jan 11 '16 at 08:47
  • \centering (I think there is a standard answer on site about that) – David Carlisle Jan 11 '16 at 10:13
  • @moose It looks like you have a solution (Ignasi's), so I will just answer your question above by not answering - there are too many places the extra space could come from. Trying to track down unwanted vertical and/or horizontal space contributed by a package, template, combination of parameters, stray character or even a missed % can be an exercise akin to the labours of Sisyphus. – Andrew Kepert Jan 12 '16 at 07:12
  • Oh and for reference, it is also possible to directly \shipout boxes as pages, if you want to get into low-level TeX hackery. incgraph looks like a better solution to the current question though. Another nice-looking package that is new to me. 8-) – Andrew Kepert Jan 12 '16 at 07:16

1 Answers1

10

incgraph

enter image description here

does what you want:

enter image description here

\documentclass[hyperref={pdfpagelabels=false},usepdftitle=false]{beamer}
\usetheme{Frankfurt} % see http://deic.uab.es/~iblanes/beamer_gallery/index_by_theme.html as fallback
\usecolortheme{beaver}
\usefonttheme{professionalfonts}
\usepackage{hyperref}
\usepackage[utf8]{inputenc} % this is needed for german umlauts
\usepackage[english]{babel} % this is needed for german umlauts
\usepackage[T1]{fontenc}    % this is needed for correct output of umlauts in pdf
\usepackage{tikz}
\usepackage{incgraph}

\newcommand {\framedgraphiconly}[1] {
    \setbeamertemplate{navigation symbols}{}
    \begin{frame}[plain]
        \begin{center}
            \includegraphics[width=\paperwidth,height=\paperheight,keepaspectratio]{#1}
        \end{center}
        %\begin{tikzpicture}[remember picture,overlay]
            %\node[at=(current page.center)] {
                %\includegraphics[width=\paperwidth,height=\paperheight,keepaspectratio]{#1}
            %};
        %\end{tikzpicture}
    \end{frame}
}

\beamertemplatenavigationsymbolsempty

% Begin:Move navigation from top to bottom
\setbeamertemplate{navigation symbols}{}
\makeatletter
\setbeamertemplate{footline}
{%
  \pgfuseshading{beamer@barshade}%
  \ifbeamer@sb@subsection%
    \vskip-9.75ex%
  \else%
    \vskip-7ex%
  \fi%
  \begin{beamercolorbox}[ignorebg,ht=2.25ex,dp=3.75ex]{section in head/foot}
    \insertnavigation{\paperwidth}
  \end{beamercolorbox}%
  \ifbeamer@sb@subsection%
    \begin{beamercolorbox}[ignorebg,ht=2.125ex,dp=1.125ex,%
      leftskip=.3cm,rightskip=.3cm plus1fil]{subsection in head/foot}
      \usebeamerfont{subsection in head/foot}\insertsubsectionhead
    \end{beamercolorbox}%
  \fi%
}%
\setbeamertemplate{headline}{%
}
\makeatother
% End:Move navigation from top to bottom


\begin{document}

\title{Art in Machine Learning}
\subtitle{\href{https://github.com/MartinThoma/}{github.com/MartinThoma/}}
\author{Martin Thoma}
\date{15. Januar 2016}
\subject{Machine Learning}

\frame{\titlepage}

\section{Examples}
\subsection{Examples}
%\framedgraphiconly{0099.jpg}

\incgraph{0099.jpg}

\section{ML-Basics}
\subsection{ML-Basics}

\begin{frame}{Was ist Machine Learning?}
    \begin{block}{Definition by Tom Mitchell: ML}
        A computer program is said to learn from \textbf{experience} $E$ with
        respect to some class of \textbf{tasks} $T$ and \textbf{performance
        measure} $P$, if its performance at tasks in $T$, as measured by $P$,
        improves with experience $E$.
    \end{block}
\end{frame}

\end{document}
Ignasi
  • 136,588
  • It looks fine for my minimal example. However, when I include it in my real document, I get `! LaTeX Error: Option clash for package hyperref.

    See the LaTeX manual or LaTeX Companion for explanation. Type H for immediate help. ...

    l.86 \RequirePackage{hyperref}[2010/06/18]`. - Do you have an idea how to fix it?

    – Martin Thoma Jan 11 '16 at 09:17
  • @moose Hyperref is loaded twice with different options; this is a common problem. Try adding \RequirePackage{incgraph} before \begin{document}. – yo' Jan 11 '16 at 09:28
  • 3
    @moose: incgraph loads hyperref thorugh bookmarks package. It has option nobookmark (and some others) to avoid loading it and problems with your previous loading options. Try \usepackage[nobookmar]{incgraph} – Ignasi Jan 11 '16 at 09:32
  • Thank you, that worked fine (\usepackage[nobookmark]{incgraph}). – Martin Thoma Jan 11 '16 at 09:40