General ⇒ General floating object with caption
General floating object with caption
is there a way to define a general floating object, for which one can define a border and a caption? All I want to do is having a sentence, which is centered, bordered and has a caption.
Thanks in advance,
Herder
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
- Stefan Kottwitz
- Site Admin
- Posts: 10360
- Joined: Mon Mar 10, 2008 9:44 pm
General floating object with caption
you could use the standard figure environment, like:
Code: Select all
\begin{figure}[ht]
\centering
\fbox{Text}
\caption{Test float}
\end{figure}
Stefan
General floating object with caption
this is exactly what I searched for, thanks.
But: Is there a way to omit the automatically generated prefix of the caption (e. g. "figure 1.3: text ...")? And can i define a own tag that will be used when referencing that figure?
- Stefan Kottwitz
- Site Admin
- Posts: 10360
- Joined: Mon Mar 10, 2008 9:44 pm
General floating object with caption
have a look at the caption package, it is designed for the customization of captions, provides many features and is very well documented.
Stefan
General floating object with caption
When i define my own floating object using the floatstyle "boxed", this boxed object always spans the whole site width. But i want it to dynamically adjust to its content, so that i don't have large boxes with only little content in it.
Let me illustrate it:
Now:
Code: Select all
-----------------------------------------------------
| Text |
-----------------------------------------------------
Code: Select all
-----------
| Text |
-----------
Re: General floating object with caption
General floating object with caption
the following code (that uses nothing more than Stefan's suggestions) seems to do what you expect:
Code: Select all
\documentclass{article}
\usepackage{float}
\usepackage{caption}
\captionsetup{labelfont=bf,font=small}
\usepackage{lipsum}% just to automatically generate some text
\newfloat{Myfloat}{htbp}{myf}
\begin{document}
\begin{Myfloat}
\centering
\fbox{text}
\caption{a simple example}
\label{myf:test1}
\end{Myfloat}
\begin{Myfloat}
\centering
\fbox{\parbox{8cm}{\lipsum[1]}}
\caption{another simple example}
\label{myf:test2}
\end{Myfloat}
\newpage
Just a test. As you see in \ref{myf:test1}...
\newpage
And as you see in \ref{myf:test2}...
\end{document}
General floating object with caption
Code: Select all
Just a test. As you see in \ref{myf:test1}...
\begin{Myfloat}
\centering
\fbox{\parbox{8cm}{\lipsum[1]}}
\caption{another simple example}
\label{myf:test1}
\end{Myfloat}
Re: General floating object with caption
Any ideas, why?