# How to center a caption beneath a figure when using wrapfig in a two column (multicol) configuration

In Partha D.'s answer[1] to the question "Perfect positioning of an image on top of text" Partha presents a solution using wrapfig (instead of pullquote) to place caption text below a figure that is centered between columns in a two-column arrangement. In Partha's example, the caption below the figure is NOT fully centered, and is instead left justified. Numerous test trials using Partha's code have not produced a fully centered caption, including placing \centering within the \caption that creates the error "! Argument of @caption has an extra }.".

What am I missing? How can I center a caption below a figure when using wrapfig?

Edit: In response to leandriis' comment below (Thank you!), adding \captionsetup{justification=centering} to the preamble does NOT appear to affect centering ... the caption beneath the figure in my project remains left-centered.

Edit 2: @leandriis - Thank you. My documentclass is: \documentclass[12pt,oneside,table,xcdraw]{book} ... I am precluded from using \documentclass[twocolumn]{article} as most of my document is single column, with two-column used only in a few chapters with an image nestled between the two columns for emphasis. \begin{multicols}{2} [and \end{multicols}] is used instead to begin [and end] the two columnar layout. Any solution to center the caption will need to reflect the use of multicols. Please note that \caption works without error everywhere else in the document. Thank you!

Below is Partha D.'s MWE with \centering inserted within the \caption command.

\usepackage{lipsum,graphicx,wrapfig}
\begin{document}

\lipsum[1]

\begin{wrapfigure}[15]{r}[0.35\columnwidth]{5.2cm}
\includegraphics[width=5cm,height=10\baselineskip]{example-image-a}
\caption{\centering This wrapfigure spans two-columns of text}
\end{wrapfigure}

\lipsum[3-5]  %  deciding the break is vital to the
%  nice functioning of a 2-col wrapfigure

\begin{wrapfigure}[17]{l}[0.35\columnwidth]{5.2cm}
%  this only creates free space without inserting anything
\end{wrapfigure}

\lipsum[6-7]

\end{document}


• Adding the caption package to the preamble and using \captionsetup{justification=centering} should result in a horizontally centered caption. – leandriis Feb 20 at 14:51
• @leandriis, Thanks but it doesn't appear to be working in my LaTeX appliction; still left justified. – RosesBouquet Feb 20 at 15:37
• I can not confirm that adding \captionsetup{justification=centering} does not work. It at least does when adding \documentclass[twocolumn]{article} in order to make your code fragment compilable. Which documentclass are you currently using? Probably it is a class that is incompatible with the captionpackage? – leandriis Feb 20 at 16:27
• Somewhat related: tex.stackexchange.com/questions/512455/… – John Kormylo Feb 21 at 1:17

Beside considering @leandris suggestion in comment, which work fine, you need to center image in wrapfigure environment:

\documentclass[twocolumn]{article}
\usepackage{lipsum,graphicx,wrapfig}
\usepackage{caption}

\begin{document}
\lipsum[1]

\begin{wrapfigure}[14]{r}[0.35\columnwidth]{5.2cm}
\vspace{-\baselineskip}
\centering
\captionsetup{justification=centering}%
\includegraphics[width=5cm,height=10\baselineskip]{example-image-duck}%
\caption{This wrapfigure spans two-columns of text}
\end{wrapfigure}

\lipsum[3-5]  %  deciding the break is vital to the
%  nice functioning of a 2-col wrapfigure

\begin{wrapfigure}[17]{l}[0.35\columnwidth]{5.2cm}
%  this only creates free space without inserting anything
\end{wrapfigure}

\lipsum[6-7]
\end{document}


Tested with recent MikTeX.