2

I have a table inside theorem environment and I would like to have a line break before the table is being drawn. Currently it will start drawing the table on the same line that the theorem is listed and it looks rather ugly. Does anyone know how I could achieve this?

I have an example in the following code:

\documentclass[12pt]{article}
\usepackage{amsthm}

\theoremstyle{plain}
\newtheorem{thm}{Theorem}[chapter]
\theoremstyle{definition}
\newtheorem{exmp}[thm]{Example} 

\begin{document}
  \begin{exmp}
     \begin{tabular}{ccc}
        $ row1 & row1 & row1 $\\
        $ row2 & row2 & row2 $\\
        $ row3 & row3 & row3 $\\ 
     \end{tabular}
  \end{exmp}
\end{document}

The solution is to add \leavevmode after \begin{exmp} and also leave a blank line before the tabular environment.

7
  • insert the command \leavevmode before the table. (i'm sure this has been asked/answered before; i'll look for a dup.) Mar 20, 2018 at 19:34
  • I was looking for something similar about this but wasn't able to find. Thank you for the suggestion though. I tried doing this but it doesn't seem to work.
    – Razvan
    Mar 20, 2018 at 19:36
  • this question asks about starting a theorem environment with a list, not a tabular, but the principle is the same: tex.stackexchange.com/q/8110/579 and this one is also similar: tex.stackexchange.com/q/319717 (can't find an exact duplicate. maybe it's time to create a "generic" question on this topic.) Mar 20, 2018 at 19:45
  • off-topic: (i) chapter doesn't exist in article document class; (ii) use of $ signs in table is wrong/fragile (what you like to achieve with them?); (iii) \end{tabular} is missing; (iv) your problem can be solved with adding ~ after begin{exmp} and insert blank line before table.
    – Zarko
    Mar 20, 2018 at 19:46
  • in addition to the `\leavevmode, leave a blank line after \begin{exmp} Mar 20, 2018 at 19:49

1 Answer 1

3

the header of a theorem object in amsthm always ends in horizontal mode. the 'tabular' environment begins in horizontal mode, so if a table is to start on a new line, it's necessary to enter vertical mode. hence a blank line will be needed.

but that's not enough, since the theorem definitions in amsthm ignore blank lines in order for the text of a theorem to continue on the same line as the header. (this is an ams style specification.) so in order for a blank line to take effect, it's necessary to put something else on the "first line".

the recommended way to short-circuit the "something on the line" requirement is to insert \leavevmode. although this seems counterintuitive, it provides a horizontal mode element that will allow the blank line to have the desired effect of starting a new paragraph. the relevant part of the example should look like this:

...
  \begin{exmp}
     \leavevmode

     \begin{tabular}{ccc}
...

another method is to add the string $ $. however, this has the disadvantage that it inserts something that takes physical space in the output, and in the edge case where a header with optional added text exactly reaches the right-hand margin, it can result in the addition of a physical blank line in the output.

irrelevant to the question, the example provided has two flaws -- article does not define \chapter, and the $ signs in the tabular are out of synch and result in errors when trying to process the file.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .