# Centering caption in wrapfigure environment

\documentclass[11pt,a4paper]{article}
\usepackage{amssymb,amsmath,amsthm}
\usepackage[dutch]{babel}
\setlength{\parindent}{1cm}
\setlength{\parskip}{0cm}
\usepackage{relsize}
\usepackage{graphicx}
\usepackage{movie15}
\usepackage{hyperref}
\usepackage{wrapfig}
\usepackage[justification=centering]{caption}
\newcommand\md{\ }

\begin{document}


I have a trouble with centering the captions on my figures (PNG-files) which I want to include in LaTeX. For example, this is what I get for one of them (I took a screenshot):

To the left of the graph is my text. The trouble I'm having is this: the 'figuur 2' and the description that follows is not really centered under the graph. It's too much to the left.

Also I'm having a problem with the 'wrapfigure' environment. For example, when I use the command:

\begin{wrapfigure}{r}{0.80\textwidth}
\centering
\includegraphics[scale=0.7]{hysteresis.png}
\caption{Hysteresis-lus}
\end{wrapfigure}


The figure (another graph) somehow shows up at the bibliography section (end of document), while I want it to the left, surrounded by my text.

Any help with these issues please?

• Any help with the last issue please? I use wrapfigure command, but still my graph always shows up at the bottom of my text... – Kamil Mar 14 '15 at 19:33
• Probably the value of 0.80\textwidth is not the real width of your figure. Try with 0pt, LaTeX will measure the real width. – Bernard Mar 14 '15 at 20:29
• Just tried that, and it doesn't fix the problem. – Kamil Mar 14 '15 at 20:40
• Finally found it! The command 'FloatBarrier' which I inserted after the graph, prevented it from going down. I'm still not sure why, but it worked. But still I want the captions to be centered, any ideas? – Kamil Mar 14 '15 at 21:05

You can replace [scale=…] with [width=…], and choose 0pt as width argument. Here is an example of boths with one of my graphics files:

\documentclass[11pt,a4paper]{article}
\usepackage{amssymb,amsmath,amsthm}
\usepackage[dutch]{babel}
\setlength{\parindent}{1cm}
\setlength{\parskip}{0cm}
\usepackage{relsize}
\usepackage{graphicx}
\usepackage{hyperref}
\usepackage{wrapfig}
\usepackage[justification=centering]{caption}
\usepackage{lipsum}

\begin{document}


% \lipsum[2]

\begin{wrapfigure}{r}{0pt}
\includegraphics[width = 0.75\linewidth]{loupnorstein2}
\caption{Hysteresis-lus}
\end{wrapfigure}

\lipsum[3]

\begin{wrapfigure}{r}{0pt}
\includegraphics[scale=0.5]{loupnorstein2}
\caption{Hysteresis-lus}
\end{wrapfigure}


\lipsum[4]

\end{document}