![如何将部分导航栏与标题居中对齐](https://linux22.com/image/335093/%E5%A6%82%E4%BD%95%E5%B0%86%E9%83%A8%E5%88%86%E5%AF%BC%E8%88%AA%E6%A0%8F%E4%B8%8E%E6%A0%87%E9%A2%98%E5%B1%85%E4%B8%AD%E5%AF%B9%E9%BD%90.png)
我的标题中有一个部分导航栏,我希望它显示部分居中对齐。虽然部分导航栏是右对齐的,但我尝试使用以下代码手动设置位置,将其置于中心:
\setbeamertemplate{headline}{%
\leavevmode%
\hbox{%
\begin{beamercolorbox}[wd=\paperwidth,ht=12.5ex]{section in head/foot}%
\insertsectionnavigation{0.5\paperwidth}
\end{beamercolorbox}%
}
}
如何使部分导航栏中的文本(部分)居中对齐?
答案1
\hfill
我在周围添加了两个\usebeamertemplate{section in head/foot}
,使它们位于中心。
\documentclass{beamer}
\usetheme{Berlin}
\setbeamertemplate{headline}{%
\leavevmode%
\hbox{%
\begin{beamercolorbox}[wd=\paperwidth,ht=12.5ex]{section in head/foot}%
\insertsectionnavigation{\paperwidth}
\end{beamercolorbox}%
}
}
\makeatletter
\def\insertsectionnavigation#1{%
\hbox to #1{%
\vbox{{\usebeamerfont{section in head/foot}\usebeamercolor[fg]{section in head/foot}%
\vskip0.5625ex%
\def\slideentry##1##2##3##4##5##6{}%
\def\sectionentry##1##2##3##4##5{%
\ifnum##5=\c@part%
\def\insertsectionhead{##2}%
\def\insertsectionheadnumber{##1}%
\def\insertpartheadnumber{##5}%
\setbox\beamer@tempbox=\hbox{%
\hyperlink{Navigation##3}{\hbox to #1{%
\hskip0.3cm%
\ifnum\c@section=##1%
{\hfill\usebeamertemplate{section in head/foot}\hfill}%
\else%
{\hfill\usebeamertemplate{section in head/foot shaded}\hfill}%
\fi\hskip0.3cm}}}%
\ht\beamer@tempbox=1.6875ex\dp\beamer@tempbox=0.75ex%
\box\beamer@tempbox\fi}%
\dohead\vskip0.5625ex}}\hfil}}
\makeatother
\begin{document}
\section{loooooooooooooong}
\frame{as}
\section{er}
\frame{sd}
\end{document}