Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have a diagram that I created with qtree, but would like to add a caption to it. How can this be done?

share|improve this question
    
Welcome to TeX.sx! how about putting it in a figure and using \caption? –  cmhughes Mar 8 '13 at 20:04
    
This seems to always give Figure 1. <my caption>, and places the diagram in the center of the next page, rather than inline with the text. Is there any alternative to this? –  Rich Ashworth Mar 8 '13 at 20:05
    
Should the desired caption have a particular formatting? I mean do you want to number the diagram and have a label for it as in Diagram 1: tree showing....? –  Gonzalo Medina Mar 8 '13 at 20:08
1  
Please post a minimal working example (MWE) that shows what you want to achieve. –  hpesoj626 Mar 8 '13 at 20:08
    
@GonzaloMedina - yes, exactly –  Rich Ashworth Mar 8 '13 at 20:10
add comment

1 Answer

up vote 2 down vote accepted

One option would be to use the newfloat package to define a new floating object, so then you can use the standard \caption command:

\documentclass{article}
\usepackage{qtree}
\usepackage{newfloat}

\DeclareFloatingEnvironment[fileext=lod]{diagram}

\begin{document}

\begin{diagram}
\centering
\Tree [.S This [.VP [.V is ] \qroof{a simple tree}.NP ] ]\par
\caption{the caption for this diagram}
\end{diagram}

\end{document}

enter image description here

The package offers some other customization possibilities and it cooperates with the caption package.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.