Tell me more ×
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.

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

enter image description here

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

\setlength{\captionmargin}{20pt}

and I get the error message :

LaTeX Error : Option clash for package option.

The package caption has already been loaded with options:
  [hang,small,bf]
There has now been an attempt to load it with options
  [options]
Adding the global 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 ; enter image description here

share|improve this question
1  
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
2  
Please post your solution as an answer to your question rather than including it in your question. – N.N. Oct 4 '11 at 16:00
@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.

1 Answer

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}%

\addtolength{\as@captionwidth}{-\wd\as@captionbox}%

13 \usebox{\as@captionbox}\parbox[t]{\as@captionwidth}

{\leavevmode#2}}
share|improve this answer
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

Not the answer you're looking for? Browse other questions tagged or ask your own question.