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!
[1] Perfect positioning of an image on top of text
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}
\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 thecaption
package?