6

After several lectures on the wrapfig package (pag. 1 ad 2) and in this guide (pag. 147), yet I don't understand how to use it correctly this package well for the creation of my book. In fact after many attempts I am able to insert an image in the correct position after numerous compilations in the desired place.

I have not understood how should I use [<number of narrow lines>], i.e. how I must choose the exact number of these narrow lines (red rectangle).

enter image description here

In some situations of my book I have little text (words) and the figure invades either a definition or a theorem or an example. I simply ask you for a simple explanation how to use correctly the parameters of wrapfig, wrapfloat environment, and the difference between r and R. Similarly for the L, l, i, I, o, O.

Lastly, I would like to know if exist a command that have the same function as the line break in Office Word software.

If the English language is not correct and not clear, please edit my question. Thank you.

Here a MWE of my problems with wrapfig.

enter image description here

\documentclass[12pt]{book}
\usepackage{newtxtext}
\usepackage[utf8]{inputenc} 
\usepackage[T1]{fontenc} 
\usepackage{graphicx} 
\usepackage[labelfont=bf]{caption}
\usepackage{wrapfig}
\usepackage{microtype} 

\usepackage{mathtools,amsthm,amssymb}
\def\vf{\varphi}
\newcommand\xyz{(x,y,z)}

\RequirePackage[framemethod=default]{mdframed}
% Definition box % added
\newmdenv[skipabove=7pt,
skipbelow=7pt,
rightline=false,
leftline=true,
topline=false,
bottomline=false,
linecolor=red,
backgroundcolor=yellow,
innerleftmargin=5pt,
innerrightmargin=5pt,
innertopmargin=2pt,
leftmargin=0cm,
rightmargin=0cm,
linewidth=4pt,
innerbottommargin=5pt]{dBox}    

\newtheorem{definitionT}{Definizione}[section]
\newenvironment{definition}{\begin{dBox}\begin{definitionT}}{\end{definitionT}\end{dBox}}   


\begin{document}
\section{Campi vettoriali, scalari, radiali, centrali e conservativi}\index{Campi vettoriali, scalari, radiali, centrali e conservativi}

\begin{definition} Un campo \textbf{vettoriale} (tridimensionale) è una funzione $\overline F: D\to\mathbb{R}^3$  dove $D$ è un aperto di $\mathbb{R}^3$; 
\end{definition}

\begin{definition}
Un campo \textbf{scalare} (tridimensionale) è una funzione $\vf: D\to\mathbb{R}$, dove $D$ è aperto di $\mathbb{R}^3$.
\end{definition}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{wrapfigure}[7]{L}{0.4\textwidth}
\vspace{-2cm}
\centering
\includegraphics[width=0.4\textwidth]{example-image-c}
\caption{Vettore posizione $\textbf{r}$.}
\label{fig:sidecap}
\end{wrapfigure}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

La variabile indipendente in $\mathbb{R}^3$ si indica molto spesso con $\mathbf{r}=|P-O|$ oppure con  $\overline r$, il vettore che è il {\em raggio vettore} o {\em vettore posizione} dall'origine al punto considerato, $\overline r=\textbf{r}=x \widehat{\mathbf x}+y\widehat{\mathbf y}+z\widehat{\mathbf z}$, con $\widehat{\mathbf x}=\overline e_1$ versore dell'asse $x$. Analogamente per gli altri\footnote{Usiamo in questo contesto $r$ minuscolo invece di $R$ maiuscolo.}. Il modulo di $\overline r$ è indicato con $r$, si pone cioè $r:=|\overline r|=\sqrt{x^2+y^2+z^2}$, distanza dall'origine del punto $(x,y,z)$. Il versore di $\overline r$ è quindi $\widehat{\mathbf r}=\overline r/r$. 

\end{document}

ADDENDUM: I would like to delete my question because I can not reproduce the problem with my fonts used. When I changed the fonts and packages (see my MWE) the result is different from what I have. I'm leaving everything as it is now. I apologise to all the users, but I hope I've done everything I have possible.

13
  • 2
    I find it hard to believe you posted this question with no usable example Dec 16, 2018 at 23:00
  • 2
    what is your question? You posted a large section of code that no one can use as it includes files and command definitions that we haven't got, and shown an image of the output with two large arrows drawn on it without any indication of what they are supposed to indicate. Dec 16, 2018 at 23:05
  • 2
    for example you have \vspace{-2cm} so that will make the image overprint the previous 2cm of text, in general it will be impossible to get any reasonable layout with such a command in your source. If you need it in this particular case then there may be some bad combination that that avoids, but in that case you need to provide an example of the problem. Dec 16, 2018 at 23:13
  • 2
    If I run the new example with a full texlive 2018 It produces ! LaTeX Error: File `mtpro2.sty' not found., ! Undefined control sequence. l.40 ... è una funzione $\overline F: D\to\mathbb and ! Package pdftex.def Error: File displacement.pdf' not found` Please provide an example that demonstrates the problem and does not use unrelated packages or fonts and image files that are not provided. Dec 17, 2018 at 0:04
  • 3
    you are specifying \begin{wrapfigure}[7] so only 7 lines are made short whatever size the figure, it is why the 10 line figure that you show overprints the last lines in the paragraph. Dec 17, 2018 at 0:08

1 Answer 1

2

At last it depends on the text around the wrapfigure. To show the effect I changed your given code to be more minimal (I used package blindtext to genaerate dummy text).

The following code

\documentclass[12pt]{book}

\usepackage{graphicx} 
\usepackage[labelfont=bf]{caption}
\usepackage{wrapfig}
\usepackage{newtxtext}

\usepackage{microtype} 
\usepackage[utf8]{inputenc} 
\usepackage[T1]{fontenc} 

\usepackage{blindtext}


\begin{document}
\section{Campi vettoriali, scalari, radiali, centrali e conservativi}\index{Campi vettoriali, scalari, radiali, centrali e conservativi}

\blindtext

\begin{wrapfigure}[12]{L}{0.4\textwidth}
%\vspace{-2cm}
\centering
\includegraphics[width=0.4\textwidth]{example-image}
\caption{Vettore posizione $\textbf{r}$.}
\label{fig:sidecap}
\end{wrapfigure}

\blindtext

\end{document}

Please see that I commented your wrong \vspace inside wrapfigure. Please see that I need to reserve 12 lines as place for the inserted wrapfigure with image example-image from class mwe you need to have installed but you need not to have it loaded ...

The result is then:

enter image description here

So depending on your used image you have to play with the numbers of lines you have to reserve for the wrapfigure ...

2
  • 2
    why not simply delete the [12] and let wrapfig use the right number of lines for the supplied image automatically? Dec 17, 2018 at 9:24
  • I have edit my question for clarifications of the wrapfig package :-(. Thank you very much to all users. I obviously really appreciated your response and everyone's comments.
    – Sebastiano
    Dec 17, 2018 at 12:32

You must log in to answer this question.

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