如何修改Beamer中\insertnavigation生成的标题栏颜色?
解决Beamer CambridgeUS模板导航栏颜色修改问题
要修改你通过\insertnavigation添加的导航栏颜色,关键是要针对Beamer中控制导航栏元素的特定颜色样式设置,你之前尝试的structure、headline等并不对应导航栏的文字和背景。
具体来说,CambridgeUS主题的导航栏内容由section in head/foot和subsection in head/foot这两个颜色元素控制,直接设置它们的背景(bg)和前景(fg)即可生效:
\xdefinecolor{scu}{RGB}{149,42,31} % 设置导航栏的背景与文字颜色 \setbeamercolor{section in head/foot}{bg=scu, fg=white} \setbeamercolor{subsection in head/foot}{bg=scu, fg=white} % 可选:设置未激活章节/小节的淡化样式 \setbeamercolor{section in head/foot shaded}{bg=scu!80, fg=white!80} \setbeamercolor{subsection in head/foot shaded}{bg=scu!80, fg=white!80}
另外,你用minipage包裹\insertnavigation的方式可以简化,直接设置headline模板为导航栏即可,通过\vspace调整高度更灵活:
\setbeamertemplate{headline}{ \vspace{0.1cm} \insertnavigation{\paperwidth} \vspace{0.1cm} }
整合修改后的完整代码如下:
\documentclass{beamer} \usepackage[utf8]{inputenc} \usepackage{csquotes} \usepackage{dirtytalk} \usepackage{xcolor} \usepackage{tgpagella} \usepackage{adjustbox} \usepackage{multirow} \usepackage{dcolumn} \usetheme{CambridgeUS} \usecolortheme{default} %----------------Set Colors \xdefinecolor{scu}{RGB}{149,42,31} \setbeamercolor{title}{bg=scu,fg=white} % 设置导航栏颜色 \setbeamercolor{section in head/foot}{bg=scu, fg=white} \setbeamercolor{subsection in head/foot}{bg=scu, fg=white} \setbeamercolor{section in head/foot shaded}{bg=scu!80, fg=white!80} \setbeamercolor{subsection in head/foot shaded}{bg=scu!80, fg=white!80} %----------------Add Headline \setbeamertemplate{headline}{ \vspace{0.1cm} \insertnavigation{\paperwidth} \vspace{0.1cm} } %----------------Title page \title[Title Sidebar] %optional {Main Title} \author[Author Sidebar] % (optional) { \vspace{0.2cm} {\large \textbf{Author}\\ {\footnotesize Institution}}} \date[August 29, 2023] % (optional) {\footnotesize{Conference} \\ Place\\} %--------------------------------------------------------------- \begin{document} \begin{frame} \titlepage \end{frame} \section*{Introduction} \begin{frame}{Introducing frame} \end{frame} \section{Section 1} \begin{frame} \end{frame} \section{Section 2} \begin{frame} \end{frame} \section{Conclusion} \begin{frame}{Concluding frame} \end{frame} \end{document}
修改后,导航栏背景会变为你定义的scu红色,文字为白色,未激活章节会显示稍浅的淡化样式,完全匹配你的需求。
内容的提问来源于stack exchange,提问作者last_resource
相关产品推荐
相关产品推荐

