2

I have the following latex code:

    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    \section{Introduction}
    \label{sec:introduction}
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    
    \subsection{Motivation}
    \label{sec:Motivation}
    
    
    
    \subsection{Related work}
    \label{sec:Related work}
    magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clitaeeeeeeeeeee kasd gubergren, no sea takimata diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptuaeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeamet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clitaeeeeeeeeeee kasd gubergren, no sea takimata diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptuaeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeamet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clitaeeeeeeeeeee kasd gubergren, no sea takimata diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptuaeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeamet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clitaeeeeeeeeeee kasd gubergren, no sea takimata diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptuaeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeamet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet 
    
    \begin{table*}[H]
        \centering
        \begin{tabular}{|c|c|c|c|c|c|}
            \hline
            & \makecell{Critera 1 \\ control} & \makecell{Critera 2 \\ optimal control} & \makecell{Critera 3 \\ smart control heuristic} & \makecell{Comparison to optimal \\ and smart control} & \makecell{Use of training data \\from other buildings} \\
            \hline
            Author 1 et al., 2020 [1] & \cmark & \rule{0.2cm}{0.2cm} & & & \\
            \hline
        \end{tabular}
        \caption{Comparison of relevant papers from the literature}
        \label{tab:my_label}
    \end{table*}
    
    \subsection{Contribution}

\label{sec:Contribution}

with the main file

\documentclass[5p,times,twocolumn]{elsarticle}
\usepackage{physics}
\usepackage{tabularx}
\usepackage{siunitx}
\usepackage{xcolor}
\usepackage{hyperref}
\hypersetup{hidelinks}
\usepackage{csquotes}
\usepackage{amssymb}% http://ctan.org/pkg/amssymb
\usepackage{pifont}% http://ctan.org/pkg/pifont
\newcommand{\cmark}{\ding{51}}%
\newcommand{\xmark}{\ding{55}}%
\usepackage{acro}
\include{sections/00_acro}
\graphicspath{{figures/}}
\usepackage{lipsum}
\usepackage{booktabs}
\usepackage{float}
\usepackage{comment}
\usepackage{subcaption}
\usepackage{framed} % Framing content
\usepackage{multicol} % Multiple columns environment
\usepackage{nomencl} % Nomenclature package

\usepackage{makecell}


\journal{}

\begin{document}

\begin{frontmatter}

\title{Title}


\author[1]{Author 1}
\author[1]{Author 2}


\address[1]{Institue 1}

\begin{abstract}
\input{sections/00_abstract}
\end{abstract}

\begin{comment}
%%Graphical abstract
\begin{graphicalabstract}
\includegraphics{grabs}
\end{graphicalabstract}

%%Research highlights
\begin{highlights}
\item Research highlight 1
\item Research highlight 2
\end{highlights}
\end{comment}

\begin{keyword}
%% keywords here, in the form: keyword \sep keyword
keyword 1 \sep keyword 2 \sep keyword 3 \sep keyword 4 \sep keyword 5 
%% PACS codes here, in the form: \PACS code \sep code
%\PACS 0000 \sep 1111
%% MSC codes here, in the form: \MSC code \sep code
%% or \MSC[2008] code \sep code (2000 is the default)
%MSC 0000 \sep 1111
\end{keyword}

\end{frontmatter}

\thispagestyle{empty} % Remove page number and header/footer on the first page

%% \linenumbers

%\input{sections/00_nomecl}
\input{sections/01_intro}
\input{sections/02_results}
\input{sections/03_conclusion}


%% If you have bibdatabase file and want bibtex to generate the
%% bibitems, please use
%%
 \bibliographystyle{elsarticle-num} 
 \bibliography{refs}

%% else use the following coding to input the bibitems directly in the
%% TeX file.

% \begin{thebibliography}{00}

% %% \bibitem{label}
% %% Text of bibliographic item

% \bibitem{}

