Graphics, Figures & TablesPstricks-add figure and jpg-file in same document

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
voorneveld
Posts: 15
Joined: Mon Sep 07, 2009 11:18 am

Pstricks-add figure and jpg-file in same document

Post by voorneveld »

I drew a color figure using pstricks-add and would like to include, in the same file, a color jpg-file (centered, with caption, and rescaled to have height 6cm). Despite surfing around, I cannot get both to work...

The code for the working pstricks-add figure is (minimized: the original picture has more stuff in it):

Code: Select all

\documentclass{article}

\usepackage{pstricks-add}

\begin{document}

\begin{figure}[h]
\begin{center}
\begin{pspicture}(0,0)(4,5)
\psaxes{->}(4,4)[$x_1$,0][$x_2$,90]
\psplot[algebraic,plotpoints=1000]{1.303}{3}{x-sqrt(3-x)}
\psplot[algebraic,plotpoints=1000]{0}{3}{x+sqrt(3-x)}
\psset{linecolor=blue}
\qdisk(1,2.4142){1pt}
\psline{->}(1,2.4142)(2.5,3)
\end{pspicture}
\end{center}
\end{figure}

\end{document} 
The file I would like to include is the jpg-file attached to this question.

How do I do this?

Thanks!

Mark Voorneveld
Attachments
stairs.jpg
stairs.jpg (41.56 KiB) Viewed 3346 times

Recommended reading 2024:

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

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

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Pstricks-add figure and jpg-file in same document

Post by localghost »

You can have both by using the auto-pst-pdf package and compiling with pdflatex. Consider the following example.

Code: Select all

\documentclass[11pt,a4paper,english]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage[font=small,labelfont=bf,tableposition=top]{caption}
\usepackage{graphicx}
\usepackage{pstricks-add}
\usepackage{auto-pst-pdf}

\pagestyle{empty}

\begin{document}
  \begin{figure}[!ht]
    \centering
    \begin{pspicture}[showgrid=false](-1,-1)(5,5)
      \psaxes{->}(4,4)[$x_1$,0][$x_2$,90]
      \psplot[algebraic,plotpoints=1000]{1.303}{3}{x-sqrt(3-x)}
      \psplot[algebraic,plotpoints=1000]{0}{3}{x+sqrt(3-x)}
      \psset{linecolor=blue}
      \qdisk(1,2.4142){1pt}
      \psline{->}(1,2.4142)(2.5,3)
    \end{pspicture}
    \caption{Your \textsf{PSTricks} figure}\label{fig:pstricks}
  \end{figure}

  \begin{figure}[!ht]
    \centering
    \includegraphics[height=6cm]{stairs}
    \caption{The included graphics file in JPG format}\label{fig:jpg}
  \end{figure}
\end{document}
To get this work, you have to call the compiler with the switch that enables shell escape.

Code: Select all

pdflatex -shell-escape jobname.tex
Adapt the settings of your LaTeX editor according to your LaTeX distribution. Concerning shell escape, there are differences between MiKTeX and TeX Live. Pay special attention to the remarks in the pst-pdf manual (although this package is not included).


Best regards and welcome to the board
Thorsten
voorneveld
Posts: 15
Joined: Mon Sep 07, 2009 11:18 am

Pstricks-add figure and jpg-file in same document

Post by voorneveld »

I had to install Perl (http://www.activestate.com/activeperl/) and use the switch --shell-escape (with two hyphens before shell) to get this to work, but now it works perfectly. Thank you!

Mark
Post Reply