0

I have a question regarding latex tables and figures. This is my code:

\begin{figure}
    \centering
    \includegraphics{Template Master Thesis/Figures/conceptual model.png}
    \caption{Conceptual model}
    \label{fig:my_label}
\end{figure}

Once I remove \begin{figure} and \end{figure} my image is appearing. But with the current code, the image is not appearing. I want to add a caption to the image but I cannot do that If I don't use \begin{figure} and \end{figure}. The same applies to adding a table.

Can someone help me in making this code work, by displaying the figure with caption in my document?

Thank you in advance!

leandriis
  • 62,593
  • 2
    Regarding "the image is not appearing": is the image not showing up at all or just not where you would expect it to show up? – leandriis Mar 24 '20 at 11:15
  • 1
    figure and table are floating environments which means they not necessarily appear in the pdf exactly where you pleaced them in the input. You can influence the positioning of floats (See How to influence the position of float environments like figure and table in LaTeX?). – leandriis Mar 24 '20 at 11:18
  • 1
    If you absolutely do not want images to float but need a caption nevertheless (however, be warned about large white spaces if an image does not fit onto the remainder of a page), you can use \captionof{figure}{...} or \captionof{table}{...} to add captions to images and tabulars outside of figure od table environments. – leandriis Mar 24 '20 at 11:18
  • Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – Alessandro Cuttin Mar 24 '20 at 11:23
  • @leandriis Thank you for your response! I see that both my figure and table appear at the end of my document. But I want it in the text... I used your tip of this page "How to influence the position of float environments like figure and table in LaTeX?" When using \begin{table}[h] it still appears at the end of my document – programming student Mar 24 '20 at 12:41
  • @leandriis I used \captionof{figure}{...} and this works! Thank you for helping me out! – programming student Mar 24 '20 at 12:53
  • Regarding: "it still appears at the end": Which documentclass are you using? – leandriis Mar 24 '20 at 13:06
  • 1
    \begin{table}[h] (figure would be more natural than table) makes going to the end quite likely as it specifies that the float may not be placed at toe top or bottom of a page or on a page that only has floats (no t b or p) so latex doesn't have many options (in fact usually it gives a warning and change sit to [ht] to give itself at least a chance to position the figure) – David Carlisle Mar 24 '20 at 15:44

0 Answers0