How to get custom section style using titlesec?












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]{Largebfseriessffamily}%
{}%
{0pt}%
{%
begin{minipage}[c]{60pt}{%
colorbox{myBlue}{%
parbox[b][15pt][t]{60pt}{% height, width
vfill%
fontfamily{phv}selectfontcenteringcolor{white}{thesection}
vfill%
}}}%
end{minipage}%
hspace{15pt}%
begin{minipage}[t]{dimexprtextwidth-75pt}
vspace*{-10pt}%
color{myBlue}{Large #1}
end{minipage}\%
color{myBlue}{rule{textwidth}{1.2pt}}
%
}

titlespacing*{section}{0pt}{3mm}{-5mm}









share|improve this question




















  • 1





    Could you post a full code, starting with documentclass and including some document body?

    – Bernard
    7 hours ago






  • 1





    Also, may it happen that your section titles be multilined?

    – Bernard
    6 hours ago
















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]{Largebfseriessffamily}%
{}%
{0pt}%
{%
begin{minipage}[c]{60pt}{%
colorbox{myBlue}{%
parbox[b][15pt][t]{60pt}{% height, width
vfill%
fontfamily{phv}selectfontcenteringcolor{white}{thesection}
vfill%
}}}%
end{minipage}%
hspace{15pt}%
begin{minipage}[t]{dimexprtextwidth-75pt}
vspace*{-10pt}%
color{myBlue}{Large #1}
end{minipage}\%
color{myBlue}{rule{textwidth}{1.2pt}}
%
}

titlespacing*{section}{0pt}{3mm}{-5mm}









share|improve this question




















  • 1





    Could you post a full code, starting with documentclass and including some document body?

    – Bernard
    7 hours ago






  • 1





    Also, may it happen that your section titles be multilined?

    – Bernard
    6 hours ago














0












0








0


1






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]{Largebfseriessffamily}%
{}%
{0pt}%
{%
begin{minipage}[c]{60pt}{%
colorbox{myBlue}{%
parbox[b][15pt][t]{60pt}{% height, width
vfill%
fontfamily{phv}selectfontcenteringcolor{white}{thesection}
vfill%
}}}%
end{minipage}%
hspace{15pt}%
begin{minipage}[t]{dimexprtextwidth-75pt}
vspace*{-10pt}%
color{myBlue}{Large #1}
end{minipage}\%
color{myBlue}{rule{textwidth}{1.2pt}}
%
}

titlespacing*{section}{0pt}{3mm}{-5mm}









share|improve this question
















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]{Largebfseriessffamily}%
{}%
{0pt}%
{%
begin{minipage}[c]{60pt}{%
colorbox{myBlue}{%
parbox[b][15pt][t]{60pt}{% height, width
vfill%
fontfamily{phv}selectfontcenteringcolor{white}{thesection}
vfill%
}}}%
end{minipage}%
hspace{15pt}%
begin{minipage}[t]{dimexprtextwidth-75pt}
vspace*{-10pt}%
color{myBlue}{Large #1}
end{minipage}\%
color{myBlue}{rule{textwidth}{1.2pt}}
%
}

titlespacing*{section}{0pt}{3mm}{-5mm}






sectioning pdftex minipage titlesec colorbox






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 7 hours ago







Ravi

















asked 7 hours ago









RaviRavi

32918




32918








  • 1





    Could you post a full code, starting with documentclass and including some document body?

    – Bernard
    7 hours ago






  • 1





    Also, may it happen that your section titles be multilined?

    – Bernard
    6 hours ago














  • 1





    Could you post a full code, starting with documentclass and including some document body?

    – Bernard
    7 hours ago






  • 1





    Also, may it happen that your section titles be multilined?

    – Bernard
    6 hours ago








1




1





Could you post a full code, starting with documentclass and including some document body?

– Bernard
7 hours ago





Could you post a full code, starting with documentclass and including some document body?

– Bernard
7 hours ago




1




1





Also, may it happen that your section titles be multilined?

– Bernard
6 hours ago





Also, may it happen that your section titles be multilined?

– Bernard
6 hours ago










2 Answers
2






active

oldest

votes


















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]{Largebfseriessffamily}%
{}%
{0pt}%
{%
renewcommand{arraystretch}{1.5}
begin{tabularx}{textwidth}{p{60pt}X}
centeringcellcolor{blue!25} thesection & #1\
arrayrulecolor{blue!25}specialrule{.25em}{-0.1em}{0em}
end{tabularx}
%
}


