# Error appliying hang figure caption [closed]

I use the report class, and the caption package to get the result:

\usepackage[hang,small,bf]{caption}

\setlength{\captionmargin}{20pt}


and I get the error message :

LaTeX Error : Option clash for package option.

[hang,small,bf]
There has now been an attempt to load it with options
[options]
hang,small,bf,options
to your \documentclass declaration may fix this.
Try typing  <return>  to proceed.


I put the latex command in the lyx preamble and get that error message. the code works well in TeXmaker, but get the error message in Lyx. the code for compile in TeXmaker :

\documentclass{report}
\usepackage[hang,small,bf]{caption}
\setlength{\captionmargin}{20pt}

\begin{document}

\begin{figure}
\caption{hbcshjjjjjjjjjjjjbndhjfgcbdrhhhhhhhhhhhf jhcjdfbchdg jkhcdbfjdb     jhdfcbdfgdh hgfhjcbhd jdfhdjhdjnj jhfhdjbdhjd jkdfhdvbjh   jdfhvjgjfgjg hjdfcdfbhdg}

\includegraphics[5cm]{pics/logo.png}

\end{figure}

\end{document}


end the result is below ;

-
That error message appears when you load the package twice with different options. Can you provide a minimal example? – egreg Oct 4 '11 at 14:18
I've solved the error :) – Verly Oct 4 '11 at 15:53
@Verly No, you have included the solution in your question. To post it as an answer cut out your solution and paste it in an answer in the form below. – N.N. Oct 4 '11 at 16:09

## closed as too localized by lockstep, Joseph Wright♦Nov 5 '11 at 22:09

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, see the FAQ.

I've solved the problem. just insert the code below in the lyx preamble :

\usepackage[hang]{caption}

\newcommand{\as@hangcaption}[2]{%

11 \sbox{\as@captionbox}{#1\space}%


 What effect should defining \as@hangcaption have? Just drop this crap, \usepackage[hang]{caption} is totally sufficient. (Where the heck did you find this code?) – Axel Sommerfeldt Oct 4 '11 at 19:40 Furthermore it's totally unclear why \usepackage[hang,small,bf]{caption} gives you an option clash error message, but \usepackage[hang]{caption} not. – Axel Sommerfeldt Oct 4 '11 at 20:08 Lyx doesn't allow to use \setlength{\captionmargin}{20pt}. Lyx read it as we load the package twice with different option. I find the code from caption package documentation : ctex.org/documents/packages/float/caption2.pdf – Verly Oct 5 '11 at 2:51 This is not the caption package documentation but the documentation of the (obsolete) caption2 package. (Furthermore your link links to a version more that 15 years old!) The caption package documentation can be found here: mirrors.ctan.org/macros/latex/contrib/caption/caption-eng.pdf – Axel Sommerfeldt Oct 5 '11 at 5:35 Furthermore \setlength{\captionmargin}{20pt} can be replaced by the package option margin=20pt, e.g. \usepackage[hang,small,bf,margin=20pt]{caption}. – Axel Sommerfeldt Oct 5 '11 at 5:39