2

I'm am using the IEEE Access Latex template and I'm getting errors when using the caption command in a listing environment. This does not happen with the IEEEtran template.

For example, this code works:

\documentclass{ieeeaccess}
\usepackage{graphicx} 
\usepackage{listings}
\usepackage{lipsum}

\begin{document}
\lipsum[1]
\begin{lstlisting}[label=listing1, language=C]
int main(void)
{
        printf("Hello world\n");
}
\end{lstlisting}
\end{document}

But the following does not, and the only difference is the caption command:

\documentclass{ieeeaccess}
\usepackage{graphicx} 
\usepackage{listings}
\usepackage{lipsum}

\begin{document}
\lipsum[1]
\begin{lstlisting}[label=listing1, language=C, caption=Listing 1]
int main(void)
{
        printf("Hello world\n");
}
\end{lstlisting}
\end{document}

In fact, the result is a series of errors like this:

! Undefined control sequence. \@makecaption ...capfont #2\strut }\ifdim \xfigwd \columnwidth \setbox \@te... l.12 ...el=listing1, language=C, caption=Listing1]

! Missing number, treated as zero.

l.12 ...el=listing1, language=C, caption=Listing1]

! Illegal unit of measure (pt inserted).

l.12 ...el=listing1, language=C, caption=Listing1]

! Infinite glue shrinkage found on current page. \@makecaption ...\ }}{\vss \raggedright \noindent \unhbox \@tempboxa \figcap... l.12 ...el=listing1, language=C, caption=Listing1]

2

ieeeaccess redefines the caption command and uses a length called \xfigwd which is normally set from a figure or table environment. As you listing uses neither of these environments, you'll have to manually do it:

\documentclass{ieeeaccess}
\usepackage{graphicx} 
\usepackage{listings}
\usepackage{lipsum}

\begin{document}
\lipsum[1]

\begingroup
\newlength{\xfigwd}
\setlength{\xfigwd}{\textwidth}
\begin{lstlisting}[label=listing1, language=C, caption={hgd}]
int main(void)
{
        printf("Hello world\n");
}
\end{lstlisting}
\endgroup
\EOD

\end{document}

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.