framesubtitle 上的条件语句:不良效果

framesubtitle 上的条件语句:不良效果

我想要得到这样的东西:

(a)框架标题或(b)框架标题|框架字幕

但是以下代码在每个带有/不带有 framesubtitle 的 frametitle 后都添加了 |,有人能帮我吗?发生了什么事?

                \documentclass[11pt]{beamer}
            
            \usepackage{color,xcolor,colortbl}
             \usepackage[absolute,overlay]{textpos}
               \usepackage[skins]{tcolorbox}
            
            \mode<presentation>
            \usetheme{default}
            
            %--------------------------------------
            %   Colors  Setup
            %--------------------------------------
               \definecolor {beamerred}   {rgb}{0.55,0,0.1}
               \setbeamercolor{structure}{fg=beamerred!90!black}
               % inner color
               \usecolortheme{orchid}
               % outer color
              \usecolortheme{whale}
            
            %--------------------------------------
            %   Fonts  Setup
            %--------------------------------------
                \usefonttheme[onlymath]{serif}              % math font
                \setbeamerfont{frametitle}{size=\Large
                                                               %series=\bfseries,
                                                               }  % frame title font size
                
                \setbeamerfont{footnote}{size=\tiny}        % footnote font size
            
            % inner theme
               \useinnertheme{rectangles}    % use rectangles
                %itemize list
                \setbeamertemplate{itemize item}[square]            % item symbol
                \setbeamertemplate{itemize subitem}[circle]         % subitem symbol
                \setbeamerfont{itemize item}{size=\normalsize}
                %enumerate list
                \setbeamertemplate{enumerate item}[numbered]        % item symbol
                \setbeamertemplate{enumerate subitem}[numbered]     % item symbol
                   \setbeamerfont{enumerate item}{size=\normalsize} % item symbol font size
            
                    
            %-------------------------------------------
            %        Outer Theme
            %-------------------------------------------
                        % navigation
                \setbeamertemplate{navigation symbols}{}
            
                   % frametitle
                      \setbeamertemplate{frametitle}{%%%%
                    \begin{textblock*}{0.88\paperwidth}(0cm,0\paperheight)
                        \begin{tcolorbox}[
                            arc=0pt,
                            boxrule=0pt,
                            left skip =0pt,
                            right skip=0pt,
                            %height=\frametitleheight,width=0.15\paperwidth,
                            height=0.10\paperheight,
                            width=0.88\paperwidth,
                            coltext=white,
                            skin=bicolor,
                            valign=center,
                            halign=left,
                            interior style={%%%
                                                   left color=structure!95!black,
                                                   right color=structure
                                                   }%%%
                            ]
                            \ifx\insertframesubtitle\@empty
                                 \insertframetitle    
                                       \else 
                                          \insertframetitle|\small \insertframesubtitle
                                       \fi
                        \end{tcolorbox}
                    \end{textblock*}
                    \hfill
                    \begin{textblock*}{0.118\paperwidth}(0.882\paperwidth,0\paperheight)
                        \begin{tcolorbox}[
                            arc=0pt,
                            boxrule=0pt,
                            left skip =0pt,
                            right skip=0pt,
                            %height=\frametitleheight,width=0.15\paperwidth,
                            height=0.10\paperheight,
                            width=0.12\paperwidth,
                            coltext=white,
                            skin=bicolor,
                            valign=center,
                            halign=right,
                            interior style={%%%
                                                   left color=structure,
                                                   right color=structure!90!white
                                                   }%%%
                            ]
                            \scriptsize \insertframenumber/\inserttotalframenumber
                        \end{tcolorbox}
                    \end{textblock*}
                    \vspace{0.10\paperheight}
                }%%%%
            
            % footline  
                \setbeamertemplate{footline}{
                       \vspace{2mm}
                    \begin{textblock*}{1.01\paperwidth}(0.92\paperwidth,0.96\paperheight)
                        {logo here}
                    \end{textblock*}
                }
            
            \mode
            <all> 
            
            %----------------------------------------
            %   Path of Figures
            %----------------------------------------
            
            
            %------------------------------------------
            %           begin of document
            %------------------------------------------
            \begin{document}
            \section{first }
            
            \begin{frame}
            \frametitle{Limits}
            \begin{itemize}
            \item first
            \item second
            \item third
            \end{itemize}
            \end{frame}
            
            \begin{frame}
            \frametitle{Limits}
            \framesubtitle{Monotone Sequence}
            
            \begin{itemize}
            \item first
            \item second
            \item third
            \end{itemize}
            \end{frame}
            %------------------------------------------
            %             end of  document
            %------------------------------------------
            \end{document}

