Use of shaded box for section numbering only?
I have been wondering "how to get shaded box for section numbers only"?
Also, How to get grey square in between left mark and page number in the header? In code below I can get solid black square.
I have attached image below of the desired output. This example is from TUGINDIA tutorials.
documentclass[12pt,twoside]{report}
usepackage{titlesec}%for formatting chapter position and names
titleformat{chapter}[display]
{normalfonthugebfseries}{chaptertitlename thechapter}{0pt}{huge}
titlespacing*{chapter}{0pt}{-20pt}{10pt}
title{bf huge xxx}
author{xxx}
date{} %to disable date
usepackage[top=1.3in, left=1.5in, right=1in]{geometry} %for setting margins
usepackage{grffile} %to avoid showing path of figure inserted
includeonly{chap1/chapter_1}
titlelabel{llap{thetitlequad}}% for section headings in margins
usepackage{fancyhdr}
pagestyle{fancy}
newcommand{helv}{%
fontfamily{phv}fontseries{}fontsize{10}{12}selectfont}
renewcommand{chaptermark}[1]{markboth{#1}{}}%formatting chapter title
renewcommand{sectionmark}[1]{markright{thesection. #1}}
fancyhf{}
fancyhead[RO]{helv rightmark{} $blacksquare$ thepage}
fancyhead[LE]{helv thepage{} $blacksquare$ leftmark}
renewcommand{headrulewidth}{0pt}
usepackage{amssymb}
parindent=0.5in
parskip=10pt
linespread{1.3}
renewcommand{abstractname}{Large Abstract} %To increase Abstract font size
begin{document}
maketitle
begin{abstract}
blahblah
end{abstract}
blah blah
end{document}
sectioning header-footer color fancyhdr
add a comment |
I have been wondering "how to get shaded box for section numbers only"?
Also, How to get grey square in between left mark and page number in the header? In code below I can get solid black square.
I have attached image below of the desired output. This example is from TUGINDIA tutorials.
documentclass[12pt,twoside]{report}
usepackage{titlesec}%for formatting chapter position and names
titleformat{chapter}[display]
{normalfonthugebfseries}{chaptertitlename thechapter}{0pt}{huge}
titlespacing*{chapter}{0pt}{-20pt}{10pt}
title{bf huge xxx}
author{xxx}
date{} %to disable date
usepackage[top=1.3in, left=1.5in, right=1in]{geometry} %for setting margins
usepackage{grffile} %to avoid showing path of figure inserted
includeonly{chap1/chapter_1}
titlelabel{llap{thetitlequad}}% for section headings in margins
usepackage{fancyhdr}
pagestyle{fancy}
newcommand{helv}{%
fontfamily{phv}fontseries{}fontsize{10}{12}selectfont}
renewcommand{chaptermark}[1]{markboth{#1}{}}%formatting chapter title
renewcommand{sectionmark}[1]{markright{thesection. #1}}
fancyhf{}
fancyhead[RO]{helv rightmark{} $blacksquare$ thepage}
fancyhead[LE]{helv thepage{} $blacksquare$ leftmark}
renewcommand{headrulewidth}{0pt}
usepackage{amssymb}
parindent=0.5in
parskip=10pt
linespread{1.3}
renewcommand{abstractname}{Large Abstract} %To increase Abstract font size
begin{document}
maketitle
begin{abstract}
blahblah
end{abstract}
blah blah
end{document}
sectioning header-footer color fancyhdr
Welcome to TeX.sx!
– Peter Jansson
Mar 3 '13 at 11:05
add a comment |
I have been wondering "how to get shaded box for section numbers only"?
Also, How to get grey square in between left mark and page number in the header? In code below I can get solid black square.
I have attached image below of the desired output. This example is from TUGINDIA tutorials.
documentclass[12pt,twoside]{report}
usepackage{titlesec}%for formatting chapter position and names
titleformat{chapter}[display]
{normalfonthugebfseries}{chaptertitlename thechapter}{0pt}{huge}
titlespacing*{chapter}{0pt}{-20pt}{10pt}
title{bf huge xxx}
author{xxx}
date{} %to disable date
usepackage[top=1.3in, left=1.5in, right=1in]{geometry} %for setting margins
usepackage{grffile} %to avoid showing path of figure inserted
includeonly{chap1/chapter_1}
titlelabel{llap{thetitlequad}}% for section headings in margins
usepackage{fancyhdr}
pagestyle{fancy}
newcommand{helv}{%
fontfamily{phv}fontseries{}fontsize{10}{12}selectfont}
renewcommand{chaptermark}[1]{markboth{#1}{}}%formatting chapter title
renewcommand{sectionmark}[1]{markright{thesection. #1}}
fancyhf{}
fancyhead[RO]{helv rightmark{} $blacksquare$ thepage}
fancyhead[LE]{helv thepage{} $blacksquare$ leftmark}
renewcommand{headrulewidth}{0pt}
usepackage{amssymb}
parindent=0.5in
parskip=10pt
linespread{1.3}
renewcommand{abstractname}{Large Abstract} %To increase Abstract font size
begin{document}
maketitle
begin{abstract}
blahblah
end{abstract}
blah blah
end{document}
sectioning header-footer color fancyhdr
I have been wondering "how to get shaded box for section numbers only"?
Also, How to get grey square in between left mark and page number in the header? In code below I can get solid black square.
I have attached image below of the desired output. This example is from TUGINDIA tutorials.
documentclass[12pt,twoside]{report}
usepackage{titlesec}%for formatting chapter position and names
titleformat{chapter}[display]
{normalfonthugebfseries}{chaptertitlename thechapter}{0pt}{huge}
titlespacing*{chapter}{0pt}{-20pt}{10pt}
title{bf huge xxx}
author{xxx}
date{} %to disable date
usepackage[top=1.3in, left=1.5in, right=1in]{geometry} %for setting margins
usepackage{grffile} %to avoid showing path of figure inserted
includeonly{chap1/chapter_1}
titlelabel{llap{thetitlequad}}% for section headings in margins
usepackage{fancyhdr}
pagestyle{fancy}
newcommand{helv}{%
fontfamily{phv}fontseries{}fontsize{10}{12}selectfont}
renewcommand{chaptermark}[1]{markboth{#1}{}}%formatting chapter title
renewcommand{sectionmark}[1]{markright{thesection. #1}}
fancyhf{}
fancyhead[RO]{helv rightmark{} $blacksquare$ thepage}
fancyhead[LE]{helv thepage{} $blacksquare$ leftmark}
renewcommand{headrulewidth}{0pt}
usepackage{amssymb}
parindent=0.5in
parskip=10pt
linespread{1.3}
renewcommand{abstractname}{Large Abstract} %To increase Abstract font size
begin{document}
maketitle
begin{abstract}
blahblah
end{abstract}
blah blah
end{document}
sectioning header-footer color fancyhdr
sectioning header-footer color fancyhdr
edited Mar 17 at 11:59
Glorfindel
255129
255129
asked Mar 3 '13 at 10:47
user26782user26782
312
312
Welcome to TeX.sx!
– Peter Jansson
Mar 3 '13 at 11:05
add a comment |
Welcome to TeX.sx!
– Peter Jansson
Mar 3 '13 at 11:05
Welcome to TeX.sx!
– Peter Jansson
Mar 3 '13 at 11:05
Welcome to TeX.sx!
– Peter Jansson
Mar 3 '13 at 11:05
add a comment |
4 Answers
4
active
oldest
votes
Here is a way to get the Section headers with color. However, I did not spend the time to make the margins look like the example, since your question seemed focused on the box and color aspect, rather than the margin aspect.
Also, I only implemented the effect down to the subsection level, though you could follow my lead and extend it to subsubsection if you wished.
As for your question on the gray square separator by the page number, things like that are discussed here: Page number in the margin and separator
documentclass{article}
usepackage{color}
makeatletter
definecolor{sectcolor}{rgb}{0.9,0.9,0.9}
letorigsectionsection
letorigsubsectionsubsection
defthesectiontext{@arabicc@section.}
defthesubsectiontext{thesectiontext@arabicc@subsection}
globalnewsavebox{sectbox}
defmakesectbox#1{saveboxsectbox{colorbox{sectcolor}
{makebox[0.5in][r]{normalfontlargebfseries#1}}}}
renewcommand thesection {usebox{sectbox}}
renewcommand thesubsection {usebox{sectbox}}
renewcommandsection{@ifstar{myheading}{mysection}}
newcommandmysection[1]{%
sectprelude{section}{thesectiontext}origsection{#1}}
newcommandmyheading[1]{%
sectprelude{section}{thesectiontext}origsection*{#1}}
renewcommandsubsection[1]{%
sectprelude{subsection}{thesubsectiontext}origsubsection{#1}}
newcommandsectprelude[2]{%
addtocounter{#1}{1}makesectbox{#2}addtocounter{#1}{-1}}
makeatother
begin{document}
section{Introduction}
It was a dark and stormy nightldots and then, a minute passed.
section{Discussion}
In the beginningldots
section{Conclusion}
ldots and it was good
subsection{Postscript}
Amen.
end{document}
I will note that something needs to be done further than this if you wish to use a table of contents, because it ends up getting stuffed with gray boxes. Also, I included the section* variant in my example, but realize that it prints no gray box at all, because section* doesn't print out thesection.
– Steven B. Segletes
Mar 8 '13 at 19:37
add a comment |
Here's an option using the titlesec
package and producing the colored boxes and the desired hanging; the example below also includes the necessary settings to produce the desired headers for the document:
documentclass{book}
usepackage[explicit]{titlesec}
usepackage{tikz}
usepackage{lipsum}
usepackage{fancyhdr}
colorlet{sectcolor}{gray!65}
newcommandgraysquare{textcolor{sectcolor}{rule{1ex}{1ex}}}
newcommand{helv}{fontfamily{phv}fontseries{}fontsize{10}{12}selectfont}
pagestyle{fancy}
renewcommand{chaptermark}[1]{markboth{#1}{}}
renewcommand{sectionmark}[1]{markright{thesection. #1}}
fancyhf{}
fancyhead[RO]{helvrightmarkhspace{0.5em}graysquarehspace{0.5em}thepage}
fancyhead[LE]{helvthepagehspace{0.5em}graysquarehspace{0.5em}leftmark}
renewcommand{headrulewidth}{0pt}
titleformat{section}
{normalfontLargebfseries}
{llap{colorbox{sectcolor}{makebox[3em][r] {thesection}}hspace{1em}}}
{0em}{#1}
begin{document}
setcounter{chapter}{1}% just for the example
section{Introduction}
A cross-reference to the last section:~ref{sec:conclusion}.
lipsum[4]
section{Discussion}
lipsum[4]
section{Conclusion}
label{sec:conclusion}
lipsum[4]
end{document}
An image of the result:
My solution changes only the formatting for the section numbers in the document body; cross-references and numbering in ToC entries will keep the standard representation.
Wow - I'm only 9 sec's too slow... that's nearly exactly the same I had :)
– clemens
Mar 8 '13 at 19:47
add a comment |
If you use a KOMA-class
you don't need any further packages:
documentclass{scrbook}
usepackage{xcolor}
usepackage{lipsum}
definecolor{sectcolor}{rgb}{0.9,0.9,0.9}
renewcommand*{othersectionlevelsformat}[3]{%
llap{colorbox{sectcolor}{makebox[2.5em][r]{#3autodot}}quad}%
}
begin{document}
chapter{Test Chapter}
section{Introduction}
A cross-reference to the last section:~ref{sec:conclusion}.
lipsum[4]
section{Discussion}
lipsum[4]
section{Conclusion}
label{sec:conclusion}
lipsum[4]
end{document}
add a comment |
you simply change in to @seccntformat
e.g.,
def@seccntformat#1{colorbox{grayten}{csname the#1endcsnamequad}}
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%2f100677%2fuse-of-shaded-box-for-section-numbering-only%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
Here is a way to get the Section headers with color. However, I did not spend the time to make the margins look like the example, since your question seemed focused on the box and color aspect, rather than the margin aspect.
Also, I only implemented the effect down to the subsection level, though you could follow my lead and extend it to subsubsection if you wished.
As for your question on the gray square separator by the page number, things like that are discussed here: Page number in the margin and separator
documentclass{article}
usepackage{color}
makeatletter
definecolor{sectcolor}{rgb}{0.9,0.9,0.9}
letorigsectionsection
letorigsubsectionsubsection
defthesectiontext{@arabicc@section.}
defthesubsectiontext{thesectiontext@arabicc@subsection}
globalnewsavebox{sectbox}
defmakesectbox#1{saveboxsectbox{colorbox{sectcolor}
{makebox[0.5in][r]{normalfontlargebfseries#1}}}}
renewcommand thesection {usebox{sectbox}}
renewcommand thesubsection {usebox{sectbox}}
renewcommandsection{@ifstar{myheading}{mysection}}
newcommandmysection[1]{%
sectprelude{section}{thesectiontext}origsection{#1}}
newcommandmyheading[1]{%
sectprelude{section}{thesectiontext}origsection*{#1}}
renewcommandsubsection[1]{%
sectprelude{subsection}{thesubsectiontext}origsubsection{#1}}
newcommandsectprelude[2]{%
addtocounter{#1}{1}makesectbox{#2}addtocounter{#1}{-1}}
makeatother
begin{document}
section{Introduction}
It was a dark and stormy nightldots and then, a minute passed.
section{Discussion}
In the beginningldots
section{Conclusion}
ldots and it was good
subsection{Postscript}
Amen.
end{document}
I will note that something needs to be done further than this if you wish to use a table of contents, because it ends up getting stuffed with gray boxes. Also, I included the section* variant in my example, but realize that it prints no gray box at all, because section* doesn't print out thesection.
– Steven B. Segletes
Mar 8 '13 at 19:37
add a comment |
Here is a way to get the Section headers with color. However, I did not spend the time to make the margins look like the example, since your question seemed focused on the box and color aspect, rather than the margin aspect.
Also, I only implemented the effect down to the subsection level, though you could follow my lead and extend it to subsubsection if you wished.
As for your question on the gray square separator by the page number, things like that are discussed here: Page number in the margin and separator
documentclass{article}
usepackage{color}
makeatletter
definecolor{sectcolor}{rgb}{0.9,0.9,0.9}
letorigsectionsection
letorigsubsectionsubsection
defthesectiontext{@arabicc@section.}
defthesubsectiontext{thesectiontext@arabicc@subsection}
globalnewsavebox{sectbox}
defmakesectbox#1{saveboxsectbox{colorbox{sectcolor}
{makebox[0.5in][r]{normalfontlargebfseries#1}}}}
renewcommand thesection {usebox{sectbox}}
renewcommand thesubsection {usebox{sectbox}}
renewcommandsection{@ifstar{myheading}{mysection}}
newcommandmysection[1]{%
sectprelude{section}{thesectiontext}origsection{#1}}
newcommandmyheading[1]{%
sectprelude{section}{thesectiontext}origsection*{#1}}
renewcommandsubsection[1]{%
sectprelude{subsection}{thesubsectiontext}origsubsection{#1}}
newcommandsectprelude[2]{%
addtocounter{#1}{1}makesectbox{#2}addtocounter{#1}{-1}}
makeatother
begin{document}
section{Introduction}
It was a dark and stormy nightldots and then, a minute passed.
section{Discussion}
In the beginningldots
section{Conclusion}
ldots and it was good
subsection{Postscript}
Amen.
end{document}
I will note that something needs to be done further than this if you wish to use a table of contents, because it ends up getting stuffed with gray boxes. Also, I included the section* variant in my example, but realize that it prints no gray box at all, because section* doesn't print out thesection.
– Steven B. Segletes
Mar 8 '13 at 19:37
add a comment |
Here is a way to get the Section headers with color. However, I did not spend the time to make the margins look like the example, since your question seemed focused on the box and color aspect, rather than the margin aspect.
Also, I only implemented the effect down to the subsection level, though you could follow my lead and extend it to subsubsection if you wished.
As for your question on the gray square separator by the page number, things like that are discussed here: Page number in the margin and separator
documentclass{article}
usepackage{color}
makeatletter
definecolor{sectcolor}{rgb}{0.9,0.9,0.9}
letorigsectionsection
letorigsubsectionsubsection
defthesectiontext{@arabicc@section.}
defthesubsectiontext{thesectiontext@arabicc@subsection}
globalnewsavebox{sectbox}
defmakesectbox#1{saveboxsectbox{colorbox{sectcolor}
{makebox[0.5in][r]{normalfontlargebfseries#1}}}}
renewcommand thesection {usebox{sectbox}}
renewcommand thesubsection {usebox{sectbox}}
renewcommandsection{@ifstar{myheading}{mysection}}
newcommandmysection[1]{%
sectprelude{section}{thesectiontext}origsection{#1}}
newcommandmyheading[1]{%
sectprelude{section}{thesectiontext}origsection*{#1}}
renewcommandsubsection[1]{%
sectprelude{subsection}{thesubsectiontext}origsubsection{#1}}
newcommandsectprelude[2]{%
addtocounter{#1}{1}makesectbox{#2}addtocounter{#1}{-1}}
makeatother
begin{document}
section{Introduction}
It was a dark and stormy nightldots and then, a minute passed.
section{Discussion}
In the beginningldots
section{Conclusion}
ldots and it was good
subsection{Postscript}
Amen.
end{document}
Here is a way to get the Section headers with color. However, I did not spend the time to make the margins look like the example, since your question seemed focused on the box and color aspect, rather than the margin aspect.
Also, I only implemented the effect down to the subsection level, though you could follow my lead and extend it to subsubsection if you wished.
As for your question on the gray square separator by the page number, things like that are discussed here: Page number in the margin and separator
documentclass{article}
usepackage{color}
makeatletter
definecolor{sectcolor}{rgb}{0.9,0.9,0.9}
letorigsectionsection
letorigsubsectionsubsection
defthesectiontext{@arabicc@section.}
defthesubsectiontext{thesectiontext@arabicc@subsection}
globalnewsavebox{sectbox}
defmakesectbox#1{saveboxsectbox{colorbox{sectcolor}
{makebox[0.5in][r]{normalfontlargebfseries#1}}}}
renewcommand thesection {usebox{sectbox}}
renewcommand thesubsection {usebox{sectbox}}
renewcommandsection{@ifstar{myheading}{mysection}}
newcommandmysection[1]{%
sectprelude{section}{thesectiontext}origsection{#1}}
newcommandmyheading[1]{%
sectprelude{section}{thesectiontext}origsection*{#1}}
renewcommandsubsection[1]{%
sectprelude{subsection}{thesubsectiontext}origsubsection{#1}}
newcommandsectprelude[2]{%
addtocounter{#1}{1}makesectbox{#2}addtocounter{#1}{-1}}
makeatother
begin{document}
section{Introduction}
It was a dark and stormy nightldots and then, a minute passed.
section{Discussion}
In the beginningldots
section{Conclusion}
ldots and it was good
subsection{Postscript}
Amen.
end{document}
edited Apr 13 '17 at 12:36
Community♦
1
1
answered Mar 8 '13 at 19:12
Steven B. SegletesSteven B. Segletes
159k9204413
159k9204413
I will note that something needs to be done further than this if you wish to use a table of contents, because it ends up getting stuffed with gray boxes. Also, I included the section* variant in my example, but realize that it prints no gray box at all, because section* doesn't print out thesection.
– Steven B. Segletes
Mar 8 '13 at 19:37
add a comment |
I will note that something needs to be done further than this if you wish to use a table of contents, because it ends up getting stuffed with gray boxes. Also, I included the section* variant in my example, but realize that it prints no gray box at all, because section* doesn't print out thesection.
– Steven B. Segletes
Mar 8 '13 at 19:37
I will note that something needs to be done further than this if you wish to use a table of contents, because it ends up getting stuffed with gray boxes. Also, I included the section* variant in my example, but realize that it prints no gray box at all, because section* doesn't print out thesection.
– Steven B. Segletes
Mar 8 '13 at 19:37
I will note that something needs to be done further than this if you wish to use a table of contents, because it ends up getting stuffed with gray boxes. Also, I included the section* variant in my example, but realize that it prints no gray box at all, because section* doesn't print out thesection.
– Steven B. Segletes
Mar 8 '13 at 19:37
add a comment |
Here's an option using the titlesec
package and producing the colored boxes and the desired hanging; the example below also includes the necessary settings to produce the desired headers for the document:
documentclass{book}
usepackage[explicit]{titlesec}
usepackage{tikz}
usepackage{lipsum}
usepackage{fancyhdr}
colorlet{sectcolor}{gray!65}
newcommandgraysquare{textcolor{sectcolor}{rule{1ex}{1ex}}}
newcommand{helv}{fontfamily{phv}fontseries{}fontsize{10}{12}selectfont}
pagestyle{fancy}
renewcommand{chaptermark}[1]{markboth{#1}{}}
renewcommand{sectionmark}[1]{markright{thesection. #1}}
fancyhf{}
fancyhead[RO]{helvrightmarkhspace{0.5em}graysquarehspace{0.5em}thepage}
fancyhead[LE]{helvthepagehspace{0.5em}graysquarehspace{0.5em}leftmark}
renewcommand{headrulewidth}{0pt}
titleformat{section}
{normalfontLargebfseries}
{llap{colorbox{sectcolor}{makebox[3em][r] {thesection}}hspace{1em}}}
{0em}{#1}
begin{document}
setcounter{chapter}{1}% just for the example
section{Introduction}
A cross-reference to the last section:~ref{sec:conclusion}.
lipsum[4]
section{Discussion}
lipsum[4]
section{Conclusion}
label{sec:conclusion}
lipsum[4]
end{document}
An image of the result:
My solution changes only the formatting for the section numbers in the document body; cross-references and numbering in ToC entries will keep the standard representation.
Wow - I'm only 9 sec's too slow... that's nearly exactly the same I had :)
– clemens
Mar 8 '13 at 19:47
add a comment |
Here's an option using the titlesec
package and producing the colored boxes and the desired hanging; the example below also includes the necessary settings to produce the desired headers for the document:
documentclass{book}
usepackage[explicit]{titlesec}
usepackage{tikz}
usepackage{lipsum}
usepackage{fancyhdr}
colorlet{sectcolor}{gray!65}
newcommandgraysquare{textcolor{sectcolor}{rule{1ex}{1ex}}}
newcommand{helv}{fontfamily{phv}fontseries{}fontsize{10}{12}selectfont}
pagestyle{fancy}
renewcommand{chaptermark}[1]{markboth{#1}{}}
renewcommand{sectionmark}[1]{markright{thesection. #1}}
fancyhf{}
fancyhead[RO]{helvrightmarkhspace{0.5em}graysquarehspace{0.5em}thepage}
fancyhead[LE]{helvthepagehspace{0.5em}graysquarehspace{0.5em}leftmark}
renewcommand{headrulewidth}{0pt}
titleformat{section}
{normalfontLargebfseries}
{llap{colorbox{sectcolor}{makebox[3em][r] {thesection}}hspace{1em}}}
{0em}{#1}
begin{document}
setcounter{chapter}{1}% just for the example
section{Introduction}
A cross-reference to the last section:~ref{sec:conclusion}.
lipsum[4]
section{Discussion}
lipsum[4]
section{Conclusion}
label{sec:conclusion}
lipsum[4]
end{document}
An image of the result:
My solution changes only the formatting for the section numbers in the document body; cross-references and numbering in ToC entries will keep the standard representation.
Wow - I'm only 9 sec's too slow... that's nearly exactly the same I had :)
– clemens
Mar 8 '13 at 19:47
add a comment |
Here's an option using the titlesec
package and producing the colored boxes and the desired hanging; the example below also includes the necessary settings to produce the desired headers for the document:
documentclass{book}
usepackage[explicit]{titlesec}
usepackage{tikz}
usepackage{lipsum}
usepackage{fancyhdr}
colorlet{sectcolor}{gray!65}
newcommandgraysquare{textcolor{sectcolor}{rule{1ex}{1ex}}}
newcommand{helv}{fontfamily{phv}fontseries{}fontsize{10}{12}selectfont}
pagestyle{fancy}
renewcommand{chaptermark}[1]{markboth{#1}{}}
renewcommand{sectionmark}[1]{markright{thesection. #1}}
fancyhf{}
fancyhead[RO]{helvrightmarkhspace{0.5em}graysquarehspace{0.5em}thepage}
fancyhead[LE]{helvthepagehspace{0.5em}graysquarehspace{0.5em}leftmark}
renewcommand{headrulewidth}{0pt}
titleformat{section}
{normalfontLargebfseries}
{llap{colorbox{sectcolor}{makebox[3em][r] {thesection}}hspace{1em}}}
{0em}{#1}
begin{document}
setcounter{chapter}{1}% just for the example
section{Introduction}
A cross-reference to the last section:~ref{sec:conclusion}.
lipsum[4]
section{Discussion}
lipsum[4]
section{Conclusion}
label{sec:conclusion}
lipsum[4]
end{document}
An image of the result:
My solution changes only the formatting for the section numbers in the document body; cross-references and numbering in ToC entries will keep the standard representation.
Here's an option using the titlesec
package and producing the colored boxes and the desired hanging; the example below also includes the necessary settings to produce the desired headers for the document:
documentclass{book}
usepackage[explicit]{titlesec}
usepackage{tikz}
usepackage{lipsum}
usepackage{fancyhdr}
colorlet{sectcolor}{gray!65}
newcommandgraysquare{textcolor{sectcolor}{rule{1ex}{1ex}}}
newcommand{helv}{fontfamily{phv}fontseries{}fontsize{10}{12}selectfont}
pagestyle{fancy}
renewcommand{chaptermark}[1]{markboth{#1}{}}
renewcommand{sectionmark}[1]{markright{thesection. #1}}
fancyhf{}
fancyhead[RO]{helvrightmarkhspace{0.5em}graysquarehspace{0.5em}thepage}
fancyhead[LE]{helvthepagehspace{0.5em}graysquarehspace{0.5em}leftmark}
renewcommand{headrulewidth}{0pt}
titleformat{section}
{normalfontLargebfseries}
{llap{colorbox{sectcolor}{makebox[3em][r] {thesection}}hspace{1em}}}
{0em}{#1}
begin{document}
setcounter{chapter}{1}% just for the example
section{Introduction}
A cross-reference to the last section:~ref{sec:conclusion}.
lipsum[4]
section{Discussion}
lipsum[4]
section{Conclusion}
label{sec:conclusion}
lipsum[4]
end{document}
An image of the result:
My solution changes only the formatting for the section numbers in the document body; cross-references and numbering in ToC entries will keep the standard representation.
edited Mar 8 '13 at 20:05
answered Mar 8 '13 at 19:45
Gonzalo MedinaGonzalo Medina
402k4113141580
402k4113141580
Wow - I'm only 9 sec's too slow... that's nearly exactly the same I had :)
– clemens
Mar 8 '13 at 19:47
add a comment |
Wow - I'm only 9 sec's too slow... that's nearly exactly the same I had :)
– clemens
Mar 8 '13 at 19:47
Wow - I'm only 9 sec's too slow... that's nearly exactly the same I had :)
– clemens
Mar 8 '13 at 19:47
Wow - I'm only 9 sec's too slow... that's nearly exactly the same I had :)
– clemens
Mar 8 '13 at 19:47
add a comment |
If you use a KOMA-class
you don't need any further packages:
documentclass{scrbook}
usepackage{xcolor}
usepackage{lipsum}
definecolor{sectcolor}{rgb}{0.9,0.9,0.9}
renewcommand*{othersectionlevelsformat}[3]{%
llap{colorbox{sectcolor}{makebox[2.5em][r]{#3autodot}}quad}%
}
begin{document}
chapter{Test Chapter}
section{Introduction}
A cross-reference to the last section:~ref{sec:conclusion}.
lipsum[4]
section{Discussion}
lipsum[4]
section{Conclusion}
label{sec:conclusion}
lipsum[4]
end{document}
add a comment |
If you use a KOMA-class
you don't need any further packages:
documentclass{scrbook}
usepackage{xcolor}
usepackage{lipsum}
definecolor{sectcolor}{rgb}{0.9,0.9,0.9}
renewcommand*{othersectionlevelsformat}[3]{%
llap{colorbox{sectcolor}{makebox[2.5em][r]{#3autodot}}quad}%
}
begin{document}
chapter{Test Chapter}
section{Introduction}
A cross-reference to the last section:~ref{sec:conclusion}.
lipsum[4]
section{Discussion}
lipsum[4]
section{Conclusion}
label{sec:conclusion}
lipsum[4]
end{document}
add a comment |
If you use a KOMA-class
you don't need any further packages:
documentclass{scrbook}
usepackage{xcolor}
usepackage{lipsum}
definecolor{sectcolor}{rgb}{0.9,0.9,0.9}
renewcommand*{othersectionlevelsformat}[3]{%
llap{colorbox{sectcolor}{makebox[2.5em][r]{#3autodot}}quad}%
}
begin{document}
chapter{Test Chapter}
section{Introduction}
A cross-reference to the last section:~ref{sec:conclusion}.
lipsum[4]
section{Discussion}
lipsum[4]
section{Conclusion}
label{sec:conclusion}
lipsum[4]
end{document}
If you use a KOMA-class
you don't need any further packages:
documentclass{scrbook}
usepackage{xcolor}
usepackage{lipsum}
definecolor{sectcolor}{rgb}{0.9,0.9,0.9}
renewcommand*{othersectionlevelsformat}[3]{%
llap{colorbox{sectcolor}{makebox[2.5em][r]{#3autodot}}quad}%
}
begin{document}
chapter{Test Chapter}
section{Introduction}
A cross-reference to the last section:~ref{sec:conclusion}.
lipsum[4]
section{Discussion}
lipsum[4]
section{Conclusion}
label{sec:conclusion}
lipsum[4]
end{document}
edited Mar 8 '13 at 20:11
Werner
449k719941699
449k719941699
answered Mar 8 '13 at 20:03
Marco DanielMarco Daniel
78.4k13223388
78.4k13223388
add a comment |
add a comment |
you simply change in to @seccntformat
e.g.,
def@seccntformat#1{colorbox{grayten}{csname the#1endcsnamequad}}
add a comment |
you simply change in to @seccntformat
e.g.,
def@seccntformat#1{colorbox{grayten}{csname the#1endcsnamequad}}
add a comment |
you simply change in to @seccntformat
e.g.,
def@seccntformat#1{colorbox{grayten}{csname the#1endcsnamequad}}
you simply change in to @seccntformat
e.g.,
def@seccntformat#1{colorbox{grayten}{csname the#1endcsnamequad}}
edited Mar 30 '16 at 8:12
Stefan Pinnow
20.3k83477
20.3k83477
answered Mar 30 '16 at 7:56
Venkatesan RamachandiranVenkatesan Ramachandiran
6971718
6971718
add a comment |
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%2f100677%2fuse-of-shaded-box-for-section-numbering-only%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
Welcome to TeX.sx!
– Peter Jansson
Mar 3 '13 at 11:05