2

Hello dear TexExchange community,

I'm having a weird problem which can be basically summarized with following image:

enter image description here

I'm including images like following:

\begin{figure}[h]
\centering 
\caption{Benutzeransicht der ersten Umfragerunde}
\vspace{0.4em}
\includegraphics[width=15cm]{Bilder/03_Methodik/ansicht.png}
\label{benutzeransicht}
\vspace{0.8em}
\begin{flushleft}
\footnotesize 
Quelle: Eigene Darstellung (Phonic.ai).
\end{flushleft}
\end{figure}

As I'm pretty inexperienced with LaTex, I can't tell what I#m doing wrong. Can someone help please? :)

3
  • 3
    Put the \label next to \caption and leave blank lines around \vspace.
    – egreg
    Mar 19, 2022 at 13:43
  • Oh wow, that was some quick help! Thank you very much, it worked! :) Mar 19, 2022 at 13:55
  • Why do you set [width=15cm] instead of [width=\textwidth]?
    – Mico
    Mar 19, 2022 at 14:27

3 Answers 3

1

You have a space between \includegraphics[...]{...} and \label, because the endline gets converted to a space. Also, \label refers to the \caption, not to the picture.

It's also better to set \vspace between paragraphs. Adapt them after trying the code below.

\begin{figure}[htp]
\centering 

\caption{Benutzeransicht der ersten Umfragerunde}
\label{benutzeransicht}

\vspace{0.4em}

\includegraphics[width=15cm]{Bilder/03_Methodik/ansicht.png}

\vspace{0.8em}

\raggedright\footnotesize 
Quelle: Eigene Darstellung (Phonic.ai).

\end{figure}

Why htp? Because you want that LaTeX finds a way to place the figure. Why \raggedright? Because flushleft adds vertical space around it.

0

The non-centering issue vanishes automatically if you replace [width=15cm] with [width=\textwidth]. Doing so will also let you omit the \centering directive and the flushleft environment. Oh, and do make sure to execute the \label directive after, not before, the \caption directive.

enter image description here

\documentclass[demo]{article} % remove 'demo' opton in real doc.
\usepackage{graphicx}
\usepackage[ngerman]{babel}

\begin{document}

\begin{figure}[ht]
\caption{Benutzeransicht der ersten Umfragerunde} \label{benutzeransicht}

\medskip
\includegraphics[width=\textwidth]{Bilder/03_Methodik/ansicht.png}

\medskip
\footnotesize 
Quelle: Eigene Darstellung (Phonic.ai).
\end{figure}

\end{document}
0

enter image description here

For writing note about image source I would use \usepackage{copyrightbox} package:

\documentclass[demo]{article} % remove 'demo' option in real doc.
\usepackage[ngerman]{babel}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{copyrightbox}

\begin{document}

\begin{figure}[ht]
\caption{Benutzeransicht der ersten Umfragerunde} \label{benutzeransicht}
\copyrightbox[b]{\includegraphics[width=\textwidth]{Bilder/03_Methodik/ansicht.png}}
                {Quelle: Eigene Darstellung (Phonic.ai).}
\end{figure}

\end{document}

You must log in to answer this question.

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