Daniel Lohmann writes:

> I would also like to highlight the first sentence and add some extra
> space to visually separate it from the additional text. The following
> shows the relevant parts of my preamble (I use koma-script):
> 
> % Figure captions
> \let\oldcaption\caption
> \def\takeshort#1.#2\next{\gdef\short{#1}\gdef\everything{\bfseries{#1}.~~#2}}
> \def\caption#1{\takeshort#1\next\oldcaption[\short]{\everything}}
> 
> \addtokomafont{caption}{\footnotesize\sffamily}
> \addtokomafont{captionlabel}{\sffamily\bfseries}
> \setcapindent{2em}
> 
> Issue is, that with \everything{\bfseries{#1}.~~#2}, not only the first
> part, but the whole text becomes typesetted in bold face. If, however, I
> use \emph instead of \bfseries it works -- only the first part becomes
> italics, as it should.

Try the following:

\let\oldcaption\caption
\def\takeshort#1.#2\next{\gdef\short{#1}\gdef\everything{{\bfseries #1}.~~#2}}
\def\caption#1{\takeshort#1\next\oldcaption[\short]{\everything}}

> I am a bit confused... Why there is such a big difference in the effects
> of \bfseries and \emph?  Any ideas how I can typeset only the first part
> in bold face?

Because \bfseries doesn't take an argument. It affects everything in its
scope, so the trick is limiting the scope by braces.

Note that the above macros also work when there is only one dot in the
caption. In this case, maybe you don't want a boldened caption, so the
following could be more appropriate:

\let\oldcaption\caption
\def\takeshort#1.#2\next{\gdef\short{#1}\def\two{#2\relax}%
     \gdef\everything{\if\two\relax #1.\else{\bfseries #1}.~~#2\fi}}
\def\caption#1{\takeshort#1\next\oldcaption[\short]{\everything}}

-- 
Enrico

Reply via email to