TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The syntax for a caption is

\caption[listoffigures/tables text]{Text actually displayed under picture/table}

But what I would like to have is something like this: If I use the above command, the text under the floating object should be

Label #.: listof text -- long text

With # being just the number and with -- being an arbitrary separator (either the -- dash itself or maybe even a \newline). Is this possible?

I'm using KOMAScript.

share|improve this question
... and if no [] is given? – yo' Jan 11 '13 at 16:04
Just the long text, of course. – Foo Bar Jan 11 '13 at 16:09
up vote 3 down vote accepted

See the commented code. If you load any float-related packages (float, floatrow, caption, algorithmic, ...) or do things like \newfloat, \restylefloat etc., this my tweak must come after all that.


\let\x@caption\caption % original \caption
\def\x@@caption[#1]#2{\x@caption[{#1}]{#1 --- #2}} % with optional arg
\def\x@@@caption#1{\x@caption[{#1}]{#1}} % without optional arg
\def\caption{\@ifnextchar[\x@@caption\x@@@caption} % new \caption



\caption[Optional text.]{Obligatory text.}

\caption{Obligatory text only.}

share|improve this answer
Thank you very much. :) – Foo Bar Jan 11 '13 at 16:20
What is the meaning of \x@ or\x@@, etc... The number of @ is for what? – Sigur Jan 11 '13 at 16:39
@Sigur the character @ behaves like a letter between \makeatletter ... \makeatother, therefore all three strings \x@caption, ... are just macro names. Further reading: tex.stackexchange.com/q/8351/11002 – yo' Jan 11 '13 at 16:44

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.