0

I am using a \twocolumn document, however, I want to add a table in the middle of the column. I tried using \onecolumn but it places the figure or table in the next page making the whole page \onecolumn.

I saw that using \multicols can solve the problem. The thing is that the final table caption is not centered no matter how I set it up and I still get the overful hbox error regarding the content of the table.

enter image description here

\documentclass[journal, a4paper, 11pt]{IEEEtran}

\usepackage{lmodern} \usepackage{graphicx} \usepackage{caption} \usepackage{tabularx} \usepackage{tabulary} \usepackage{url}
\usepackage{amsmath} \usepackage[left=1.5cm,right=1.5cm,top=1.5cm,bottom=1.5cm]{geometry} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{empheq} \usepackage{textcomp} \usepackage{float} \usepackage{booktabs} \usepackage{xspace} \usepackage{makecell} \usepackage{algorithm} \usepackage{algpseudocode} \usepackage{hhline} \usepackage[style=numeric,sorting=none]{biblatex} \addbibresource{references.bib} % \renewcommand{\refname}{Referencias} % \parindent=5mm \setlength{\parindent}{1em} \setlength{\parskip}{1em} \renewcommand{\baselinestretch}{1.25} % \renewcommand{\tablename}{Tabla} % \renewcommand{\figurename}{Figura} \PassOptionsToPackage{hyphens}{url}\usepackage{hyperref}

\usepackage{hyperref} \hypersetup{ colorlinks=true, linkcolor=blue, filecolor=magenta,
urlcolor=cyan, pdftitle={Overleaf Example}, citecolor=blue, pdfpagemode=FullScreen, }

\usepackage{placeins} %FloatBarrier \usepackage{fancyhdr}

\newcommand{\eg}{e.g.@\xspace} \newcommand{\ie}{i.e.@\xspace}

\newcommand{\mac}{\overline{\overline{c}}} \newcommand{\sm}{\mathrm{sm}}

\newcommand{\MATLAB}{\textsc{Matlab}\xspace} \newcommand{\dd}{\mathrm{d}}

% \renewcommand{\abstract}{\textbf{\emph{Resumen}} -- } % \renewcommand\appendixname{Anexos}

\setlength{\parskip}{1mm}%

\newcommand{\reynolds}{\mathrm{Re}}

% Matlab code \usepackage[framed,numbered,autolinebreaks,useliterate]{mcode}

\makeatletter \long\def@makecaption#1#2{\ifx@captype% \footnotesize{\normalfont\footnotesize #1}\ {\normalfont\footnotesize\scshape #2}% @IEEEtablecaptionsepspace \else @IEEEfigurecaptionsepspace \setbox@tempboxa\hbox{\normalfont\footnotesize {#1.}~~ #2}% \ifdim \wd@tempboxa >\hsize% \setbox@tempboxa\hbox{\normalfont\footnotesize {#1.}~~ }% \parbox[t]{\hsize}{\normalfont\footnotesize \noindent\unhbox@tempboxa#2}% \else \hbox to\hsize{\normalfont\footnotesize\hfil\box@tempboxa\hfil}\fi\fi} \makeatother

\usepackage{etoolbox} \apptocmd{\sloppy}{\hbadness 10000\relax}{}{}

\usepackage{pdfpages} \usepackage{multicol}

\begin{document} % \onecolumn \maketitle

\section{Introduction} The following report analyzes the mission \textbf{New Horizons} mission to Pluto and its insights. This report is based on the experience from Dr. Alan Stern, principal investigator of the New Horizons mission and the Chief Scientist at Moon Express \cite{stern2018chasing}.

NASA's New Horizons spacecraft is the first spacecraft to explore Pluto up close, flying by the dwarf planet and its moons on July 14, 2015. In early 2019, New Horizons flew past its second major science target—2014 MU69, the most distant object ever explored up close \cite{nasa_new_horizons}.

