10

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

  • Should the section be numbered? – Bernard Jul 22 '14 at 9:08
  • @Bernard: no only the title is important – ma.mehralian Jul 22 '14 at 9:35
10

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

| improve this answer | |
  • Just emphasizing the feature: mine and this one don't support multiple lines of section title. – kiss my armpit Jul 22 '14 at 15:00
4

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

| improve this answer | |

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.