Graphics, Figures & TablesFigure does not show in pdf

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
Es_dutch
Posts: 8
Joined: Fri Apr 24, 2020 9:35 pm

Figure does not show in pdf

Post by Es_dutch »

Hi everyone,
I could not find a solution to my problem on google. Hope one of you can help me. I am new to Latex and use a template I got from a beginners course.

I want to put multiple pictures (PNG format) in my latex document. Though, when I compile it the pictures are not in the pdf. I see a black border and the path of the image inside it. The caption does appear.
You can see it in this picture:
Aantekening 2020-04-24 215030.png
Aantekening 2020-04-24 215030.png (16.93 KiB) Viewed 5226 times
I have the following code in the preamble.

\documentclass[12pt]{report}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{csquotes}
\usepackage{subfiles}
\usepackage{amsmath}
\usepackage{adjustbox}
\usepackage{graphicx}
\usepackage{epstopdf}
\usepackage{ltablex}
\usepackage{booktabs}
\usepackage{tcolorbox}
\usepackage{caption}
\usepackage[font=small,labelfont=bf]{caption}
\usepackage{setspace}
\usepackage{placeins}
\usepackage[hidelinks]{hyperref}
\usepackage{chngpage}
\usepackage{dcolumn}
\usepackage[toc, page]{appendix}
\usepackage{chngcntr}
\usepackage{subcaption}

\usepackage{import}
\renewcommand{\baselinestretch}{1.5}

\usepackage[english]{babel}
\usepackage{apacite}
\usepackage{natbib}
\usepackage[backend=biber, maxcitenames=2, style=apa, sorting=anyt]{biblatex}
\DeclareNameAlias{sortname}{family-given}
\addbibresource{bibliography.bib}
\usepackage[autostyle, english = british]{csquotes}

\usepackage{geometry}
\geometry{margin=2.5cm}

\counterwithout{figure}{chapter}
\counterwithout{table}{chapter}

\usepackage[compact]{titlesec}
\titleformat{\chapter}{\LARGE\bfseries}{\thechapter}{1em}{}
\titlespacing{\chapter}{0pt}{-20pt}{10pt}
\titleformat{\section}{\large\bfseries}{\thesection}{1em}{}
\usepackage{parskip}

\usepackage{fancyhdr}
\fancyhf{}
\pagestyle{fancy}
\fancyfoot[l]{\thepage}
\fancyhead[r]{\nouppercase{\leftmark}}
\renewcommand{\footrulewidth}{0pt}
\renewcommand{\headrulewidth}{0,5pt}
\fancypagestyle{plain}{}

\hyphenation{con-sti-tu-tion-al}



And in the section where I want my figure I have the following code (I have my images in a seperate folder called images):

\begin{figure}
\centering
\begin{subfigure}[b]{0.4\linewidth}
\includegraphics[width=\linewidth]{images/instrumenta.png}
\caption{Instrument a}
\label{fig:instrumenta}
\end{subfigure}

\begin{subfigure}[b]{0.4\linewidth}
\includegraphics[width=\linewidth]{images/instrumentb.png}
\caption{Instrument b}
\label{fig:instrumentb}
\end{subfigure}

\caption{Correlation figures instruments}
\label{fig:corinstruments}

\end{figure}


Hope someone can help me! Thank you in advance.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Ijon Tichy
Posts: 640
Joined: Mon Dec 24, 2018 10:12 am

Figure does not show in pdf

Post by Ijon Tichy »

I cannot reproduce the problem with the shown code, because it is not a Infominimal working example but only some code snippets. However, the mentioned result usually happens with option draft. So maybe somewhere (but not in the shown code) this option is set.

BTW: You should load package only once. Loading them more than once results in option clash errors in your example. And you should never combine natbib or apacite with biblatex. These packages are incompatible and the combination results in error messages. And hyperref should be loaded after most other package, e.g., after titlesec.

I would recommend to reduce the preamble to those package you really need. If if you need more help, you should create and show a Infominimal working example.
Sorry, but I can no longer participate here as the administrator is trampling on my wishes on one of his other platforms. :cry:
Es_dutch
Posts: 8
Joined: Fri Apr 24, 2020 9:35 pm

Figure does not show in pdf

Post by Es_dutch »

Thank you for your quick answer! Sorry that I did not put it in the right format.
I will check my packages and which i dont need. I copied them from the template so I am not sure which ones are necessary for the lay out and which ones are not.

I checked my packages and also look into the draft tip you gave me. It worked so thank you very much!
Post Reply