# Long Underscore to Divide Sections of Text

Is there a way to write an underscore that extends along the full length of the page, to represent a break in sections?

As of now, I'm using the \blank{?cm} command explained in this answer, but with this solution I need to specify the length of the blank manually (so if I change my page size later, I'll have to go back and change all these parameters)...

-
Are you planning to use this rule for every \section of your document? –  Gonzalo Medina Dec 16 '11 at 17:55
No, just to use once in a while to indicate separation between a special section. –  jamaicanworm Dec 16 '11 at 19:16

Here is an alternative macro definition that does not take an argument:

\documentclass{article}

\def\blank{\medskip\hrule\medskip}

\begin{document}
Cillum dolore eu fugiat nulla pariatur. Excepteur sint
occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit
anim id est laborum.
\blank
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam.
\end{document}


The \hrule inserts a horizontal rule that takes up all the available space. A \medskip before and after makes sure there is a little space above and below the rule. You could also use \smallskip or \bigskip for a smaller or bigger space.

Addendum: I like Peter Grill's addition of some ornament in his solution. Here is a \blankwith macro that takes an ornament like in \blankwith{$\clubsuit$}. This macro again relies more on TeX than LaTeX. It puts the ornament slightly lowered in the middle of the line with some space left and right. The line is drawn using \hrulefill.

\def\blankwith#1{\par\nobreak\bigskip
\hbox to \hsize{\hrulefill\kern.5em\lower.5ex\hbox{#1}\kern.5em\hrulefill}
\bigskip}

-
Is there any reason this answer is so much simpler than @Werner's? I tried this one and it works, but might there by any complicated drawbacks? –  jamaicanworm Dec 16 '11 at 19:37
@jamaicanworm: one possible issue is that you will have to manually remove the rule if a page break occurs just before it. –  Gonzalo Medina Dec 16 '11 at 19:43
I was a little surprised that \noindent wasn't needed. Otherwise the solution is simple because it relies on the stretchability built into \hrule, a TeX primitive. –  Christian Lindig Dec 16 '11 at 19:49
@jamaicanworm: Your original usage is still supported in my \blank{<len>} definition (now having the <len> optional). If this original definition was not required, then @ ChristianLindig's solution is the easiest. However, you didn't request an alternative to \blank, so I incorporated the original with the new. –  Werner Dec 16 '11 at 20:08
Do you agree with @Gonzalo that it might help to include \leaders before \medskip\hrule\medskip? –  jamaicanworm Dec 19 '11 at 16:08

Use

\newcommand\blank[1][\textwidth]{\noindent\rule[-.2ex]{#1}{.4pt}}


instead, making the former mandatory argument optional. Now you can use

\blank


which typesets a \rule of width \textwidth. Otherwise, specify \blank[5cm]. If you're interested keeping the same format (using \blank{<len>} rather than \blank[<len>]), this is also possible by using xparse. Here is such a definition:

\documentclass{article}
\usepackage{xparse}% http://ctan.org/pkg/xparse
\NewDocumentCommand{\blank}{G{\textwidth}}{%
\noindent\rule[-.2ex]{#1}{.4pt}%
}
\begin{document}
Here is some text. \blank{5cm} \par
\blank \par
\blank{2cm} Here is some more text.
\end{document}

-
I would recommend to add the command \nonindent to the definition of \blank –  Marco Daniel Dec 16 '11 at 17:57
@MarcoDaniel: Thanks, good suggestion. –  Werner Dec 16 '11 at 19:13

I suggest using \leaders in the definition of the rule to guarantee that it won't appear if a page break occurs just before a new \section:

\documentclass{article}

\newcommand\MySecRule{%

\begin{document}

\section{Test}\MySecRule
\section{Test}\newpage
\MySecRule\section{Test}

\end{document}

-

You can use \linewidth to specify the width of the line so that if the \linewidth does change this won't need adjustment, as I have done for the first rule in the example below. This will also adapt to the column width if you use more than one column.

If you want to get fancier, there are many options as to what to use as a separator. To illustrate, I have used an ornament from this question and another from this question on how to insert a border:

\documentclass{article}
\usepackage{xcolor}
\usepackage{lipsum}

\newcommand*{\MyLine}[1][black]{\par\noindent{\color{#1}{\underline{\hspace{\linewidth}}}\newline\par}}

%------------------------
% Ornament from http://tex.stackexchange.com/questions/11320/end-of-paragraph-with-ornament
\usepackage{pifont,fourier-orns}% These are needed only for the ornament

\newcommand\ornline[2][1ex]{\trivlist\item\crulefill[#1]#2\crulefill[#1]\endtrivlist}

%------------------------
%http://tex.stackexchange.com/questions/30973/how-do-i-insert-a-border-below-text/30979#30979
\usepackage{xcolor}% http://ctan.org/pkg/xcolor
\usepackage{xparse}% http://ctan.org/pkg/xparse
\NewDocumentCommand{\myrule}{O{1pt} O{3pt} O{black}}{%
\par\nobreak % don't break a page here
\kern\the\prevdepth % don't take into account the depth of the preceding line
\kern#2 % space before the rule
{\color{#3}\hrule height #1 width\hsize} % the rule
\kern#2 % space after the rule
\nointerlineskip % no additional space after the rule
}
%------------------------

\begin{document}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam in erat vitae libero dictum imperdiet volutpat nec orci.  Nam vel magna vitae risus tristique ornare. Etiam iaculis tincidunt ante, sed consectetur dui sagittis at.
\MyLine[red]
Duis porttitor lacus ut sapien varius ut dapibus odio dapibus. Pellentesque sed odio et nisl lacinia rutrum at quis diam. Mauris a nulla sed est blandit varius eget id massa.
\ornline[0.6ex]{\decoone}
Vivamus libero nibh, dignissim laoreet sollicitudin nec, lobortis nec orci. Pellentesque dolor libero, pretium ut euismod nec, tempor sit amet diam. Mauris vestibulum ornare lacus, in tincidunt dolor adipiscing vel.
\myrule[5pt][5pt][orange]
Maecenas mattis sodales justo, ut fringilla leo vulputate sit amet.Vivamus in felis quis justo viverra blandit id mollis velit. Aenean mi dolor, pulvinar eu ornare et, hendrerit sed tortor. In vitae vulputate felis.
\end{document}

-