christopheradams / tufte-latex

Automatically exported from code.google.com/p/tufte-latex
0 stars 1 forks source link

Referencing tables not working when using subfigure package #48

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
First of all, thank you very much for these great document classes. I'm
using tufte-book for my Diplomarbeit and I'm really happy with it.

However, there seems to be a bug in the current SVN version (as of
9/4/2010) regarding referencing tables and using the subfigure package at
the same time. 

If one compiles the attached .tex-file without uncommenting the line

\usepackage[FIGBOTCAP,TABBOTCAP]{subfigure}

then the \ref-command produces the number 1.2 (which is the current section
number) instead of 1.1 (which is the correct table number). In contrast,
when commenting the above line everything works as expected (besides that I
have to do a manual \stepcounter{figure} after using the \subfigure command.

In the meantime I uncommented the following lines in tufte-common.def as a
workaround:

\ifthenelse{\boolean{@tufte@packages@subfigure}}{%
% don't move the label while inside a \subfigure or \subtable command
\global\let\label\@tufte@orig@label%
}{}% subfigure package is not loaded

The error occurs with recent texlive and Miktex installations.

Thank you very much in advance.

Roy

Original issue reported on code.google.com by roy...@gmail.com on 9 Apr 2010 at 12:19

Attachments:

GoogleCodeExporter commented 9 years ago
I observe the same with figures too on MacTeX 2009.

Original comment by oleg.lob...@gmail.com on 11 Apr 2010 at 5:12

GoogleCodeExporter commented 9 years ago
I've having the same issue in XeLaTeX (called from TeXShop) -- the figure 
number itself is correct, but references to the figure gives me the section or 
subsection name. I tried poking around inside the .def file but it's a bit 
beyond me. 

In case it helps, here are some additional characteristics of the bug:

1. Doesn't seem to affect the List of Figures or List of Tables
2. Doesn't seem to affect the number of the Figures or Tables themselves
3. Affects *all* references to Figures and Tables, including ones that precede 
the first occurrence of a subfigure 

But let me finish by saying that this system is brilliant -- I've always loved 
Tufte's books, and if I can sort this issue out then there is nothing standing 
between me and submitting my PhD using this format (aside from debugging 
leftover from the Perl scripts that I wrote to convert the basic LaTeX 
formatting to this more sophisticated one).

Thanks again,

jon

Original comment by jreades@gmail.com on 12 Aug 2010 at 4:40

GoogleCodeExporter commented 9 years ago
Playing around with what roymen suggested, I commented out these lines in 
tufte-common.def:

    % Handle subfigure package compatibility
    %\ifthenelse{\boolean{@tufte@packages@subfigure}}{%
    %  % don't move the label while inside a \subfigure or \subtable command
    %  \global\let\label\@tufte@orig@label%    %}{}% subfigure package is not loaded

This fixed the numbering within the document (i.e. the Figure and Table 
reference numbers are now correct), but the hyperlinks still take me to the 
start of the section or subsection.

It would be amazingly helpful if this could be fixed shortly since I hope to 
submit in the next 2-3 weeks and would like to supply an electronic copy with 
working hyperrefs. Since LaTeX isn't really my thing, the best I can offer in 
return in some Perl scripts that I've used to ease the conversion from standard 
LaTeX formatting to Tufte-LaTeX formatting.

Many thanks!

jon

Original comment by jreades@gmail.com on 17 Aug 2010 at 1:45

GoogleCodeExporter commented 9 years ago
jon,

simply disabling subfigure package works too.

Unfortunally this means you need to rework all your subfigures. There is also a 
subfig package, but I have not tried it.

--
Greetings,
Oleg

Original comment by oleg.lob...@gmail.com on 17 Aug 2010 at 2:04

GoogleCodeExporter commented 9 years ago

Hi Oleg,

I was dreading the idea of disabling subfigure since I would have to manually 
combine a good three-dozen figures in order to make about ten that could be 
referenced properly.

Fortunately, I'm pleased to report that subfig works! Sometimes LaTeX reminds 
me of Java 1.x where there are 90 ways of doing similar things, but all with 
slightly different features, and how exactly one finds out about the 90 
quasi-equivalent options is beyond me. :-)

The only oddity is that now all of my Figure captions are normal-text sized 
instead of the original caption font size. Sidenotes/footnotes are still 
correctly formatted. I'll dig into this some time in the next couple of weeks 
and report back if I can figure it out.

If this isn't something that will be changed, it might be useful to have the 
next release of the Tufte report an error much like it does for subsubsection, 
or at least a warning.

And for the reference of anyone else who is trying to deal with this, the 
fastest way to make the switch (if you're not on Windows) is using a 
Terminal/TTY:

perl -i -p -e 's|subfigure|subfloat|g' *.tex

Then just change the package import from subfigure to subfig.

The final step is that you now need to manually add '\\' where you want the 
subfig environment to add a line-break since it's default behaviour is to stack 
everything horizontally off the side of the page. Go figure.

Thank you again Oleg, that was really helpful.

jon

Original comment by jreades@gmail.com on 17 Aug 2010 at 3:01

GoogleCodeExporter commented 9 years ago
This problem went away for me when I used a caption for entire figure. Without 
a caption references in the text would put the section number. With a caption 
everything worked as you would expect it. Example:

\begin{figure}
\centering
\subfigure[Subfigure 1] % caption for subfigure 1
{
    \label{fig:sub1}
    \includegraphics[scale=0.5]{subfig1.eps}
}
\subfigure[Subfigure 2] % caption for subfigure 2
{
    \label{fig:sub2}
    \includegraphics[scale=0.5]{subfig2.eps}
}

\caption{Results for subfigure}
\label{fig:results}
\end{figure}

Original comment by warzini...@gmail.com on 19 Jan 2011 at 10:35

GoogleCodeExporter commented 9 years ago
The problem appears when \label{...} is not the last entry before \end{figure}.

Original comment by pkmanwar...@gmail.com on 25 May 2012 at 4:15