
\FS
저는 몇 가지 명령을 작성했으며 최근에는 그림 소스를 추가하기 위한 몇 가지 편리한 명령을 추가했습니다 .
\newcommand{\FS}[1]{%
\protect\\{\protect\scriptsize{}Bildquelle: #1}}
이것이 맞는지(모두)는 모르겠지만 \protect
내부에서는 작동하는 것 같습니다 \caption
. 불행하게도 저는 선택적 매개변수를 추가하여 명령을 개선하려고 했습니다.
\newcommand{\FS}[2][Bildquelle]{%
\protect\ifthenelse{\equal{#1}{}}%
\protect\\{\protect\scriptsize{}#2}
\protect\\{\protect\scriptsize{}#1: #2}}
#2
선택적 매개변수가 지정되지 않은 변형을 사용하면 확장이 출력되고 그 뒤에 확장되는 효과가 있습니다 Bildquelle: #2
(실제로 선택적 매개변수를 지정하는 경우에도 출력은 설명된 대로 복제됩니다). 예를 들어:
나는 TeX에 대한 답변을 읽은 후에도 문제를 스스로 해결할 수 있을 만큼 충분히 깊이 있지 않습니다 \protect
. 명령은 어떻게 작성해야 합니까?
답변1
필요 \ifthenelse{<condition>}{<true>}{<false>}
하고 그룹화되어야 합니다 <true>
. <false>
그렇지 않은 경우 다음의 두 토큰은 및 을 <condition>
나타내는 것으로 가정됩니다 . 설정에서 is 및 is 입니다 . 당신은 아마도 다음과 같은 것을 찾고 있었을 것입니다.<true>
<false>
<true>
\protect
\\
<false>
\newcommand{\FS}[2][Bildquelle]{%
\protect\ifthenelse{\equal{#1}{}}%
{\protect\\{\protect\scriptsize{}#2}}
{\protect\\{\protect\scriptsize{}#1: #2}}}
조건부 테스트 사용매크로 값이 비어 있는지 또는 일반 TeX 조건문을 사용하여 텍스트를 생성하지 않는지 확인하는 방법은 무엇입니까?, 대신 다음과 같이 정의할 수 있습니다 \FS
.
\newcommand{\FS}[2][Bildquelle]{%
\\
\scriptsize
\if\relax\detokenize{#1}\relax\else
#1:
\fi
#2%
}
다음은 사용에 대한 완전한 최소 예입니다.
\documentclass{article}
\usepackage{caption}
\newcommand{\FS}[2][Bildquelle]{%
\\
\scriptsize
\if\relax\detokenize{#1}\relax\else
#1:
\fi
#2%
}
\begin{document}
\begin{figure}
\caption{Some caption. \FS{abc}}
\caption{Another caption. \FS[abc]{def}}
\caption{Final caption. \FS[]{ghi}}
\end{figure}
\end{document}