1

I have the following minipage:

\begin{minipage}{\textwidth}
    \centering
    \begin{minipage}[ht]{0.4\textwidth}
        \centering
        \includegraphics[width=.6\linewidth] {fig/grafo1.eps}
        \label{fig:g1_5}
        \captionof{figure}{Grafo de ejemplo(¿?).}
    \end{minipage}
    \quad
    \begin{minipage}[ht]{0.4\textwidth}
        \centering
        \begin{tabular}{|c|c|c|c|c|}
            \hline
            \begin{tabular}[c]{@{}c@{}}Iteración\\ Vértice\end{tabular} & 1                         & 2                          & 3                         & 4                         \\ \hline
            1                                                           & -1                        & -1                         & \cellcolor[HTML]{C0C0C0}1  & -                         \\ \hline
            2                                                           & -3                        & \cellcolor[HTML]{C0C0C0}-1 & -                         & -                         \\ \hline
            3                                                           & \cellcolor[HTML]{C0C0C0}0 & -                          & -                         & -                         \\ \hline
            \cellcolor[HTML]{C0C0C0}4                                   & -                         & -                          & -                         & -                         \\ \hline
            5                                                           & -2                        & -2                         & 0                         & \cellcolor[HTML]{C0C0C0}2 \\ \hline
        \end{tabular}
        \captionof{table}{Ejemplo de una construcción voraz.}
        \label{tab:cv}
    \end{minipage}
\end{minipage}

And after that I tried to refenrence the figure:

Now I reference \ref{fig:g1_5} 

The minipage is seen like:

enter image description here

As you can see, figure caption is ok, but reference it is not:

Now I reference 4.3.2

(It is the number of the section)

How I can use the figure reference in the minipage?

It may be:

Now I reference Figure 4.4

5
  • A figure reference must be in a figure-like float. Think of minipages as sub-sections for the purpose of labels.
    – WesH
    Jun 4, 2019 at 18:24
  • Is there any way to deceive latex, and make it think it is a reference of a figure? In the same was as I used captionof{figure}
    – scd
    Jun 4, 2019 at 18:26
  • @Sergio Cavero: You should provide a compilable MWE. What class and packages are you using?
    – Marian G.
    Jun 4, 2019 at 18:27
  • Sorry Marian, but I was writing a book and I was using to many packages... @MarianG.
    – scd
    Jun 4, 2019 at 18:32
  • In the future, your MWE should include only packages required to produce the error. Make it easy for helpers to reproduce your error. So for this MWE you would just need graphicx and xcolor with the table option (I think).
    – WesH
    Jun 4, 2019 at 21:05

1 Answer 1

3

\label always after \caption!

   \captionof{figure}{Grafo de ejemplo(¿?).}
   \label{fig:g1_5}
1
  • What an inattention! Many thanks.
    – scd
    Jun 4, 2019 at 18:35

You must log in to answer this question.

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