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.

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)...

share|improve this question
2  
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

4 Answers 4

up vote 7 down vote accepted

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.

Demo

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}
share|improve this answer
    
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
1  
@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
1  
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
2  
@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:

enter image description here

\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}
share|improve this answer
3  
I would recommend to add the command \nonindent to the definition of \blank –  Marco Daniel Dec 16 '11 at 17:57
1  
@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{%
  \leaders\vrule width \textwidth\vskip0.4pt\smallskip}

\begin{document}

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

\end{document}
share|improve this answer

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:

enter image description here

\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\crulefill[1][1ex]{\leavevmode\leaders\hrule depth \dimexpr-#1+0.4pt height #1\hfill\kern0pt}
\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}
share|improve this answer

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.