% \end{thebibliography}
\end{document}
\endinput
%%
%% End of file `elsarticle-template-num.tex'.

The problem is that when using \begin{table*}[H] the table disappears. When just using \begin{table*} the table is being displayed in the middle of the next page which is not what I want. I want it to be displayed at the place where it is defined in the code. So I use the [H] but this does not work. Do you know how I can place the table at the position where it is defined?

14
  • 3
    Remove \begin{table} and \end{table} and use \captionof instead of \caption. Then the table doesn't float, i.e., will be placed at the position where it is first seen regardless of whether there is space or not.
    – Marijn
    Commented Dec 5, 2023 at 15:22
  • 1
    Or first try \begin{table*}[h] (with lower case h) or maybe t or b, that might already work and is a bit less drastic than not using a float at all.
    – Marijn
    Commented Dec 5, 2023 at 15:23
  • 2
    unrelated but don't use \include in the preamble. Commented Dec 5, 2023 at 15:27
  • 1
    AFAIK, package float does not support float type H for floats over two columns like table* or figure*. Usually table* and figure* only support float options t and p.
    – cabohah
    Commented Dec 5, 2023 at 15:29
  • 1
    you can not use H with table^ Commented Dec 5, 2023 at 16:47

1 Answer 1

5

The column spanning float environments table* and figure* do not support the float option H of package float. They only support t, p (and with package dblfloatfix also b). Additionally column spanning floats like table* and figure* are never printed to the current page but earliest at the next page.

To say it clearly: You cannot use [H] with table*.

For a small table you could indeed use \begin{table}[H] to place it only here. But, because your table is wide (even wider than the text area), I would suggest to use:

\begin{table*}
    \centering
    \begin{tabular}{|c|c|c|c|c|c|}
        \hline
        & \makecell{Critera 1 \\ control} & \makecell{Critera 2 \\ optimal control} & \makecell{Critera 3 \\ smart control heuristic} & \makecell{Comparison to optimal \\ and smart control} & \makecell{Use of training data \\from other buildings} \\
        \hline
        Author 1 et al., 2020 [1] & \cmark & \rule{0.2cm}{0.2cm} & & & \\
        \hline
    \end{tabular}
    \caption{Comparison of relevant papers from the literature}
    \label{tab:my_label}
\end{table*}

or to make it fit the text area width:

\begin{table*}
    \centering
    \begin{tabular}{|c|c|c|c|c|c|}
        \hline
        & \makecell{Critera 1 \\ control} & \makecell{Critera 2 \\ optimal
      control} & \makecell{Critera 3 \\ smart control heuristic} &
                                                                   \makecell{Comparison to \\ optimal \\ and smart control} & \makecell{Use of training data \\from other buildings} \\
        \hline
        Author 1 et al., 2020 [1] & \cmark & \rule{0.2cm}{0.2cm} & & & \\
        \hline
    \end{tabular}
    \caption{Comparison of relevant papers from the literature}
    \label{tab:my_label}
\end{table*}

After adding some more text, it should be printed at the top of the next page.

And don't worry too much about the exact placement of figures and tables. The publisher may change them anyway.

However, if you insist in placing the table manually, you would have to do the whole page breaking manually, e.g.:

\documentclass[5p,times,twocolumn]{elsarticle}
\usepackage{physics}
\usepackage{tabularx}
\usepackage{siunitx}
\usepackage{xcolor}
\usepackage{hyperref}
\hypersetup{hidelinks}
\usepackage{csquotes}
\usepackage{amssymb}% http://ctan.org/pkg/amssymb
\usepackage{pifont}% http://ctan.org/pkg/pifont
\newcommand{\cmark}{\ding{51}}%
\newcommand{\xmark}{\ding{55}}%
\usepackage{acro}
%\include{sections/00_acro}
\graphicspath{{figures/}}
\usepackage{lipsum}
\usepackage{booktabs}
\usepackage{float}
\usepackage{comment}
\usepackage{subcaption}
\usepackage{framed} % Framing content
\usepackage{multicol} % Multiple columns environment
\usepackage{nomencl} % Nomenclature package

\usepackage{makecell}

\usepackage{mwe}% for demonstration only
\journal{}

\begin{document}

\begin{frontmatter}

\title{Title}


\author[1]{Author 1}
\author[1]{Author 2}


\address[1]{Institue 1}

\begin{abstract}
%\input{sections/00_abstract}
\end{abstract}

\begin{comment}
%%Graphical abstract
\begin{graphicalabstract}
\includegraphics{grabs}
\end{graphicalabstract}

%%Research highlights
\begin{highlights}
\item Research highlight 1
\item Research highlight 2
\end{highlights}
\end{comment}

\begin{keyword}
%% keywords here, in the form: keyword \sep keyword
keyword 1 \sep keyword 2 \sep keyword 3 \sep keyword 4 \sep keyword 5 
%% PACS codes here, in the form: \PACS code \sep code
%\PACS 0000 \sep 1111
%% MSC codes here, in the form: \MSC code \sep code
%% or \MSC[2008] code \sep code (2000 is the default)
%MSC 0000 \sep 1111
\end{keyword}

\end{frontmatter}

\thispagestyle{empty} % Remove page number and header/footer on the first page

%% \linenumbers

%\input{sections/00_nomecl}
%\input{sections/01_intro}
%\input{sections/02_results}
%\input{sections/03_conclusion}
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    \section{Introduction}
    \label{sec:introduction}
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    
    \subsection{Motivation}
    \label{sec:Motivation}
    
    
    
    \subsection{Related work}
    \label{sec:Related work}
    magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clitaeeeeeeeeeee kasd gubergren, no sea takimata diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptuaeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeamet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clitaeeeeeeeeeee kasd gubergren, no sea takimata diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptuaeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeamet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clitaeeeeeeeeeee kasd gubergren, no sea takimata diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptuaeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeamet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clitaeeeeeeeeeee kasd gubergren, no sea takimata diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptuaeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeamet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet 
    
    \begin{table}[H]
      \begin{minipage}{\textwidth}
        \centering
        \begin{tabular}{|c|c|c|c|c|c|}
            \hline
            & \makecell{Critera 1 \\ control} & \makecell{Critera 2 \\ optimal
          control} & \makecell{Critera 3 \\ smart control heuristic} &
                                                                       \makecell{Comparison to \\ optimal \\ and smart control} & \makecell{Use of training data \\from other buildings} \\
            \hline
            Author 1 et al., 2020 [1] & \cmark & \rule{0.2cm}{0.2cm} & & & \\
            \hline
        \end{tabular}
        \caption{Comparison of relevant papers from the literature}
        \label{tab:my_label}
        \end{minipage}
    \end{table}

    \newpage
    
    \subsection{Contribution}
    \label{sec:Contribution}

    \Blindtext[2]

    \parfillskip0pt % hack for invisible par
    Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
    Etiam lobortis facilisis sem. Nullam nec mi et neque pharetra
    sollicitudin. Praesent imperdiet mi nec ante. Donec ullamcorper, felis non
    sodales commodo, lectus velit ultrices augue, a dignissim nibh lectus
    placerat pede. Vivamus nunc nunc, molestie ut, ultricies vel, semper in,
    velit. Ut porttitor. Praesent

    \newpage\parfillskip 0pt plus 1fil % revert hack after new page

\noindent% part of hack for invisible par
in sapien. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Duis
fringilla tristique neque. Sed interdum libero ut metus. Pellentesque
placerat. Nam rutrum augue a leo. Morbi sed elit sit amet ante lobortis
sollicitudin. Praesent blandit blandit mauris. Praesent lectus tellus, aliquet
aliquam, luctus a, egestas a, turpis. Mauris lacinia lorem sit amet
ipsum. Nunc quis urna dictum turpis accumsan semper.

    \Blindtext[7]

%% If you have bibdatabase file and want bibtex to generate the
%% bibitems, please use
%%
 \bibliographystyle{elsarticle-num} 
 \bibliography{refs}

%% else use the following coding to input the bibitems directly in the
%% TeX file.

% \begin{thebibliography}{00}

% %% \bibitem{label}
% %% Text of bibliographic item

% \bibitem{}

% \end{thebibliography}
\end{document}
\endinput
%%
%% End of file `elsarticle-template-num.tex'.

I would not recommend to do this!

Another suggestion would be to use package midfloat and environment strip. You still cannot use \begin{float*}[H]…\end{float*} inside strip and \begin{float}[H]…\end{float} inside strip is also not recommended and usually does not work. But you can use strip with \captionof:

\begin{strip}
    \begin{tabular}{|c|c|c|c|c|c|}
        \hline
        & \makecell{Critera 1 \\ control} & \makecell{Critera 2 \\ optimal
      control} & \makecell{Critera 3 \\ smart control heuristic} &
                                                                   \makecell{Comparison to \\ optimal \\ and smart control} & \makecell{Use of training data \\from other buildings} \\
        \hline
        Author 1 et al., 2020 [1] & \cmark & \rule{0.2cm}{0.2cm} & & & \\
        \hline
    \end{tabular}
    \captionof{table}{Comparison of relevant papers from the literature}
    \label{tab:my_label}
\end{strip}

But in my tests, the column break of the second column is too early:

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .