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.

In the following code the package that give the problems is

\usepackage[font=small,format=plain,labelfont=bf,up,textfont=it,up,width=0.85\textwidth]{caption}

What I want to do is change captionwidth so that it is less wide than the normal text. The problem comes when I want to use subfloat to put several pictures next to each other. The subcaptions don't stay underneath the pictures, but overlay or swap or... do things they shouldn't be doing. My question is, if there is a way to change captionwidth, without this problem in subfloat?

\documentclass[a4paper,11pt,twoside]{book}
\usepackage[dutch,british]{babel}
\usepackage{hyperref}
\usepackage{url}
\usepackage{amssymb,amsmath}
\usepackage{amsthm}
\usepackage[width=0.85\textwidth]{caption} %THIS IS THE PACKAGE WITH THE PROBLEM
\usepackage[margin=3cm]{geometry}
\usepackage{float}
\usepackage{subfig}
\usepackage{graphicx}

\selectlanguage{british}

\begin{document}

\begin{figure}[!ht]
  \centering
 \subfloat[fig1, not ok]{\label{fig1}\includegraphics[height=0.15\textwidth]{fig1}}\quad
 \subfloat[fig2, not ok]{\label{fig2}\includegraphics[height=0.15\textwidth]{fig2}}
  \caption{This caption is ok \cite{cursus, cd}.}
  \label{figTotal}
\end{figure}

\end{document}
share|improve this question
2  
Note that you should try and keep your examples minimal. For example, you don't need babel, hyperref, url, amssymb, amsmath, amsthm, nor float with this example. Also, you don't need to use \cite (since you don't supply a bibliography and it has no relevance here). More importantly, since this problem deals with widths, not supplying the figures fig1 and fig2 is a problem. Rather use something like \rule{50pt}{20pt} to create a 50pt x 20pt rectangle to "simulate" your images. Subsequently, you won't even need the graphicx package. –  Werner Apr 12 '12 at 15:40

1 Answer 1

Separate the setting for figure and subfigure captions:

\usepackage{caption}
\usepackage{subfig}
\captionsetup[figure]{width=.85\textwidth}
\captionsetup[subfigure]{margin=0pt}
share|improve this answer
1  
...or add margin=0pt to the options of the subfig package, e.g. \usepackage[margin=0pt]{subfig}. This will not only fix the problem for subfigures alone, but for subtables and subwhatevers as well. –  Axel Sommerfeldt Apr 13 '12 at 7:04

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.