\begin{center} \begin{multicols}{2} \begin{table}[H] \resizebox{\textwidth}{!}{% \centering \begin{tabular}{|c|c|} \hline Nation & United States of America (USA) \ \hline Objective(s) & Pluto Flyby, Kuiper Belt Object Flyby \ \hline Spacecraft & New Horizons \ \hline Spacecraft Mass & 1,054 pounds (478 kilograms) \ \hline Mission Design and Management & NASA / Johns Hopkins University Applied Physics Laboratory (APL) \ \hline Launch Vehicle & Atlas V 551 (AV-010) \ \hline Launch Date and Time & Jan. 19, 2006 / 19:00:00 UT \ \hline Launch Site & Cape Canaveral, Fla. / Launch Complex 41 \ \hline Scientific Instruments & \begin{tabular}[c]{@{}l@{}}Ralph-Visible and Infrared Imager/Spectrometer\ Alice-Ultraviolet Imaging Spectrometer\ Radio-Science Experiment (REX)\ Long-Range Reconnaissance Imager (LORRI)\ Solar Wind and Plasma Spectrometer (SWAP)\ Pluto Energetic Particle Spectrometer Science Investigation (PEPSSI)\ Student Dust Counter (SDC)\end{tabular} \ \hline \end{tabular} } \captionsetup{justification=centering} \caption{New Horizons mission characteristics. Source: \cite{nasa_new_horizons}.} \label{tab:my-table} \end{table} \end{multicols} \end{center}

  • Please extend your code fragment to complete small document, which we can compile as it is. If I understand you correctly, you like to have over two columns, right? If this is the case, than tray \begin{table*} ... \end{table*}. Table will appear on the top of the next page from point of insertion to document. – Zarko May 24 '21 at 17:40
  • You could use \usepackage{stfloats} to get the table at the bottom of the page with \twocolumn. But it looks like the table is too wide, so to avoid the overfull box you should make it narrower. Restructure or use a smaller font. – Pieter van Oostrum May 24 '21 at 17:49
  • @Zarko I have tried \begin{table*} but it does not seem to be working. I have added the small document code for a clearer explatnation. – Yi Qiang Ji May 24 '21 at 18:19
  • @PietervanOostrum I cannot manage to get it working with \usepackage{stfloats}. The document is still the same. – Yi Qiang Ji May 24 '21 at 18:20
  • The document you have given, doesn't use \twocolumn but multicols. stfloats works with \twocolumn. – Pieter van Oostrum May 24 '21 at 19:05
  • Apparently IEETRAN is by default \twocolumn, therefore the table will be typeset in a half-pagewidth column (giving the overfull box) and the caption is typeset cantered in that column, not centred in the full page width. – Pieter van Oostrum May 24 '21 at 19:18
  • And using multicols in a single column of a twocolumn document isn't a good idea either (you will get two quarter-columns). – Pieter van Oostrum May 24 '21 at 19:22
  • See https://tex.stackexchange.com/questions/329709/how-to-put-figure-at-middle-or-at-desired-position-on-a-page/531802?r=SearchResults&s=1|39.3820#531802 The idea is to use \afterpage and \twocoloumn[...] to terminate two column, use multiol to print the remaining text, add the figure or table, then resume two column formatting. – John Kormylo May 24 '21 at 23:26

2 Answers2

2

Let's tackle the various issues that arise from your question.

(1) IEEEtran for journal will produce a two columns document. No additional packages are needed.

(2) The class allows for wider tables using table*. (No vertical lines on the sides for their style)

(3) The wide table will go to the next page. The instructions recommend using the dblfloatfix package to make the floats in two columns come out in the correct order.

(4) The caption of the table should go at the top of the table.

(5) To center the caption on the page, place it in a \parbox{\textwidth}{\caption{ ....}}

