
\secimage
내 섹션 제목 페이지에 이미지를 정의했습니다 .
\AtBeginSection[]{
\begin{frame}
\vfill
\begin{center}
%\centering
\includegraphics[width=4cm]{\secimage}\\
\begin{beamercolorbox}[sep=8pt,center,shadow=true,rounded=true]{title}
\usebeamerfont{title}\insertsectionhead\par%
\end{beamercolorbox}
\end{center}
\vfill
\end{frame}
}
그리고 각 섹션에 대해 \renewcommand{\secimage}{figureofchoice}
. 하지만 섹션 중 하나에서 너비/높이를 다시 정의하고 싶습니다. \renewcommand{\secimage}[heigth=4cm]{image}
renewcommand 문서에서 옵션을 정의하는 것처럼 시도했지만 컴파일 오류가 발생했습니다.
누군가 내가 뭘 잘못하고 있는지 말해 줄 수 있다면
답변1
다음 코드는 표기법 변경을 제안합니다. 대신 추가 옵션을 지정할 수 있는 곳을 \renewcommand{\secimage}{<image>}
사용합니다 .\setsecimage{[<options>]{<image>}}
\newcommand{\setsecimage}[1]{\gdef\secimagedetail{#1}}% Store section image detail
\let\secimagedetail\relax% Default definition of section image detail
\AtBeginSection{
\begin{frame}
\vfill
\begin{center}
\ifx\secimagedetail\relax\else % If section image exists
\expandafter\includegraphics\secimagedetail \\
\fi
\begin{beamercolorbox}[sep=8pt,center,shadow=true,rounded=true]{title}
\usebeamerfont{title}\insertsectionhead\par%
\end{beamercolorbox}
\end{center}
\vfill
\end{frame}
\let\secimagedetail\relax% Remove section image detail
}
일반적인 사용법은 다음과 같습니다.
\setsecimage{[width=50pt]{example-image}}
\section{A section}
\section{Another section}
\setsecimage{{example-image}}
\section{Final section}
\setsecimage
위 코드의 마지막 섹션에 대해 아무것도 포함하지 않은 경우 에도 에서와 같이 인수를 <options>
"이중 중괄호"로 묶어야 합니다 .<image>
\setsecimage{{<image>}}
답변2
\setsecimage
와 동일한 구문을 사용하여 명령을 정의합니다 \includegraphics
. 비결은 다른 매크로를 재정의한다는 것입니다.
\documentclass{beamer}
\AtBeginSection[]{
\begin{frame}
\vfill
\begin{center}
%\centering
\addsecimage\\
\begin{beamercolorbox}[sep=8pt,center,shadow=true,rounded=true]{title}
\usebeamerfont{title}\insertsectionhead\par%
\end{beamercolorbox}
\end{center}
\vfill
\end{frame}
}
\newcommand{\setsecimage}[2][width=4cm]{%
\renewcommand{\addsecimage}{\includegraphics[#1]{#2}}%
}
\newcommand{\addsecimage}{} % initialize
\begin{document}
\setsecimage{example-image}
\section{Normal}
\setsecimage[width=2cm]{example-image-a}
\section{Small}
\end{document}