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.

The following MWE:

\documentclass[11pt]{memoir}

\usepackage{caption}

\captionsetup[table]{
         listformat=empty,
         tablename=Table,
         justification=justified,
         labelsep=quad,
         position=above,
         skip=\onelineskip,
         width=\linewidth,
         labelfont={small},
         font={small}
         }

\begin{document}

    \begin{table}
        \caption{A table.}
    \end{table}

\end{document}

generates the error message ! Package caption Error: Can be used only in preamble. If I comment the \captionsetup command, there is no such error message. I know the class memoir provides its own tools for captions, but I'd rather use the package caption for them. Anyone could possibly shed some light on this issue?

EDIT: As soon as I comment the key tablename, the problem disappears. But even though it works, I wouldn't call it precisely a satisfactory solution.

share|improve this question
add comment

2 Answers

up vote 15 down vote accepted

Edit: Thanks to Gonzalo Medina, I think I have an explanation. :)

tablename and figurename are indeed valid entries for \captionsetup, as long as you are using it without the optional argument. The idea: \captionsetup without the optional argument works globally, so it makes sense to set both figure and table names via figurename and tablename respectivelly.

The following code works:

\captionsetup{
   tablename=Table,
   listformat=empty,
   justification=justified,
   labelsep=quad,
   position=above,
   skip=\onelineskip,
   width=\linewidth,
   labelfont={small},
   font={small}
}

We are setting the caption layout globally.

Now, when we provide the optional argument, we are limiting our scope to the float we are setting up. Say, if we use \captionsetup[table]{...}, we are configuring the captions within the table scope, so there's no point of using tablename, but only name.

We can use the name key instead of tablename, since we are configuring table:

\documentclass[11pt]{memoir}

\usepackage{caption}

\captionsetup[table]{
   name=Table,
   listformat=empty,
   justification=justified,
   labelsep=quad,
   position=above,
   skip=\onelineskip,
   width=\linewidth,
   labelfont={small},
   font={small}
}

\begin{document}

\begin{table}
\caption{A table.}
\end{table}

\end{document}

If we want to use tablename instead, we must use \captionsetup without the optional argument:

\documentclass[11pt]{memoir}

\usepackage{caption}

\captionsetup{
   tablename=Table,
   listformat=empty,
   justification=justified,
   labelsep=quad,
   position=above,
   skip=\onelineskip,
   width=\linewidth,
   labelfont={small},
   font={small}
}

\begin{document}

\begin{table}
\caption{A table.}
\end{table}

\end{document}

Just for reference, another way to rename the table name is with \renewcommand{\tablename}{Table}. However, as AstroPig mentioned in the comments, it doesn't work if we use babel with the french language.

share|improve this answer
    
Interestingly, the tablename option is apparently used for French tables (ref. lines 66, 67, and 1043 in caption.sty). I wonder what would happen if the default language was set to French through babel. –  AstroPig7 Aug 13 '12 at 19:36
    
Actually, I have used tablename and figurename as keys for that command in several classes of my own loading all of them the class memoirwithout that problem appearing, and typing the float name as set in the corresponding key. I don't really know what the problem is. –  Marcos Aug 13 '12 at 19:45
1  
@AstroPig7: you are absolutely right, redefining \tablename as it is doesn't work with babel and french. Thankfully, I found that the caption package provides a name key exactly for this purpose - and it works with French too. :) –  Paulo Cereda Aug 13 '12 at 20:09
    
@Marcos: I really can't tell what happened. The tablename key is not part of the caption package specification. However, it provides a generic name key which can be used for renaming your float. I updated the answer accordingly, please make sure to use the name key instead of my first suggestion. :) –  Paulo Cereda Aug 13 '12 at 20:11
    
@Marcos: Thanks to Gonzalo Medina, we found the explanation for tablename vs. name. See my new edit. :) –  Paulo Cereda Aug 13 '12 at 22:09
show 1 more comment

Some of the options for the caption package conflict with the definition of the memoir document class. The following Google Groups post should help.

Ref. 1: Google Groups.

share|improve this answer
    
I have checked your link, which led me to consider commenting some of the keys in the command. See my EDIT, please. –  Marcos Aug 13 '12 at 19:20
3  
Please provide a complete answer. You can use the link as a reference. –  Marco Daniel Aug 13 '12 at 19:21
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.