![Beamer에서 조건부로 하위 섹션 인쇄](https://rvso.com/image/298822/Beamer%EC%97%90%EC%84%9C%20%EC%A1%B0%EA%B1%B4%EB%B6%80%EB%A1%9C%20%ED%95%98%EC%9C%84%20%EC%84%B9%EC%85%98%20%EC%9D%B8%EC%87%84.png)
저는 우리 대학의 템플릿을 PowerPoint에서 Beamer로 이식하고 헤더에 섹션(및 존재하는 경우 하위 섹션)을 표시하는 코드를 추가했습니다.
headline
이 목적을 위해 템플릿 에 넣은 코드 조각은 다음과 같습니다 .
\begin{beamercolorbox}[wd=0.6\paperwidth,ht=0.1\beamer@PoliMI@headheight]{section in head/foot}%
\usebeamerfont{section in head/foot}\par%
\vfill\strut\insertsectionhead%
\ifx\insertsubsection\empty\else%
~--~\insertsubsectionhead%
\fi%
\strut\par%
\end{beamercolorbox}\\%
그러나 하위 섹션에서 "종료"할 때( 발행 \subsection*{}
) 섹션 이름 뒤의 대시는 여전히 인쇄됩니다.
하위 섹션 이름이 무효인지 어떻게 테스트할 수 있나요?
대안으로 어떻게 비울 수 있습니까 \insertsubsection
?
MWE:
\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}\normalfont
\usepackage[T1]{fontenc}
\setbeamertemplate{navigation symbols}{}
\setbeamertemplate{headline}{%
\begin{beamercolorbox}[wd=0.6\paperwidth,ht=0.016\paperwidth]{section in head/foot}%
\usebeamerfont{section in head/foot}%
\par\vfill\strut\insertsectionhead%
\ifx\insertsubsection\empty\else~--~\insertsubsectionhead%
\fi\strut\par%
\end{beamercolorbox}%
}
\begin{document}
\section{aaa}
\begin{frame}~\end{frame}
\subsection{bbb}
\begin{frame}~\end{frame}
\subsection*{}
\begin{frame}~\end{frame}
\end{document}
세 번째 프레임에는 "aaa -"가 아닌 "aaa"만 표시되어야 합니다.
업데이트: 하위 섹션이 아직 정의되지 않은 경우 \insertsubsection
는 비어 있는 반면, a가 \subsection*{}
실행되면 매크로가 에서 확장되고 \expandafter \hyperlink \subsectionlink
, 하위 섹션이 비어 있거나( \insertsubsectionhead
로 확장됨 \hyperlink {Navigation\the \c@page }{}
) 비어 있지 않습니다( 두 번째 프레임에서 \insertsubsectionhead
으로 확장됨 ).\hyperlink {Navigation\the \c@page }{bbb}
답변1
코드 조각을 다음으로 대체했습니다.
\ifx\insertsubsection\empty\else%
\ifdefempty{\subsecname}{\relax}{%
~--~\insertsubsectionhead%
}%
\fi
그리고 그것은 작동합니다 !!!
불행히도 etoolbox
패키지를 로드해야 합니다...
편집하다:
\setbox0=\hbox{\subsecname\unskip}\ifdim\wd0=0pt\else%
~--~\insertsubsectionhead%
\fi%
또한 작동하며 필요하지 않습니다 etoolbox
.
이것이 "깨끗한" 해결책인지는 모르겠습니다.
답변2
댓글을 달 수는 없지만 @Astrinus의 두 번째 솔루션에 문제가 있었고 그럼에도 불구하고 공유하고 싶었습니다.
\subsecname
새 섹션이 생성될 때 기본적으로 삭제되지 않습니다. \insertsubsectionhead
그것을 해결하기 위해 그것을 교체 했습니다.
\setbox0=\hbox{\insertsubsectionhead\unskip}\ifdim\wd0=0pt\else%
- \insertsubsectionhead%
\fi%
답변3
다음을 통해 하위 섹션의 끝을 인식하는 데 문제가 있었습니다.
\ifx\insertsubsection\empty
중괄호로 SubSection을 제한하면 작동합니다.
{
\subsection{SubSection Title}
<subsection frames>
}
<other frames>
해당 하위 섹션 내부와 외부 프레임 사이의 조건이 올바르게 달랐습니다.