答案1

您的问题在于您不是在\insertframesubtitle与进行比较\@empty,而是在与控制符号 进行比较\@,因为您没有\makeatletter将其变成@字母,以便它可以成为控制字的一部分。

因此,只要按照\makeatletter...\makeatother你的\setbeamertemplate{frametitile}意愿解决你的问题:

\documentclass[11pt]{beamer}

\usepackage{color,xcolor,colortbl}
\usepackage[absolute,overlay]{textpos}
\usepackage[skins]{tcolorbox}

\mode<presentation>
\usetheme{default}

%--------------------------------------
%   Colors  Setup
%--------------------------------------
\definecolor {beamerred}   {rgb}{0.55,0,0.1}
\setbeamercolor{structure}{fg=beamerred!90!black}
% inner color
\usecolortheme{orchid}
% outer color
\usecolortheme{whale}

%--------------------------------------
%   Fonts  Setup
%--------------------------------------
\usefonttheme[onlymath]{serif}              % math font
\setbeamerfont{frametitle}{size=\Large
%series=\bfseries,
}  % frame title font size

\setbeamerfont{footnote}{size=\tiny}        % footnote font size

% inner theme
\useinnertheme{rectangles}    % use rectangles
%itemize list
\setbeamertemplate{itemize item}[square]            % item symbol
\setbeamertemplate{itemize subitem}[circle]         % subitem symbol
\setbeamerfont{itemize item}{size=\normalsize}
%enumerate list
\setbeamertemplate{enumerate item}[numbered]        % item symbol
\setbeamertemplate{enumerate subitem}[numbered]     % item symbol
\setbeamerfont{enumerate item}{size=\normalsize} % item symbol font size


%-------------------------------------------
%        Outer Theme
%-------------------------------------------
% navigation
\setbeamertemplate{navigation symbols}{}

% frametitle
\makeatletter
\setbeamertemplate{frametitle}{%%%%
  \begin{textblock*}{0.88\paperwidth}(0cm,0\paperheight)
    \begin{tcolorbox}[
        arc=0pt,
        boxrule=0pt,
        left skip =0pt,
        right skip=0pt,
        %height=\frametitleheight,width=0.15\paperwidth,
        height=0.10\paperheight,
        width=0.88\paperwidth,
        coltext=white,
        skin=bicolor,
        valign=center,
        halign=left,
        interior style={%%%
          left color=structure!95!black,
          right color=structure
          }%%%
        ]
        \ifx\insertframesubtitle\@empty
        \insertframetitle    
        \else 
        \insertframetitle|\small \insertframesubtitle
        \fi
    \end{tcolorbox}
  \end{textblock*}
  \hfill
  \begin{textblock*}{0.118\paperwidth}(0.882\paperwidth,0\paperheight)
    \begin{tcolorbox}[
        arc=0pt,
        boxrule=0pt,
        left skip =0pt,
        right skip=0pt,
        %height=\frametitleheight,width=0.15\paperwidth,
        height=0.10\paperheight,
        width=0.12\paperwidth,
        coltext=white,
        skin=bicolor,
        valign=center,
        halign=right,
        interior style={%%%
          left color=structure,
          right color=structure!90!white
          }%%%
        ]
        \scriptsize \insertframenumber/\inserttotalframenumber
    \end{tcolorbox}
  \end{textblock*}
  \vspace{0.10\paperheight}
  }%%%%
\makeatother

% footline  
\setbeamertemplate{footline}{
  \vspace{2mm}
  \begin{textblock*}{1.01\paperwidth}(0.92\paperwidth,0.96\paperheight)
    {logo here}
  \end{textblock*}
}

\mode
<all> 

%----------------------------------------
%   Path of Figures
%----------------------------------------


%------------------------------------------
%           begin of document
%------------------------------------------
\begin{document}
\section{first }

\begin{frame}
  \frametitle{Limits}
  \begin{itemize}
    \item first
    \item second
    \item third
  \end{itemize}
\end{frame}

\begin{frame}
  \frametitle{Limits}
  \framesubtitle{Monotone Sequence}

  \begin{itemize}
    \item first
    \item second
    \item third
  \end{itemize}
\end{frame}
%------------------------------------------
%             end of  document
%------------------------------------------
\end{document}

在此处输入图片描述

相关内容