## LaTeX forum ⇒ General ⇒ General floating object with caption

LaTeX specific issues not fitting into one of the other forums of this category.
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

### Re: General floating object with caption

Hi Herder,

caption2 in now an obsolete package. Maybe the problem is that you are using an old version of caption. Please compile the following code (it compiles OK for me and the reference is also OK) and please post here (as an attachment) the .log file you get after compilation.
\listfiles\documentclass{article}\usepackage{float}\usepackage{caption}\captionsetup{labelfont=bf,font=small}\usepackage{lipsum}% just to automatically generate some text \newfloat{Myfloat}{htbp}{myf} \begin{document} Just a test. As you see in \ref{myf:test1}... \begin{Myfloat}   \centering   \fbox{text}   \caption{a simple example}   \label{myf:test1}\end{Myfloat} \end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...

Herder
Posts: 16
Joined: Tue Aug 05, 2008 2:32 pm
That did it! I reinstalled the caption-package and now it works like a charm.

By the way, is there any special thing i need to pay attention when using labels in self-defined floating objects? Because these labels are the only ones left causing undefined references.

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm
Herder wrote:...By the way, is there any special thing i need to pay attention when using labels in self-defined floating objects?...

Same precautions as with labels for standard floats.
Herder wrote:...Because these labels are the only ones left causing undefined references.

Hmm. Remember that you must compile your document twice to get the references right. Did you try with the code I posted in my previous response? Do you experience problems with the reference in that example? If so, then please attach, as I suggested before, the .log file obtained. On the other hand, if my example works OK for you but your document presents problems, then please post here a minimal working example showing the undesired behaviour.
Last edited by gmedina on Fri Aug 15, 2008 5:49 pm, edited 1 time in total.
1,1,2,3,5,8,13,21,34,55,89,144,233,...

Herder
Posts: 16
Joined: Tue Aug 05, 2008 2:32 pm
Your example doesn't work for me, there is no link when referencing the label. Attached is the log-file. Strange ... In my document, there are links, but all leading to the beginning of the document.
Attachments
LaTeX1.log
Log file of the example code

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm
Hi,

I didn't notice any strange results looking at the .log file. But
Herder wrote:Your example doesn't work for me, there is no link when referencing the label. Attached is the log-file.

Now I a'm confused. Are you talking now about hyperlinks? If this is so, then, of course there's no links with my example. In this example I was addressing the references issue. If you want to get hyperlinks then load the hyperref package.

Let's clarify things: Try the following simple code:
\listfiles\documentclass{article}\usepackage{float}\usepackage{caption}\captionsetup{labelfont=bf,font=small}\usepackage{lipsum}% just to automatically generate some text\usepackage{hyperref} \newfloat{Myfloat}{htbp}{myf} \begin{document} Just a test. As you see in \ref{myf:test1}... \lipsum[2]\begin{Myfloat}   \centering   \fbox{text}   \caption{a simple example}   \label{myf:test1}\end{Myfloat} \end{document}

I'll attach the outcome you should get (test.pdf). If you get a different result, please report exactly what you get.
Attachments
test.pdf
1,1,2,3,5,8,13,21,34,55,89,144,233,...

Herder
Posts: 16
Joined: Tue Aug 05, 2008 2:32 pm
This example works well. Reference and link are correctly set up. Sorry for confusing references with links in my last posts.

I attached a listing of all files included in my document. I also noticed some warnings like
pdfTeX warning (dest): name{MyFloatObject.4.5} has been referenced but does not exist, replaced by a fixed one

in the log file concerning my self-defined floating objects.

Here is the definition of one of my floating objects:
\newfloat{MyFloatObject}{H}{myfo}[chapter]

Here how I try to label and reference it:
Some text here, see \ref{myfo:sometext} for ... \begin{MyFloatObject}\centeringSome text here\caption{Some text here, too}\label{myfo:sometext}\end{MyFloatObject}

I also tried other forms like \label{sometext} and \ref{sometext} ...

Attachments
listfiles_output.txt
Output of listfiles

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm
Hi,

Not really; using the standard document class book the following simple code (that uses your definitions) works OK for me:
\documentclass{book}\usepackage{float}\usepackage{hyperref} \newfloat{MyFloatObject}{H}{myfo}[chapter] \begin{document} \chapter{Dummy chapter}Some text here, see \ref{myfo:sometext} for ...\begin{MyFloatObject}   \centering   Some text here   \caption{Some text here, too}   \label{myfo:sometext}\end{MyFloatObject} \end{document}

However, reading the file you attached I noticed that you are using a non-standard document class:
*File List*  scidoc.cls    	2003/12/12 Scientific document

I am not familiar with that document class and I couldn't even find it. At this point all I can do is recommend you to load the hyperref package after loading all the other packages (there are exceptions to this rule); if this does not work, then build a minimal working example (I provided the link some responses above) showing your problem and attaching here the file scidoc.cls and perhaps someone will have the time to take a look at it.
1,1,2,3,5,8,13,21,34,55,89,144,233,...

Herder
Posts: 16
Joined: Tue Aug 05, 2008 2:32 pm
Yes, it is a non-standard class, I know. Unforunately, I have to use this class.
I tidied up the class-file a little bit (e. g. including the hyperref-package after all the other packages) and now, the references seem to work.

Thank you very much for your help!