Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

According to the two-column example document below, how can you put text and image on the same line? I'm interested in how to insert text at Some text here and more text here with the image right aligned.

Example:

|     #TEXT######################### |     #TEXT######################### |
| ################################## | ################################## |
| ################################## | ################################## |
| ################################## | ################################## |
| ################################## | ################################## |
| #################                  | ################################## |
|                                    |                                    |
|                      ************* | ################################## |
|   Some text here     ************* | ################################## |
|                      ************* | ################################## |
|                      **IMAGE.JPG** | ################################## |
|   more text here     ************* |                                    |
|                      ************* | ################################## |
|                      ************* | ################################## |
|                      ************* | ################################## |
|                                    |                                    |
|     #TEXT######################### | ################################## |
| ################################## | ################################## |
| ################################## | ################################## |
| ################################## | ################################## |
| ################################## | ################################## |
| #################                  | ################################## |
share|improve this question
    
Is "Some text here" and "More text here" the figure caption (you could use the sidecap package for that)? Or do you want the main text to wrap around the image (wrapfig package)? Or is it completely unrelated text (use a tabular)? –  Jake Aug 2 '11 at 4:57
    
I tried xport's example but it's not exactly what I need. I need precise positioning of Some text here & more text here including the spacing as depicted above. wrapfig should be eliminated then. I'd like to see sidecap and tabular examples to see which one has better precise text positioning. –  Level1Coder Aug 2 '11 at 5:44
    
I'd also like to add that the example depicted above is one column out of a two-column document. –  Level1Coder Aug 2 '11 at 5:49
    
A bit of a random question: Did you make that ASCII mockup of the two column document by hand, or did you generate it using some tool? –  Jake Aug 2 '11 at 7:18
1  
You seem to know how the question should be phrased. What title do you recommend to change to? I try to ask questions as accurate as possible. Other times if I don't know how to word the question (like in this case), I mix & match keywords to force a somewhat decent question phrase out so people sorta know what problem I have. If you can phrase this question title better, be my guest ;-) –  Level1Coder Aug 2 '11 at 12:50
show 2 more comments

3 Answers

up vote 5 down vote accepted

Since you mention the need to precisely position the text, may I suggest using TikZ? Here's an example that uses one node for the image, and two nodes placed using the positioning library to have a horizontal gap of 5 mm to the image, with their vertical centers positioned 5 mm and 23 mm below the top of the image:

enter image description here

The image is taken from Wikipedia

\documentclass[twocolumn]{article}
\usepackage{tikz,lipsum}
\usetikzlibrary{positioning}
\begin{document}

\lipsum[1]

{
\raggedleft
\begin{tikzpicture}
\node (bottle) {\includegraphics{normflasche}};
\node [left=0.5cm of bottle.north west, yshift=-5mm] {Cap};
\node [left=0.5cm of bottle.north west, yshift=-23mm] {Pearls};
\end{tikzpicture}

}

\lipsum[2-6]
\end{document}
share|improve this answer
    
I also need the positioning to be dynamic. Meaning if a line is inserted in the paragraph above Some text here, the entire layout will will adjust by one line down also. Does the TikZ package allow this? –  Level1Coder Aug 2 '11 at 6:35
    
Yes, the whole tikzpicture environment will move as a whole. –  Jake Aug 2 '11 at 6:36
add comment

Development Phase

enter image description here

Production Phase

enter image description here

Source Code

\documentclass[twocolumn]{article}
\usepackage{graphicx,lipsum,pst-node}

\begin{document}

\lipsum[1]

\noindent
\begin{center}
{
\endlinechar=-1\relax

\newsavebox\IBox
\savebox\IBox{\includegraphics[width=0.5\linewidth]{hen.jpg}}

\newdimen\WIDTH\WIDTH=\linewidth
\newdimen\HEIGHT\HEIGHT=1\ht\IBox

\psset
{
    xunit=0.1\WIDTH,
    yunit=0.1\HEIGHT,
    nodesep=5pt,
    style=gridstyle
}



\pspicture(\WIDTH,\HEIGHT)

% put figure 
\rput[bl]
    (
        \dimexpr\WIDTH-\wd\IBox\relax,
        \dimexpr\HEIGHT-\ht\IBox\relax
    ){\usebox\IBox}

% add an annotation to mouth
\pnode(0.6\WIDTH,0.8\HEIGHT){a}

\rput[rt](0.4\WIDTH,0.8\HEIGHT)
    {
        \rnode[r]{A}{Mouth}
    }
\ncline[linecolor=blue]{->}{A}{a}

% add an annotation to feet
\pnode(0.7\WIDTH,0.1\HEIGHT){b}

\rput[rt](0.4\WIDTH,0.5\HEIGHT)
    {
        \rnode[r]{B}{Feet}
    }
\ncline[linecolor=blue]{->}{B}{b}

% turn of this grid in the production phase!
%\psgrid
\endpspicture
}
\end{center}

\lipsum[2-4]
\end{document}
share|improve this answer
add comment

There are a number of ways to do this, depending on your typesetting preference and eventual goal (personal use, or perhaps publication submission). In addition to using the wrapfigure environment from the wrapfigure package, you could use the minipage environment:

\documentclass{article}
\usepackage[english]{babel}
\usepackage{graphicx,lipsum}
\begin{document}
\lipsum[1]

\newlength{\oldparindent} \setlength{\oldparindent}{\parindent}% Save \parindent
\setbox0=\hbox{\includegraphics[width=0.35\textwidth]{tiger}}% Original image
\noindent\begin{minipage}[t]{0.6\textwidth}
  \hskip\oldparindent\lipsum[2]% Text to the left of image
\end{minipage}\hfill
\begin{minipage}[t]{0.35\textwidth}
  \raisebox{-\ht0}{\usebox0}% Insert image
\end{minipage} \\

\lipsum[3]
\end{document}

You could also attempt a layout using the tabularx environment - specifically the X column type - from the tabularx package in the following way:

\documentclass{article}
\usepackage[english]{babel}
\usepackage{graphicx,lipsum,tabularx}
\begin{document}
\lipsum[1]

\smallskip

\newlength{\oldparindent} \setlength{\oldparindent}{\parindent}
\setbox0=\hbox{\includegraphics[width=0.35\textwidth]{tiger}}
\noindent\begin{tabularx}{\textwidth}{@{}Xc@{}}
  \hskip\oldparindent\lipsum[2] & \raisebox{-\ht0}{\usebox0}%
\end{tabularx}

\vspace{-2ex}

\lipsum[3]
\end{document}

Using minipages to display text and image next to one another

In case of a document using the twocolumn option, using \linewidth instead of \textwidth for the tabularx example outputs the following:

Using tabularx in twocolumn document to display text and image next to one another

I understand my vertical spacing is a little hack-ish. However, according to the information provided it might suffice.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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