7

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?

5

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)

4

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.