Beamer 讲义:删除带有消息的图片

Beamer 讲义:删除带有消息的图片

当我制作一组幻灯片的讲义时,由于版权原因,我想删除一些(漫画)图片。在讲义中,我想获得一个与图片大小相同的框架,并在中间显示一条消息,内容是“由于版权原因,图片被删除”。

我想出了以下解决方案,使用包calc

\only<beamer>{\includegraphics[width=<width>]{<filename>}}
\only<handout>{%
    \raisebox{\heightof{\includegraphics[width=<width>]{<filename>}}*\real{-0.5}}[0pt][0pt]%
        {\begin{minipage}{<width>}\centering Picture removed for copyright reasons\end{minipage}}
    \frame{\phantom{\includegraphics[width=<width>]{<filename>}}}%
 }

它可以工作,我最终会把它变成一个命令,但我想知道:

  1. 有没有办法简化代码?
  2. 我不明白为什么我必须降低文本而不是将其升高。基线是否位于所包含图形的顶部?

答案1

是的,可以简化:

\documentclass{article}
\usepackage{graphicx}

\newsavebox{\remimagebox}
\newcommand{\removedincludegraphics}[2][]{%
  \begingroup
  \sbox\remimagebox{\includegraphics[#1]{#2}}%
  \setlength{\fboxsep}{-\fboxrule}%
  \fbox{\parbox[b][\ht\remimagebox][s]{\wd\remimagebox}{%
    \vfill
    \centering Picture removed for copyright reasons
    \vfill
    \vspace{0pt}
  }}%
  \endgroup
}

\begin{document}

\includegraphics[width=3cm]{example-image}
\removedincludegraphics[width=3cm]{example-image}

\end{document}

在此处输入图片描述

可能有一个更好的实现,可以避免文本过度填充:

\documentclass{article}
\usepackage{graphicx,adjustbox}

\newsavebox{\remimagebox}
\newcommand{\removedincludegraphics}[2][]{%
  \begingroup
  \sbox\remimagebox{\includegraphics[#1]{#2}}%
  \setlength{\fboxsep}{-\fboxrule}%
  \fbox{\parbox[b][\ht\remimagebox][s]{\wd\remimagebox}{%
    \vfill
    \centering
    \begin{adjustbox}{max width=.9\wd\remimagebox,max height=\ht\remimagebox}
    \begin{tabular}{@{}c@{}}
    Picture removed \\ for copyright \\ reasons
    \end{tabular}
    \end{adjustbox}
    \vfill
    \vspace{0pt}
  }}%
  \endgroup
}

\begin{document}

\includegraphics[width=5cm]{example-image}
\removedincludegraphics[width=5cm]{example-image}

\includegraphics[width=3cm]{example-image}
\removedincludegraphics[width=3cm]{example-image}

\includegraphics[width=1cm]{example-image}
\removedincludegraphics[width=1cm]{example-image}

\end{document}

在此处输入图片描述

答案2

这里提出的两种解决方案并没有直接解决这个问题,但它们确实通过隐藏受版权保护的图像提供了类似的结果。第一个解决方案使用 Beamer 的\includeonlylecture命令。带有受版权保护的图像的幻灯片被指定为私人幻灯片。所有其他幻灯片都是公开的。取消注释该\includeonlylecture{public}行将仅包含公开图像。私人图像将不包括在内。

\documentclass{beamer}

%\includeonlylecture{public}

\begin{document}

\lecture{public}{public}

\begin{frame}{This slide has a creative commons image.}

    The slide and information are always included.

    \vspace*{\baselineskip}

    \includegraphics[width=3cm]{example-image}

\end{frame}

% Hide the copyrighted slide.

\lecture{private}{private}

\begin{frame}{This slide has a copyright-protected image.}

    The slide does not contain any pubic information so the entire slide is hidden.

    \vspace*{\baselineskip}

    \includegraphics[width=3cm]{example-image}

\end{frame}

\lecture{public}{public}

\begin{frame}{This slide has a creative commons image.}

    The slide and image are always included.

    \vspace*{\baselineskip}

    \includegraphics[width=3cm]{example-image}

\end{frame}

\end{document}

在此处输入图片描述

此示例使用 Beamer 的\alt命令来删除受版权保护的图像。更改所\documentclass使用的命令。该[handout]表单将删除受版权保护的图像。

\documentclass{beamer}
%\documentclass[handout]{beamer}

%Puts the copyright restriction in a \parbox as wide as the image.
\newcommand\copyrighted[2]{%
    \alt<handout>{%
        \parbox{#1}{\centering Image removed for copyright reasons.}}% Handout
        {\includegraphics[width=#1]{#2}}%Non-handout
}

\begin{document}

\begin{frame}{This slide has a creative commons image.}

    The image is always available.

    \vspace*{\baselineskip}

    \includegraphics[width=3cm]{example-image}

\end{frame}

\begin{frame}{This slide has a copyright-protected image.}

    Public information with a copyright-protected image.

    \vspace*{\baselineskip}

    \alt<handout>{Image removed for copyright reasons.} 
    {\includegraphics[width=3cm]{example-image}}

\end{frame}

\begin{frame}{This slide also has a copyright-protected image.}

    Same information but in macro form. 

    \vspace*{\baselineskip}

    \copyrighted{3cm}{example-image}

\end{frame}

\end{document}

在此处输入图片描述

相关内容