[Tex/LaTex] How to put figure caption on top?

captionspositioningtables

I have a table that I have inserted as a figure in LateX because it was externally created. I would like to have the caption on top, but it is not working. Any suggestions?

\newline
\topcaption{\textbf{{Table 1}}
\newline
\includegraphics[origin=c, scale=0.74]{table1}

Best Answer

A common misunderstanding by many beginners to LaTeX is that a tabular like environment can only be in a table environment and a graphics/diagram etc. must be contained in a figure environment.

However, LaTeX does not really care about the fact that the table might be included as an image 'only'. As long as the graphics format is the 'table' can be included as an image of course too.

The only relevance that is needed is the \caption which must appear inside the floating environment.

If the floating is not desired (or not possible), the \captionof{floattype}{your caption title} can be used instead -- this requires the very sophisticated caption package, however!

Either way the caption appears at the top if it is placed before the \includegraphics command -- no need to use weird \newline calls.

\documentclass{article}

\usepackage{caption}
\usepackage{graphicx}


\begin{document}
\listoftables
\clearpage
\begin{table}[ht]
\centering
\caption{Foo caption} \label{foo}
\includegraphics[scale=0.3]{ente}
\end{table}

Or using a \verb!\captionof! - command:

\begin{center}
\captionof{table}{Foobar caption} \label{foobar}
\includegraphics[scale=0.3]{ente}
\end{center}

There are two nice figures: \ref{foo} and \ref{foobar}
\end{document}

enter image description here