How can I number paragraphs (and sections) in the margin?
I am (still) trying replicate the layout of this document.
Sections and paragraphs are all numbered, in the margin (the chapter titles do not treat this as a margin, but I can ignore that). They are left-aligned.
So far, Google and playing have uncovered these:
1) parano.sty
This allows me to auto-number paragraphs, which is nice. It has no flexibility for depth (i.e. sub-paragraphs) and I haven't tested moving its numbers.
2) paragraph{}
This is the closest solution so far. Using setcounter{secnumdepth}{5}
I can add numbers to my paragraphs. This code then puts all of the numbers in the margin:
makeatletter
def@seccntformat#1{protectmakebox[0pt][r]{csname the#1endcsnamequad}}
makeatother
I can make these left-aligned by increasing [0pt]
and changing r
to l
, but I haven't been able to get the hanging indent right (or to move the box into the left margin)
Further, paragraphs without a title leave some space (presumably to separate text from the title?), further stopping the neat alignment I am aiming for.
This solution (with the same limitations) also allows me to use sub-paragraphs, which I will eventually need.
numbering margins boxes paragraphs
add a comment |
I am (still) trying replicate the layout of this document.
Sections and paragraphs are all numbered, in the margin (the chapter titles do not treat this as a margin, but I can ignore that). They are left-aligned.
So far, Google and playing have uncovered these:
1) parano.sty
This allows me to auto-number paragraphs, which is nice. It has no flexibility for depth (i.e. sub-paragraphs) and I haven't tested moving its numbers.
2) paragraph{}
This is the closest solution so far. Using setcounter{secnumdepth}{5}
I can add numbers to my paragraphs. This code then puts all of the numbers in the margin:
makeatletter
def@seccntformat#1{protectmakebox[0pt][r]{csname the#1endcsnamequad}}
makeatother
I can make these left-aligned by increasing [0pt]
and changing r
to l
, but I haven't been able to get the hanging indent right (or to move the box into the left margin)
Further, paragraphs without a title leave some space (presumably to separate text from the title?), further stopping the neat alignment I am aiming for.
This solution (with the same limitations) also allows me to use sub-paragraphs, which I will eventually need.
numbering margins boxes paragraphs
I've updated my initial answer with a new approach, defining two new fresh sectional units.
– Gonzalo Medina
May 10 '12 at 2:33
Link is broken @Martin
– alexy13
Oct 13 '14 at 13:58
see also How can I do numbering with a hanging indent to the left into the page margin?
– barbara beeton
Jan 18 '15 at 15:05
@alexy13 As best I can find, this is (an updated version of) the document publicapps.caa.co.uk/docs/33/…
– owjburnham
Aug 11 '17 at 13:57
add a comment |
I am (still) trying replicate the layout of this document.
Sections and paragraphs are all numbered, in the margin (the chapter titles do not treat this as a margin, but I can ignore that). They are left-aligned.
So far, Google and playing have uncovered these:
1) parano.sty
This allows me to auto-number paragraphs, which is nice. It has no flexibility for depth (i.e. sub-paragraphs) and I haven't tested moving its numbers.
2) paragraph{}
This is the closest solution so far. Using setcounter{secnumdepth}{5}
I can add numbers to my paragraphs. This code then puts all of the numbers in the margin:
makeatletter
def@seccntformat#1{protectmakebox[0pt][r]{csname the#1endcsnamequad}}
makeatother
I can make these left-aligned by increasing [0pt]
and changing r
to l
, but I haven't been able to get the hanging indent right (or to move the box into the left margin)
Further, paragraphs without a title leave some space (presumably to separate text from the title?), further stopping the neat alignment I am aiming for.
This solution (with the same limitations) also allows me to use sub-paragraphs, which I will eventually need.
numbering margins boxes paragraphs
I am (still) trying replicate the layout of this document.
Sections and paragraphs are all numbered, in the margin (the chapter titles do not treat this as a margin, but I can ignore that). They are left-aligned.
So far, Google and playing have uncovered these:
1) parano.sty
This allows me to auto-number paragraphs, which is nice. It has no flexibility for depth (i.e. sub-paragraphs) and I haven't tested moving its numbers.
2) paragraph{}
This is the closest solution so far. Using setcounter{secnumdepth}{5}
I can add numbers to my paragraphs. This code then puts all of the numbers in the margin:
makeatletter
def@seccntformat#1{protectmakebox[0pt][r]{csname the#1endcsnamequad}}
makeatother
I can make these left-aligned by increasing [0pt]
and changing r
to l
, but I haven't been able to get the hanging indent right (or to move the box into the left margin)
Further, paragraphs without a title leave some space (presumably to separate text from the title?), further stopping the neat alignment I am aiming for.
This solution (with the same limitations) also allows me to use sub-paragraphs, which I will eventually need.
numbering margins boxes paragraphs
numbering margins boxes paragraphs
asked May 9 '12 at 21:56
MartinMartin
13015
13015
I've updated my initial answer with a new approach, defining two new fresh sectional units.
– Gonzalo Medina
May 10 '12 at 2:33
Link is broken @Martin
– alexy13
Oct 13 '14 at 13:58
see also How can I do numbering with a hanging indent to the left into the page margin?
– barbara beeton
Jan 18 '15 at 15:05
@alexy13 As best I can find, this is (an updated version of) the document publicapps.caa.co.uk/docs/33/…
– owjburnham
Aug 11 '17 at 13:57
add a comment |
I've updated my initial answer with a new approach, defining two new fresh sectional units.
– Gonzalo Medina
May 10 '12 at 2:33
Link is broken @Martin
– alexy13
Oct 13 '14 at 13:58
see also How can I do numbering with a hanging indent to the left into the page margin?
– barbara beeton
Jan 18 '15 at 15:05
@alexy13 As best I can find, this is (an updated version of) the document publicapps.caa.co.uk/docs/33/…
– owjburnham
Aug 11 '17 at 13:57
I've updated my initial answer with a new approach, defining two new fresh sectional units.
– Gonzalo Medina
May 10 '12 at 2:33
I've updated my initial answer with a new approach, defining two new fresh sectional units.
– Gonzalo Medina
May 10 '12 at 2:33
Link is broken @Martin
– alexy13
Oct 13 '14 at 13:58
Link is broken @Martin
– alexy13
Oct 13 '14 at 13:58
see also How can I do numbering with a hanging indent to the left into the page margin?
– barbara beeton
Jan 18 '15 at 15:05
see also How can I do numbering with a hanging indent to the left into the page margin?
– barbara beeton
Jan 18 '15 at 15:05
@alexy13 As best I can find, this is (an updated version of) the document publicapps.caa.co.uk/docs/33/…
– owjburnham
Aug 11 '17 at 13:57
@alexy13 As best I can find, this is (an updated version of) the document publicapps.caa.co.uk/docs/33/…
– owjburnham
Aug 11 '17 at 13:57
add a comment |
2 Answers
2
active
oldest
votes
After giving a look at the linked document, I could detect six sectional units: chapters, sections, numbered subsections with title, numbered subsections without title, numbered subsubsections with title, and numbered subsubsections without title. So the problem is how to define these six sectional units.
The code below shows a possible solution using the titlesec package; the underlaying idea is to use llap
and parbox
es to typeset the numbers hanging onto the margin. The length titleindent
allows you to easily control the hanging indent.
paragraph
has been changed so that it will allow numbered subsections without title and subparagraph
was also redefined to allow numbered subsubsections.
The following table shows the "dictionary" between each secional unit of the document and the LaTeX command that will be used to typeset it:
Chapters ->
chapter
Sections ->
section
Numbered subsections with title ->
subsection
Numbered subsections without title ->
paragraph
Numbered subsubsections with title ->
subsubsection
Numbered subsubsections without title ->
subparagraph
And here's the code (feel free to make the necessary adjustments to satisfy your requirements):
documentclass{book}
usepackage{titlesec}
usepackage{etoolbox}
usepackage{lipsum}
setcounter{secnumdepth}{5}
renewcommandthesection{arabic{section}}
% this length controls tha hanging indent for titles
% change the value according to your needs
newlengthtitleindent
setlengthtitleindent{2cm}
pretocmd{paragraph}{stepcounter{subsection}}{}{}
pretocmd{subparagraph}{stepcounter{subsubsection}}{}{}
titleformat{chapter}[block]
{normalfonthugebfseries}{}{0pt}{hspace*{-titleindent}}
titleformat{section}
{normalfontLargebfseries}{llap{parbox{titleindent}{thesectionhfill}}}{0em}{}
titleformat{subsection}
{normalfontlarge}{llap{parbox{titleindent}{thesubsectionhfill}}}{0em}{bfseries}
titleformat{subsubsection}
{normalfontnormalsize}{llap{parbox{titleindent}{thesubsubsection}}}{0em}{bfseries}
titleformat{paragraph}[runin]
{normalfontlarge}{llap{parbox{titleindent}{thesubsectionhfill}}}{0em}{}
titleformat{subparagraph}[runin]
{normalfontnormalsize}{llap{parbox{titleindent}{thesubsubsectionhfill}}}{0em}{}
titlespacing*{chapter}{0pt}{0pt}{20pt}
titlespacing*{subsubsection}{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}
titlespacing*{paragraph}{0pt}{3.25ex plus 1ex minus .2ex}{0em}
titlespacing*{subparagraph}{0pt}{3.25ex plus 1ex minus .2ex}{0em}
begin{document}
chapter{Test chapter}
section{Test Section}
lipsum[2]
subsection{Test Subsection}
lipsum[2]
paragraph{}% acts like a numbered subsection without title
lipsum[2]
subsubsection{Test Subsubsection}
lipsum[2]
subparagraph{}% acts like a numbered subsubsection without title
lipsum[2]
end{document}
The previous approach assumes that you won't use paragraph
and subparagraph
with their standard formatting; another (perhaps more sensible) option is to define two fresh new sectional units; this, of course, requires a little additional work, but now you will have the standard sectional units plus the two new ones.
The following code illustrates this approach defining subsectionwt
(for numbered subsections without titles) and subsubsectionwt
(for numbered subsubsections without titles); it also makes the necessary provisions for the ToC.
The new "dictionary" is now:
Chapters ->
chapter
Sections ->
section
Numbered subsections with title ->
subsection
Numbered subsections without title ->
subsectionwt
Numbered subsubsections with title ->
subsubsection
Numbered subsubsections without title ->
subsubsectionwt
Paragraphs ->
paragraph
Subparagraphs ->
subparagraph
The example code:
documentclass{book}
usepackage{titlesec,titletoc}
usepackage{etoolbox}
usepackage{lipsum}
setcounter{secnumdepth}{5}
renewcommandthesection{arabic{section}}
% this length controls tha hanging indent for titles
% change the value according to your needs
newlengthtitleindent
setlengthtitleindent{2cm}
% counters for the new sectional units
newcounter{subsectionwt}
newcounter{subsubsectionwt}
% definition of the new sectional units with the representation of the counters
titleclass{subsectionwt}{straight}[subsubsection]
renewcommand{thesubsectionwt}{thesection.arabic{subsectionwt}}
titleclass{subsubsectionwt}{straight}[subsectionwt]
renewcommand{thesubsubsectionwt}{thesubsection.arabic{subsubsectionwt}}
% subsection must increase the subsectionwt counter
% and subsectionwt must increase the subsection counter
% Analogous treatment for subsubsection and subsubsectionwt
pretocmd{subsectionwt}{stepcounter{subsection}}{}{}
pretocmd{subsection}{stepcounter{subsectionwt}}{}{}
pretocmd{subsubsectionwt}{stepcounter{subsubsection}}{}{}
pretocmd{subsubsection}{stepcounter{subsubsectionwt}}{}{}
% format for the sectional units
titleformat{chapter}[block]
{normalfonthugebfseries}{}{0pt}{hspace*{-titleindent}}
titleformat{section}
{normalfontLargebfseries}{llap{parbox{titleindent}{thesectionhfill}}}{0em}{}
titleformat{subsection}
{normalfontlarge}{llap{parbox{titleindent}{thesubsectionhfill}}}{0em}{bfseries}
titleformat{subsectionwt}[runin]
{normalfontlarge}{llap{parbox{titleindent}{thesubsectionwthfill}}}{0em}{bfseries}
titleformat{subsubsection}
{normalfontnormalsize}{llap{parbox{titleindent}{thesubsubsection}}}{0em}{bfseries}
titleformat{subsubsectionwt}[runin]
{normalfontnormalsize}{llap{parbox{titleindent}{thesubsubsectionwt}}}{0em}{bfseries}
titlespacing*{chapter}{0pt}{0pt}{20pt}
titlespacing*{subsection}{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}
titlespacing*{subsectionwt}{0pt}{3.25ex plus 1ex minus .2ex}{0em}
titlespacing*{subsubsection}{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}
titlespacing*{subsubsectionwt}{0pt}{3.25ex plus 1ex minus .2ex}{0em}
% numbered entries without title shouldn't go to the ToC
titlecontents{subsectionwt}{}{}{}{}
titlecontents{subsubsectionwt}{}{}{}{}
begin{document}
tableofcontents
chapter{Test chapter}
section{Test Section}
lipsum[2]
subsection{Test Subsection}
lipsum[2]
subsectionwt{}% for numbered subsections without title
lipsum[2]
subsubsection{Test Subsubsection}
lipsum[2]
subsubsectionwt{}% for numbered subsubsections without title
lipsum[2]
end{document}
Great solution, it helped immensely also for me. A couple of bugs: - If you have asubsectionwt
as first, it's numbered as 0 - If you increase the section counter, thesubsectionwt
counter should be reset for the second,newcounter{subsectionwt}[section]
does the trick
– Helios
Dec 30 '14 at 18:03
add a comment |
If the section number is below the title, put parbox[b]
in the answer by @GonzaloMedina. To increase the indent for subsections, see the answer to automatic legal-style indentation in all ((sub)sub)sections.
New contributor
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%2f55197%2fhow-can-i-number-paragraphs-and-sections-in-the-margin%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
After giving a look at the linked document, I could detect six sectional units: chapters, sections, numbered subsections with title, numbered subsections without title, numbered subsubsections with title, and numbered subsubsections without title. So the problem is how to define these six sectional units.
The code below shows a possible solution using the titlesec package; the underlaying idea is to use llap
and parbox
es to typeset the numbers hanging onto the margin. The length titleindent
allows you to easily control the hanging indent.
paragraph
has been changed so that it will allow numbered subsections without title and subparagraph
was also redefined to allow numbered subsubsections.
The following table shows the "dictionary" between each secional unit of the document and the LaTeX command that will be used to typeset it:
Chapters ->
chapter
Sections ->
section
Numbered subsections with title ->
subsection
Numbered subsections without title ->
paragraph
Numbered subsubsections with title ->
subsubsection
Numbered subsubsections without title ->
subparagraph
And here's the code (feel free to make the necessary adjustments to satisfy your requirements):
documentclass{book}
usepackage{titlesec}
usepackage{etoolbox}
usepackage{lipsum}
setcounter{secnumdepth}{5}
renewcommandthesection{arabic{section}}
% this length controls tha hanging indent for titles
% change the value according to your needs
newlengthtitleindent
setlengthtitleindent{2cm}
pretocmd{paragraph}{stepcounter{subsection}}{}{}
pretocmd{subparagraph}{stepcounter{subsubsection}}{}{}
titleformat{chapter}[block]
{normalfonthugebfseries}{}{0pt}{hspace*{-titleindent}}
titleformat{section}
{normalfontLargebfseries}{llap{parbox{titleindent}{thesectionhfill}}}{0em}{}
titleformat{subsection}
{normalfontlarge}{llap{parbox{titleindent}{thesubsectionhfill}}}{0em}{bfseries}
titleformat{subsubsection}
{normalfontnormalsize}{llap{parbox{titleindent}{thesubsubsection}}}{0em}{bfseries}
titleformat{paragraph}[runin]
{normalfontlarge}{llap{parbox{titleindent}{thesubsectionhfill}}}{0em}{}
titleformat{subparagraph}[runin]
{normalfontnormalsize}{llap{parbox{titleindent}{thesubsubsectionhfill}}}{0em}{}
titlespacing*{chapter}{0pt}{0pt}{20pt}
titlespacing*{subsubsection}{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}
titlespacing*{paragraph}{0pt}{3.25ex plus 1ex minus .2ex}{0em}
titlespacing*{subparagraph}{0pt}{3.25ex plus 1ex minus .2ex}{0em}
begin{document}
chapter{Test chapter}
section{Test Section}
lipsum[2]
subsection{Test Subsection}
lipsum[2]
paragraph{}% acts like a numbered subsection without title
lipsum[2]
subsubsection{Test Subsubsection}
lipsum[2]
subparagraph{}% acts like a numbered subsubsection without title
lipsum[2]
end{document}
The previous approach assumes that you won't use paragraph
and subparagraph
with their standard formatting; another (perhaps more sensible) option is to define two fresh new sectional units; this, of course, requires a little additional work, but now you will have the standard sectional units plus the two new ones.
The following code illustrates this approach defining subsectionwt
(for numbered subsections without titles) and subsubsectionwt
(for numbered subsubsections without titles); it also makes the necessary provisions for the ToC.
The new "dictionary" is now:
Chapters ->
chapter
Sections ->
section
Numbered subsections with title ->
subsection
Numbered subsections without title ->
subsectionwt
Numbered subsubsections with title ->
subsubsection
Numbered subsubsections without title ->
subsubsectionwt
Paragraphs ->
paragraph
Subparagraphs ->
subparagraph
The example code:
documentclass{book}
usepackage{titlesec,titletoc}
usepackage{etoolbox}
usepackage{lipsum}
setcounter{secnumdepth}{5}
renewcommandthesection{arabic{section}}
% this length controls tha hanging indent for titles
% change the value according to your needs
newlengthtitleindent
setlengthtitleindent{2cm}
% counters for the new sectional units
newcounter{subsectionwt}
newcounter{subsubsectionwt}
% definition of the new sectional units with the representation of the counters
titleclass{subsectionwt}{straight}[subsubsection]
renewcommand{thesubsectionwt}{thesection.arabic{subsectionwt}}
titleclass{subsubsectionwt}{straight}[subsectionwt]
renewcommand{thesubsubsectionwt}{thesubsection.arabic{subsubsectionwt}}
% subsection must increase the subsectionwt counter
% and subsectionwt must increase the subsection counter
% Analogous treatment for subsubsection and subsubsectionwt
pretocmd{subsectionwt}{stepcounter{subsection}}{}{}
pretocmd{subsection}{stepcounter{subsectionwt}}{}{}
pretocmd{subsubsectionwt}{stepcounter{subsubsection}}{}{}
pretocmd{subsubsection}{stepcounter{subsubsectionwt}}{}{}
% format for the sectional units
titleformat{chapter}[block]
{normalfonthugebfseries}{}{0pt}{hspace*{-titleindent}}
titleformat{section}
{normalfontLargebfseries}{llap{parbox{titleindent}{thesectionhfill}}}{0em}{}
titleformat{subsection}
{normalfontlarge}{llap{parbox{titleindent}{thesubsectionhfill}}}{0em}{bfseries}
titleformat{subsectionwt}[runin]
{normalfontlarge}{llap{parbox{titleindent}{thesubsectionwthfill}}}{0em}{bfseries}
titleformat{subsubsection}
{normalfontnormalsize}{llap{parbox{titleindent}{thesubsubsection}}}{0em}{bfseries}
titleformat{subsubsectionwt}[runin]
{normalfontnormalsize}{llap{parbox{titleindent}{thesubsubsectionwt}}}{0em}{bfseries}
titlespacing*{chapter}{0pt}{0pt}{20pt}
titlespacing*{subsection}{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}
titlespacing*{subsectionwt}{0pt}{3.25ex plus 1ex minus .2ex}{0em}
titlespacing*{subsubsection}{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}
titlespacing*{subsubsectionwt}{0pt}{3.25ex plus 1ex minus .2ex}{0em}
% numbered entries without title shouldn't go to the ToC
titlecontents{subsectionwt}{}{}{}{}
titlecontents{subsubsectionwt}{}{}{}{}
begin{document}
tableofcontents
chapter{Test chapter}
section{Test Section}
lipsum[2]
subsection{Test Subsection}
lipsum[2]
subsectionwt{}% for numbered subsections without title
lipsum[2]
subsubsection{Test Subsubsection}
lipsum[2]
subsubsectionwt{}% for numbered subsubsections without title
lipsum[2]
end{document}
Great solution, it helped immensely also for me. A couple of bugs: - If you have asubsectionwt
as first, it's numbered as 0 - If you increase the section counter, thesubsectionwt
counter should be reset for the second,newcounter{subsectionwt}[section]
does the trick
– Helios
Dec 30 '14 at 18:03
add a comment |
After giving a look at the linked document, I could detect six sectional units: chapters, sections, numbered subsections with title, numbered subsections without title, numbered subsubsections with title, and numbered subsubsections without title. So the problem is how to define these six sectional units.
The code below shows a possible solution using the titlesec package; the underlaying idea is to use llap
and parbox
es to typeset the numbers hanging onto the margin. The length titleindent
allows you to easily control the hanging indent.
paragraph
has been changed so that it will allow numbered subsections without title and subparagraph
was also redefined to allow numbered subsubsections.
The following table shows the "dictionary" between each secional unit of the document and the LaTeX command that will be used to typeset it:
Chapters ->
chapter
Sections ->
section
Numbered subsections with title ->
subsection
Numbered subsections without title ->
paragraph
Numbered subsubsections with title ->
subsubsection
Numbered subsubsections without title ->
subparagraph
And here's the code (feel free to make the necessary adjustments to satisfy your requirements):
documentclass{book}
usepackage{titlesec}
usepackage{etoolbox}
usepackage{lipsum}
setcounter{secnumdepth}{5}
renewcommandthesection{arabic{section}}
% this length controls tha hanging indent for titles
% change the value according to your needs
newlengthtitleindent
setlengthtitleindent{2cm}
pretocmd{paragraph}{stepcounter{subsection}}{}{}
pretocmd{subparagraph}{stepcounter{subsubsection}}{}{}
titleformat{chapter}[block]
{normalfonthugebfseries}{}{0pt}{hspace*{-titleindent}}
titleformat{section}
{normalfontLargebfseries}{llap{parbox{titleindent}{thesectionhfill}}}{0em}{}
titleformat{subsection}
{normalfontlarge}{llap{parbox{titleindent}{thesubsectionhfill}}}{0em}{bfseries}
titleformat{subsubsection}
{normalfontnormalsize}{llap{parbox{titleindent}{thesubsubsection}}}{0em}{bfseries}
titleformat{paragraph}[runin]
{normalfontlarge}{llap{parbox{titleindent}{thesubsectionhfill}}}{0em}{}
titleformat{subparagraph}[runin]
{normalfontnormalsize}{llap{parbox{titleindent}{thesubsubsectionhfill}}}{0em}{}
titlespacing*{chapter}{0pt}{0pt}{20pt}
titlespacing*{subsubsection}{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}
titlespacing*{paragraph}{0pt}{3.25ex plus 1ex minus .2ex}{0em}
titlespacing*{subparagraph}{0pt}{3.25ex plus 1ex minus .2ex}{0em}
begin{document}
chapter{Test chapter}
section{Test Section}
lipsum[2]
subsection{Test Subsection}
lipsum[2]
paragraph{}% acts like a numbered subsection without title
lipsum[2]
subsubsection{Test Subsubsection}
lipsum[2]
subparagraph{}% acts like a numbered subsubsection without title
lipsum[2]
end{document}
The previous approach assumes that you won't use paragraph
and subparagraph
with their standard formatting; another (perhaps more sensible) option is to define two fresh new sectional units; this, of course, requires a little additional work, but now you will have the standard sectional units plus the two new ones.
The following code illustrates this approach defining subsectionwt
(for numbered subsections without titles) and subsubsectionwt
(for numbered subsubsections without titles); it also makes the necessary provisions for the ToC.
The new "dictionary" is now:
Chapters ->
chapter
Sections ->
section
Numbered subsections with title ->
subsection
Numbered subsections without title ->
subsectionwt
Numbered subsubsections with title ->
subsubsection
Numbered subsubsections without title ->
subsubsectionwt
Paragraphs ->
paragraph
Subparagraphs ->
subparagraph
The example code:
documentclass{book}
usepackage{titlesec,titletoc}
usepackage{etoolbox}
usepackage{lipsum}
setcounter{secnumdepth}{5}
renewcommandthesection{arabic{section}}
% this length controls tha hanging indent for titles
% change the value according to your needs
newlengthtitleindent
setlengthtitleindent{2cm}
% counters for the new sectional units
newcounter{subsectionwt}
newcounter{subsubsectionwt}
% definition of the new sectional units with the representation of the counters
titleclass{subsectionwt}{straight}[subsubsection]
renewcommand{thesubsectionwt}{thesection.arabic{subsectionwt}}
titleclass{subsubsectionwt}{straight}[subsectionwt]
renewcommand{thesubsubsectionwt}{thesubsection.arabic{subsubsectionwt}}
% subsection must increase the subsectionwt counter
% and subsectionwt must increase the subsection counter
% Analogous treatment for subsubsection and subsubsectionwt
pretocmd{subsectionwt}{stepcounter{subsection}}{}{}
pretocmd{subsection}{stepcounter{subsectionwt}}{}{}
pretocmd{subsubsectionwt}{stepcounter{subsubsection}}{}{}
pretocmd{subsubsection}{stepcounter{subsubsectionwt}}{}{}
% format for the sectional units
titleformat{chapter}[block]
{normalfonthugebfseries}{}{0pt}{hspace*{-titleindent}}
titleformat{section}
{normalfontLargebfseries}{llap{parbox{titleindent}{thesectionhfill}}}{0em}{}
titleformat{subsection}
{normalfontlarge}{llap{parbox{titleindent}{thesubsectionhfill}}}{0em}{bfseries}
titleformat{subsectionwt}[runin]
{normalfontlarge}{llap{parbox{titleindent}{thesubsectionwthfill}}}{0em}{bfseries}
titleformat{subsubsection}
{normalfontnormalsize}{llap{parbox{titleindent}{thesubsubsection}}}{0em}{bfseries}
titleformat{subsubsectionwt}[runin]
{normalfontnormalsize}{llap{parbox{titleindent}{thesubsubsectionwt}}}{0em}{bfseries}
titlespacing*{chapter}{0pt}{0pt}{20pt}
titlespacing*{subsection}{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}
titlespacing*{subsectionwt}{0pt}{3.25ex plus 1ex minus .2ex}{0em}
titlespacing*{subsubsection}{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}
titlespacing*{subsubsectionwt}{0pt}{3.25ex plus 1ex minus .2ex}{0em}
% numbered entries without title shouldn't go to the ToC
titlecontents{subsectionwt}{}{}{}{}
titlecontents{subsubsectionwt}{}{}{}{}
begin{document}
tableofcontents
chapter{Test chapter}
section{Test Section}
lipsum[2]
subsection{Test Subsection}
lipsum[2]
subsectionwt{}% for numbered subsections without title
lipsum[2]
subsubsection{Test Subsubsection}
lipsum[2]
subsubsectionwt{}% for numbered subsubsections without title
lipsum[2]
end{document}
Great solution, it helped immensely also for me. A couple of bugs: - If you have asubsectionwt
as first, it's numbered as 0 - If you increase the section counter, thesubsectionwt
counter should be reset for the second,newcounter{subsectionwt}[section]
does the trick
– Helios
Dec 30 '14 at 18:03
add a comment |
After giving a look at the linked document, I could detect six sectional units: chapters, sections, numbered subsections with title, numbered subsections without title, numbered subsubsections with title, and numbered subsubsections without title. So the problem is how to define these six sectional units.
The code below shows a possible solution using the titlesec package; the underlaying idea is to use llap
and parbox
es to typeset the numbers hanging onto the margin. The length titleindent
allows you to easily control the hanging indent.
paragraph
has been changed so that it will allow numbered subsections without title and subparagraph
was also redefined to allow numbered subsubsections.
The following table shows the "dictionary" between each secional unit of the document and the LaTeX command that will be used to typeset it:
Chapters ->
chapter
Sections ->
section
Numbered subsections with title ->
subsection
Numbered subsections without title ->
paragraph
Numbered subsubsections with title ->
subsubsection
Numbered subsubsections without title ->
subparagraph
And here's the code (feel free to make the necessary adjustments to satisfy your requirements):
documentclass{book}
usepackage{titlesec}
usepackage{etoolbox}
usepackage{lipsum}
setcounter{secnumdepth}{5}
renewcommandthesection{arabic{section}}
% this length controls tha hanging indent for titles
% change the value according to your needs
newlengthtitleindent
setlengthtitleindent{2cm}
pretocmd{paragraph}{stepcounter{subsection}}{}{}
pretocmd{subparagraph}{stepcounter{subsubsection}}{}{}
titleformat{chapter}[block]
{normalfonthugebfseries}{}{0pt}{hspace*{-titleindent}}
titleformat{section}
{normalfontLargebfseries}{llap{parbox{titleindent}{thesectionhfill}}}{0em}{}
titleformat{subsection}
{normalfontlarge}{llap{parbox{titleindent}{thesubsectionhfill}}}{0em}{bfseries}
titleformat{subsubsection}
{normalfontnormalsize}{llap{parbox{titleindent}{thesubsubsection}}}{0em}{bfseries}
titleformat{paragraph}[runin]
{normalfontlarge}{llap{parbox{titleindent}{thesubsectionhfill}}}{0em}{}
titleformat{subparagraph}[runin]
{normalfontnormalsize}{llap{parbox{titleindent}{thesubsubsectionhfill}}}{0em}{}
titlespacing*{chapter}{0pt}{0pt}{20pt}
titlespacing*{subsubsection}{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}
titlespacing*{paragraph}{0pt}{3.25ex plus 1ex minus .2ex}{0em}
titlespacing*{subparagraph}{0pt}{3.25ex plus 1ex minus .2ex}{0em}
begin{document}
chapter{Test chapter}
section{Test Section}
lipsum[2]
subsection{Test Subsection}
lipsum[2]
paragraph{}% acts like a numbered subsection without title
lipsum[2]
subsubsection{Test Subsubsection}
lipsum[2]
subparagraph{}% acts like a numbered subsubsection without title
lipsum[2]
end{document}
The previous approach assumes that you won't use paragraph
and subparagraph
with their standard formatting; another (perhaps more sensible) option is to define two fresh new sectional units; this, of course, requires a little additional work, but now you will have the standard sectional units plus the two new ones.
The following code illustrates this approach defining subsectionwt
(for numbered subsections without titles) and subsubsectionwt
(for numbered subsubsections without titles); it also makes the necessary provisions for the ToC.
The new "dictionary" is now:
Chapters ->
chapter
Sections ->
section
Numbered subsections with title ->
subsection
Numbered subsections without title ->
subsectionwt
Numbered subsubsections with title ->
subsubsection
Numbered subsubsections without title ->
subsubsectionwt
Paragraphs ->
paragraph
Subparagraphs ->
subparagraph
The example code:
documentclass{book}
usepackage{titlesec,titletoc}
usepackage{etoolbox}
usepackage{lipsum}
setcounter{secnumdepth}{5}
renewcommandthesection{arabic{section}}
% this length controls tha hanging indent for titles
% change the value according to your needs
newlengthtitleindent
setlengthtitleindent{2cm}
% counters for the new sectional units
newcounter{subsectionwt}
newcounter{subsubsectionwt}
% definition of the new sectional units with the representation of the counters
titleclass{subsectionwt}{straight}[subsubsection]
renewcommand{thesubsectionwt}{thesection.arabic{subsectionwt}}
titleclass{subsubsectionwt}{straight}[subsectionwt]
renewcommand{thesubsubsectionwt}{thesubsection.arabic{subsubsectionwt}}
% subsection must increase the subsectionwt counter
% and subsectionwt must increase the subsection counter
% Analogous treatment for subsubsection and subsubsectionwt
pretocmd{subsectionwt}{stepcounter{subsection}}{}{}
pretocmd{subsection}{stepcounter{subsectionwt}}{}{}
pretocmd{subsubsectionwt}{stepcounter{subsubsection}}{}{}
pretocmd{subsubsection}{stepcounter{subsubsectionwt}}{}{}
% format for the sectional units
titleformat{chapter}[block]
{normalfonthugebfseries}{}{0pt}{hspace*{-titleindent}}
titleformat{section}
{normalfontLargebfseries}{llap{parbox{titleindent}{thesectionhfill}}}{0em}{}
titleformat{subsection}
{normalfontlarge}{llap{parbox{titleindent}{thesubsectionhfill}}}{0em}{bfseries}
titleformat{subsectionwt}[runin]
{normalfontlarge}{llap{parbox{titleindent}{thesubsectionwthfill}}}{0em}{bfseries}
titleformat{subsubsection}
{normalfontnormalsize}{llap{parbox{titleindent}{thesubsubsection}}}{0em}{bfseries}
titleformat{subsubsectionwt}[runin]
{normalfontnormalsize}{llap{parbox{titleindent}{thesubsubsectionwt}}}{0em}{bfseries}
titlespacing*{chapter}{0pt}{0pt}{20pt}
titlespacing*{subsection}{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}
titlespacing*{subsectionwt}{0pt}{3.25ex plus 1ex minus .2ex}{0em}
titlespacing*{subsubsection}{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}
titlespacing*{subsubsectionwt}{0pt}{3.25ex plus 1ex minus .2ex}{0em}
% numbered entries without title shouldn't go to the ToC
titlecontents{subsectionwt}{}{}{}{}
titlecontents{subsubsectionwt}{}{}{}{}
begin{document}
tableofcontents
chapter{Test chapter}
section{Test Section}
lipsum[2]
subsection{Test Subsection}
lipsum[2]
subsectionwt{}% for numbered subsections without title
lipsum[2]
subsubsection{Test Subsubsection}
lipsum[2]
subsubsectionwt{}% for numbered subsubsections without title
lipsum[2]
end{document}
After giving a look at the linked document, I could detect six sectional units: chapters, sections, numbered subsections with title, numbered subsections without title, numbered subsubsections with title, and numbered subsubsections without title. So the problem is how to define these six sectional units.
The code below shows a possible solution using the titlesec package; the underlaying idea is to use llap
and parbox
es to typeset the numbers hanging onto the margin. The length titleindent
allows you to easily control the hanging indent.
paragraph
has been changed so that it will allow numbered subsections without title and subparagraph
was also redefined to allow numbered subsubsections.
The following table shows the "dictionary" between each secional unit of the document and the LaTeX command that will be used to typeset it:
Chapters ->
chapter
Sections ->
section
Numbered subsections with title ->
subsection
Numbered subsections without title ->
paragraph
Numbered subsubsections with title ->
subsubsection
Numbered subsubsections without title ->
subparagraph
And here's the code (feel free to make the necessary adjustments to satisfy your requirements):
documentclass{book}
usepackage{titlesec}
usepackage{etoolbox}
usepackage{lipsum}
setcounter{secnumdepth}{5}
renewcommandthesection{arabic{section}}
% this length controls tha hanging indent for titles
% change the value according to your needs
newlengthtitleindent
setlengthtitleindent{2cm}
pretocmd{paragraph}{stepcounter{subsection}}{}{}
pretocmd{subparagraph}{stepcounter{subsubsection}}{}{}
titleformat{chapter}[block]
{normalfonthugebfseries}{}{0pt}{hspace*{-titleindent}}
titleformat{section}
{normalfontLargebfseries}{llap{parbox{titleindent}{thesectionhfill}}}{0em}{}
titleformat{subsection}
{normalfontlarge}{llap{parbox{titleindent}{thesubsectionhfill}}}{0em}{bfseries}
titleformat{subsubsection}
{normalfontnormalsize}{llap{parbox{titleindent}{thesubsubsection}}}{0em}{bfseries}
titleformat{paragraph}[runin]
{normalfontlarge}{llap{parbox{titleindent}{thesubsectionhfill}}}{0em}{}
titleformat{subparagraph}[runin]
{normalfontnormalsize}{llap{parbox{titleindent}{thesubsubsectionhfill}}}{0em}{}
titlespacing*{chapter}{0pt}{0pt}{20pt}
titlespacing*{subsubsection}{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}
titlespacing*{paragraph}{0pt}{3.25ex plus 1ex minus .2ex}{0em}
titlespacing*{subparagraph}{0pt}{3.25ex plus 1ex minus .2ex}{0em}
begin{document}
chapter{Test chapter}
section{Test Section}
lipsum[2]
subsection{Test Subsection}
lipsum[2]
paragraph{}% acts like a numbered subsection without title
lipsum[2]
subsubsection{Test Subsubsection}
lipsum[2]
subparagraph{}% acts like a numbered subsubsection without title
lipsum[2]
end{document}
The previous approach assumes that you won't use paragraph
and subparagraph
with their standard formatting; another (perhaps more sensible) option is to define two fresh new sectional units; this, of course, requires a little additional work, but now you will have the standard sectional units plus the two new ones.
The following code illustrates this approach defining subsectionwt
(for numbered subsections without titles) and subsubsectionwt
(for numbered subsubsections without titles); it also makes the necessary provisions for the ToC.
The new "dictionary" is now:
Chapters ->
chapter
Sections ->
section
Numbered subsections with title ->
subsection
Numbered subsections without title ->
subsectionwt
Numbered subsubsections with title ->
subsubsection
Numbered subsubsections without title ->
subsubsectionwt
Paragraphs ->
paragraph
Subparagraphs ->
subparagraph
The example code:
documentclass{book}
usepackage{titlesec,titletoc}
usepackage{etoolbox}
usepackage{lipsum}
setcounter{secnumdepth}{5}
renewcommandthesection{arabic{section}}
% this length controls tha hanging indent for titles
% change the value according to your needs
newlengthtitleindent
setlengthtitleindent{2cm}
% counters for the new sectional units
newcounter{subsectionwt}
newcounter{subsubsectionwt}
% definition of the new sectional units with the representation of the counters
titleclass{subsectionwt}{straight}[subsubsection]
renewcommand{thesubsectionwt}{thesection.arabic{subsectionwt}}
titleclass{subsubsectionwt}{straight}[subsectionwt]
renewcommand{thesubsubsectionwt}{thesubsection.arabic{subsubsectionwt}}
% subsection must increase the subsectionwt counter
% and subsectionwt must increase the subsection counter
% Analogous treatment for subsubsection and subsubsectionwt
pretocmd{subsectionwt}{stepcounter{subsection}}{}{}
pretocmd{subsection}{stepcounter{subsectionwt}}{}{}
pretocmd{subsubsectionwt}{stepcounter{subsubsection}}{}{}
pretocmd{subsubsection}{stepcounter{subsubsectionwt}}{}{}
% format for the sectional units
titleformat{chapter}[block]
{normalfonthugebfseries}{}{0pt}{hspace*{-titleindent}}
titleformat{section}
{normalfontLargebfseries}{llap{parbox{titleindent}{thesectionhfill}}}{0em}{}
titleformat{subsection}
{normalfontlarge}{llap{parbox{titleindent}{thesubsectionhfill}}}{0em}{bfseries}
titleformat{subsectionwt}[runin]
{normalfontlarge}{llap{parbox{titleindent}{thesubsectionwthfill}}}{0em}{bfseries}
titleformat{subsubsection}
{normalfontnormalsize}{llap{parbox{titleindent}{thesubsubsection}}}{0em}{bfseries}
titleformat{subsubsectionwt}[runin]
{normalfontnormalsize}{llap{parbox{titleindent}{thesubsubsectionwt}}}{0em}{bfseries}
titlespacing*{chapter}{0pt}{0pt}{20pt}
titlespacing*{subsection}{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}
titlespacing*{subsectionwt}{0pt}{3.25ex plus 1ex minus .2ex}{0em}
titlespacing*{subsubsection}{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}
titlespacing*{subsubsectionwt}{0pt}{3.25ex plus 1ex minus .2ex}{0em}
% numbered entries without title shouldn't go to the ToC
titlecontents{subsectionwt}{}{}{}{}
titlecontents{subsubsectionwt}{}{}{}{}
begin{document}
tableofcontents
chapter{Test chapter}
section{Test Section}
lipsum[2]
subsection{Test Subsection}
lipsum[2]
subsectionwt{}% for numbered subsections without title
lipsum[2]
subsubsection{Test Subsubsection}
lipsum[2]
subsubsectionwt{}% for numbered subsubsections without title
lipsum[2]
end{document}
edited May 10 '12 at 2:29
answered May 9 '12 at 22:22
Gonzalo MedinaGonzalo Medina
402k4113141580
402k4113141580
Great solution, it helped immensely also for me. A couple of bugs: - If you have asubsectionwt
as first, it's numbered as 0 - If you increase the section counter, thesubsectionwt
counter should be reset for the second,newcounter{subsectionwt}[section]
does the trick
– Helios
Dec 30 '14 at 18:03
add a comment |
Great solution, it helped immensely also for me. A couple of bugs: - If you have asubsectionwt
as first, it's numbered as 0 - If you increase the section counter, thesubsectionwt
counter should be reset for the second,newcounter{subsectionwt}[section]
does the trick
– Helios
Dec 30 '14 at 18:03
Great solution, it helped immensely also for me. A couple of bugs: - If you have a
subsectionwt
as first, it's numbered as 0 - If you increase the section counter, the subsectionwt
counter should be reset for the second, newcounter{subsectionwt}[section]
does the trick– Helios
Dec 30 '14 at 18:03
Great solution, it helped immensely also for me. A couple of bugs: - If you have a
subsectionwt
as first, it's numbered as 0 - If you increase the section counter, the subsectionwt
counter should be reset for the second, newcounter{subsectionwt}[section]
does the trick– Helios
Dec 30 '14 at 18:03
add a comment |
If the section number is below the title, put parbox[b]
in the answer by @GonzaloMedina. To increase the indent for subsections, see the answer to automatic legal-style indentation in all ((sub)sub)sections.
New contributor
add a comment |
If the section number is below the title, put parbox[b]
in the answer by @GonzaloMedina. To increase the indent for subsections, see the answer to automatic legal-style indentation in all ((sub)sub)sections.
New contributor
add a comment |
If the section number is below the title, put parbox[b]
in the answer by @GonzaloMedina. To increase the indent for subsections, see the answer to automatic legal-style indentation in all ((sub)sub)sections.
New contributor
If the section number is below the title, put parbox[b]
in the answer by @GonzaloMedina. To increase the indent for subsections, see the answer to automatic legal-style indentation in all ((sub)sub)sections.
New contributor
New contributor
answered 3 hours ago
Tupolev._Tupolev._
1011
1011
New contributor
New contributor
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%2f55197%2fhow-can-i-number-paragraphs-and-sections-in-the-margin%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
I've updated my initial answer with a new approach, defining two new fresh sectional units.
– Gonzalo Medina
May 10 '12 at 2:33
Link is broken @Martin
– alexy13
Oct 13 '14 at 13:58
see also How can I do numbering with a hanging indent to the left into the page margin?
– barbara beeton
Jan 18 '15 at 15:05
@alexy13 As best I can find, this is (an updated version of) the document publicapps.caa.co.uk/docs/33/…
– owjburnham
Aug 11 '17 at 13:57