TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to include "table code" as a sub-figure (instead of an image) using the package subfig? If so, how?

share|improve this question

migrated from stackoverflow.com Mar 8 '12 at 20:50

This question came from our site for professional and enthusiast programmers.

up vote 12 down vote accepted

You can include any content (table, text, figure, ...) within a figure or table environment. That is, there is no restriction to only have figures within a figure environment, nor to only have a tabular within a table environment. The same goes for \subfloat from the \subfig package. The respective environments just maintain different counters and they end up in different "List of ..."s - administrative differences of sorts.

Here's a minimal example:

enter image description here

\usepackage{subfig}% http://ctan.org/pkg/subfig
\usepackage{booktabs}% http://ctan.org/pkg/booktabs
\newcommand{\mytab}{% Just for this example
    One & Two & Three \\
    $x$ & $y$ & $z$ \\
    1 & 2 & 3 \\

  \caption{Here are some tables in a \texttt{figure} environment.}%

  \caption{Here are some tables in a \texttt{table} environment.}%

share|improve this answer
Is caption label the only difference between figure and table ? I really don't know this. – kiss my armpit Mar 8 '12 at 21:35
Which % is/are really necessary in your code above? – kiss my armpit Mar 8 '12 at 21:36
@DamienWalters: As mentioned, the caption label displays differently, the environments maintain different counters and end up in different "List of..."s, but apart from that, they're the same things - an environment that can float. In the above code, perhaps only % following \subfloat seems necessary (not exactly sure). I took the example from the subfig documentation. – Werner Mar 8 '12 at 21:44

Your Answer


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.