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
NEW: TikZ book now 40% off at Amazon.com for a short time.
And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p
- Stefan Kottwitz
- Site Admin
- Posts: 10335
- 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: 10335
- 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?