Graphics, Figures & Tablespstricks and subfigures

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
tonie
Posts: 9
Joined: Sat Jan 26, 2008 1:18 pm

pstricks and subfigures

Post by tonie »

Hello again,
currently I tried to handle two pspictures in subfigures. I would like to have them next to each other. However, it does not work properly. Right now, Latex compiles it and arrange my pspicture among each others Do you know whether there are any problems between pstricks and subfigure?

Here is my simple code:

Code: Select all

\documentclass[twoside,a4paper,11pt]{document}
\usepackage{pstricks-add}
\usepackage{pst-coil}
\usepackage{pst-node}
\usepackage{subfigure}

\begin{document}

\begin{figure}[ht]
\centering
\subfigure[test2]{
\psset{unit=0.5cm}
\begin{pspicture}(-0.5,-1.25)(5,1.25)
\cnode(0.5,0.5){0.5}{A}
\cnode[fillstyle=solid,fillcolor=lightgray](3.5,2.5){0.5}{B}
\nccoil[coilwidth=0.3]{<->}{A}{B}
 \end{pspicture}
\label{fig:subfig2}
}

\subfigure[test1]{
 \psset{unit=0.5cm}
 \begin{pspicture}(-0.5,-1.25)(10,1.25)
 \psplot[linecolor=blue,linewidth=1.5pt,plotpoints=500] {0}{5.424}{ x dup add RadtoDeg sin }
 \psaxes[xunit=0.785,showorigin=false, trigLabels]{->}(0,0)(-1,-1.25)(7.8,1.25)
 \end{pspicture}
\label{fig:comwa}
}

\label{fig:bliblablup}
\caption{test1 und test2}
\end{figure}

\end{document}
Cheers, tonie

Recommended reading 2024:

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

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

fatra2
Posts: 126
Joined: Fri May 01, 2009 1:43 pm

Re: pstricks and subfigures

Post by fatra2 »

Hi there,

I never worked with pspicture, but from the code you gave, I would say your problem comes from the sizing of the picture.

Subfigure environment will fit the pictures next to each other as far as possible. If the pictures would overfill the page, then one picture is put underneath the other ones.

I believe to solve your problem, you would need to make sure that your pictures created with pspicutres are not more than 1\textwidth in total.

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

pstricks and subfigures

Post by localghost »

Alternatively to the suggestions of fatra2 you can modify the type area with the geometry package.

Since the subfigure package is considered obsolete and the subfig package isn't maintained any more, you should think about using subcaption which comes with the caption package. It has its own manual and is very easy to handle.

Note that the [url=p://ctan.org/pkg/pstricks-add]pstricks-add[/url] package has to be loaded as the last package from the [url=p://ctan.org/pkg/pstricks]pstricks[/url] family.

Code: Select all

\usepackage{pst-coil,pst-node,pstricks-add}

Best regards
Thorsten
tonie
Posts: 9
Joined: Sat Jan 26, 2008 1:18 pm

pstricks and subfigures

Post by tonie »

First of all, many thanks

By using

Code: Select all

 \psset{unit=0.5cm}
I tried to make sure that I can put two figures as subfigures next to each other. Anyway, I did it with the subcaption and a minipage and it's working, hehe...

Code: Select all

\documentclass[twoside,a4paper,11pt]{memoir}
\usepackage{pst-coil}
\usepackage{pst-node}
\usepackage{pstricks-add}
\usepackage{subfigure}
\usepackage{caption}

\begin{document}

\begin{figure}
\begin{minipage}[b]{.5\linewidth}
\centering\large A
 \psset{unit=0.5cm}
 \begin{pspicture}(-0.5,-1.25)(10,1.25)
 \psplot[linecolor=blue,linewidth=1.5pt,plotpoints=500] {0}{5.424}{ x dup add RadtoDeg sin }
 \psaxes[xunit=0.785,showorigin=false, trigLabels]{->}(0,0)(-1,-1.25)(7.8,1.25)
 \end{pspicture}
\subcaption{A subfigure}\label{fig:1a}
\end{minipage}%
\begin{minipage}[b]{.5\linewidth}
\centering\large B
 \psset{unit=0.5cm}
 \begin{pspicture}(-0.5,-1.25)(10,1.25)
 \psplot[linecolor=blue,linewidth=1.5pt,plotpoints=500] {0}{5.424}{ x dup add RadtoDeg sin }
 \psaxes[xunit=0.785,showorigin=false, trigLabels]{->}(0,0)(-1,-1.25)(7.8,1.25)
 \end{pspicture}
\subcaption{Another subfigure}\label{fig:1b}
\end{minipage}
\caption{A figure}\label{fig:1}
\end{figure}

\end{document}
Cheers, tonie
Post Reply