0

I am trying to design a custom section. My desire section will be something like this :

enter image description here

But I am unable to get the exact result. This is what I was trying :

enter image description here

Horizontal rule will be joined at the bottom of the section number box. Section number box width will be 60pt and it is fixed. Could you please help to getting my desire result. You can also do it from scratch if you have any easier and standard solution.

My code snippet :

\renewcommand*\thesection{\arabic{section}}
\usepackage[explicit]{titlesec}
\definecolor{myBlue}{HTML}{0088FF}

\titleformat{\section}[block]{\Large\bfseries\sffamily}%
{}%
{0pt}%
{%
\begin{minipage}[c]{60pt}{%
        \colorbox{myBlue}{%
            \parbox[b][15pt][t]{60pt}{% height, width
                \vfill%
                \fontfamily{phv}\selectfont\centering\color{white}{\thesection}
                \vfill%
            }}}%
\end{minipage}%
\hspace{15pt}%
\begin{minipage}[t]{\dimexpr\textwidth-75pt}
    \vspace*{-10pt}%
    \color{myBlue}{\Large #1}
\end{minipage}\\%
\color{myBlue}{\rule{\textwidth}{1.2pt}}
%
}

\titlespacing*{\section}{0pt}{3mm}{-5mm}
  • 1
    Could you post a full code, starting with \documentclass and including some document body? – Bernard Apr 9 at 8:35
  • 1
    Also, may it happen that your section titles be multilined? – Bernard Apr 9 at 8:42
1

I will let you figure out the colour/sizing part of the problem but a simpler solution would be this one :

\usepackage[table]{xcolor}
\usepackage[explicit]{titlesec}
\usepackage{tabularx}
\usepackage{ctable}

\titleformat{\section}[block]{\Large\bfseries\sffamily}%
{}%
{0pt}%
{%
\renewcommand{\arraystretch}{1.5}
\begin{tabularx}{\textwidth}{p{60pt}X}
\centering\cellcolor{blue!25} \thesection & #1\\
\arrayrulecolor{blue!25}\specialrule{.25em}{-0.1em}{0em}
\end{tabularx}
%
}

picture

  • Thanks a million! There is a small space at the starting point of the tabularx but I have fixed that using \hspace{-0.25em} – Ravi Apr 9 at 10:26
1

Here is what you want with a simpler code:

\documentclass{article}
\usepackage{lipsum}
\usepackage{xcolor}
\renewcommand*\thesection{\arabic{section}}
\usepackage[explicit]{titlesec}
\definecolor{myBlue}{HTML}{0088FF}

\titleformat{\section}[hang]{\Large\bfseries\sffamily}%
{\rlap{\color{myBlue}\rule[-6pt]{\textwidth}{1.2pt}}\colorbox{myBlue}{%
           \raisebox{0pt}[13pt][3pt]{ \makebox[60pt]{% height, width
                \fontfamily{phv}\selectfont\color{white}{\thesection}}
            }}}%
{15pt}%
{ \color{myBlue}#1
%
}
\titlespacing*{\section}{0pt}{3mm}{5mm}

\begin{document}

\section{heading on level 1 (section)}
\lipsum[1]

\end{document} 

enter image description here

  • Thank you very much for helping me – Ravi Apr 9 at 10:21

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.