3

i've read this question and the subfigure environment works fine, except captions aren't centered below the images. Instead, it looks like this: enter image description here

is there a way to fix this? my config.cfg looks like this so far:

\let\origincludegraphics\includegraphics
\Preamble{xhtml,pic-tabular}


\Configure{HtmlPar}
{\EndP\Tg<p>}
{\EndP\Tg<p>}
{\HCode{</p>\Hnewline}}
{\HCode{</p>\Hnewline}}


\Configure{picture}
{\DeclareGraphicsExtensions{.eps}\Picture+[PICT]{}}
{\EndPicture}

%%%Images

\Configure{graphics*}
    {jpg}
    {%  
       \Picture[pict]{\csname Gin@base\endcsname .jpg
          \space width="\the\dimexpr \expandafter\csname
Gin@req@width\endcsname *2"
}%  
      \special{t4ht+@File: \csname Gin@base\endcsname.jpg}
     }
\Configure{graphics*}
    {png}
    {%  
       \Picture[pict]{\csname Gin@base\endcsname .png
          \space width="\the\dimexpr \expandafter\csname
Gin@req@width\endcsname *2"
}%  
      \special{t4ht+@File: \csname Gin@base\endcsname.png}
     }


\Configure{graphics*}
{eps}
{%  
\openin15=\csname Gin@base\endcsname\PictExt\relax 
  \ifeof15 
  \Needs{"convert \csname Gin@base\endcsname.eps 
    \csname Gin@base\endcsname\PictExt"}% 
  \fi 
  \closein15 
   \Picture[pict]{\csname Gin@base\endcsname \PictExt
      \space width="\the\dimexpr \expandafter\csname
Gin@req@width\endcsname *1.5"
}%  
  \special{t4ht+@File: \csname Gin@base\endcsname\PictExt}
 }


\Configure{Picture*}{\let\includegraphics\origincludegraphics}{}
\Configure{Picture+}{\let\includegraphics\origincludegraphics}{}



%%%%%%Subfigure

\ConfigureEnv{subfigure}{\ifvmode\IgnorePar\fi\EndP\HCode{<div class="subfigure">}}{\ifvmode\IgnorePar\fi\EndP\HCode{</div>}}{}{}
\Css{.subfigure{display: inline-block;}}
\Css{.subfigure img{display:block;}}

\Css{.figure div.caption{text-align: center;}}
\Css{div.figure{text-align:center;clear:both;overflow:auto;width:100\%;margin-bottom:1em;}}

%%%%%MINIPAGE

\makeatletter
\def\striptextwidth#1\textwidth{#1}
\newcount\mini@count
\let\oldiimini\@iiiminipage
\def\@iiiminipage#1#2[#3]#4{%
\xdef\miniwidth{\strip@pt\dimexpr(\striptextwidth#4pt)*100\relax\%}
\oldiimini{#1}{#2}[#3]{#4}
}

\ConfigureEnv{minipage}{\advance\mini@count by 1\relax\ifvmode\IgnorePar\fi\EndP\HCode{<div class="minipage" align="center" id="minipage\the\mini@count">}}
{\ifvmode\IgnorePar\fi\EndP\HCode{</div>\Hnewline}%
\Css{\#minipage\the\mini@count{width:\miniwidth;}}%
}{}{}
\makeatother
\Css{div.minipage {
 float: left; 
 } 
}
\Css{div.minipage:last-child {
 clear: none; 
 float: right; 
 }
}
\Css{div.figure{clear:both;overflow:auto;width:100\%;max-width:100\%;height:auto;}}


\begin{document}
\CssFile[custom.css] 
/* css.sty */
\EndCssFile
\Configure{CoverMimeType}{image/jpg}
\DeclareGraphicsExtensions{.eps,.png,.jpg,.gif,}
\EndPreamble

edit: this problem only occurs when the caption is too long. A workaround is to force a line break manually.

2

The subfigure just needs to be correctly styled using the CSS styles. It needs to have maximum width set, as it would grow without break otherwise. Try these definitions:

\Css{.subfigure{display: inline-block;max-width:30\%;}}
\Css{.subfigure img{display:block; margin-left:auto;margin-right:auto;}}

The max-width property depends on number of subfigures you use, you will need to play with different percentages to find the best value.

It may look in this way:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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