Line spacing with line in between

Try

\documentclass{article}
\usepackage{lipsum}
\makeatletter
\def\mysettings{\bgroup%
\parindent=0pt %
\lineskip0pt %
\parskip0pt %
\def\\{\@@par\vspace{10pt}\hrule\vspace{10pt}}}
\makeatother

\def\endmysettings{\egroup}
\begin{document}

\section{introduction}
\begin{mysettings}
X-rays first discovered in 1895 are a form of Electromagnetic radiation 
with\\ 
wavelengths of the order of $10^{-10}m$ to simplify this an equivalent unit 
of\\ 
angstrom (A) is used.\\ 
\lipsum[1]

{\ttfamily\meaning\\}
\end{mysettings}

X-rays first discovered in 1895 are a form of Electromagnetic radiation 
with\\ 
wavelengths of the order of $10^{-10}m$ to simplify this an equivalent unit 
of\\ 
angstrom (A) is used.
{\ttfamily\meaning\\}
\end{document}

What I have done is to redefine the \\ to a simpler form. This is done in a group, so it that it does not interfere with the original definition.


This solution uses \vsplit to pull off one line at a time and reformat it. The \parbox is to restrict where pagebreaks can occur.

Note: \vspace doesn't do anything until the end of a line, whereas \vskip can only be used in vmode.

\documentclass{article}
\usepackage{environ}

\newsavebox{\myenvbox}

\NewEnviron{myenv}[2]% #1 = distance above line, #2 = distance below line
{\interlinepenalty=-10000
  \setbox\myenvbox=\vbox{\BODY}%
  \noindent
  \loop\ifdim\ht\myenvbox>0pt
    \setbox0=\vsplit\myenvbox to \ht\strutbox
    \parbox[b]{\textwidth}{\unvbox0\vskip#1\hrule}\vspace{#2}
  \repeat}

\begin{document}

\section{introduction}

\begin{myenv}{10pt}{10pt}
X-rays first discovered in 1895 are a form of Electromagnetic radiation 
with  
wavelengths of the order of $10^{-10}m$ to simplify this an equivalent unit 
of   
angstrom (A) is used.
\end{myenv}

\end{document}

demo


A simple solution using the ulem package. You can define your own underline style using, for example, the following command:

\newcommand\buline{\bgroup\markoverwith{\rule[-3ex]{.4pt}{.4pt}}\ULon}

which can be fine tuned, colored, or replaced by a different line style (dashes, etc.) as required. Also add \linespread{2.5} to the preamble to increase line-spacing as needed.

\documentclass[12pt,a4paper]{article}
\usepackage{ulem}
\linespread{2.5}
\begin{document}

\newcommand\buline{\bgroup\markoverwith{\rule[-3ex]{.4pt}{.4pt}}\ULon}

\section{introduction}

\buline{%
X-rays first discovered in 1895 are a form of Electromagnetic radiation 
with 
wavelengths of the order of $10^{-10}m$ to simplify this an equivalent unit 
of 
angstrom (A) is used.}

\end{document}

enter image description here

Tags:

Line Spacing