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've definied an environment with

\newenvironment{definiere}{\begin{leftbar} \textbf{Definition:}\newline }{\end{leftbar}}

Unfortunately sometimes this environment is spread over two pages, where the left-bar is about 2cm long and "Definition" written as header, but the actual definition itself is on the next page.

I'm using this environment mostly like this:

\begin{definiere}
   \begin{equation}
     WMC=\sum_{i=1}^n {c_i} \label{eq:WMC}
   \end{equation}
\end{definiere}

I can avoid this behaviour by moving paragraphs below or above the definition, but sometimes it doesn't make sense anymore. My question is, does someone see a more elegant solution to my needs?

share|improve this question
    
Would making it a floating environment solve your problem? –  ℝaphink Apr 27 '11 at 8:58
    
@Raphink: How ? –  adnc Apr 27 '11 at 9:00
1  
Please state what you want not what you don't want, especially in the title. You want an environment which doesn't break over multiple pages? Then say so in the title. At the moment the title means the exact opposite for me! –  Martin Scharrer Apr 27 '11 at 9:06
    
You are right, unfortunately I can not edit the title anymore. Sorry –  adnc Apr 27 '11 at 9:08
    
@adnc: Of course you can edit the title: tex.stackexchange.com/posts/16729/edit –  Martin Scharrer Apr 27 '11 at 9:11
show 1 more comment

2 Answers 2

up vote 5 down vote accepted

Your \textbf{Definition} is a title like a section title. Suppress the page break like \section does it:

\makeatletter
\newenvironment{definiere}
  {\begin{leftbar}%
   \textbf{Definition:}\par\nobreak\@afterheading}
  {\end{leftbar}}
\makeatother
share|improve this answer
    
That works great! –  adnc Apr 27 '11 at 9:19
add comment

Ulrike's answer is probably the correct way of doing something like that. Another approach that seemed to work for me---you could pack everything inside a minipage. Hopefully, someone else can explain exactly why it worked.

\newenvironment{definiere}{\begin{minipage}{\textwidth}\begin{leftbar} \textbf{Definition:}\newline }{\end{leftbar}\end{minipage}}
share|improve this answer
add comment

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.