1

I have added a table and after the table a graph.

I am using \begin{table}[H] (i tried with !h but it doesn't fix the problem) to control position of tables and similar code for figures. But although I put explicitly the table before the graph, the graph appears before. Is there any way to control it? Is there any way to order all floats in one shot?

What i have in my file looks like this:

\begin{center}
\begin{table}[h]
\centering
\caption{Convergencia pm6}
\label{convergencia_cluster_pm6_table}
\begin{tabular}{|l|l|l|}
\hline
\textbf{nºconf} & \textbf{$\Delta G^0$-SS} & \textbf{$\Delta G^0$-Packmol} \\ \hline
5 & -64.6 & -64.7 \\ \hline
10 & -65.5 & -64.1 \\ \hline
15 & -63.7 & -66.5 \\ \hline
20 & -64.3 & -65.0 \\ \hline
30 & -65.9 & -66.3 \\ \hline
40 & -67.2 & -65.6 \\ \hline
\end{tabular}
\end{table}
\end{center}
and for images:

\begin{figure}
\caption{Convergencia pm6 cluster}
\label{Convergencia_cluser_pm6_figure}    
\includegraphics[page=1,trim=0 140 0 360, clip, width=\linewidth]{imagenes/all_results_thesis.pdf}
\end{figure}
  • I think you have an answer at comments on your previous question... see here https://tex.stackexchange.com/questions/35125/how-to-use-the-placement-options-t-h-with-figures and try to use ht! or other options from the answer there – koleygr Aug 27 '17 at 02:10
  • see https://tex.stackexchange.com/a/7028/117534 – Troy Aug 27 '17 at 02:11
  • ! has to be before ht (!ht)... sorry. It was wrong in the previous comment too... But the others are more experienced... So you may ignore my answers – koleygr Aug 27 '17 at 02:18
  • 2
    If you don't want them to float, don't use a float. You don't have to put them in float environments, after all. If you really want it here, the answer isn't H. It is not to use table or figure at all. Use caption or capt-of if you need captions. – cfr Aug 27 '17 at 02:19
  • 1
    @koleygr No. That is the point of using those packages (one of). You have a caption. The caption gets added to the relevant list. It does not, however, float. The author of the float package has said just how much he regrets adding the H option. It is completely unnecessary always, and just causes problems in cases like this. – cfr Aug 27 '17 at 02:22
  • @cfr I show your edited comment (had not think about caption out of environment) and deleted the comment that was saying "In a thesis is suggested to have a list of figures and a list of tables and I think he need both floats". Your both above comments are really usefull for me (and I think for others too) – koleygr Aug 27 '17 at 02:26
  • @cfr The way to solve the problem was adding this: \usepackage[spanish,es-noquoting]{babel}. That's why i didn't accept the answer, and i hadn't seen it also. –  Aug 27 '17 at 03:52
  • @koleygr thanks but the information in that post didn't solve the problem; I tried with [h],[!h],[H], any of them was helpful –  Aug 27 '17 at 04:13
  • 1
    @HernanMiraola [!ht] was my suggestion... but I thing @cfr's solution should work (Almost nothing could break it) – koleygr Aug 27 '17 at 04:17
  • @koleygr cfr solution would be replacing \begin{table} by \captionof{table} or I misunderstood the answer? –  Aug 27 '17 at 04:21
  • 2
    @HernanMiraola just replace table or figure with center in your code and caption with captionof{table} or \captionof{figure} and leave text of caption as is. For example old \caption{Mytable 1} will become \captionof{table}{Mytable 1}... Add also \usepackage{caption} in your preamble – koleygr Aug 27 '17 at 04:35
  • Your updated code doesn't show a figure-like object. What are you trying to show? For sure, if the tabular object and the graph object have to be placed together, use neither a table nor a figure environment. – Mico Aug 27 '17 at 07:30
  • @HernanMiraola Oh, I thought you didn't like the es-noquoting solution. That's why I offered another. (I know this is off-topic.) You don't need to accept my answer and probably shouldn't if you're using another solution. – cfr Aug 27 '17 at 11:33
  • 1
    @HernanMiraola If you'd leave a comment saying whether it worked or not, when you have time to test, I'd much appreciate it. (The site will be tidier if you accept, I guess, but I'm personally much more interested in knowing it works or not in a real Spanish document!) – cfr Aug 27 '17 at 20:07
  • @cfr Good. I will try it today. Thanks for the patience.. –  Aug 28 '17 at 00:30

1 Answers1

5

Rather than using H, which is unnecessary at the best of times, and counter-productive otherwise, use caption or capt-of and don't use floats.

In general, if you don't want something to float, the answer is not to make it a float. Trying to make it a non-floating float is just a recipe for headaches.

...
\usepackage{caption}
...
\begin{center}
  ...
  \captionof{<type of thing>}{<caption>}\label{<type:key>}
\end{center}
...

For example,

\documentclass{article}
\usepackage{caption}
\begin{document}
\listoffigures
\listoftables
\begin{center}
  some other kind of stuff
  \captionof{table}{My table.}\label{tab:mytab}
  \bigskip

  some stuff
  \captionof{figure}{My figure.}\label{fig:myfig}
\end{center}
\end{document}

captions without floats

If you have no other use for caption, use capt-of instead. (But who doesn't have a use for caption?)

cfr
  • 198,882
  • It works good. Thanks cfr. Only one extra question: when I run latex it returns: Package caption Warning: The optionhypcap=true' will be ignored for this (caption) particular \caption on input line 17. See the caption package documentation for explanation.` –  Aug 27 '17 at 06:11
  • I have seen that a solution would be to use \usepackage[hypcap=false]{caption} and I want to ask you if it is a good option to do that. –  Aug 27 '17 at 06:12
  • @HernanMiraola Sorry, but that's above my pay grade. There's apparently a hypcap packages, but it isn't usually necessary, according to caption's manual. If you can't find something on this, I'd ask a new question so you get the hyper-linking folks. I mostly use it for Beamer stuff and then Beamer mostly takes care of everything for me. – cfr Aug 27 '17 at 20:09