4

I want to write text near image, how should I do it(example):

|-----|
| pic |- this is text about picture.
|_____|
5

Another possibility is to use the InsertBoxL command from the generic insbox macro package. You can choose the number of full length lines before insertion of the graphic file, and if the number of shorter lines is not correct, you change it with an optional argument:

\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}

\input{insbox}

\begin{document}

\InsertBoxL{2}{\includegraphics[scale=0.25]{sendak.png}}%
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec varius dapibus metus eget ultrices. Nulla sagittis mauris rutrum, blandit augue eget, laoreet augue. Phasellus enim odio, sagittis in mi sed, fringilla mollis odio. Phasellus quis purus ultricies, tempor purus at, tempus quam. Donec ultricies, ligula ac pretium porttitor, nibh nunc. Integer eros nibh, cursus at est sed, volutpat tristique justo. Donec ornare facilisis lorem, id feugiat elit pellentesque at. Nulla odio mauris, luctus sed faucibus id, dignissim dictum velit. Morbi vehicula velit at massa tristique rhoncus.%

\InsertBoxL{0}{\includegraphics[scale=0.25]{sendak.png}}%
Phasellus quis purus ultricies, tempor purus at, tempus quam. Donec ultricies, ligula ac pretium porttitor, nibh nunc. Integer eros nibh, cursus at est sed, volutpat tristique justo. Donec ornare facilisis lorem, id feugiat elit pellentesque at. Nulla odio mauris, luctus sed faucibus id, dignissim dictum velit. Morbi vehicula velit at massa tristique rhoncus.

\InsertBoxL{0}{\includegraphics[scale=0.25]{sendak.png}}[-1]%
Phasellus quis purus ultricies, tempor purus at, tempus quam. Donec ultricies, ligula ac pretium porttitor, nibh nunc. Integer eros nibh, cursus at est sed, volutpat tristique justo. Donec ornare facilisis lorem, id feugiat elit pellentesque at. Nulla odio mauris, luctus sed faucibus id, dignissim dictum velit. Morbi vehicula velit at massa tristique rhoncus.

\end{document} 

enter image description here

3

Since the context was explained now, I think a good solution is to include minipages:

\begin{minipage}[l]{width}
 \includegraphics[options]{pic.png}
\end{minipage}
\begin{minipage}[r]{width}
 text
\end{minipage}

Since these pages align vertically you can be sure, that you write beside the picture in the corresponding minipage. Make sure, that the total width of both minipages is a little less than 1\textwidth (e.g. 0.45\textwidth for each minipage).

A possibility is the wrapfig package. Here you can find a good example with source-code.

Basically you need to include the package and then use its environment:

\usepackage{wrapfig} % in preamble

% in text
\begin{wrapfigure}{r}{0.5\textwidth}
  \begin{center}
    \includegraphics[width=0.48\textwidth]{gull}
  \end{center}
  \caption{A gull}
\end{wrapfigure}

All the text around it will be wrapped around the picture.

Otherwise you may be thinking of minipages (fixed invisible regions) or columned styles,... You'd need to be more specific what you really need.

  • I don't need text all around picture. It is small picture and that picture should be few rows explanation of that picture. And in one page should be about ten parts of pictures/texts – Pr0t3 Dec 7 '15 at 9:45
  • like danger sign - this is danger sign so keep away from it, because bla bla and bla bla. – Pr0t3 Dec 7 '15 at 9:47
2

When the situation is as easy as in the example, you can proceed as follows:

\inlcudegraphics{pic} -- this is text about the picture.

Note that for TeX a picture is just a box to set into the line just like text.

For more advanced examples (several lines of text beside the pictue) you can make use of the command \parbox.

EDIT: The command \parbox has one optional and two required arguments. Its syntax is \parbox[position]{width}{content} where position is one of the three letters bct (meaning bottom, vertically centered, or top alignment) and width can be given explicitly (e.g. {1cm}) or relatively (e.g. {.8\linewidth} meaning 80% of the width of the line. A complete example parbox may look like

\parbox[c]{.8\linewidth}{-- this is text about the picture.}
  • So, if there is two or three lines of text near picture I should use \parbox{pic}-- this is text ? – Pr0t3 Dec 7 '15 at 9:26
  • @Pr0t3: No, you put the text into a parbox that sits besides the box for the picture. It does not harm when you put the picture in a parbox, too, but it is also not necessary. – jknappen - Reinstate Monica Dec 7 '15 at 9:28
  • Okey. maybe you could tell how in includegraphics I should set my pic size? [Width=0.1] or something other? – Pr0t3 Dec 7 '15 at 9:31
  • \includegraphics[width=10cm,height=10cm,keepaspectratio]{Pic/aaa/bal.png} -- \parbox {aaa,bbb and ccc.} how to use it properly? – Pr0t3 Dec 7 '15 at 9:43
  • it is writing text near image, but not in middle of image, but bottom, maybe you know how to change it? – Pr0t3 Dec 8 '15 at 10:01
1

Tikz is (almost) always the answer =) (the image is page 2 of the document obtained)

\documentclass{article}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{matrix}
\usepackage{mwe} %% to get images
\usepackage{lipsum} %% dummy text

\begin{document}

\lipsum

  \begin{tikzpicture}
    \matrix [ampersand replacement=\amp] {
      \node{\includegraphics{example-grid-100x100pt}}; \amp \node[text height=1.5ex,text depth=.25ex]{text for image 1}; \\
      \node{\includegraphics{example-grid-100x100pt}}; \amp \node[text height=1.5ex,text depth=.25ex]{text for image 2}; \\
    };
  \end{tikzpicture}

\lipsum

\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.