# Underlines under text that do not flow to the other page

I am using the KOMA script srcbook class, and my plan is to have text and horizontal lines under each section of text for writing.

For example

\chapter{1}

this is a sentence
\oneline
etc.


Where \oneline is defined as

\newcommand{\oneline}{
\vspace{0.6cm}
\hrule
\vspace{0.3cm}
}


There are a lot of problems with this approach. I cannot use footnotes (because the horizontal lines get cut off), and the horizontal lines flow onto the next page.

Is there a simple way to create a horizontal line under text such that it does not flow onto the next page, or at least so that the text and the horizontal lines are grouped together?

I am aware that floats can be used to include graphics, is it a good approach here?

• Welcome! Could you post a full yet minimal compilable code showing the problem? Aug 20, 2016 at 12:57

Simply use \nobreak:

% My standard header for TeX.SX answers:
\documentclass[a4paper]{article} % To avoid confusion, let us explicitly
% declare the paper format.

\usepackage[T1]{fontenc}         % Not always necessary, but recommended.
% End of standard header.  What follows pertains to the problem at hand.

\newcommand*{\oneline}{%
\par\nobreak\vspace{6mm}%
\hrule
\nobreak\vspace{3mm}%
}

\begin{document}

\vspace{543pt} % then try incrementing this to 544pt

Some text.
\oneline
Some other text.

\end{document}


Addition: It is perhaps a good idea to make the \oneline macro “stable” w.r.t. interline glue too. You might want to reduce the amount of vertical spacing (6mm, 3mm) to smaller values, in this case.

% My standard header for TeX.SX answers:
\documentclass[a4paper]{article} % To avoid confusion, let us explicitly
% declare the paper format.

\usepackage[T1]{fontenc}         % Not always necessary, but recommended.
% End of standard header.  What follows pertains to the problem at hand.

\newcommand*{\oneline}{%
\vskip -\prevdepth
\par\nobreak\vskip 6mm
\hrule
\nobreak\vskip 3mm \relax
\setlength\prevdepth{0pt}%
}

\begin{document}