LaTeX forum ⇒ GeneralGeneral floating object with caption

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

Re: General floating object with caption

Postby gmedina » Fri Aug 15, 2008 4:58 pm

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.
  1. \listfiles
  2. \documentclass{article}
  3. \usepackage{float}
  4. \usepackage{caption}
  5. \captionsetup{labelfont=bf,font=small}
  6. \usepackage{lipsum}% just to automatically generate some text
  7.  
  8. \newfloat{Myfloat}{htbp}{myf}
  9.  
  10. \begin{document}
  11.  
  12. Just a test. As you see in \ref{myf:test1}...
  13.  
  14. \begin{Myfloat}
  15. \centering
  16. \fbox{text}
  17. \caption{a simple example}
  18. \label{myf:test1}
  19. \end{Myfloat}
  20.  
  21. \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

Postby Herder » Fri Aug 15, 2008 5:07 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.

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

Postby gmedina » Fri Aug 15, 2008 5:47 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

Postby Herder » Fri Aug 15, 2008 7:48 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
(4.04 KiB) Downloaded 119 times

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

Postby gmedina » Fri Aug 15, 2008 8:13 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:
  1. \listfiles
  2. \documentclass{article}
  3. \usepackage{float}
  4. \usepackage{caption}
  5. \captionsetup{labelfont=bf,font=small}
  6. \usepackage{lipsum}% just to automatically generate some text
  7. \usepackage{hyperref}
  8.  
  9. \newfloat{Myfloat}{htbp}{myf}
  10.  
  11. \begin{document}
  12.  
  13. Just a test. As you see in \ref{myf:test1}...
  14.  
  15. \lipsum[2]
  16. \begin{Myfloat}
  17. \centering
  18. \fbox{text}
  19. \caption{a simple example}
  20. \label{myf:test1}
  21. \end{Myfloat}
  22.  
  23. \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
(19.04 KiB) Downloaded 129 times
1,1,2,3,5,8,13,21,34,55,89,144,233,...

Herder
Posts: 16
Joined: Tue Aug 05, 2008 2:32 pm

Postby Herder » Fri Aug 15, 2008 11:57 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:
  1. \newfloat{MyFloatObject}{H}{myfo}[chapter]

Here how I try to label and reference it:
  1. Some text here, see \ref{myfo:sometext} for ...
  2.  
  3. \begin{MyFloatObject}
  4. \centering
  5. Some text here
  6. \caption{Some text here, too}
  7. \label{myfo:sometext}
  8. \end{MyFloatObject}


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

Does this information help you solving the problem?
Attachments
listfiles_output.txt
Output of listfiles
(2.8 KiB) Downloaded 127 times

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

Postby gmedina » Sat Aug 16, 2008 1:14 am

Hi,
Herder wrote:...Does this information help you solving the problem?

Not really; using the standard document class book the following simple code (that uses your definitions) works OK for me:
  1. \documentclass{book}
  2. \usepackage{float}
  3. \usepackage{hyperref}
  4.  
  5. \newfloat{MyFloatObject}{H}{myfo}[chapter]
  6.  
  7. \begin{document}
  8.  
  9. \chapter{Dummy chapter}
  10. Some text here, see \ref{myfo:sometext} for ...
  11. \begin{MyFloatObject}
  12. \centering
  13. Some text here
  14. \caption{Some text here, too}
  15. \label{myfo:sometext}
  16. \end{MyFloatObject}
  17.  
  18. \end{document}

However, reading the file you attached I noticed that you are using a non-standard document class:
  1. *File List*
  2. 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

Postby Herder » Sat Aug 16, 2008 10:04 am

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! :D


Return to “General”

Who is online

Users browsing this forum: No registered users and 10 guests