왜 Beamer의 \insertauthor가 비어 있지 않은 것으로 보고합니까?

왜 Beamer의 \insertauthor가 비어 있지 않은 것으로 보고합니까?

저는 각 제목 페이지 요소가 선택 사항인 비머 테마를 작업 중입니다. 예를 들어, 제목 슬라이드에 커다란 빈 공간을 만들기 위해 빈 날짜를 정의하고 싶지 않습니다. 나는 다음과 같이 조건부로 각 요소의 레이아웃을 래핑함으로써 이를 수행할 수 있다고 생각했습니다.

\ifx\insertdate\empty%
\else
   ...
   \insertdate
   \vskip{1em}
   ...
\fi

그리고 이 패턴은 예상대로 작동합니다... 작성자를 제외하면요. 어떤 이유로든 다른 제목 페이지 요소와 달리 는 \ifx\insertauthor\empty결코 평가되지 않는 것 같습니다 .true

\documentclass{beamer}
\author{}
\date{}
\begin{document}
  \ifx\insertauthor\empty
    empty
  \else
    nonempty
  \fi
  % outputs "nonempty"

  \ifx\insertdate\empty
    empty
  \else
    nonempty
  \fi
  % outputs "empty"
\end{document}

왜 이런거야? 빈 작성자를 테스트할 수 있는 해결 방법이 있나요?

답변1

의 정의 텍스트는 \insertauthor비어 있지 않습니다. 이는 매크로가 이미 제공되어야 하는 데이터로 작업을 수행하도록 되어 있기 때문에 매우 분명합니다.

beamerbasetitle.sty, 149행 및 다음에서 :

% The \author command
%
%
\def\author{\@dblarg\beamer@author}
\long\def\beamer@author[#1]#2{%
  \def\insertauthor{\def\inst{\beamer@insttitle}\def\and{\beamer@andtitle}#2}%
  \def\beamer@shortauthor{#1}%
  \ifbeamer@autopdfinfo%
    \def\beamer@andstripped{}%
    \beamer@stripands#2 \and\relax
    {\let\inst=\@gobble\let\thanks=\@gobble\def\and{, }\hypersetup{pdfauthor={\beamer@andstripped}}}
  \fi%
}

\author따라서 선택적 인수 유무에 관계없이 지정하면 \insertauthor정의됩니다(비어 있지 않음). 173번째 줄에서 우리는 다음을 찾습니다.

\author{}

우리는 그것이 \insertauthor초기화되었으며 작업 시작 시 결코 비어 있지 않다고 추론합니다 beamer.

다른 명령이 나타날 \beamer@shortauthor때까지 작업 시작 시 실제로 비어 있는 test 를 사용하는 것이 더 나을 것입니다 .\author

\documentclass{beamer}
\author{}
\date{}
\begin{document}

\makeatletter
\ifx\beamer@shortauthor\empty
  empty
\else
  nonempty
\fi
\makeatother

\end{document}

답변2

당신은 비머로부터 영감을 얻을 수 있습니다.https://github.com/josephwright/beamer/blob/1b04c51a596a51530adeff278ca2c43aa963c9b1/base/themes/inner/beamerinnerthemeinmargin.sty#L68-L74이 테스트를 반복하세요. 이는 사용자가 빈 짧은 저자를 선택하더라도 저자 이름이 제목 페이지에 인쇄된다는 장점이 있습니다.

\documentclass{beamer}
\author[]{test}
\date{}
\begin{document}

\makeatletter
\expandafter\ifblank\expandafter{\beamer@andstripped}{
  empty
}{%
  nonempty
}
\makeatother

  \ifx\insertdate\empty
    empty
  \else
    nonempty
  \fi
  % outputs "empty"
\end{document}

(클래스 옵션 사용자에게 문제가 있었습니다 usepdftitle=false. 이는 이미 비머 개발 버전에서 수정되었으며 비머 v3.72 이상에 포함되어야 합니다)

관련 정보