Centering caption in wrapfigure environment

4,012

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}
%\graphicspath{ {c:/Bureaublad} }
\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} 

enter image description here

Share:
4,012

Related videos on Youtube

Kamil
Author by

Kamil

I'm a PhD student in theoretical high energy physics who likes to do pure mathematics from time to time.

Updated on August 01, 2022

Comments

  • Kamil
    Kamil over 1 year
    \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}
    \graphicspath{ {c:/Bureaublad} }
    \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):

    enter image description here

    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?

    • Kamil
      Kamil over 8 years
      Any help with the last issue please? I use wrapfigure command, but still my graph always shows up at the bottom of my text...
    • Bernard
      Bernard over 8 years
      Probably the value of 0.80\textwidth is not the real width of your figure. Try with 0pt, LaTeX will measure the real width.
    • Kamil
      Kamil over 8 years
      Just tried that, and it doesn't fix the problem.
    • Kamil
      Kamil over 8 years
      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?