Graphics, Figures & Tableseps with psfrag with tikz

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
theo moore
Posts: 72
Joined: Thu Jan 15, 2009 3:16 pm

eps with psfrag with tikz

Post by theo moore »

So here is the situation: I want to make the figures in my document more uniform. This includes a small number of plots of data, but most of the figures are 2D diagrams (of the cartesian plane).

There are two important things:
  1. Labels should be replaced by uniform LaTeX equivalents
  2. I'd like to bound each picture by a dotted rounded rectangle.
I gave PGF/TiKz a try. Unfortunately, I found it much too difficult. A diagram that would take me an hour in Inkscape would take me a day to do in tikz. It's just too low-level for my needs. Simple diagrams can be made in TiKz with an acceptable amount of effort. But as soon as it starts getting complex, then the time required increases quickly.

The thing is, while I can easily accomplish my first goal using psfrag, I found that to do the second, I could do:

Code: Select all

\begin{tikzpicture}[%
tight background, 
background rectangle/.style = {draw=black, dotted,rounded corners=5ex}, 
show background rectangle]

\end{tikzpicture}
Something like that.

Is there a way for me to do both at the same time? That is, I'd like to import in an eps figure, bound it by a tikz background, then annotate it using psfrag?

If not, what is the alternative? I suppose I can convert from eps2pgf, then do the annotation and background entirely in tikz, but that sounds clunky.

The last alternative is to create the background I want in each image. The problem with that is that I want the rounded rectangles to be invariant with the scaling of the image (so they are each uniform in the document).

Suggestions?

Recommended reading 2024:

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

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

theo moore
Posts: 72
Joined: Thu Jan 15, 2009 3:16 pm

eps with psfrag with tikz

Post by theo moore »

Oh wow, I think it all works if you just chuck everything together:

Code: Select all

\begin{figure} 
  \psfrag{x}[cl][cl][0.85]{$\Re(z)$}
  \psfrag{y}[Bc][Bc][0.85]{$\Im(z)$}
\begin{tikzpicture}[%
tight background, 
background rectangle/.style = {draw=black, dotted,rounded corners=5ex}, 
show background rectangle
]
\node (0, 0) {\includegraphics[width=5cm]{figurehere}};
\end{tikzpicture}
\caption{La di da}
\end{figure}
I think I've settled on my method to make the images, then: (1) Design them in Inkscape, (2) Annotate them using psfrag, and (3) wrap them in Tikz
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

eps with psfrag with tikz

Post by localghost »

theo moore wrote:So here is the situation: I want to make the figures in my document more uniform. This includes a small number of plots of data, but most of the figures are 2D diagrams (of the cartesian plane).

There are two important things:
  1. Labels should be replaced by uniform LaTeX equivalents
  2. I'd like to bound each picture by a dotted rounded rectangle.
I gave PGF/TiKz a try. Unfortunately, I found it much too difficult. A diagram that would take me an hour in Inkscape would take me a day to do in tikz. It's just too low-level for my needs. Simple diagrams can be made in TiKz with an acceptable amount of effort. But as soon as it starts getting complex, then the time required increases quickly. [...]
I think pgf/tikZ in combination with pgfplots could be a good choice.

Code: Select all

\documentclass[11pt,a4paper,english]{report}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage{babel}
\usepackage[font=small,labelfont=bf,tableposition=top]{caption}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{backgrounds}
\usepackage{pgfplots}

\parindent0em

\begin{document}
\begin{figure}[!ht]
  \centering
  \begin{tikzpicture}[%
    background rectangle/.style={draw=black,dotted,rounded corners=5mm},
    show background rectangle,
    inner frame sep=5mm,
  ]
    \begin{axis}[legend entries={$x$,$x^2$}]
      \addplot (\x,\x);
      \addplot (\x,\x^2);
    \end{axis}
%    \node(0,0){\includegraphics[width=5cm]{filename}};
  \end{tikzpicture}
  \caption{A framed plot}\label{fig:fplot}
\end{figure}
\end{document}
The according manuals explain the details.

If you would show an example of your diagrams, we may be able to find an appropriate solution with pgf/tikZ.


Best regards
Thorsten
theo moore
Posts: 72
Joined: Thu Jan 15, 2009 3:16 pm

eps with psfrag with tikz

Post by theo moore »

Hi, thank you for the reply.

What advantages would doing it in PGF have over psfrag?

Also, if I'd like to wrap everything a rectangle, we know that we can use:

Code: Select all

\begin{tikzpicture}[%
    background rectangle/.style={draw=black,dotted,rounded corners=5mm},
    show background rectangle,
    inner frame sep=5mm]

stuff goes here

\end{tikzpicture}
Rather than repeat this for each image, how would I create a command so that this template could be set up very simply, possibly with some input commands (like how much to separate the frame).
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

eps with psfrag with tikz

Post by localghost »

theo moore wrote:[...] What advantages would doing it in PGF have over psfrag? [...]
At the beginning you talked about uniformity or consistency. Regarding your diagrams and plots pgf/tikZ or pstricks would ensure that to the highest degree.
theo moore wrote:[...] Also, if I'd like to wrap everything a rectangle, we know that we can use [...] Rather than repeat this for each image, how would I create a command so that this template could be set up very simply, possibly with some input commands (like how much to separate the frame).
You could define your own environment with the frame separation as a parameter. You only would have to distinguish between PGF stuff and non-PGF stuff. Latter one would go into a node like shown with the included graphics file.
Post Reply