7

I have a little problem how to create a caption to my table. It looks ok as of now, but I would like to indent the heading of a new paragraph. Also right now, I cannot even create a new paragraph because an error pops up. I read that I have to give an optional argument to the caption to prevent the error (is there another method? I don't want to have additional names in my LOT)

But my main question is if it is possible to start new intendet paragraphs within a caption, BUT WITHOUT having the very first paragraph below the numbering indented. There is no such example in the documentation of the package caption, also \DeclareCaptionFormatdoes not work in this case because we don't wanna change #3 in general but rather the following paragraphs.

If you compile my example you will see a nice little table. Again, the only change I would like to make is indentation of further paragraphs in case of rather long captions.

Thanks for any hints.

\documentclass[a4paper, headsepline, smallheadings]{scrreprt}
\usepackage{mathptmx}
\usepackage{booktabs}
\usepackage[labelfont=bf, labelsep=newline,singlelinecheck=false,format=plain,indention=2cm]{caption}
\usepackage{floatrow}

\KOMAoption{captions}{tableheading}
\setcapindent{0em}

\begin{document}
\begin{table}[htpb]
\begin{floatrow}
\ttabbox{%
\begin{tabular}{lcccc}
& \multicolumn{4}{c}{xax} \\
\cmidrule(rl){2-5}
& 3543 & 34535 & 1233 & 32525 \\
\midrule
AA  & 543235sdgf35 & sdf35sf & sf35 & sdfsf543s \\
BB  & gsfg35sf & dfgdfg &
235sf & 235f \\
CC & sdfdsf & sffsf & sdfsdf & 353w5fs \\
\bottomrule
\end{tabular}}
{\caption{Here is the table caption. It should be indented from the following paragraph: \\ 'indented new paragraph'.}}
\end{floatrow}
\end{table}
\end{document}

edit: I am using the floatrow-package because it allows you to start the caption in the next line below the numbering of the table. ttabbox has 2 arguments, the 1st is the table and the 2nd is the caption, that's really all there is to know about that, looks more complicated than it is.

  • Welcome to the site! Thanks for providing an example to work with :) Have you looked at the hang option? – cmhughes Oct 11 '13 at 19:07
  • @cmhughes Hi, thank you. Yes I have, but I think it works from the very first paragraph already. My problem is I only want it to work from the second. Ideally, you could choose which paragraphs to indent and which not to. – TomM Oct 11 '13 at 19:22
  • Inserting something like \hspace*{1em} after \\ inside the \caption might be a solution? – karlkoeller Oct 12 '13 at 7:48
2

The problem is that some of the macros governing the typesetting of the caption aren't \long, that is, they don't accept \par in their argument.

A quick workaround is to add an empty optional argument to \caption, which however would be bad if you want to typeset the list of tables.

A different workaround is to say

\DeclareRobustCommand{\captionpar}{\par}

in the preamble and use \captionpar instead of \par or an empty line in the caption. This hides \par from TeX's eyes when it's absorbing the argument; it's similar to using \endgraf, the difference is that ultimately the “real” \par will be used (\endgraf might not have the current meaning of \par).

A more drastic solution is to make the relevant commands \long:

\usepackage{etoolbox}
\makeatletter
\patchcmd[\long]{\caption@prepareanchor}{}{}{}{}
\patchcmd[\long]{\caption@@@addcontentsline}{}{}{}{}
\patchcmd[\long]{\addcontentsline}{}{}{}{}
\makeatother

With this patch you can even type

\caption{Here is the table caption. It should be indented from
         the following paragraph:

         'indented new paragraph'.}

instead of the more awkward

\caption{Here is the table caption. It should be indented from
         the following paragraph:\captionpar
         'indented new paragraph'.}

required by the solution above.

In any case, you need to define a parindent for the caption:

\usepackage[
  labelfont=bf,
  labelsep=newline,
  singlelinecheck=false,
  format=plain,
  indention=2cm,
  parindent=1em, % <--- adjust to suit
]{caption}

enter image description here

2

This is one of the few situations where paragraphs need to be closed with \endgraf instead of \par. You also need to set \parindent to a non-zero length:

Sample output

\documentclass[a4paper, headsepline, smallheadings]{scrreprt}
\usepackage{mathptmx}
\usepackage{booktabs}
\usepackage[labelfont=bf, labelsep=newline,singlelinecheck=false,format=plain,indention=2cm]{caption}
\usepackage{floatrow}

\KOMAoption{captions}{tableheading}
\setcapindent{0em}

\begin{document}

\begin{table}[htpb]
  \begin{floatrow}
    \ttabbox{%
    \begin{tabular}{lcccc}
      & \multicolumn{4}{c}{xax} \\
      \cmidrule(rl){2-5}
      & 3543 & 34535 & 1233 & 32525 \\
      \midrule
      AA  & 543235sdgf35 & sdf35sf & sf35 & sdfsf543s \\
      BB  & gsfg35sf & dfgdfg &
      235sf & 235f \\
      CC & sdfdsf & sffsf & sdfsdf & 353w5fs \\
      \bottomrule
    \end{tabular}}
    {\caption{Here is the table caption. It should be indented from the
    following paragraph: \endgraf\setlength{\parindent}{1em}
    `indented new paragraph' with more text, a little more text and
    some words. \endgraf
    Another paragraph.}} 
  \end{floatrow}
\end{table}

\end{document}

You will find some discussion of \endgraf at When is it better to use \par than \endgraf?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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