picture






share|improve this answer
























  • 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
    5 hours ago



















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]{Largebfseriessffamily}%
{rlap{color{myBlue}rule[-6pt]{textwidth}{1.2pt}}colorbox{myBlue}{%
raisebox{0pt}[13pt][3pt]{ makebox[60pt]{% height, width
fontfamily{phv}selectfontcolor{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






share|improve this answer
























  • Thank you very much for helping me

    – Ravi
    5 hours ago












Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f483919%2fhow-to-get-custom-section-style-using-titlesec%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









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]{Largebfseriessffamily}%
{}%
{0pt}%
{%
renewcommand{arraystretch}{1.5}
begin{tabularx}{textwidth}{p{60pt}X}
centeringcellcolor{blue!25} thesection & #1\
arrayrulecolor{blue!25}specialrule{.25em}{-0.1em}{0em}
end{tabularx}
%
}


picture






share|improve this answer
























  • 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
    5 hours ago
















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]{Largebfseriessffamily}%
{}%
{0pt}%
{%
renewcommand{arraystretch}{1.5}
begin{tabularx}{textwidth}{p{60pt}X}
centeringcellcolor{blue!25} thesection & #1\
arrayrulecolor{blue!25}specialrule{.25em}{-0.1em}{0em}
end{tabularx}
%
}


picture






share|improve this answer
























  • 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
    5 hours ago














1












1








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]{Largebfseriessffamily}%
{}%
{0pt}%
{%
renewcommand{arraystretch}{1.5}
begin{tabularx}{textwidth}{p{60pt}X}
centeringcellcolor{blue!25} thesection & #1\
arrayrulecolor{blue!25}specialrule{.25em}{-0.1em}{0em}
end{tabularx}
%
}


picture






share|improve this answer













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]{Largebfseriessffamily}%
{}%
{0pt}%
{%
renewcommand{arraystretch}{1.5}
begin{tabularx}{textwidth}{p{60pt}X}
centeringcellcolor{blue!25} thesection & #1\
arrayrulecolor{blue!25}specialrule{.25em}{-0.1em}{0em}
end{tabularx}
%
}


picture







share|improve this answer












share|improve this answer



share|improve this answer










answered 6 hours ago









Rémi NazinRémi Nazin

50128




50128













  • 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
    5 hours ago



















  • 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
    5 hours ago

















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
5 hours ago





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
5 hours ago











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]{Largebfseriessffamily}%
{rlap{color{myBlue}rule[-6pt]{textwidth}{1.2pt}}colorbox{myBlue}{%
raisebox{0pt}[13pt][3pt]{ makebox[60pt]{% height, width
fontfamily{phv}selectfontcolor{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






share|improve this answer
























  • Thank you very much for helping me

    – Ravi
    5 hours ago
















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]{Largebfseriessffamily}%
{rlap{color{myBlue}rule[-6pt]{textwidth}{1.2pt}}colorbox{myBlue}{%
raisebox{0pt}[13pt][3pt]{ makebox[60pt]{% height, width
fontfamily{phv}selectfontcolor{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






share|improve this answer
























  • Thank you very much for helping me

    – Ravi
    5 hours ago














1












1








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]{Largebfseriessffamily}%
{rlap{color{myBlue}rule[-6pt]{textwidth}{1.2pt}}colorbox{myBlue}{%
raisebox{0pt}[13pt][3pt]{ makebox[60pt]{% height, width
fontfamily{phv}selectfontcolor{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






share|improve this answer













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]{Largebfseriessffamily}%
{rlap{color{myBlue}rule[-6pt]{textwidth}{1.2pt}}colorbox{myBlue}{%
raisebox{0pt}[13pt][3pt]{ makebox[60pt]{% height, width
fontfamily{phv}selectfontcolor{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







share|improve this answer












share|improve this answer



share|improve this answer










answered 6 hours ago









BernardBernard

175k778209




175k778209













  • Thank you very much for helping me

    – Ravi
    5 hours ago



















  • Thank you very much for helping me

    – Ravi
    5 hours ago

















Thank you very much for helping me

– Ravi
5 hours ago





Thank you very much for helping me

– Ravi
5 hours ago


















draft saved

draft discarded




















































Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f483919%2fhow-to-get-custom-section-style-using-titlesec%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

Calculate evaluation metrics using cross_val_predict sklearn

Insert data from modal to MySQL (multiple modal on website)