0

I have in my document several tikz pictures wraped with wrapfigure, only one of them is having overllaping with text, here is a screenshot of the pdf output

As you can see, the math equation is centered as if no wrap figure was present, here is the code (bear in mind, I'v stripped most of non-issue code). However when compiling the code on overleaf (project url is in the bottom) the problem is non-exsitent, I'm using MikTeX + PDFLaTeX on windows 10 machine.

\documentclass[12pt]{book}

\usepackage[top = 1in,
            bottom = 1in,
            left = 0.75in,
            right = 0.75in
            ]{geometry}
\usepackage{tikz}
\usetikzlibrary{3d}

\usepackage{graphicx}
\usepackage{amsmath, amsfonts}
\usepackage{wrapfig}
\usepackage{pgfplots}

\begin{document}
\begin{wrapfigure}{r}{0.35\textwidth}
\vspace{-60pt}
\begin{tikzpicture}[scale = 3]

\filldraw [very thick, draw = red, fill = red!10] (0, 0) -- (0.5, 0) arc[start angle = 0, end angle = 45, radius = 0.5] -- cycle;

\filldraw [very thick, draw = red, fill = red!10, rotate = 90] (0, 0) -- (0.5, 0) arc[start angle = 0, end angle = 45, radius = 0.5] -- cycle;

\node [anchor = south west] at (22.5: 0.5) {$\Psi$};
\node [anchor = south east] at (112.5: 0.5) {$\Psi$};

\node [anchor = west] at (1, 0) {$\vec{i}$};
\node [anchor = south] at (0, 1) {$\vec{j}$};
\node [anchor = south west] at (45:1) {$\vec{u}$};
\node [anchor = south east] at (135:1) {$\vec{v_1}$};
\node [anchor = north west] at (0.1, 0) {$O$};
\node [anchor = east] at (-0.1, 0) {$\vec{k}$};

\filldraw [fill = orange!50, draw = orange, very thick] (0, 0) circle (0.075);

\begin{scope}[red, ->, very thick]
\draw (0, 0) -- (0, 1);
\draw (0, 0) -- (1, 0);
\end{scope}

\begin{scope}[rotate = 45, green, ->, very thick]
\draw (0, 0) -- (0, 1);
\draw (0, 0) -- (1, 0);
\end{scope}
\draw (-1, -1) rectangle (1.2, 2);
\end{tikzpicture}
\end{wrapfigure}




\subsection{Mutation Rotation $\theta$}

It is the rotation around the $\vec{u}$ axis.

$$\vec{\Omega}(R_2/R_1) = \dot{\theta} \vec{u}$$

$$\left(\vec{u},\vec{v_1}, \vec{k_0}\right)\longrightarrow\left(\vec{u}, \vec{v},\vec{k_s}\right)$$

\end{document}

Here is a screen shot of this program, you can see there is a wraping problem along the x-axis.

Screenshot of mini-code execution

I've uploaded the whole code to overleaf.com, in case you needed all of it.

3
  • the image you show is not from the code that you post (section numbering at least is different) I get equations centred in the remaining space (texlive 2021) this output. Possibly not releated but you should not use $$ in latex. Oct 12, 2021 at 15:12
  • as commented the code you posted does not show the mis-aligned equations see it on overleaf at overleaf.com/read/tbmcchrfqhpf your full document has other warnings in particular wrapfig with conflicting positions. Oct 12, 2021 at 17:14
  • I'm not able to point out the problem, overleaf seems to output the pdf better than MikTeX, I changed the layout of the material to avoid this problem Oct 12, 2021 at 17:25

1 Answer 1

0

Use a tighter rectangle around the figure or none at all.

The figure should be after the \subsection to avoid the warning Stationary wrapfigure forced to float

Running MikTeX and pdflatex. This is pdfTeX, Version 3.141592653-2.6-1.40.22 (MiKTeX 21.3)

a

% !TeX TS-program = pdflatex

\listfiles
\documentclass[12pt]{book}

\usepackage[top = 1in,
            bottom = 1in,
            left = 0.75in,
            right = 0.75in
            ]{geometry}
\usepackage{tikz}
\usetikzlibrary{3d}

\usepackage{graphicx}
\usepackage{amsmath, amsfonts}
\usepackage{wrapfig}
\usepackage{pgfplots}
\pgfplotsset{compat=1.17}

\begin{document}

\subsection{Mutation Rotation $\theta$}

\begin{wrapfigure}{r}{0.4\textwidth}
\vspace{-40pt} % changed <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
\begin{tikzpicture}[scale = 3]

    \filldraw [very thick, draw = magenta, fill = red!10] (0, 0) -- (0.5, 0) arc[start angle = 0, end angle = 45, radius = 0.5] -- cycle;
    
    \filldraw [very thick, draw = magenta, fill = red!10, rotate = 90] (0, 0) -- (0.5, 0) arc[start angle = 0, end angle = 45, radius = 0.5] -- cycle;
    
    \node [anchor = south west] at (22.5: 0.5) {$\Psi$};
    \node [anchor = south east] at (112.5: 0.5) {$\Psi$};
    
    \node [anchor = west] at (1, 0) {$\vec{i}$};
    \node [anchor = south] at (0, 1) {$\vec{j}$};
    \node [anchor = south west] at (45:1) {$\vec{u}$};
    \node [anchor = south east] at (135:1) {$\vec{v_1}$};
    \node [anchor = north west] at (0.1, 0) {$O$};
    \node [anchor = east] at (-0.1, 0) {$\vec{k}$};
    
    \filldraw [fill = orange!50, draw = orange, very thick] (0, 0) circle (0.075);
    
    \begin{scope}[red, ->, very thick]
    \draw (0, 0) -- (0, 1);
    \draw (0, 0) -- (1, 0);
    \end{scope}
    
    \begin{scope}[rotate = 45, green, ->, very thick]
    \draw (0, 0) -- (0, 1);
    \draw (0, 0) -- (1, 0);
    \end{scope}
    \draw[xshift =-10mm,yshift = -2mm] (0, 0) rectangle (2.3, 1.5); % changed <<<<<<<<<<<<<<
\end{tikzpicture}
\end{wrapfigure}
It is the rotation around the $\vec{u}$ axis.

\[\vec{\Omega}(R_2/R_1) = \dot{\theta} \vec{u}\]

\[\left(\vec{u},\vec{v_1}, \vec{k_0}\right)\longrightarrow\left(\vec{u}, \vec{v},\vec{k_s}\right)\]

\end{document}

The command \listfiles at the beginning will put a list of all files loaded and their version in the .log file.

Compare with mine to see if any package need updating.

*File List*
book.cls    2020/04/10 v1.4m Standard LaTeX document class
bk12.clo    2020/04/10 v1.4m Standard LaTeX file (size option)
geometry.sty    2020/01/02 v5.9 Page Geometry
keyval.sty    2014/10/28 v1.15 key=value parser (DPC)
ifvtex.sty    2019/10/25 v1.7 ifvtex legacy package. Use iftex instead.
iftex.sty    2020/03/06 v1.0d TeX engine tests
geometry.cfg
tikz.sty    2020/12/27 v3.1.8b (3.1.8b)
pgf.sty    2020/12/27 v3.1.8b (3.1.8b)
pgfrcs.sty    2020/12/27 v3.1.8b (3.1.8b)
pgfrcs.code.tex
pgfcore.sty    2020/12/27 v3.1.8b (3.1.8b)
graphicx.sty    2020/09/09 v1.2b Enhanced LaTeX Graphics (DPC,SPQR)
graphics.sty    2020/08/30 v1.4c Standard LaTeX Graphics (DPC,SPQR)
trig.sty    2016/01/03 v1.10 sin cos tan (DPC)
graphics.cfg    2016/06/04 v1.11 sample graphics configuration
pdftex.def    2020/10/05 v1.2a Graphics/color driver for pdftex
pgfsys.sty    2020/12/27 v3.1.8b (3.1.8b)
pgfsys.code.tex
pgfsyssoftpath.code.tex    2020/12/27 v3.1.8b (3.1.8b)
pgfsysprotocol.code.tex    2020/12/27 v3.1.8b (3.1.8b)
xcolor.sty    2016/05/11 v2.12 LaTeX color extensions (UK)
color.cfg    2016/01/02 v1.6 sample color configuration
pgfcore.code.tex
pgfcomp-version-0-65.sty    2020/12/27 v3.1.8b (3.1.8b)
pgfcomp-version-1-18.sty    2020/12/27 v3.1.8b (3.1.8b)
pgffor.sty    2020/12/27 v3.1.8b (3.1.8b)
pgfkeys.sty    
pgfkeys.code.tex
pgfmath.sty    
pgfmath.code.tex
pgffor.code.tex
tikz.code.tex
amsmath.sty    2020/09/23 v2.17i AMS math features
amstext.sty    2000/06/29 v2.01 AMS text
amsgen.sty    1999/11/30 v2.0 generic functions
amsbsy.sty    1999/11/29 v1.2d Bold Symbols
amsopn.sty    2016/03/08 v2.02 operator names
amsfonts.sty    2013/01/14 v3.01 Basic AMSFonts support
wrapfig.sty    2003/01/31  v 3.6
pgfplots.sty    2020/02/29 v1.17 Data Visualization (1.17)
l3backend-pdftex.def    2021-03-18 L3 backend support: PDF output (pdfTeX)
supp-pdf.mkii
epstopdf-base.sty    2020-01-24 v2.11 Base part for package epstopdf
epstopdf-sys.cfg    2021/03/18 v2.0 Configuration of epstopdf for MiKTeX
umsa.fd    2013/01/14 v3.01 AMS symbols A
umsb.fd    2013/01/14 v3.01 AMS symbols B
***********
2
  • the box is just for outlining, even without it the problem persists, and there is something wrong with miktex at that location, because overleaf compiled it normally, so I gave up as I'm too beginner to solve such nasty problem. And your proposed solution works with me also, but not at the desired spot, as I said, something wrong with miktex or its version of pdflatex. but still thanks Oct 12, 2021 at 20:20
  • @Allaw Hussein Please try the code of my answer as it is, complete, is in your installation. What result you got from \listfiles? I made only three changes: the \vspace before the figure, the position of \subsection and the dimension of the rectangle around the figure, Oct 12, 2021 at 20:31

You must log in to answer this question.

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