![将 beameroutertheme 适配到 beamerinnertheme](https://linux22.com/image/463093/%E5%B0%86%20beameroutertheme%20%E9%80%82%E9%85%8D%E5%88%B0%20beamerinnertheme.png)
这是关于我自己的 beamer 主题的收尾工作。我或多或少已经完成了一半的 beameroutertheme.sty 设计,但与 innertheme 相比,它发生了变化。我希望红条和徽标的间距与首页上的对齐(就长度而言)。不幸的是,任何改变它的尝试都会破坏设计。不幸的是,我对 tikz 的经验很少或几乎没有,多亏了这里的社区,我才走到了今天。
\documentclass[10pt,%
aspectratio=169,%
]{beamer}
\usepackage {mwe}
\usepackage{tikz}
\usepackage{xcolor}
\title{TITLE}
\author{NAME}
\institute{INSTITUT}
\date{DATE}
%\titlegraphic{\includegraphics[width=\paperwidth]{example-image-duck}}
%beamertheme.sty
\usetikzlibrary{shapes}
\setbeamertemplate{navigation symbols}{}
\setbeamertemplate{footline}{
\begin{beamercolorbox}[wd=\paperwidth, ht=2em, dp = 1em]{foot}
\hspace*{1em}
{\normalsize \inserttitle}\hfill{\normalsize \insertauthor, \insertdate} \hfill{\normalsize \insertpagenumber}
\hspace*{1em}
\end{beamercolorbox}}
%beamercolortheme.sty
\setbeamercolor*{author}{fg=white}
\setbeamercolor*{date}{fg=white}
\setbeamercolor*{structure}{fg=white}
\setbeamercolor*{section in toc}{fg=gray}
\setbeamercolor*{framtitle}{fg=white}
\setbeamercolor*{section}{fg=white}
\setbeamercolor*{normal text}{fg=gray}
\setbeamercolor*{foot}{fg=gray,bg=white}
\setbeamercolor*{title}{fg=white}
\setbeamercolor*{title page header}{fg=white}
%beamerinnertheme.sty
\defbeamertemplate*{title page}{test}[1][]
{
\begin{tikzpicture}[remember picture,overlay]
\node[fill=blue,minimum height=1cm,text width=\paperwidth] at ([yshift=2.5cm]current page.south) {\hspace{4cm}\usebeamerfont{title}\inserttitle};
\fill[color=green] (current page.south west) rectangle ++(2.95,1.9);
\node[fill=red,minimum height=1.9cm,text width=\paperwidth-6.5cm] at ([yshift=0.95cm]current page.south) {\hspace{0.9cm}\usebeamerfont{author}\insertauthor\par\vskip0.1cm \hspace{0.9cm}\usebeamerfont{author}\insertdate};
\node[anchor=south east, inner sep =0.1cm] at (current page.south east) {\includegraphics[width=2.8cm]{example-image-b}};
\begin{scope}
\clip ([yshift=3cm]current page.south west) rectangle (current page.north east);
\ifx\inserttitlegraphic\empty%
\node[anchor=south, inner sep=0cm] at ([yshift=3cm]current page.south) {\includegraphics[width=\paperwidth]{example-image-16x9}};
\else
\node[inner sep=0cm] at ([yshift=1.5cm]current page.center) {\inserttitlegraphic};
\fi
\end{scope}
\end{tikzpicture}
}
%beameroutertheme.sty
\defbeamertemplate*{frametitle}{test}[1][]
{
\begin{beamercolorbox}[wd=\paperwidth,ht=1.2cm]{frametitle}
\begin{tikzpicture}
\useasboundingbox[fill=white](0,0) rectangle(\the\paperwidth,1.2);
\fill[color=green] (0,0) rectangle(2.95,1.1); %5.2 old
\fill[color=red] (3.05,0) rectangle(\the\paperwidth-100,1.1);
% \fill[red] (3.05,1.15) rectangle(\the\paperwidth,0.8);
\ifx\insertframesubtitle\@empty%
{\node at (\the\paperwidth-50,0.61){\includegraphics[width=2.8cm]{example-image-b}};%
\node[anchor=west, white,font=\large] at (3.2,0.55){\insertframetitle};}%
\else%
{\node at (\the\paperwidth-50,0.61){\includegraphics[width=2.8cm]{example-image-b}};%
\node[anchor= west, white,font=\large] at (3.2,0.75){\insertframetitle};%
\node[anchor= west, white,font=\small] at (3.2,0.35){\insertframesubtitle};}%
\fi
\end{tikzpicture}
\end{beamercolorbox}
}
\setbeamertemplate{headline}{%
\leavevmode%
\hbox{%
\begin{beamercolorbox}[wd=\paperwidth,ht=5.2ex,dp=0.125ex]{palette}%
\insertsectionnavigationhorizontal{\paperwidth}{}{\hskip0pt plus1filll}
\end{beamercolorbox}%
}
}
\setbeamertemplate{section in head/foot}{%
\if\insertsectionheadnumber1
\tikz\node[draw=blue,fill=blue,shape=signal,very thick,text=white]{\insertsectionhead\hskip.3cm};
\else
\tikz\node[draw=blue,fill=blue,shape=signal,signal from=west, signal to=east,very thick,text=white] {\insertsectionhead\hskip.3cm};
\fi
}
\setbeamertemplate{section in head/foot shaded}{%
\if\insertsectionheadnumber1
\tikz\node[draw=blue,fill=white,shape=signal,very thick,text=blue]{\insertsectionhead\hskip.3cm};
\else
\tikz\node[draw=blue,fill=white,shape=signal,signal from=west, signal to=east,very thick,text=blue] {\insertsectionhead\hskip.3cm};
\fi
}
%End of beameroutertheme
\begin{document}
\begin{frame}[plain]
\titlepage
\end{frame}
\section{Sec 1}
\begin{frame}{Title}
\blindtext
\end{frame}
\section{Sec 2}
\begin{frame}{Title 2}
\framesubtitle{Subtitle}
\blindtext
\end{frame}
\end{document}
答案1
\documentclass[10pt,%
aspectratio=169,%
]{beamer}
\usepackage {mwe}
\usepackage{tikz}
\usepackage{xcolor}
\title{TITLE}
\author{NAME}
\institute{INSTITUT}
\date{DATE}
%\titlegraphic{\includegraphics[width=\paperwidth]{example-image-duck}}
%beamertheme.sty
\usetikzlibrary{shapes}
\setbeamertemplate{navigation symbols}{}
\setbeamertemplate{footline}{
\begin{beamercolorbox}[wd=\paperwidth, ht=2em, dp = 1em]{foot}
\hspace*{1em}
{\normalsize \inserttitle}\hfill{\normalsize \insertauthor, \insertdate} \hfill{\normalsize \insertpagenumber}
\hspace*{1em}
\end{beamercolorbox}}
%beamercolortheme.sty
\setbeamercolor*{author}{fg=white}
\setbeamercolor*{date}{fg=white}
\setbeamercolor*{structure}{fg=white}
\setbeamercolor*{section in toc}{fg=gray}
\setbeamercolor*{framtitle}{fg=white}
\setbeamercolor*{section}{fg=white}
\setbeamercolor*{normal text}{fg=gray}
\setbeamercolor*{foot}{fg=gray,bg=white}
\setbeamercolor*{title}{fg=white}
\setbeamercolor*{title page header}{fg=white}
\setbeamerfont{frametitle}{size=\large}
\setbeamerfont{framesubtitle}{size=\small}
%beamerinnertheme.sty
\defbeamertemplate*{title page}{test}[1][]
{
\begin{tikzpicture}[remember picture,overlay,inner sep=0pt,outer sep=0pt]
\node[fill=blue,minimum height=1cm,text width=\paperwidth] at ([yshift=2.5cm]current page.south) {\hspace{4cm}\usebeamerfont{title}\inserttitle};
\fill[color=green] (current page.south west) rectangle ++(2.95,1.9);
\node[fill=red,minimum height=1.9cm,text width=\paperwidth-6.3cm] at ([yshift=0.95cm]current page.south) {\hspace{0.9cm}\usebeamerfont{author}\insertauthor\par\vskip0.1cm \hspace{0.9cm}\usebeamerfont{author}\insertdate};
\node[anchor=south east, inner sep =0.1cm] at (current page.south east) {\includegraphics[width=2.8cm]{example-image-b}};
\begin{scope}
\clip ([yshift=3cm]current page.south west) rectangle (current page.north east);
\ifx\inserttitlegraphic\empty%
\node[anchor=south, inner sep=0cm] at ([yshift=3cm]current page.south) {\includegraphics[width=\paperwidth]{example-image-16x9}};
\else
\node[inner sep=0cm] at ([yshift=1.5cm]current page.center) {\inserttitlegraphic};
\fi
\end{scope}
\end{tikzpicture}
}
%beameroutertheme.sty
\defbeamertemplate*{frametitle}{weincampus}[1][]
{
\begin{tikzpicture}[remember picture,overlay,inner sep=0pt,outer sep=0pt]
\fill[color=green] ([yshift=-1.7cm]current page.north west) rectangle ++(2.95,1.2);
\node[fill=red,minimum height=1.2cm,text width=\paperwidth-6.3cm] at ([yshift=-1.1cm]current page.north) {\hspace{0.9cm}\usebeamerfont{frametitle}\insertframetitle\par
\hspace{0.9cm}\usebeamerfont{framesubtitle}\insertframesubtitle};
\node[anchor=north east, inner sep =0.1cm] at (current page.north east) {\includegraphics[width=2.8cm]{example-image-b}};
\end{tikzpicture}
\vskip1.2cm
}
\setbeamertemplate{headline}{%
\leavevmode%
\hbox{%
\begin{beamercolorbox}[wd=\paperwidth,ht=5.2ex,dp=0.125ex]{palette}%
\insertsectionnavigationhorizontal{\paperwidth}{}{\hskip0pt plus1filll}
\end{beamercolorbox}%
}
}
\setbeamertemplate{section in head/foot}{%
\if\insertsectionheadnumber1
\tikz\node[draw=blue,fill=blue,shape=signal,very thick,text=white]{\insertsectionhead\hskip.3cm};
\else
\tikz\node[draw=blue,fill=blue,shape=signal,signal from=west, signal to=east,very thick,text=white] {\insertsectionhead\hskip.3cm};
\fi
}
\setbeamertemplate{section in head/foot shaded}{%
\if\insertsectionheadnumber1
\tikz\node[draw=blue,fill=white,shape=signal,very thick,text=blue]{\insertsectionhead\hskip.3cm};
\else
\tikz\node[draw=blue,fill=white,shape=signal,signal from=west, signal to=east,very thick,text=blue] {\insertsectionhead\hskip.3cm};
\fi
}
%End of beameroutertheme
\begin{document}
\begin{frame}[plain]
\titlepage
\end{frame}
\section{Sec 1}
\begin{frame}{Title}
\blindtext
\end{frame}
\section{Sec 2}
\begin{frame}{Title 2}
\framesubtitle{Subtitle}
\blindtext
\end{frame}
\end{document}