21

How do insert image between text and text wrap with shapepar or other package? enter image description here

2
  • Although this is not an exact duplicate, the following post should guide you through the steps using Xfig: tex.stackexchange.com/questions/32997/….
    – Werner
    Nov 12, 2011 at 3:07
  • I used the steps in the link that you passed, but I can not subtract the signal section with -. It does not work. Nov 12, 2011 at 5:21

2 Answers 2

28

Use package cutwin and run the example with xelatex because I use an eps image as vector graphic which has no background. Using a png image with clipping may also be possible.

\documentclass{article}

\usepackage{cutwin,graphicx,pstricks,lipsum}
\begin{document}

\opencutcenter
\newcommand\Margins{%
0.4\textwidth, 0.4\textwidth,
0.35\textwidth, 0.35\textwidth,
0.32\textwidth, 0.32\textwidth,
0.3\textwidth, 0.3\textwidth,
0.28\textwidth, 0.28\textwidth,
0.26\textwidth, 0.26\textwidth,
0.26\textwidth, 0.26\textwidth,
0.28\textwidth, 0.28\textwidth,
0.3\textwidth, 0.3\textwidth,
0.32\textwidth, 0.32\textwidth,
0.35\textwidth, 0.35\textwidth,
0.4\textwidth, 0.4\textwidth}
\renewcommand\putstuffinpic{%
  \rput(0,-5\normalbaselineskip){%
    \includegraphics[width=0.38\textwidth]{tiger}}}
\begin{shapedcutout}{2}{12}{\Margins}% 2 normal lines, 12 shaped lines
\lipsum[1]
\end{shapedcutout}

\end{document} 

enter image description here

0
30

