Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am using the package linguex (for 'linguistic examples') to number the examples in my text, using its command \ex.

I am creating a table that I am numbering with this command \ex.:

\ex. \label{my_table}
\begin{tabular}[t]{l l l l}
Row 1 & Row 2 & Row 3 & Row 4\\
etc.
\end{tabular}

The option [t] for \begin{tabular} is necessary to have the example number be on the same line as the first row in the table.

My table is rather large, so I want to make it a float, so I embed the section above within a {table} environment. When I do this, however, the example number for my table is separated from the table, i.e. there is a page break between them. How can I prevent this?

\ex. \label{my_table}
\begin{table}
\begin{tabular}[t]{l l l l}
Row 1 & Row 2 & Row 3 & Row 4\\
etc.
\end{tabular}
\end{table}
share|improve this question
4  
Hi. It's preferable to post a minimal working example (MWE) that illustrates your problem rather than code snippets like this. –  Alan Munn Nov 28 '11 at 5:23

1 Answer 1

up vote 6 down vote accepted

You can't put an ex. into a floating environment, but you can simulate it by manually adding the example number inside the table environment. Depending on where the table floats to it's possible that the numbering might be out of order, but try it and see.

\documentclass{article}
\usepackage{linguex}
\begin{document}
Some text.
\ex. The first example.

\begin{table}[hbt]
\refstepcounter{ExNo}\theExNo\hspace{\Exlabelsep}\label{table}
\begin{tabular}[t]{l l l l}
Row 1 & Row 2 & Row 3 & Row 4\\
Row 1 & Row 2 & Row 3 & Row 4\\
Row 1 & Row 2 & Row 3 & Row 4
\end{tabular}
\end{table}
Some more text. This is a reference to example \ref{table}.
\ex. Another example.

\end{document}
\end{tabular}

Update

Note that the placement of the \label command matters with respect to subsequent reference to it via the \ref command. If the label is placed immediately after the table, it will refer to the table counter, which is not what you want. If you place it after the stepping and displaying of the ExNo counter, it will behave as a reference to the example number, which is what you want.

output of code

share|improve this answer
    
What does the option [hbt] after {table} do? –  Sverre Nov 28 '11 at 20:25
    
These are standard float placement options which can be added to any floating element. h means "approximately here", t means "top of page", and b means "bottom of page". See the LaTeX Wikibook for more details. –  Alan Munn Nov 28 '11 at 20:57
    
@Sverre Based on the problem you raised with the label, I've changed the solution slightly to accommodate it. –  Alan Munn Nov 28 '11 at 21:00
    
Great! Thanks Alan. –  Sverre Nov 28 '11 at 21:52

Your Answer

 
discard

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.