2

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?

1
  • 1
    Welcome! Could you post a full yet minimal compilable code showing the problem?
    – Bernard
    Aug 20 '16 at 12:57
1

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}

Let's skip to the bottom of the page:

\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}

Let's skip to the bottom of the page:

\vspace{537pt} % then try incrementing this to 538pt

Some text, with descenders: fgjpqy.
\oneline
Some other text.

\showboxbreadth = 1000
\showboxdepth = 10
\showlists

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.