1

Problem description / My situation: First, I added in the preamble:

\RequirePackage{array}

to be able to use \raggedright\arraybackslash in

\begin{tabular}[t]{l>{\raggedright}p{0.35\linewidth}>{\raggedright\arraybackslash}p{0.3\linewidth}}

Then, still in the preamble, I added:

\RequirePackage{float}

to be able to add the option [H] in

\begin{figure}[H]

My question: If I use the option [H], figures or tables disappear once I compile the latex document. In order to see/show them after compiling the document, I should replace [H] by [!htbp], but obviously the figures and tables are not in the exact spot I want/need. Is there any conflict between the packages float and array? How can I use both packages and the option [H] at the same time? In other words, if I use \begin{table*}[H] or \begin{figure*}[H] instead of \begin{table*} or \begin{figure*}, both Figures and Tables disappear. Please check with and without [H].

Minimal working example: Note: I am using the "Scientific Report" template in Overleaf, and I added

\RequirePackage{array}
\RequirePackage{float}

inside the file wlscirep.cls, there included. Here following the minimal working example:

\documentclass[fleqn,10pt]{wlscirep}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lipsum}

\title{Title of this document}

\begin{document}

\maketitle
\section*{Section Title}
\lipsum[2-12]

% ------ FIGURE --------------------------------------------------
\begin{figure*}[H]
\centering
\includegraphics[width=\textwidth]{stream.jpg}
\caption{A stream.}
\end{figure*}

% ------ TABLE 1 -------------------------------------------------
\begin{table*}[H]
    \centering
    \begin{tabular}[t]{ c c c c c c c c c c}
    \toprule
    &$A$&$B$&$C$&$D$&$E$&$F$&$\alpha$&$\beta$&$\gamma$\\
    \midrule
    London
    & $0.1$ & $5.6$ & $0.5$ & $3$ & $9$ & $0.01$ & $4$  & $8$ & $22$\\
    Paris & $0.8$ & $6$ & $22.4$ & & & & &  $4$ \\
    Moscow & $0.7$ & $54$ & & & & & & &  $45$ \\
    Berlin & $0.2$ & $1.01$ & $41$ & & & & &  $92$ \\
    Rome & $0.9$ & $24$ & $601$ & & & & & &  $9.5$ \\
    \bottomrule
    \end{tabular}
    \caption{Some values.}
    \label{Tab:table_1}
\end{table*}

% ------ TABLE 2 -------------------------------------------------
\begin{table*}[H]
    \centering
    \begin{tabular}[t]{l>{\raggedright}p{0.35\linewidth}>{\raggedright\arraybackslash}p{0.3\linewidth}}
    \toprule
    &Feature 1 &Feature 2\\
    \midrule
    London&-&50 \\
    Paris&80&50 \\
    Rome&8&0 \\
    Ottawa&9&7 \\
    Berlin&7&1 \\
    Mexico City&4&2 \\
    Dakar&5&5 \\
    Ljubljana&9&- \\
    Washington D.C.&0&- \\
    Abu Dhabi&1&- \\
    Viennas&2&- \\
    Brussels&2&- \\
    Luanda&3&- \\
    Moscow&0&- \\
    Lima&-&2 \\
    \bottomrule
    \end{tabular}
    \caption{Features for each city.}
    \label{Tab:table_2}
\end{table*}

\end{document}

After compiling this code: enter image description here

11
  • 2
    Welcome to TEX.SE! In a standard setup there should be no issue with array and float, so whatever is happening is related to some code you are withholding. Please provide a full minimal working example which reproduces the issue, starting with \documentclass{...} and ending with \end{document}.
    – campa
    Apr 12, 2021 at 11:26
  • My guess is that the document class doesn't like the [H] option. Just don't use it. It simply destroys the document's pagination.
    – egreg
    Apr 12, 2021 at 13:33
  • Thanks @campa! I added the "minimal working example" as suggested..
    – limone
    Apr 12, 2021 at 13:34
  • thanks @egreg, Yes, I removed, but the figure and table are not going exactly where I want, even if I use the option [!htbp] in \begin{table*}[!htbp] (or in the figure)..
    – limone
    Apr 12, 2021 at 13:36
  • @limone That's normal: it's very unlikely that the available space on a page can make tables or figures to fit, so LaTeX has the floating mechanism. Captions have precisely the purpose of explaining the figure or table and of providing a number for cross-reference.
    – egreg
    Apr 12, 2021 at 13:40

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.