Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question
    
You could simply not use \caption inside \Nocaption but put the text inside a \parbox or whatever. –  Axel Sommerfeldt Jan 10 '13 at 20:38
    
I must be missing something, why not just not use \caption ? –  David Carlisle Jan 10 '13 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. –  pythonista Jan 10 '13 at 20:40
    
Try \newcommand\NOcaption{\begingroup\def\addtocontents##1##2{}\expandafter\endgrou‌​p\caption} (not guaranteed). –  tohecz Jan 10 '13 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}? –  Axel Sommerfeldt Jan 10 '13 at 20:49
show 4 more comments

1 Answer

up vote 3 down vote accepted

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}
share|improve this answer
    
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. –  pythonista Jan 10 '13 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 –  David Carlisle Jan 10 '13 at 21:41
    
disabling the behaviour of \capstart made it possible not to use \caption at all as you suggested. Thanks a lot. –  pythonista Jan 10 '13 at 21:46
    
@DavidCarlisle It's probably better to add the \capstartfalse and \capstrarttrue method. –  egreg Jan 10 '13 at 21:56
add comment

Your Answer

 
discard

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.