如何从投影仪内部主题自定义标题页徽标大小?

发布于 2025-01-15 15:19:32 字数 2016 浏览 5 评论 0原文

我目前正在构建一个自定义投影仪主题,我终于找到了完美的徽标高度 [height=0.2\textheight] 并希望将其设置为我的默认主题(所以我不需要记住将来会这样)。

但是,我不知道内部投影仪主题中的 \inserttitlegraphic 命令怎么可能做到这一点。代码如下:


% Title page
\setbeamertemplate{title page}{
  \hfill{\usebeamercolor[fg]{titlegraphic}\inserttitlegraphic\par}
  \vfill
  \begingroup
      \centering
      % ------------------------
      \begin{beamercolorbox}[sep=8pt,center]{title}
      \usebeamerfont{title}\textbf{\inserttitle}\par%
      \ifx\insertsubtitle\@empty%
      \else%
          \vskip0.25em%
          {\usebeamerfont{subtitle}\usebeamercolor[fg]{subtitle}\textit{\insertsubtitle}\par}%
      \fi%
      \end{beamercolorbox}%
      \vskip0.5em\par
      % ------------------------
      \begin{beamercolorbox}[sep=8pt,center]{author}
      \usebeamerfont{author}\insertauthor
      \end{beamercolorbox}
      \vskip-1em
      % ------------------------
      \begin{beamercolorbox}[sep=8pt,center]{institute}
      \usebeamerfont{institute}\insertinstitute
      \end{beamercolorbox}
      % ------------------------
      \begin{beamercolorbox}[sep=8pt,center]{date}
      \usebeamerfont{date}\insertdate
      \end{beamercolorbox}\vskip0.5em
  \endgroup
  \vfill
}

% TOC
\setbeamertemplate{section in toc}{\leavevmode\leftskip=1.4em\rlap{\hskip-1.3em\inserttocsectionnumber.}\textbf{\inserttocsection}\par}
\setbeamertemplate{subsection in toc}{\leavevmode\leftskip=3.2em\rlap{\hskip-2em\inserttocsectionnumber.\inserttocsubsectionnumber}\inserttocsubsection\par}

% Items
\setbeamertemplate{blocks}[rounded][shadow=false]
\setbeamertemplate{block title}[]
\setbeamertemplate{enumerate items}[default]
\setbeamertemplate{items}[circle]

% Frame
\setbeamertemplate{frametitle}{\vspace*{0.5em}\bfseries\insertframetitle\par\vskip-6pt\hrulefill\vspace{-0.1em}}

到目前为止,我总是必须将 \titlegraphic{\includegraphics[height=0.2\textheight]{hu-logo.png}} 添加到我的主乳胶文档中。我想简单地引用徽标文件并让该主题自动填充高度,作为该主题的设置徽标高度

我将感谢您的帮助和解释。

I'm currently building a custom beamer theme and I finally found the perfect logo height [height=0.2\textheight] and would like to set it into my default theme (so I don't need to remember it in the future).

However, I don't know how's that possible with the \inserttitlegraphic command in the inner beamer theme. Here's the code:


% Title page
\setbeamertemplate{title page}{
  \hfill{\usebeamercolor[fg]{titlegraphic}\inserttitlegraphic\par}
  \vfill
  \begingroup
      \centering
      % ------------------------
      \begin{beamercolorbox}[sep=8pt,center]{title}
      \usebeamerfont{title}\textbf{\inserttitle}\par%
      \ifx\insertsubtitle\@empty%
      \else%
          \vskip0.25em%
          {\usebeamerfont{subtitle}\usebeamercolor[fg]{subtitle}\textit{\insertsubtitle}\par}%
      \fi%
      \end{beamercolorbox}%
      \vskip0.5em\par
      % ------------------------
      \begin{beamercolorbox}[sep=8pt,center]{author}
      \usebeamerfont{author}\insertauthor
      \end{beamercolorbox}
      \vskip-1em
      % ------------------------
      \begin{beamercolorbox}[sep=8pt,center]{institute}
      \usebeamerfont{institute}\insertinstitute
      \end{beamercolorbox}
      % ------------------------
      \begin{beamercolorbox}[sep=8pt,center]{date}
      \usebeamerfont{date}\insertdate
      \end{beamercolorbox}\vskip0.5em
  \endgroup
  \vfill
}

% TOC
\setbeamertemplate{section in toc}{\leavevmode\leftskip=1.4em\rlap{\hskip-1.3em\inserttocsectionnumber.}\textbf{\inserttocsection}\par}
\setbeamertemplate{subsection in toc}{\leavevmode\leftskip=3.2em\rlap{\hskip-2em\inserttocsectionnumber.\inserttocsubsectionnumber}\inserttocsubsection\par}

% Items
\setbeamertemplate{blocks}[rounded][shadow=false]
\setbeamertemplate{block title}[]
\setbeamertemplate{enumerate items}[default]
\setbeamertemplate{items}[circle]

% Frame
\setbeamertemplate{frametitle}{\vspace*{0.5em}\bfseries\insertframetitle\par\vskip-6pt\hrulefill\vspace{-0.1em}}

So far, I'm always having to add \titlegraphic{\includegraphics[height=0.2\textheight]{hu-logo.png}} to my main latex document. Id like to simple reference the logo file and have this theme automatically fill in the height, as the set logo height for this theme

I'll appreciate the help and explanation.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

孤凫 2025-01-22 15:19:32

为了确保标题图形设置为您在主题中选择的高度,您可以让您的投影仪主题完成此操作,并为您的用户提供通过主题选项更改文件名的可能性:

\documentclass{beamer}

\begin{filecontents*}[overwrite]{beamerthemeHU.sty}
\DeclareOptionBeamer{logofile}{\titlegraphic{\includegraphics[height=0.2\textheight]{#1}}}
\ExecuteOptionsBeamer{logofile=example-image-duck}
\ProcessOptionsBeamer
\end{filecontents*}

\usetheme[
  logofile=example-image
]{HU}

\begin{document}
    
\begin{frame}
\maketitle
\end{frame} 
    
\end{document}

To make sure the title graphic gets set with the height you choose in your theme, you could let your beamer theme do it and just offer your users the possibility to change the file name via a theme option:

\documentclass{beamer}

\begin{filecontents*}[overwrite]{beamerthemeHU.sty}
\DeclareOptionBeamer{logofile}{\titlegraphic{\includegraphics[height=0.2\textheight]{#1}}}
\ExecuteOptionsBeamer{logofile=example-image-duck}
\ProcessOptionsBeamer
\end{filecontents*}

\usetheme[
  logofile=example-image
]{HU}

\begin{document}
    
\begin{frame}
\maketitle
\end{frame} 
    
\end{document}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文