18

What I am try here is have the image on the left side and it should be surrounded by text on the right and bottom side.

For example how can below image_3.png float to left?

\usepackage{lipsum}
\begin{document}

\includegraphics[scale=0.5]{./images/image_3.png}
\lipsum[1]    

\end{document}
3
  • Depending on your distribution, you can either look at the wrapfig package or the picins package.
    – Werner
    Commented Oct 20, 2011 at 19:20
  • 1
    If you want to use URLs in your text, use the url package to provide you with a consistent format: \url{http://ftp.dante.de/tex-archive/help/Catalogue/entries/pgf.html}
    – Werner
    Commented Oct 20, 2011 at 19:35
  • @Werner thanks! oh, the url screw up is totally was my fault. I just put a text there to illustrate the point.
    – tugberk
    Commented Oct 20, 2011 at 19:42

2 Answers 2

12

As Werner mentions you can use the wrapfig package:

\documentclass{article}
\usepackage[demo]{graphicx}% Don't use [demo] option in your real example
\usepackage{wrapfig}
\usepackage{lipsum}% for dummy text

\begin{document}
\begin{wrapfigure}{l}{0.5\textwidth}\centering
    \includegraphics[scale=0.5]{./images/image_3.png}
    \caption{Image3.png}
\end{wrapfigure}
\lipsum[1]
\end{document}
2
  • thanks! one problem I am having is to setting the right and bottom margins. I can control bottom margin with \vspace but how I can control the right one or left?
    – tugberk
    Commented Oct 20, 2011 at 19:41
  • 1
    Does adjust the width {0.6\textwidth} not do what you want? Commented Oct 20, 2011 at 19:53
6

You can insert the image using wrapfig, and adjust the left and right margins through modification of \leftskip and \rightskip.

enter image description here

\documentclass{article}
%\usepackage{graphicx}% http://ctan.org/pkg/graphicx
\usepackage[showframe]{geometry}% http://ctan.org/pkg/geometry
\usepackage{wrapfig}% http://ctan.org/pkg/wrapfig
\usepackage{url}% http://ctan.org/pkg/url
\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\begin{document}

\lipsum[1]

\addtolength{\leftskip}{5em} \addtolength{\rightskip}{2em}% Adjust margins

% \begin{wrapfigure}[<number of narrow lines>]{<placement>}[<overhang>]{<width>} <stuff> \end{wrapfigure}
\begin{wrapfigure}[6]{l}{5em}
  \rule{5em}{4\baselineskip}% place your image here using \includegraphics
\end{wrapfigure}
\noindent You can draw graphics directly with TeX commands using the \verb!tikz! package: 
\url{http://ftp.dante.de/tex-archive/help/Catalogue/entries/pgf.html} It comes 
with very good documentation with many examples.
You can draw graphics directly with TeX commands using the \verb!tikz! package: 
\url{http://ftp.dante.de/tex-archive/help/Catalogue/entries/pgf.html} It comes 
with very good documentation with many examples.

\addtolength{\leftskip}{-5em} \addtolength{\rightskip}{-2em}% Restore margins

\lipsum[2]
\end{document}​

If you're after modifying the margins of the actual image that you included, you need to modify the parameters of the wrapfigure environment:

\begin{wrapfigure}[<number of narrow lines>]{<placement>}[<overhang>]{<width>}
  <stuff>
\end{wrapfigure}

Increasing <number of narrow lines> will push the bottom further down, while increasing <width> will push the right margin further in.

For completeness, I've included lipsum for dummy text as well as url since you had an URL in your MWE. geometry (with the package option showframe) was also included to show the margin adjustment with respect to the other document elements.

You must log in to answer this question.

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