在幻灯片和标题页的标题中插入 tikzpictures 时出现问题,LaTeX beamer

在幻灯片和标题页的标题中插入 tikzpictures 时出现问题,LaTeX beamer

我正在创建自定义投影仪主题,但在幻灯片标题中插入图形时遇到了问题。

对于图形,我已将.eps文件导出到 Ti使用 Inkscape 编写的 Z 代码,效果很好。对于标题页的页眉和普通页的页眉,我都有一张单独的图像。我想将它们放在每张幻灯片的顶部,顶部、左侧或右侧没有空格,但也不重叠。

根据我使用的方法,生成的图像要么太小且未正确对齐,要么太大导致图像被剪切,这也是我不希望的。

您能为我的问题提供解决方案吗?

为了更好地说明,我提供了一个示例代码:

\documentclass{beamer}
\usetheme{default}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage[none]{hyphenat}
\usepackage{pgf}
\usepackage{xcolor}
\usepackage{amsmath}

%graphics
\definecolor{c00519d}{RGB}{0,81,157}
\definecolor{cffffff}{RGB}{255,255,255}

\newcommand{\blankframeheader}{
\begin{tikzpicture}[y=0.80pt, x=0.80pt, yscale=-1.000000, xscale=1.000000, inner sep=0pt, outer sep=0pt]
\begin{scope}[shift={(0,-715.74804)}]
  \path[fill=c00519d] (0.0000,741.9754) -- (0.0000,715.7480) --
    (230.3150,715.7480) -- (460.6299,715.7480) -- (460.6299,735.7849) --
    (460.6299,755.8217) -- (291.4636,755.8727) .. controls (130.5669,755.9207) and
    (107.2812,755.9810) .. (103.4114,756.3572) .. controls (102.9047,756.4062) and
    (100.5901,756.5116) .. (98.2677,756.5909) .. controls (95.9454,756.6699) and
    (93.0089,756.8049) .. (91.7421,756.8902) .. controls (89.2381,757.0589) and
    (85.5793,757.2925) .. (81.8386,757.5224) .. controls (71.6262,758.1501) and
    (49.2989,760.4954) .. (36.6201,762.2723) .. controls (34.7622,762.5327) and
    (32.5166,762.8458) .. (31.6299,762.9681) .. controls (29.0767,763.3203) and
    (27.9960,763.4812) .. (26.0256,763.8026) .. controls (25.0122,763.9679) and
    (23.4230,764.2128) .. (22.4941,764.3468) .. controls (20.5806,764.6230) and
    (13.0199,765.9332) .. (7.2933,766.9811) .. controls (5.1821,767.3674) and
    (2.6774,767.8004) .. (1.7274,767.9433) -- (0.0000,768.2030) --
    (0.0000,741.9757) -- cycle;
\end{scope}
\end{tikzpicture}
}


\newcommand{\titlepageheader}{
\begin{tikzpicture}[y=0.80pt, x=0.80pt, yscale=-1.000000, xscale=1.000000,     inner sep=0pt, outer sep=0pt]
\begin{scope}[shift={(0,-715.74804)}]
  \path[fill=c00519d] (0.0000,757.5176) -- (0.0000,715.7480) --
    (230.3150,715.7480) -- (460.6299,715.7480) -- (460.6299,729.2431) .. controls
    (460.6299,741.7994) and (460.5752,742.7374) .. (459.8427,742.7281) .. controls
    (459.4097,742.7231) and (454.1973,742.4228) .. (448.2595,742.0619) .. controls
    (433.1563,741.1439) and (413.7831,740.7138) .. (387.5319,740.7138) .. controls
    (367.4161,740.7138) and (339.3755,741.1990) .. (335.1399,741.6204) .. controls
    (334.2665,741.7073) and (330.4142,741.9011) .. (326.5794,742.0510) .. controls
    (322.7446,742.2008) and (318.0888,742.4159) .. (316.2332,742.5288) .. controls
    (314.3777,742.6417) and (309.3170,742.9446) .. (304.9874,743.2018) .. controls
    (300.6577,743.4591) and (293.1680,743.9681) .. (288.3435,744.3329) .. controls
    (187.7250,751.9426) and (95.0905,769.1877) .. (9.7839,796.1902) --
    (0.0000,799.2871) -- cycle;
\end{scope}
\end{tikzpicture}
}


\setbeamertemplate{headline}{\resizebox{\paperwidth}{!}{\blankframeheader}}

\setbeamertemplate{title page}{
    \begin{picture}(0,0)
        \put(-32,40){   % This line is fiddeling with coordinates. I would like to define that the
                        % picture is put in the top left corner, the width set to the width of the
                        % slide and y is scaled accordingly.
                        % I want to avoid any white space or oversize of the images.
    \resizebox{\paperwidth}{!}{\titlepageheader}
    }
    \put(0,-50){%
        \begin{minipage}[b][22mm][t]{95mm}
            \begin{flushleft}
                \usebeamerfont{title}\inserttitle\par%
                  \ifx\insertsubtitle\@empty%
                  \else%
                    \vskip0.25em%
                    {\usebeamerfont{subtitle}\usebeamercolor[fg]{subtitle}\insertsubtitle\par}%
                  \fi%     
                \vskip1em\par
                  \usebeamerfont{author}\insertauthor\par
                  \usebeamerfont{institute}\insertinstitute\par
                  \usebeamerfont{date}\insertdate
            \end{flushleft}
        \end{minipage}
    }
\end{picture}
}


