1

This is driving me mad, so hopefully someone can put me out of my misery. I can't seem to match the caption formatting of a 'normal' table with that of the longtable. The issue i have is using the ieeeaccess.cls file (or so i believe). From what i understand longtable should format the caption with the same format as the article class but it seems to revert back to the default. The MWE code below is my example. I would like the same font/format shown in Table 1 to be replicated in Table 2 at the top of the table and across the page span. I have tried to carve out the code that formats the captions from the cls file (described here) but it doesn't want to work with me. I also tried replicating with captionsetup but i couldn't get this to work either. Any suggestions? Is there something simple that i am missing? How do i force longtable to use the caption format from the class? Or force it to use the caption formatting from another Table?

\documentclass{ieeeaccess}
\usepackage{graphicx}
\usepackage{longtable}
\usepackage{lipsum}
\setlength{\LTcapwidth}{\textwidth}
\begin{document}
\lipsum[1]

Normal Table\ref{tab:table1} and long Table\ref{tab:longtable}

\begin{table} [h] \caption{first caption}\label{tab:table1} \centering \begin{tabular}{l l} \hline \textbf{H1} & \textbf{H2} \ \hline 1 & 2 \ 1 & 2 \ \hline \end{tabular} \end{table}

\onecolumn

\begin{longtable}{|p{4cm}|p{4cm}|p{4cm}|p{4cm}|} \caption{A simple longtable A simple longtable A simple longtable A simple longtable A simple longtable A simple longtable A simple longtable}\label{tab:longtable}\ \hline \textbf{First entry} & \textbf{Second entry} & \textbf{Third entry} & \textbf{Fourth entry} \ \hline \endfirsthead % \multicolumn{4}{c}% \caption[]{A simple longtable A simple longtable A simple longtable A simple longtable A simple longtable A simple longtable A simple longtable}\ \hline \textbf{First entry} & \textbf{Second entry} & \textbf{Third entry} & \textbf{Fourth entry} \ \hline \endhead \hline \multicolumn{4}{r}{\textit{Continued on next page}} \ \endfoot \hline \endlastfoot \hline \hline 1 & 2 & 3 & 4 \ 1 & 2 & 3 & 4 \ 1 & 2 & 3 & 4 \ 1 & 2 & 3 & 4 \ 1 & 2 & 3 & 4 \ 1 & 2 & 3 & 4 \ 1 & 2 & 3 & 4 \ 1 & 2 & 3 & 4 \ 1 & 2 & 3 & 4 \ 1 & 2 & 3 & 4 \ 1 & 2 & 3 & 4 \ 1 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& 3 & 4 \ 1 & 2 & 3 & 4 \ 1 & 2 & 3 & 4 \ 1 & 2 & 3 & 4 \ 1 & 2 & 3 & 4 \ 1 & 2 & 3 & 4 \ 1 & 2 & 3 & 4 \ 1 & 2 & 3 & 4 \ 1 & 2 & 3 & 4 \ \end{longtable} \twocolumn \EOD \end{document}

  • Welcome to TeX.SE! – Mensch Feb 02 '23 at 17:13
  • Longtable uses a custom caption. It might be possible to modify it to match IEEEtran. – John Kormylo Feb 02 '23 at 18:05
  • I can't find how to download ieeaccess.doc. It appears to only be available through overleaf. – John Kormylo Feb 02 '23 at 18:14
  • Thanks for taking a look. The ieeeaccess.cls is available through the link i embedded above. The format of the manuscript has more color and embedded graphics than other IEEE templates, which is why it isn't a very clean way of posting here and asking for assistance.

    I have implemented your solution below. I can probably live without the Table caption appearing on every page. Thanks.

    – colbrown Feb 02 '23 at 19:30

1 Answers1

1

The easy solution is to simply add a normal table caption before the longtable. I don't know what IEEE will think of a "Continued" caption.

