Graphics, Figures & TablesCentered Caption for a Picture

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
drmCA
Posts: 31
Joined: Mon Aug 13, 2012 12:18 am

Centered Caption for a Picture

Post by drmCA »

The caption by \captionof sticks to the right side of a pspicture environment. Is it possible to center it?

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
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Centered Caption for a Picture

Post by localghost »

For an adequate problem description please prepare a self-contained and minimal example in order to avoid speculations and guesswork. I'm really tired of asking for this. Since you are not new to the forum, you should know how essential this procedure is. And you have been told more than once to do so. It's rather impolite to try it this way again.


Thorsten
drmCA
Posts: 31
Joined: Mon Aug 13, 2012 12:18 am

Centered Caption for a Picture

Post by drmCA »

Code: Select all

\documentclass[10pt,letterpaper]{article}
%\documentclass[10pt,letterpaper]{beamer}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{pstricks, pst-node}
\usepackage{pst-eucl}
\usepackage{wrapfig}
\usepackage{caption}
\usepackage{lipsum}
\begin{document}

% Compile sequence: F2, F4, F8, F7
Triangles

eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr\\
%\setlength\intextsep{0pt}
\begin{wrapfigure}{l}{0pt}
\pspicture(0,0)(5,4)
\pstTriangle(0,0){B}(4,3){A}(4,0){C}
\pstMarkAngle{C}{B}{A}{$\alpha$}
\pstMarkAngle{B}{A}{C}{$\beta$}
\pstMarkAngle{A}{C}{B}{$\gamma$}
\pcline[linestyle=none](0,0)(4,3)
\naput[nrot=:U]{c}
\pcline[linestyle=none](0,0)(4,0)
\tbput{a}
\pcline[linestyle=none](4,0)(4,3)
\trput{b}
\endpspicture
\captionof{figure}{Straight triangle 1}
\end{wrapfigure}
\begin{wrapfigure}{r}{0pt}
\pspicture(0,0)(4,5)
\pstTriangle(0,0){B}(3,4){A}(3,0){C}
\pstMarkAngle{C}{B}{A}{$\alpha$}
\pstMarkAngle{B}{A}{C}{$\beta$}
\pstMarkAngle{A}{C}{B}{$\gamma$}
\pcline[linestyle=none](0,0)(3,4)
\naput[nrot=:U]{c}
\pcline[linestyle=none](0,0)(3,0)
\tbput{a}
\pcline[linestyle=none](3,0)(3,4)
\trput{b}
\endpspicture
\captionof{figure}{Straight triangle 2}
\end{wrapfigure}
Square triangle:

eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr 
\[\alpha+\beta+\gamma=180^{\circ}\]
\[a^{2}+b^{2}=c^{2}\]
\[a=\sqrt{c^{2}-b^{2}}\]
\[b=\sqrt{c^{2}-a^{2}}\]
Trigonometry equations:

eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr 
\[\sin\alpha=\frac{b}{c}\quad\cos\alpha=\frac{a}{c}\quad\tan\alpha=\frac{b}{a}\]
\[\sin\beta=\frac{a}{c}\quad\cos\beta=\frac{b}{c}\quad\tan\beta=\frac{a}{b}\]
eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr 

eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr eklrewkr 
%\lipsum
\end{document}
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Centered Caption for a Picture

Post by localghost »

First of all some considerations regarding your strategy of asking questions.
  • Read more thoroughly about a minimal example.
  • Use the forum search before posting.
  • Read package manuals.
Now some points about things you are doing wrong.
  • Every now and then you should listen to the compiler and have a look at what it tells you in the log file. You get a clear warning.

    Code: Select all

    Package wrapfig Warning: Collision between wrapping environments on input line 34.
    You need to follow a certain sequence of wrapped figures and text (see code).
  • Inside the wrapfigure environment you can use the usual \caption command.
  • The use of the pspicture environment is syntactically wrong (see code).
It's unclear what causes the problem. Probably one of the last two points. Furthermore you need to specify the lines beside the first picture explicitly (see code).

Code: Select all

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{pst-eucl,pstricks-add}
\usepackage{auto-pst-pdf}  % allow PSTricks code with PDFLaTeX
\usepackage{wrapfig}

\begin{document}
  Triangles

  The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.

  \begin{wrapfigure}[19]{l}{0pt}
    \begin{pspicture}(0,0)(5,4)
      \pstTriangle(0,0){B}(4,3){A}(4,0){C}
      \pstMarkAngle{C}{B}{A}{$\alpha$}
      \pstMarkAngle{B}{A}{C}{$\beta$}
      \pstMarkAngle{A}{C}{B}{$\gamma$}
      \pcline[linestyle=none](0,0)(4,3)
      \naput[nrot=:U]{c}
      \pcline[linestyle=none](0,0)(4,0)
      \tbput{a}
      \pcline[linestyle=none](4,0)(4,3)
      \trput{b}
    \end{pspicture}
    \caption{Straight triangle 1}
  \end{wrapfigure}

  Square triangle:

  The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.

  \[
    \alpha+\beta+\gamma=180^{\circ}
  \]
  \[
    a^{2}+b^{2}=c^{2}
  \]
  \[
    a=\sqrt{c^{2}-b^{2}}
  \]
  \[
    b=\sqrt{c^{2}-a^{2}}
  \]

  \begin{wrapfigure}{r}{0pt}
    \begin{pspicture}(0,0)(4,5)
      \pstTriangle(0,0){B}(3,4){A}(3,0){C}
      \pstMarkAngle{C}{B}{A}{$\alpha$}
      \pstMarkAngle{B}{A}{C}{$\beta$}
      \pstMarkAngle{A}{C}{B}{$\gamma$}
      \pcline[linestyle=none](0,0)(3,4)
      \naput[nrot=:U]{c}
      \pcline[linestyle=none](0,0)(3,0)
      \tbput{a}
      \pcline[linestyle=none](3,0)(3,4)
      \trput{b}
    \end{pspicture}
    \caption{Straight triangle 2}
  \end{wrapfigure}

  Trigonometry equations:

  The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.
  \[
    \sin\alpha=\frac{b}{c}\quad\cos\alpha=\frac{a}{c}\quad\tan\alpha=\frac{b}{a}
  \]
  \[
    \sin\beta=\frac{a}{c}\quad\cos\beta=\frac{b}{c}\quad\tan\beta=\frac{a}{b}
  \]
  The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.   The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.

  The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.   The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.
\end{document}
Next time we'd appreciate a proper minimal example right at the beginning. Otherwise it can happen that your question is left orphaned.
drmCA
Posts: 31
Joined: Mon Aug 13, 2012 12:18 am

Re: Centered Caption for a Picture

Post by drmCA »

There will be no next time as I don't want to deal with rude persons like you. You are volunteering to be here, I did not push you and giving me lectures on how to conduct myself is exactly what is defined as impolite. Back at you. I'm not even going to bother reading your answer and whatever you might want to reply with.
Last edited by localghost on Thu Nov 28, 2013 11:03 am, edited 1 time in total.
Reason: Offensive language edited out.
Post Reply