Enrico Forestieri wrote:
> Lyx user writes:
>
>> I would like to insert code in my preamble that will replace every instance
>> of
>>
>> \caption{Short. Long long long long.}
>>
>> with
>>
>> \caption[Short]{Short. Long long long long.}
>>
>> However, I am not too familiar with LaTeX and TeX commands. Specifically, I
>> don't know how to extract the text before the '.' character. After that I
>> think
>> a macro and \renewcommand would finish the job. Can anyone help me?
>
> Sure. Put the following in the preamble:
>
> \let\oldcaption\caption
> \def\takeshort#1.#2\next{\gdef\short{#1}\gdef\everything{#1.#2}}
> \def\caption#1{\takeshort#1\next\oldcaption[\short]{\everything}}
This is so cool, I was looking for something like that as well!
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.
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?
Thanks!
Daniel