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.

Could anyone tell me how can I put section between 2 horizontal lines.

I tried something similar to the following code but it did not work.

\makeatletter
\renewcommand\section{‎
    \hrule
    \@startsection {section}{1}{\z@}%
        {-3.5ex \@plus -1ex \@minus -.2ex}%
        {2.3ex \@plus.2ex}%
        {\large\scshape}‎‎
    \protect ‎\hrule
}
\makeatother

this is a sample picture for ‎‎\section{Experience}‎

sample

share|improve this question
    
Should the section be numbered? –  Bernard Jul 22 at 9:08
    
@Bernard: no only the title is important –  mehralian Jul 22 at 9:35

2 Answers 2

up vote 10 down vote accepted

We can exploit the fact that the final argument of \@startsection in the definition of \section can contain a one parameter macro which will receive the section title (with the number) as argument.

\documentclass{article}

\makeatletter
\renewcommand\section{%
  \@startsection{section}{1}
    {\z@}%
    {-3.5ex \@plus -1ex \@minus -.2ex}%
    {2.3ex \@plus.2ex}%
    {\ruled@title}%
}
\newcommand{\ruled@title}[1]{%
  \vbox{\hrule\vskip2pt\hbox{\large\scshape #1}\vskip2pt\hrule}%
}
\makeatother

\setcounter{secnumdepth}{-2}

\begin{document}
\section{experience}

Whatever you want to tell about your experience.

\end{document}

enter image description here

share|improve this answer
    
Thanks a lot. That solves my problem. –  mehralian Jul 22 at 9:30
    
Just emphasizing the feature: mine and this one don't support multiple lines of section title. –  Who is crazy first Jul 22 at 15:00

Another simple but not perfect solution.

\documentclass[preview,border=12pt,12pt]{standalone}
\def\Section#1{\section*{\tabular{@{}c@{}}\hline #1\\\hline \endtabular}}
\begin{document}
\Section{PSTricks is fun!}
Bla bla bla
\end{document}

enter image description here

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.