\title{A beamer Title}
\subtitle{A beamer Subtitle}
\author{Author Name}
\institute{Institution}
\date{date}

\begin{document}

\begin{frame}[plain]    % I have used [plain] to remove the headline from the titlepage
                        % However i would prefer to do this in the \setbeamertemplate definition
                        % rather than manually in the document
    \titlepage
\end{frame}


\begin{frame}
*
\end{frame}


\end{document}

答案1

首先,你缺少一些%让你的 tikz 图片正确缩放到全纸宽度的东西。看看SE 问题,了解有关为什么需要这样做的更多信息。这个问题解决了,我建议将您的 tikz 图片放在背景模板中。我认为这会让事情变得容易得多。要将标题框自动设置为纯色并更改背景,我认为只需重新定义命令就很有意义maketitle

在此处输入图片描述

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{pgf}
\usepackage{amsmath}

%graphics
\definecolor{c00519d}{RGB}{0,81,157}
\definecolor{cffffff}{RGB}{255,255,255}

\newcommand{\blankframeheader}{% <-- This percent sign is important.
\begin{tikzpicture}[y=0.80pt, x=0.80pt, yscale=-1.000000, xscale=1.000000, inner sep=0pt, outer sep=0pt]
\begin{scope}[shift={(0,-715.74804)}]
  \path[fill=c00519d] (0.0000,741.9754) -- (0.0000,715.7480) --
    (230.3150,715.7480) -- (460.6299,715.7480) -- (460.6299,735.7849) --
    (460.6299,755.8217) -- (291.4636,755.8727) .. controls (130.5669,755.9207) and
    (107.2812,755.9810) .. (103.4114,756.3572) .. controls (102.9047,756.4062) and
    (100.5901,756.5116) .. (98.2677,756.5909) .. controls (95.9454,756.6699) and
    (93.0089,756.8049) .. (91.7421,756.8902) .. controls (89.2381,757.0589) and
    (85.5793,757.2925) .. (81.8386,757.5224) .. controls (71.6262,758.1501) and
    (49.2989,760.4954) .. (36.6201,762.2723) .. controls (34.7622,762.5327) and
    (32.5166,762.8458) .. (31.6299,762.9681) .. controls (29.0767,763.3203) and
    (27.9960,763.4812) .. (26.0256,763.8026) .. controls (25.0122,763.9679) and
    (23.4230,764.2128) .. (22.4941,764.3468) .. controls (20.5806,764.6230) and
    (13.0199,765.9332) .. (7.2933,766.9811) .. controls (5.1821,767.3674) and
    (2.6774,767.8004) .. (1.7274,767.9433) -- (0.0000,768.2030) --
    (0.0000,741.9757) -- cycle;
\end{scope}
\end{tikzpicture}% <-- This percent sign is important.
}


\newcommand{\titlepageheader}{% <-- This percent sign is important.
\begin{tikzpicture}[y=0.80pt, x=0.80pt, yscale=-1.000000, xscale=1.000000,     inner sep=0pt, outer sep=0pt]
\begin{scope}[shift={(0,-715.74804)}]
  \path[fill=c00519d] (0.0000,757.5176) -- (0.0000,715.7480) --
    (230.3150,715.7480) -- (460.6299,715.7480) -- (460.6299,729.2431) .. controls
    (460.6299,741.7994) and (460.5752,742.7374) .. (459.8427,742.7281) .. controls
    (459.4097,742.7231) and (454.1973,742.4228) .. (448.2595,742.0619) .. controls
    (433.1563,741.1439) and (413.7831,740.7138) .. (387.5319,740.7138) .. controls
    (367.4161,740.7138) and (339.3755,741.1990) .. (335.1399,741.6204) .. controls
    (334.2665,741.7073) and (330.4142,741.9011) .. (326.5794,742.0510) .. controls
    (322.7446,742.2008) and (318.0888,742.4159) .. (316.2332,742.5288) .. controls
    (314.3777,742.6417) and (309.3170,742.9446) .. (304.9874,743.2018) .. controls
    (300.6577,743.4591) and (293.1680,743.9681) .. (288.3435,744.3329) .. controls
    (187.7250,751.9426) and (95.0905,769.1877) .. (9.7839,796.1902) --
    (0.0000,799.2871) -- cycle;
\end{scope}
\end{tikzpicture}% <-- This percent sign is important.
}

\setbeamercolor{frametitle}{fg=white}
\setbeamertemplate{background}{\resizebox{\paperwidth}{!}{\blankframeheader}}

\setbeamertemplate{title page}{%
\vspace*{2em}
\usebeamerfont{title}\inserttitle\par%
\ifx\insertsubtitle\@empty%
\else%
    \vspace*{0.25em}
    {\usebeamerfont{subtitle}\usebeamercolor[fg]{subtitle}\insertsubtitle\par}%
\fi%
\vspace*{1em}
\usebeamerfont{author}\insertauthor\par
\usebeamerfont{institute}\insertinstitute\par
\usebeamerfont{date}\insertdate
}

\renewcommand{\maketitle}{%
\setbeamertemplate{background}{\resizebox{\paperwidth}{!}{\titlepageheader}}
\frame[plain,noframenumbering]{\titlepage}
\setbeamertemplate{background}{\resizebox{\paperwidth}{!}{\blankframeheader}}
}

\title{A beamer Title}
\subtitle{A beamer Subtitle}
\author{Author Name}
\institute{Institution}
\date{date}

\begin{document}

\maketitle

\begin{frame}{Frametitle}
Framecontent
\end{frame}

\end{document}

相关内容