Here is a similar play-by-play of what was described by @KarlOveHufthammer in his excellent answer regarding the coat-of-arms construction using Xfig. I'm running Windows 7 with Cygwin/X, and is therefore also able to use Xfig (version 3.2.5b). I also have transfig (version 3.2.5c-1, also called fig2dev) installed as part of the Cygwin/X distribution setup:

  1. Open Xfig and set up a comfortable view/zoom level that is detailed enough. It does not have to be perfect, since LaTeX will resize the paragraph shape as specified using \shapepar to match whatever text you want to put into it.

    enter image description here

  2. Draw the outer shape of the paragraph. In this case I used the rectangle tool to draw a square.

    enter image description here

  3. Once complete, edit the rectangle and add the comment "+" (without the quotes).

    enter image description here

  4. Now draw the interior cut-out shape. In this case I used the circle tool.

    enter image description here

  5. Once complete, edit the rectangle and add the comment "-" (without the quotes).

    enter image description here

  6. Save the image in Xfig format as (say) myshape.fig.

    enter image description here

    The Xfig file looks like this:

    #FIG 3.2  Produced by xfig version 3.2.5b
    Landscape
    Center
    Inches
    Letter  
    100.00
    Single
    -2
    1200 2
    # -
    1 3 0 1 0 7 50 -1 -1 0.000 1 0.0000 3000 3000 1500 1500 3000 3000 4500 3000
    # +
    2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
         0 0 6000 0 6000 6000 0 6000 0 0
    
  7. Execute:

    fig2dev -L shape -n myshape myshape.fig myshape.shape
    

    The flag -L sets the output language used to shape (that conforms to shapepar). Other languages also exist, but this option should be specified first. The flag -n sets the name to be used within the output file myshape.shape. So, using -L shape -n <name> will create \<name>par. The output myshape.shape from myshape.fig now contains the newly-created macro \myshapepar{<par>} where the paragraph definition in "shape language" is given by \myshapeshape:

    \def\myshapepar#1{\shapepar{\myshapeshape}#1\par}
    \def\myshapeshape{%
    {25.0833}%
    {0.0833333}b{0.0833333}\\%
    {0.0833333}t{0.0833333}{50}\\%
    {12.5833}t{0.0833333}{25}st{25.0833}{25}\\%
    {12.6667}t{0.0833333}{23.3333}t{26.75}{23.3333}\\%
    {13.0833}t{0.0833333}{21.6667}t{28.4167}{21.6667}\\%
    {13.5833}t{0.0833333}{20}t{30.0833}{20}\\%
    {14.4167}t{0.0833333}{18.5}t{31.5833}{18.5}\\%
    {15.4167}t{0.0833333}{17.0833}t{33}{17.0833}\\%
    {16.5833}t{0.0833333}{15.8333}t{34.25}{15.8333}\\%
    {17.8333}t{0.0833333}{14.75}t{35.3333}{14.75}\\%
    {19.3333}t{0.0833333}{13.9167}t{36.1667}{13.9167}\\%
    {20.9167}t{0.0833333}{13.25}t{36.8333}{13.25}\\%
    {22.5}t{0.0833333}{12.75}t{37.3333}{12.75}\\%
    {24.25}t{0.0833333}{12.5}t{37.5833}{12.5}\\%
    {25.9167}t{0.0833333}{12.5}t{37.5833}{12.5}\\%
    {27.6667}t{0.0833333}{12.75}t{37.3333}{12.75}\\%
    {29.25}t{0.0833333}{13.25}t{36.8333}{13.25}\\%
    {30.8333}t{0.0833333}{13.9167}t{36.1667}{13.9167}\\%
    {32.3333}t{0.0833333}{14.75}t{35.3333}{14.75}\\%
    {33.5833}t{0.0833333}{15.8333}t{34.25}{15.8333}\\%
    {34.75}t{0.0833333}{17.0833}t{33}{17.0833}\\%
    {35.75}t{0.0833333}{18.5}t{31.5833}{18.5}\\%
    {36.5833}t{0.0833333}{20}t{30.0833}{20}\\%
    {37.0833}t{0.0833333}{21.6667}t{28.4167}{21.6667}\\%
    {37.5}t{0.0833333}{23.3333}t{26.75}{23.3333}\\%
    {37.5833}t{0.0833333}{25}jt{25.0833}{25}\\%
    {50.0833}t{0.0833333}{50}\\%
    {50.0833}e{50.0833}%
    }
    
  8. Create and compile your TeX file:

    \documentclass{article}
    \usepackage{shapepar}% http://ctan.org/pkg/shapepar
    \usepackage{lipsum}% http://ctan.org/pkg/lipsum
    \input{myshape.shape}% Contains \myshapepar{<par>}
    \begin{document}
    \myshapepar{\lipsum*[1-3]}
    \end{document}
    

    enter image description here

    As mentioned, the size of the shape is not necessary. If you supply \lipsum*[1] instead (a shorter paragraph text), the output resembles:

    enter image description here

    Also note the use of \lipsum*. \shapepar does not allow the use of \par. Line breaking is achieved using \\.

Image insertion is achieved with an overlay, by moving the image to appropriate position using horizontal/vertical skips or otherwise.

6
  • Thank you, is not working because I could not install the transfig plugin in Ubuntu. Nov 12, 2011 at 5:34
  • With the shape defined already in the code above, you can just use it without having to install transfig. The answer merely shows how it can be achieved. In your specific case, the answer (shape-wise) matches your post exactly.
    – Werner
    Nov 12, 2011 at 5:36
  • @RegisdaSilva: Your original question shows the shape of a square-ish block with a circle in the middle that has the text removed. That shape is contained in my answer. If that is sufficient for your purpose, then you can use the code as provided. If you want the shape to be different (say, taller vertically, or with the cut-out circle not centered), then you either have to edit the \myshapeshape macro manually using the guidelines of the shapepar documentation, or use the above steps to recreate an alternative shape.
    – Werner
    Nov 12, 2011 at 6:42
  • You can override the command rput some other way to dispose of the package pstricks? Nov 14, 2011 at 3:09
  • 1
    @NikosAlexandris: You could use tikz and it's remember overlay specification; textpos or esopic. Any one of those would work. Alternatively you could make the image non-existent (in terms of its real estate and then push it left/right up/down into position (\smash{\raisebox[<down>]{<up>}{\makebox[0pt]{\hspace{<left>}\includegraphics{...}\hspace{<right>}}}}).
    – Werner
    Sep 3, 2012 at 14:50

You must log in to answer this question.

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