(6) Do not use \resizebox{ since it will change the font size of the table from the default (footnotesize).

w

X

% !TeX TS-program = pdflatex

\documentclass[journal, a4paper, 11pt]{IEEEtran}

\usepackage{graphicx} \usepackage{kantlipsum} % dummy text \usepackage{dblfloatfix} % floats in twocolumns come out in the right order

\begin{document} \title{A title}

\author {Only One}

\maketitle

\section{Introduction} The following report analyzes the mission \textbf{New Horizons} mission to Pluto and its insights. This report is based on the experience from Dr. Alan Stern, principal investigator of the New Horizons mission and the Chief Scientist at Moon Express \cite{stern2018chasing}.

NASA's New Horizons spacecraft is the first spacecraft to explore Pluto up close, flying by the dwarf planet and its moons on July 14, 2015. In early 2019, New Horizons flew past its second major science target—2014 MU69, the most distant object ever explored up close \cite{nasa_new_horizons}

\section{Overview}

  1. \kant[1-3]

\begin{table}[tb] \centering \renewcommand{\arraystretch}{1.4} %expand the cells \parbox{\textwidth}{\caption{New Horizons mission characteristics. Source:\cite{nasa_new_horizons}.}} \label{tab:my-table}
\begin{tabular}{c|l} \hline Nation & United States of America (USA) \ \hline Objective(s) & Pluto Flyby, Kuiper Belt Object Flyby \ \hline Spacecraft & New Horizons \ \hline Spacecraft Mass & 1,054 pounds (478 kilograms) \ \hline Mission Design and Management & NASA / Johns Hopkins University Applied Physics Laboratory (APL) \ \hline Launch Vehicle & Atlas V 551 (AV-010) \ \hline Launch Date and Time & Jan. 19, 2006 / 19:00:00 UT \ \hline Launch Site & Cape Canaveral, Fla. / Launch Complex 41 \ \hline Scientific Instruments & \begin{tabular}[c]{@{}l@{}} Ralph-Visible and Infrared Imager/Spectrometer\ Alice-Ultraviolet Imaging Spectrometer\ Radio-Science Experiment (REX)\ Long-Range Reconnaissance Imager (LORRI)\ Solar Wind and Plasma Spectrometer (SWAP)\ Pluto Energetic Particle Spectrometer Science Investigation (PEPSSI)\ Student Dust Counter (SDC) \end{tabular} \ \hline \end{tabular} \end{table
}

  1. \kant[1-6]

\end{document}

Simon Dispa
  • 39,141
1

I think the best you can do is to give the class the onecolumn option, and use multicol to make the text two-column, and put the table between two of these.

\documentclass[journal, a4paper, 11pt, onecolumn]{IEEEtran}
....
\usepackage{multicol}
....
\begin{multicols}{2}
\section{Introduction}
The following report analyzes the mission \textbf{New Horizons} mission to Pluto and its insights. This report is based on the experience from Dr. Alan Stern, principal investigator of the New Horizons mission and the Chief Scientist at Moon Express \cite{stern2018chasing}.
....
\end{multicols}
\begin{table}[H]
...
\end{table}

\begin{multicols}{2} ... more text ... \end{multicols}

enter image description here

  • I used multicole but I still get the same result, the caption is not centered and I have overful hbox. Is it possible to ceter it? I used twocolum as it is part of IEEEtran.cls package – Yi Qiang Ji May 24 '21 at 19:41
  • Well, if you use twocolumn, then that is to be expected as I explained. If you use the structure that I proposed, including the onecolumn option, it will work. See the image I added. – Pieter van Oostrum May 24 '21 at 20:22
  • If you insist on using \twocolumn, then you can only have the table at the top of the page, or with stfloats also at the bottom, but not "HERE". The \twocolumn code doesn't allow that. And then you have to use table* instead of table. – Pieter van Oostrum May 24 '21 at 20:26
  • Hi Pieter, I see now what you meant. It is way better to use \onecolumn for the whole document and add \multicols when needed! Problem solved! Thanks for the help and time. I really appreciated! – Yi Qiang Ji May 25 '21 at 05:47