[Tugindia] tugindia Digest, Vol 42, Issue 3

Ravi Gautam aol_gautam at rediffmail.com
Sat Jun 17 20:18:40 CEST 2006


  
Hi,
In the following url
  http://www.tug.org/TeXnik/mainFAQ.cgi?file=floats/nonFloat
the following code facilitates us to use subfigures with pagebreak.
**************************************************************
   \newcounter{mySubCounter}
\newcommand{\mySubCaption}{}
\newenvironment{myFirstSubFigure}[1] {% caption as parameter
   \addtocounter{figure}{1}% increase the float figure counter
   \begin{mySubFigure}{#1}%
}{%
   \end{mySubFigure}%
}
\newenvironment{mySubFigure}[1] {% caption as parameter
   \renewcommand\mySubCaption{#1}
   \refstepcounter{mySubCounter}
}
{%
   \vspace{1ex}
   \addtocontents{lof}{\protect\contentsline %
          {figure}%
          {\numberline{%
             \arabic{figure}\alph{mySubCounter}}{\mySubCaption}}%
          {\arabic{page}}%
}
   \hfill\textbf{Figure \thefigure\alph{mySubCounter} : \mySubCaption\hfill%
   \vspace{1ex}%
}
\newenvironment{myLastSubFigure}[1] {% caption as parameter
   \begin{mySubFigure}{#1}
}{%
   \end{mySubFigure}%
   \setcounter{mySubCounter}{0}% resetting the subcounter
}
********************************************************************

I am not able to understand how to put label. If we put the label
in the begining of the caption, we get only figure number starting rom
1 (that is subcounter) by using \ref and not the full reference umber
foreg. instead of Figure 14.2b we get Figure 2.

A solution to the above problem will be highly appreciated.

Also in the List of figures was not giving proper figure number. For example, instead of 14.2b it would put 2b. However, a minor change solved the problem.

*********************************************************************
   \newcounter{mySubCounter}
\newcommand{\mySubCaption}{}
\newenvironment{myFirstSubFigure}[1] {% caption as parameter
   \addtocounter{figure}{1}% increase the float figure counter
   \begin{mySubFigure}{#1}%
}{%
   \end{mySubFigure}%
}
\newenvironment{mySubFigure}[1] {% caption as parameter
   \renewcommand\mySubCaption{#1}
   \refstepcounter{mySubCounter}
}
{%
   \vspace{1ex}
   \addtocontents{lof}{\protect\contentsline %
          {figure}%
          {\numberline{%            \arabic{chapter}.\arabic{figure}\alph{mySubCounter}}{\mySubCaption}}%
          {\arabic{page}}%
}
   \hfill\textbf{Figure \thefigure\alph{mySubCounter} : \mySubCaption\hfill%
   \vspace{1ex}%
}
\newenvironment{myLastSubFigure}[1] {% caption as parameter
   \begin{mySubFigure}{#1}
}{%
   \end{mySubFigure}%
   \setcounter{mySubCounter}{0}% resetting the subcounter
}

*********************************************************************
However problem \label and ref still is still remaining.

I tried to understand subfloat.sty. The counter parentfigure seems to
address the problem but seems to be difficult to workout.
 
Regards,
Ravi Shankar Gautam



More information about the tugindia mailing list