I have been searching and trying for a while looking for the cause of the warning and the unexpected placement of the figure at the bottom of the text when it should be beside the text. I thought of providing an MWE of the error. Problem is that there is no problem when the code is very short. I get what I expected. But I am writing a book with twoside option with uneven inner and outer margins set in geometry package. The content is already too long to actually pinpoint the cause. I made a separate chapter for making some biography and add the author's picture at the side of the text, preferably on the left top corner (at the start of the text). In this chapter there are no lists or code listings or whatsoever that may conflict with wrapfigure environment. But still I get the warning and wrong placement of figure. I am using Overleaf for the project. And the chapter is just a separate file that is included in the main script via input command. Writing small code with wrapfig is just fine. I might try using minipage as an alternative. But I thought this could be the best. Any clarification and solution would be helpful.

From Overleaf

My preamble is as follows:

\documentclass[10pt, twoside]{book}


\usepackage{mathtools, nccmath}

\usepackage{wrapfig, blindtext}
\usepackage{cleveref} % For making multiple references.
\usepackage[numbered, useliterate]{mcode} % For MATLAB codes.
%\usepackage{xcolor} % For colored environments or texts.
\usepackage{listings} % For code listings.
\usepackage{caption, subcaption} % For figures and subfigures.
\graphicspath{ {./graphics/} }
\usepackage[paperwidth=6in, paperheight=9in, top=0.5in, bottom=0.5in, outer=0.5in, inner=0.75in,includehead,includefoot]{geometry}
\makeindex[columns=2, title=Alphabetical Index, options=-s]
\usepackage{verbatim} % For commenting block of codes
\usepackage{emptypage} % For inserting empty pages at the end of chapters.
\renewcommand{\listfigurename}{List of Figures}
\renewcommand{\listtablename}{List of Table}
% For reducing space between chapter title and top of page
{\normalfont\huge\bfseries}{\chaptertitlename\ \thechapter}{20pt}{\Huge} 

% For header and footer line on every page
\lfoot{cdass text(import)}
            \ifnum \c@secnumdepth >\m@ne \if@mainmatter
              \@chapapp\ \thechapter. \ \fi\fi#1}}{}}

  • the preamble is not that helpful to debug your problem, almost all of it will not be related so it just complicates debugging. What is needed is a small self contained example that reproduces the problem. Once you make that you can easily test deleting packages in the preamble and only post the document using packages needed to show the problem. Jun 23, 2021 at 9:10
  • in particular the error messag esays that wrapfig is in a conflicting environment (which usually means it is in a list or display environment) but your image shows it at the same level as \chapter which is usually at the top level. In any case the error is about the position of wrapfig in the document so not really related to the preamble settings at all. Jun 23, 2021 at 9:12
  • Exactly, I tried to find the cause by actually copying everything from the preamble and making a separate script with just one chapter and the wrapfigure environment. I found no problems and no warnings. Everything went perfect.
    – SolidMark
    Jun 23, 2021 at 9:14
  • 1
    large is fine but justify should never be used as a command it is like \center and is the internal implementation of the begin{justify} environment. ragged2e adds that for completeness to match flushleft and flushright but I have never seen any document where it is useful: justification is the default in tex. If you have any instances of \justify simply remove them. Jun 23, 2021 at 11:44
  • 1
    but the error from wrapfig is just a symptom the document was already in error if it's all in the scope of \justify Jun 23, 2021 at 12:29

1 Answer 1


The example (as clarified in comments) can be simplified to






which produces the warning

Package wrapfig Warning: wrapfigure used inside a conflicting environment on in
put line 9.

The error here is \center which is the internal form of \begin{center} and should not be used as a command. The command form is \centering which makes no warning.

The actual case was \justify from ragged2e which is again the internal environment form, the command form is \justifying. However for this case the fix is simpler: you can just remove the command. The ragged2e package adds \justifying as a complement to \centering, \raggedright and \raggedleft, but justification is the default in TeX and I have never seen any valid use of this command. When it is used it is usually an attempt to mitigate a earlier error where \raggedright has not been used with the correct scope so is applying to too much of the document, but it is much better to fix the use of \raggedright so that it is in a group and ends at the correct place rather than try to undo the raggedness by applying \justifying within the ragged section.

You must log in to answer this question.

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