How to get custom section style using titlesec?
I am trying to design a custom section. My desire section will be something like this :
But I am unable to get the exact result. This is what I was trying :
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
add a comment |
I am trying to design a custom section. My desire section will be something like this :
But I am unable to get the exact result. This is what I was trying :
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
1
Could you post a full code, starting withdocumentclass
and including some document body?
– Bernard
7 hours ago
1
Also, may it happen that your section titles be multilined?
– Bernard
6 hours ago
add a comment |
I am trying to design a custom section. My desire section will be something like this :
But I am unable to get the exact result. This is what I was trying :
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
I am trying to design a custom section. My desire section will be something like this :
But I am unable to get the exact result. This is what I was trying :
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
sectioning pdftex minipage titlesec colorbox
edited 7 hours ago
Ravi
asked 7 hours ago
RaviRavi
32918
32918
1
Could you post a full code, starting withdocumentclass
and including some document body?
– Bernard
7 hours ago
1
Also, may it happen that your section titles be multilined?
– Bernard
6 hours ago
add a comment |
1
Could you post a full code, starting withdocumentclass
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
add a comment |
2 Answers
2
active
oldest
votes
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}
%
}
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
add a comment |
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}
Thank you very much for helping me
– Ravi
5 hours ago
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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}
%
}
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
add a comment |
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}
%
}
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
add a comment |
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}
%
}
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}
%
}
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
add a comment |
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
add a comment |
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}
Thank you very much for helping me
– Ravi
5 hours ago
add a comment |
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}
Thank you very much for helping me
– Ravi
5 hours ago
add a comment |
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}
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}
answered 6 hours ago
BernardBernard
175k778209
175k778209
Thank you very much for helping me
– Ravi
5 hours ago
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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