Graphics, Figures & TablesCaption and PSTricks

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
coachbennett1981
Posts: 274
Joined: Fri Feb 05, 2010 10:15 pm

Caption and PSTricks

Post by coachbennett1981 »

For the following code I am having difficulty moving the caption further down. Is there a way I can do this? I have several other figures labeled. I would like the Figure 1 to be at the bottom of the figure.

Code: Select all

\documentclass[12pt]{article}

\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage[font=small,labelsep=none]{caption}
\usepackage{pstricks}
\usepackage{pstricks-add}

\begin{document}

\begin{figure}[h]
\centering
\begin{pspicture}(0,0)(5,0)
\psset{unit=.75cm}
\pspolygon[fillstyle=vlines](0,0)(0,4)(4,4)(4,0)
\pspolygon(0,0)(0,-4)(4,-4)(4,0)
\pcline[offset=12pt]{<->}(0,0)(0,4)
\ncput*[nrot=:U]{18}
\pcline[offset=12pt]{<->}(5,-4)(5,0)
\ncput*[nrot=:U]{18}
\pcline[offset=12pt]{<->}(0,-1)(4,-1)
\ncput*[nrot=:U]{18}
\end{pspicture}

\caption{}
\end{figure}
Thank you,

Nick
Last edited by coachbennett1981 on Thu Nov 25, 2010 3:06 am, edited 1 time in total.

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

Caption and PSTricks

Post by localghost »

Please check your examples for completeness and minimal content. You have already been reminded in the past. The code as provided is not compilable.

Regarding the problem you have to reserve adequate space for your figure. You are using negative coordinates for some graphic elements but the size of the picture is only within positive coordinates. Moreover the picture has only horizontal size but no vertical (which doesn't make much sense). To avoid such problems, it is helpful to enable the showgrid option for the pspicture environment while composing a figure.

Code: Select all

\documentclass[12pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[font=small,labelsep=none]{caption}
\usepackage{pstricks-add}

\begin{document}
  \begin{figure}[!ht]
    \centering
    \psset{unit=.75cm}
    \begin{pspicture}[showgrid=true](-1,-4)(5,4)
      \psframe[fillstyle=vlines](0,0)(4,4)
      \psframe(0,0)(4,-4)
      \pcline[offset=12pt]{<->}(0,0)(0,4)
      \ncput*[nrot=:U]{18}
      \pcline[offset=12pt]{<->}(5,-4)(5,0)
      \ncput*[nrot=:U]{18}
      \pcline[offset=12pt]{<->}(0,-1)(4,-1)
      \ncput*[nrot=:U]{18}
    \end{pspicture}
    \caption{}
  \end{figure}
\end{document}

Thorsten
coachbennett1981
Posts: 274
Joined: Fri Feb 05, 2010 10:15 pm

Re: Caption and PSTricks

Post by coachbennett1981 »

Sorry about that. I forgot the \end{document}. I need to be more careful. Again I apologize. I see the grid and what it does, but what does the ! do for the figure environment?




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

Caption and PSTricks

Post by localghost »

There are some additional conditions for float placement which are overridden by the exclamation mark in the location parameters. It is documented in Appendix C.9 of the Lamport book.
L. Lamport wrote:[…] The loc¹ argument can also contain the character »!«, which directs LaTeX to try harder to place the figure or table at the earliest possible place in the document allowed by the rest of the argument. What "try harder" means is explained below. […]
¹With loc he means the optional location parameters for a float environment.

In the following text he goes into detail but that would go beyond the scope of my post. If you have access to this book it's worth to take a look. I don't know many sources where this parameter is documented. You may find something in our resources for beginners.

I always add the exclamation mark to the parameter list because it provides me with the best results without any of the well known placement problems (which are often described here in the forum).
coachbennett1981
Posts: 274
Joined: Fri Feb 05, 2010 10:15 pm

Re: Caption and PSTricks

Post by coachbennett1981 »

Thank you for the response. I appreciate it.
Post Reply