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.

I am trying to make section headers like in this resume. I want one line above the text and one below with the above line thicker than the one below. The lines also need to span the entire page. I have tried something like

\rule{\textwidth}{1px}\\ Heading\\ \rule{\textwidth}{0.5px}\\

but the spacing is way off. There is too much spacing between the lines and the text. How can I make it look like in the example?

share|improve this question
add comment

2 Answers

up vote 6 down vote accepted
\newcommand\myheading[1]{\par
  \bigskip
  \hrule height 1pt
  \kern 2pt
  \hbox to \textwidth{\textbf{#1}\hfil}
  \kern 2pt
  \hrule height 0.5pt
  \kern\medskipamount}

We close a paragraph, leave a vertical space and draw a 1pt thick rule; after it we leave a small space (customize it to suit you) and print the heading, with another small space after it. A 0.5pt thick rule and another space.

Four tricks are used in this low level code: (1) a vertical space inserted via \kern won't be used by TeX to break a page, so the only permissible place for breaking is at the \bigskip preceding the heading; (2) \hbox doesn't start the horizontal mode and no glue (so no place for page breaking) is inserted before or after a box contributed to the main vertical list; (3) a \kern in vertical mode produces a vertical space that is fixed in length; (4) an \hrule without a width specification extends to cover the widest box in the vertical list (here the \hbox to \textwidth{...}. A consequence of the page break rules is that no page break can intervene between the heading and the paragraph following it (provided it doesn't insert penalties, which may happen if the following item is a list such as itemize).

Gonzalo's solution based on titlesec is very clean, but sometimes a low level code is faster, provided we understand it. :-)

share|improve this answer
    
This works great. Can you give me some insight into what is going on in this code? What does the kern command do here? –  Justin J Stark Jun 16 '11 at 1:47
    
\kern 2pt gives an incompressible space but there is a trick : in horizontal mode you get an horizontal displacement (movement) and in vertical mode you get an vertical displacement. Another trick, TeX can't cut a line on a \kern. In math mode you have \mkern. –  Alain Matthes Jun 16 '11 at 6:40
    
Thank you. After playing around with both solutions, I wound up using this. As it is lower level, I find it much easier to control the layout/spacings. –  Justin J Stark Jun 17 '11 at 14:55
add comment

You can use the titlesec package to redefine the way \section behaves:

\documentclass{article}
\usepackage{titlesec}
\usepackage{lipsum}% just to generate filler text

\setlength\parskip{0pt}

\titleformat{\section}
  {\normalfont\large\bfseries}{}{0em}{\hrule height 1pt\vspace{2pt}}[\hrule height 0.2pt]
\titlespacing*{\section}
  {0pt}{0pt}{10pt}

\begin{document} 

\section{EDUCATION}
\lipsum[1]
\section{LEGAL EXPERIENCE}
\lipsum[1]

\end{document}

EDIT: as requested in a comment, here's the modification of the code that allows to use \so, from the soul package, for the section titles:

\documentclass{article}
\usepackage{soul}
\usepackage[explicit]{titlesec}
\usepackage{lipsum}% just to generate filler text

\setlength\parskip{0pt}

\titleformat{\section}
  {\normalfont\large\bfseries}{}{0em}{\hrule height 1pt\vspace{2pt}\so{#1}}[\hrule height 0.2pt]
\titlespacing*{\section}
  {0pt}{0pt}{10pt}

\begin{document} 

\section{EDUCATION}
\lipsum[1]
\section{LEGAL EXPERIENCE}
\lipsum[1]

\end{document}
share|improve this answer
    
This is a good idea. How can I combine this with \so from the soul package to make the section titles' characters have more spacing? –  Justin J Stark Jun 16 '11 at 1:52
    
@Justin J Stark: you can use \section{\so{EDUCATION}} (after loading soul in the preamble) or \section[EDUCATION]{\so{EDUCATION}} if a table of contents will be generated. –  Gonzalo Medina Jun 16 '11 at 1:57
    
@Justin J Stark: for an automatic solution see my updated answer. –  Gonzalo Medina Jun 16 '11 at 2:17
    
Excellent. I think using \section makes more sense. Thank you very much. –  Justin J Stark Jun 16 '11 at 3:35
    
letter spacing can be obtained also with microtype, the command is \textls. –  egreg Jun 16 '11 at 8:52
add comment

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.