\documentclass{IEEEtran}
\usepackage{graphicx}
\usepackage{longtable}
\usepackage{lipsum}
\setlength{\LTcapwidth}{\textwidth}
\begin{document}
\lipsum[1]

Normal Table\ref{tab:table1} and long Table\ref{tab:longtable}

\begin{table} [h] \caption{first caption}\label{tab:table1} \centering \begin{tabular}{l l} \hline \textbf{H1} & \textbf{H2} \ \hline 1 & 2 \ 1 & 2 \ \hline \end{tabular} \end{table}

\onecolumn \begin{table}[h!] \caption{A simple longtable A simple longtable A simple longtable A simple longtable A simple longtable A simple longtable A simple longtable} \label{tab:longtable} \end{table} % \vskip-\intextsep \setlength{\LTpre}{0pt}% \begin{longtable}{|p{4cm}|p{4cm}|p{4cm}|p{4cm}|} \hline \textbf{First entry} & \textbf{Second entry} & \textbf{Third entry} & \textbf{Fourth entry} \ \hline \endfirsthead % \multicolumn{4}{c}% \hline \textbf{First entry} & \textbf{Second entry} & \textbf{Third entry} & \textbf{Fourth entry} \ \hline \endhead \hline \multicolumn{4}{r}{\textit{Continued on next page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4 \ 1 & 2 & 3 & 4 \ 1 & 2 & 3 & 4 \ 1 & 2 & 3 & 4 \ 1 & 2 & 3 & 4 \ 1 & 2 & 3 & 4 \ 1 & 2 & 3 & 4 \ 1 & 2 & 3 & 4 \ 1 & 2 & 3 & 4 \ 1 & 2 & 3 & 4 \ 1 & 2 & 3 & 4 \ 1 & 2 & 3 & 4 \ 1 & 2 & 3 & 4 \ 1 & 2 & 3 & 4 \ 1 & 2 & 3 & 4 \ 1 & 2 & 3 & 4 \ 1 & 2 & 3 & 4 \ 1 & 2 & 3 & 4 \ 1 & 2 & 3 & 4 \ 1 & 2 & 3 & 4 \ 1 & 2 & 3 & 4 \ 1 & 2 & 3 & 4 \ \end{longtable} \twocolumn

\end{document}


This version modifies the longtable caption format. Only the firsthead caption appears in the \listoftables.

\documentclass{IEEEtran}
\usepackage{graphicx}
\usepackage{longtable}
\usepackage{lipsum}
\setlength{\LTcapwidth}{\textwidth}
\usepackage{showframe}% MWE only
\makeatletter
\def\LT@makecaption#1#2#3{%
  \LT@mcol\LT@cols c{\hbox to\z@{\hss\parbox[t]\LTcapwidth{%
    \centering #1{#2\\}#3%
    \endgraf\vskip\baselineskip}%
  \hss}}}
\makeatother
\begin{document}
\lipsum[1]

Normal Table\ref{tab:table1} and long Table\ref{tab:longtable}

\begin{table} [h] \caption{first caption}\label{tab:table1} \centering \begin{tabular}{l l} \hline \textbf{H1} & \textbf{H2} \ \hline 1 & 2 \ 1 & 2 \ \hline \end{tabular} \end{table}

\onecolumn \begin{longtable}{|p{4cm}|p{4cm}|p{4cm}|p{4cm}|} \caption{A simple longtable A simple longtable A simple longtable A simple longtable A simple longtable A simple longtable A simple longtable} \label{tab:longtable}\ \hline \textbf{First entry} & \textbf{Second entry} & \textbf{Third entry} & \textbf{Fourth entry} \ \hline \endfirsthead % \multicolumn{4}{c}% \caption[]{A simple longtable A simple longtable A simple longtable A simple longtable A simple longtable A simple longtable A simple longtable}\ \hline \textbf{First entry} & \textbf{Second entry} & \textb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