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'm wondering if exists a way in LaTeX to create a section title style (for a resume) like this:

--------------------Education-------------------

There's for sure a wrong way, simply adding - sign but requires to write manually all characters... in that case why even using LaTeX? :)

What about \hline \line or something similar?

share|improve this question
    
Some time ago I gave an answer to this, allowing for multiple line titles, using the titlesec package: tex.stackexchange.com/a/57258/3954. –  Gonzalo Medina Jun 22 '12 at 2:10
add comment

2 Answers

A nice exercise in low level TeX commands. :)

\documentclass{article}

\usepackage{lipsum} % mock text

%%% this is the important code
\newcommand{\myresumesection}[1]{%
  \par\addvspace{\bigskipamount}
  \noindent\myresumetitle{#1}\par
  \addvspace{\medskipamount}
}
\newcommand{\myresumetitle}[1]{%
  \makebox[\textwidth][s]{\large\bfseries
    \leaders\hrule height \dimexpr .5ex + 0.2pt\relax
                   depth -\dimexpr .5ex - 0.2pt\relax\hfill
    \ #1\ 
    \leaders\hrule height \dimexpr .5ex + 0.2pt\relax
                   depth -\dimexpr .5ex - 0.2pt\relax\hfill
  }%
}
%%% end of the important code

\begin{document}

\lipsum[2]

\myresumesection{Education}

\lipsum[1]

\end{document}

The mysterious instructions are:

  1. Make sure we are at the start of a paragraph
  2. Add some vertical space
  3. Print the title in a box
  4. End the line
  5. Add some vertical space

Now the more mysterious instructions

  1. The box is as wide as the lines
  2. Its content must be stretched to fill, in \large size and boldface type
  3. Print a rule at mid height of the letters without ascenders or descenders (1ex is precisely the height of an "x"); the rule is actually slightly higher, and its depth is negative, so the net effect is a rule 0.4pt thick
  4. Print the title surrounded by spaces
  5. Print another rule to fill

enter image description here

In order to avoid a page break just after the title, change the first definition into

\makeatletter
\newcommand{\myresumesection}[1]{%
  \par\addvspace{\bigskipamount}
  \noindent\myresumetitle{#1}\par
  \nobreak\vskip\medskipamount\@afterheading
}
\makeatother

(\@afterheading is the magic trick that LaTeX uses for section titles)

share|improve this answer
    
Thanks! I'll try both yours and Werner solution –  Teo Jun 22 '12 at 8:33
add comment

The xhfill package provides these extensible rules. And, since this is for a resume, it would most likely be overkill to use \sections. Here's a minimal example showing the use of xhfill via \mytitle[<thickness>]{<title>}:

enter image description here

\documentclass{article}
\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\usepackage{xhfill}% http://ctan.org/pkg/xhfill
\newcommand*{\mytitle}[2][.4pt]{%
  \bigskip\noindent\leavevmode\xrfill{#1}~{\bfseries\large#2}~\xrfill{#1}\mbox{}\nobreak\par
}
\begin{document}
\mytitle{Education}
\lipsum[1]
\mytitle{Professional background}
\lipsum[2]
\end{document}​

Default for <thickness> is .4pt.

share|improve this answer
    
Thanks! I'll definitely try both solutions! –  Teo Jun 22 '12 at 8:33
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.