Graphics, Figures & TablesMerging two EPS figures

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
gandi
Posts: 23
Joined: Tue Oct 20, 2009 2:45 pm

Merging two EPS figures

Post by gandi »

I'd like to merge two figures, where the second one (created by Inkscape) should become an inset to the first one (which is a graph made in Origin 8). They should overlap, however, i.e. transparencey is required. The final output needs to be an EPS file.

My only solution so far was to create two PDF figures first (because of PDF's support of transparency) and combine them using this LaTeX code:

Code: Select all

\documentclass{article}
\usepackage{graphicx}
% ******************************************************************************
\begin{document}
\pagestyle{empty}    % to remove page number
\begin{figure}
    \includegraphics[width=\columnwidth]{fig1}%
    \setlength{\unitlength}{0.01\linewidth}
    \begin{picture}(100,0)    % picture environment for inset
        \put(37,148){\includegraphics[width=27\unitlength]{fig2}}
    \end{picture}
\end{figure}
\end{document}
pdflatex then gives a satisfying PDF. However converting this to EPS (using pdf2ps) in a next step gives a significantly larger file than the original PDF. When I include the obtained EPS in the (actual) LaTeX document and build a DVI, the quality of the figure is rather poor, i.e. it's not a vector graphic any more.

What's the best way to combine two EPS or PDF files? I've tried using Inkscape, but this causes troubles with certain fonts.

Thanks in advance.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Merging two EPS figures

Post by gmedina »

Hi,

try using the overpic package.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
gandi
Posts: 23
Joined: Tue Oct 20, 2009 2:45 pm

Merging two EPS figures

Post by gandi »

Hi gmedina,

thanks for your reply, but I don't see how overpic would help. If I use it to create a PDF from separate PDF images, I run into the same troubles as before when I try to convert the PDF into an EPS. If I use overpic to merge EPS files, the images are put on top of each other, without transparency.

Have I missed something?

I have uploaded the desired output to: http://tinyurl.com/37vspoo. The crucial bit is the sketch explaining the angles in panel (a). Without transparency the sketch partly covers the black datapoints. I don't seem to be able to convert the uploaded PDF into a decent EPS, however.

Any help is highly appreciated!
gandi
Posts: 23
Joined: Tue Oct 20, 2009 2:45 pm

Merging two EPS figures

Post by gandi »

I now came up with a (somewhat complicated) solution to the problem.

I start off with an Origin 8 graph and a sketch drawn in Inkscape (which should become an inset of the graph).
  • Export graph and sketch as PDF.
  • Use above LaTeX code to merge the two PDFs (overlay the sketch onto the graph) into one PDF.
  • Open this PDF in Acrobat Reader and print to a .ps file, using a PostScript printer driver.
  • Open the .ps file in Inkscape.
  • Greek letters might have been lost, re-insert them.
  • Save as .eps file.
Voilà - two files merged into one EPS file. Transparent regions of the top file remain transparent, and the whole thing is still a vector graphics. I then included the EPS file in a LaTeX document which was uploaded to Manuscript Central. The webiste converted it correctly.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Merging two EPS figures

Post by localghost »

Perhaps you can use another approach which relies on plotting your data with pgfplots and do the rest with pgf/tikZ. See code below for a minimal example.

Code: Select all

\documentclass[11pt,a4paper]{article}
\usepackage{fixltx2e}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{pgfplots}
\usepackage{siunitx}

\begin{document}
  \begin{tikzpicture}[font=\tiny]
%    \draw (-2,-1) grid (9,17);
    \begin{axis}[%
      enlargelimits,
      width=10cm,height=7cm,
      xmin=-135,xmax=135,ymin=0,ymax=2,
      xtick={-135,-90,...,135},
      ylabel={Critical Current Density j\textsubscript{c} (\SI{e10}{\ampere\per\meter\squared})},
      y tick label style={%
        /pgf/number format/.cd,
        /pgf/number format/fixed,
        /pgf/number format/fixed zerofill,
        /pgf/number format/precision=1
      }
    ]
    \end{axis}
    \begin{scope}[yshift=5.425cm]
      \begin{axis}[%
        enlargelimits,
        width=10cm,height=7cm,
        xmin=-135,xmax=135,ymin=0,ymax=2,
        xtick={-135,-90,...,135},
        xticklabels={,,},
        ylabel={Critical Current Density j\textsubscript{c} (\SI{e10}{\ampere\per\meter\squared})},
        y tick label style={%
          /pgf/number format/.cd,
          /pgf/number format/fixed,
          /pgf/number format/fixed zerofill,
          /pgf/number format/precision=1
        }
      ]
      \end{axis}
    \end{scope}
    \begin{scope}[yshift=10.85cm]
      \begin{axis}[%
        enlargelimits,
        width=10cm,height=7cm,
        xmin=-135,xmax=135,ymin=0,ymax=2,
        xtick={-135,-90,...,135},
        xticklabels={,,},
        ylabel={Critical Current Density j\textsubscript{c} (\SI{e10}{\ampere\per\meter\squared})},
        y tick label style={%
          /pgf/number format/.cd,
          /pgf/number format/fixed,
          /pgf/number format/fixed zerofill,
          /pgf/number format/precision=1
        }
      ]
      \end{axis}
    \end{scope}
    \begin{scope}[shift={(4cm,15cm)}]
      \draw[->] (0,0) -- (1,0);
      \draw[->] (0,0) -- (0,1,0);
      \draw[->] (0,0) -- (0,0,1);
    \end{scope}
  \end{tikzpicture}
\end{document}

Best regards
Thorsten
Post Reply