2

While I don't regret switching a thesis to KOMA script, I do (sometimes) regret stopping using the caption package even though it works fine with scrreprt! I need a solution that won't require using the caption package. Here is an MWE:

\documentclass{scrreprt}

\KOMAoption{captions}{tableheading, figuresignature}
\usepackage{graphicx}
\usepackage{lipsum}

\makeatletter
\newcommand\NOcaption[1]{%
  \renewcommand*{\figureformat}{}
  \renewcommand*{\tableformat}{}
  \renewcommand*{\captionformat}{}
  \addtocounter{\@captype}{-1}
  \caption{#1}}
\makeatother


\begin{document}
\listoffigures
\listoftables
\clearpage

\lipsum[1]
\begin{table}[ht]
\centering
\NOcaption{}
\begin{tabular}{c}
A table
\end{tabular}
\end{table}

\lipsum[2]
\begin{figure}[ht]
\centering
A figure
\NOcaption{}
\end{figure}

\lipsum[3]


\end{document}

Using the above combination, the caption does not appear in the main text, however, there's an entry for the figure/table in the lists.

Edit: The whole point of defining a new command NOcaption is to save my self from renewing figureformat, tableformat and captionformat at every table or figure. It was taken from this question. I can see why this is a bit confusing because the correct definition should be:

\makeatletter
\newcommand\NOcaption{% %NO arguments any more.
  \renewcommand*{\figureformat}{}
  \renewcommand*{\tableformat}{}
  \renewcommand*{\captionformat}{}
  \addtocounter{\@captype}{-1}
  \caption{}}
\makeatother

Then I would just use \NOcaption instead of \NOcaption{}

Putting things in terms of the caption package, I'm looking for an equivalent of list=no in KOMA scrpt, see this answer.


Edit: I should have put this in the MWE, I'm also using hyperref and hypcap. This is why I'm trying to put an 'empty' caption in the first place as hypcap gives an error if no caption was found.

Package hypcap Error: You have forgotten to use \caption.

\usepackage{hyperref}
\usepackage[all]{hypercap}
9
  • You could simply not use \caption inside \Nocaption but put the text inside a \parbox or whatever.
    – user2574
    Commented Jan 10, 2013 at 20:38
  • I must be missing something, why not just not use \caption ? Commented Jan 10, 2013 at 20:39
  • I don't want the caption to appear in the main text nor an entry for the figure/label in the list of figures/tables.
    – abdulhaq-e
    Commented Jan 10, 2013 at 20:40
  • Try \newcommand\NOcaption{\begingroup\def\addtocontents##1##2{}\expandafter\endgroup\caption} (not guaranteed).
    – yo'
    Commented Jan 10, 2013 at 20:44
  • @AbdulhaqElhouderi I don't understand your comment. Why simply not using \caption, as David and I suggested? Why not using \parbox{\linewidth}{#1} (or something else) instead of \caption{#1}?
    – user2574
    Commented Jan 10, 2013 at 20:49

1 Answer 1

3

If you do not want captions just omit the \caption command there is no need to redefine all the caption internals For hycap you need to turn off its mechanisms as described in its manual:

\documentclass{scrreprt}

\KOMAoption{captions}{tableheading, figuresignature}
\usepackage{graphicx,hycap}
\usepackage{lipsum}

\begin{document}
\listoffigures
\listoftables
\clearpage

\lipsum[1]
\capstartfalse
\begin{table}[ht]
\centering
\begin{tabular}{c}
A table
\end{tabular}
\end{table}
\capstarttrue

\lipsum[2]
\capstartfalse
\begin{figure}[ht]
\centering
A figure
\end{figure}
\capstarttrue

\lipsum[3]


\end{document}
4
  • I'm sorry for the confusion caused. hypcap gives an error if there's no caption. I know I forgot to include it in the MWE.
    – abdulhaq-e
    Commented Jan 10, 2013 at 21:36
  • 2
    I'd never heard of that package but its manual says you can use \captstartfalse just before the figure to turn off the behaviour see example top of page 3 Commented Jan 10, 2013 at 21:41
  • disabling the behaviour of \capstart made it possible not to use \caption at all as you suggested. Thanks a lot.
    – abdulhaq-e
    Commented Jan 10, 2013 at 21:46
  • @DavidCarlisle It's probably better to add the \capstartfalse and \capstrarttrue method.
    – egreg
    Commented Jan 10, 2013 at 21:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .