Graphics, Figures & TablesFrame around text + table (+ figure)

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
bgeorge
Posts: 7
Joined: Thu Oct 29, 2009 2:13 pm

Frame around text + table (+ figure)

Post by bgeorge »

Hi all,

I'm looking for a solution to placing a frame around some text that includes a table. The 'framed' environment does exactly what I want for pure text

Code: Select all

\begin{framed}
Paragraph or more of text, can run to multiple pages.
\end{framed}
However it does not work when tables are included.

Is there a solution to this problem?

Thanks in advance,

Ben.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

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

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Frame around text + table (+ figure)

Post by gmedina »

One possible solution would be to typeset your tables not as floating objects, so you can safely use the framed environment.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
bgeorge
Posts: 7
Joined: Thu Oct 29, 2009 2:13 pm

Re: Frame around text + table (+ figure)

Post by bgeorge »

How do I do that? Sorry, I'm far from a Latex expert.
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Frame around text + table (+ figure)

Post by gmedina »

A little example (I used the demo option for the graphicx package so my example will be compilable for everyone; don't forget to delete that option in your actual code):

Code: Select all

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{framed}
\usepackage{caption}
\usepackage{lipsum} % justo to generate filler text

\begin{document}

\begin{framed}
\lipsum[1]
\begin{center}
  \begin{tabular}{cc}
    column1a & column2a \\
    column1b & column 2b
  \end{tabular}
  \captionof{table}{A test non-floating table.}
\end{center}
\lipsum[1-3]
\begin{center}
  \includegraphics{name}
  \captionof{figure}{A test non-floating figure.}
\end{center}
\lipsum[1]
\end{framed}

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
bgeorge
Posts: 7
Joined: Thu Oct 29, 2009 2:13 pm

Re: Frame around text + table (+ figure)

Post by bgeorge »

Thank you, I will test this out tomorrow.

Ben.
Post Reply