[Tex/LaTex] Multiline caption for wide figures in IEEE Access Latex Template

document-classesieee-style

IEEE Access' Latex template uses its own figure class named \Figure

\Figure[t!](topskip=0pt, botskip=0pt, midskip=0pt){fig1.png}{<caption>\label{fig1}}

This command is for wide figures, that is, figures which span two columns. (For column-width figures the syntax [width=\columnwidth] is inserted before {fig1.png})

A problem arises when the caption is longer than the width of the printable area of the paper. It extends beyond the page as a single line.

This problem does not occur for column-width figures with long captions. It automatically converts to a multiline.

This post provides a workaround but it messes with the font type and the font size.

So, I decided to do my own research and I tried looking into the ieeeaccess.cls file (which you can also find here). But I am a complete noob to .cls files. I have a strong feeling that something is missing in the ieeeaccess.cls file under the Captions section.

It reads as

%%%
%Captions
\def\@IEEEtablestring{table}

\long\def\@makecaption#1#2{%
% test if is a for a figure or table
\ifx\@captype\@IEEEtablestring%
% if a table, do table caption
\begin{flushleft}
\vspace*{5pt}
{\vss\color{accessblue}\tablecapheadfont #1. \ }{\raggedright\tablecapfont#2\vss}%
\end{flushleft}
\@IEEEtablecaptionsepspace% V1.6 was a hard coded 8pt
% if not a table, format it as a figure
\else
\@IEEEfigurecaptionsepspace% V1.6 was a hard coded 5pt
% 3/2001 use footnotesize, not small; use two nonbreaking spaces, not one
\setbox\@tempboxa\hbox{\strut{\color{accessblue}\figcapheadfont #1. \ }\raggedright\figcapfont#2\strut}%
%\ifdim \wd\@tempboxa >\columnwidth%
\ifdim \xfigwd >\columnwidth%
% if caption is longer than a line, let it wrap around
\setbox\@tempboxa\hbox{{\color{accessblue}\figcapheadfont #1. \ }}%
\mbox{}\hfill\begin{tabular}{@{}l@{}}\noindent\raggedright\unhbox\@tempboxa\figcapfont#2\end{tabular}\hfill\mbox{}%
% if caption is shorter than a line,
% allow user to control short figure caption justification (left or center)
\else%
%\ifcenterfigcaptions \hbox to\hsize{\footnotesize\hfil\box\@tempboxa\hfil}%
%\else 
\setbox\@tempboxa\hbox{{\color{accessblue}\figcapheadfont #1. \ }}%
%\parbox[t]{\columnwidth}
{\vss\raggedright\noindent\unhbox\@tempboxa\figcapfont#2\vss}%
%\hbox to\hsize{\box\@tempboxa\hfil}%
%\fi
\fi\fi\vskip 1pt plus 1pt minus 1pt}

I sense that there should be a nested elseif to check the condition \ifdim \xfigwd >\textwidth%.

However, I seem to not find anything regarding nested \ifdim.

As I stated earlier I am a complete noob to .cls files and its syntax. And my observations might very well be wrong.

Does anyone, who is familiar with .cls syntax, happen to share the same observations as mine, and hopefully know what can be changed in the .cls file to make multiline captions possible for wide figures?

Thanks in advance.

Best Answer

Okay, so after fiddling around with the ieeeaccess.cls file, I found that replacing \columnwidth with \textwidth allows multiline to appear (magically) for a wide figure as well as a column-width figure.

So, under the Caption section, simply replace the line

\ifdim \xfigwd >\columnwidth%

with

\ifdim \xfigwd >\textwidth%

Note that I still am unsure why this is works (but it does). I leave the technical explanation to the experts.

That being said, it also does not mess the font type and the font size that IEEE Access sets, which is what I wanted.

P.s: If anyone finds this solution incorrect, explains why it is, and provides a sound solution, I will gladly remove mine. (It will still be my preferred solution for the moment:)). And I hope IEEE Access takes note of this problem.

[UPDATE]

Works with \linewidth% too. Thanks to user @Zarko for that suggestion.