Graphics, Figures & TablesCaption of Table A messed with Table B. Why?

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
pantera
Posts: 11
Joined: Mon Feb 20, 2012 6:01 pm

Caption of Table A messed with Table B. Why?

Post by pantera »

Hi everyone,

I'm preparing the appendix that contains several tables. Each of the table has a short description of the numbers in the table. I know that the \caption can be used so that the description is tied with the table. However, because I'm new to LaTex and because one of the table has a long description that contains both text and a long math equation, I typed in the description separately, i.e. not inside the \caption command. In my main.tex file, I organize things that look like below:

Code: Select all

\section*{Table 2: ABC}\label{tab:2}
\input{Table2_A}
\input{Table2_B}
\input{Table2_C}

\section*{Table 3: DEF{tab:3}
\input{Table3}
where Table 3 has a long description that contains text and a long math equation.
When I compiled and got the pdf output, it looked completely mysterious to me that the description for Table 3 was messed up, i.e. it doesn't sit right on top of Table 3, but instead somewhere just below Table 2, as below.

....
Table 2: ABC
Table 2A
Table 2B
Description for Table 3 %%% Problem is here - the description for Table 3 goes here, whereas Table 3 itself sits at the end

Table 2C
Table 3 itsefl sits here


I can't make sense of it. Could anyone please help???

Recommended reading 2024:

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

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

Caption of Table A messed with Table B. Why?

Post by Stefan Kottwitz »

That's normal, because tables are placed by LaTeX automatically, they are so called floating environments. For getting good page breaks and a good layout, LaTeX tries to put tables where they appear or a bit later at a page top, if you like also at a page bottom or on a separate page. This can be adjusted though by positioning options, if you use a table environment. Automatic placement is a great thing for big documents.

If you read a LaTeX introduction, have a look at floats or a section about figures and tables, it's usually explained.

Use \caption for the description, also if it's a bit longer, because captions are kept together with the table. Otherwise you might need a minipage where you put the table content and the description inside.

Stefan
LaTeX.org admin
pantera
Posts: 11
Joined: Mon Feb 20, 2012 6:01 pm

Re: Caption of Table A messed with Table B. Why?

Post by pantera »

Thank you so much, Stefan! Is it possible to put inside \caption a long text that includes a math equation, i.e. include \begin{equation}...\end{equation} inside \caption command? I have tried it but I always receive error messages. I don't want my table to automatically float around, but I cannot put a math formula inside \caption command. What should I do, given that I'm a total LaTeX newbie (just got to know Latex for one week now). Thanks
User avatar
Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

Caption of Table A messed with Table B. Why?

Post by Stefan Kottwitz »

Using displayed and numbered equations in a caption is very unusual. Perhaps you would like to use inline math expressions. That's no problem, for example:

Code: Select all

\caption{Plot for function $y=2x^3$}
Since you are new to LaTeX, I recommend to read an introduction. There are also nice books giving a quick start. Have a look at the LaTeX Beginner's Guide for example, it has been written as a fast paced LaTeX introduction. Of course you could also get it from Amazon.

Learning LaTeX requires reading a bit, as this great software can be a bit sophisticated. Understanding the concepts is important. Regarding problems, we gladly help here in the forum.

Stefan
LaTeX.org admin
pantera
Posts: 11
Joined: Mon Feb 20, 2012 6:01 pm

Re: Caption of Table A messed with Table B. Why?

Post by pantera »

Hi Stefan, thanks so much for taking time to help.
Post Reply