How can I number paragraphs (and sections) in the margin? The Next CEO of Stack OverflowIndenting text after numbered paragraphsHow can I do numbering with a hanging indent to the left into the page margin?Problems with paragraphs in marginsHow do I make a hanging indent for numbered paragraphs?How to number (on the left margin) paragraphs instead of lines?Paragraph Numbering in Margin Problemautomatic legal-style indentation in all ((sub)sub)sectionsFormat letter for my thesis in my country using ms wordHow to create an eviroment for questions in which the number of the question is in the left margin and the solution and the question text are aligned?Using memoir, how do I number paragraphs?Indentation of sections and paragraphs to show hierarchyNumber and reference paragraphsExclude line numbers from margin widthFormatting: Numbering paragraphs of sectionsHow to number (on the left margin) paragraphs instead of lines?How can I hang the bibliography cite key into the left margin like section numbers in memoir?How can I top align AND left align a box flush with the top of a paragraph?Indentation on numbered paragraphsHow to create a (colored) box that hangs into the left margin?

Is it my responsibility to learn a new technology in my own time my employer wants to implement?

Only print output after finding pattern

Why do remote companies require working in the US?

Visit to the USA with ESTA approved before trip to Iran

Implement the Thanos sorting algorithm

Describing a person. What needs to be mentioned?

Can a caster that cast Polymorph on themselves stop concentrating at any point even if their Int is low?

How should I support this large drywall patch?

Is a stroke of luck acceptable after a series of unfavorable events?

WOW air has ceased operation, can I get my tickets refunded?

How to start emacs in "nothing" mode (`fundamental-mode`)

How do I solve this limit?

What does this shorthand mean?

Increase performance creating Mandelbrot set in python

How long to clear the 'suck zone' of a turbofan after start is initiated?

Anatomically Correct Strange Women In Ponds Distributing Swords

How to safely derail a train during transit?

What size rim is OK?

What is the purpose of the Evocation wizard's Potent Cantrip feature?

Apart from "berlinern", do any other German dialects have a corresponding verb?

What's the point of interval inversion?

How to write papers efficiently when English isn't my first language?

Removing read access from a file

% symbol leads to superlong (forever?) compilations



How can I number paragraphs (and sections) in the margin?



The Next CEO of Stack OverflowIndenting text after numbered paragraphsHow can I do numbering with a hanging indent to the left into the page margin?Problems with paragraphs in marginsHow do I make a hanging indent for numbered paragraphs?How to number (on the left margin) paragraphs instead of lines?Paragraph Numbering in Margin Problemautomatic legal-style indentation in all ((sub)sub)sectionsFormat letter for my thesis in my country using ms wordHow to create an eviroment for questions in which the number of the question is in the left margin and the solution and the question text are aligned?Using memoir, how do I number paragraphs?Indentation of sections and paragraphs to show hierarchyNumber and reference paragraphsExclude line numbers from margin widthFormatting: Numbering paragraphs of sectionsHow to number (on the left margin) paragraphs instead of lines?How can I hang the bibliography cite key into the left margin like section numbers in memoir?How can I top align AND left align a box flush with the top of a paragraph?Indentation on numbered paragraphsHow to create a (colored) box that hangs into the left margin?










20















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 setcountersecnumdepth5 I can add numbers to my paragraphs. This code then puts all of the numbers in the margin:



makeatletter
def@seccntformat#1protectmakebox[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.










share|improve this question






















  • 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















20















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 setcountersecnumdepth5 I can add numbers to my paragraphs. This code then puts all of the numbers in the margin:



makeatletter
def@seccntformat#1protectmakebox[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.










share|improve this question






















  • 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













20












20








20


6






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 setcountersecnumdepth5 I can add numbers to my paragraphs. This code then puts all of the numbers in the margin:



makeatletter
def@seccntformat#1protectmakebox[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.










share|improve this question














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 setcountersecnumdepth5 I can add numbers to my paragraphs. This code then puts all of the numbers in the margin:



makeatletter
def@seccntformat#1protectmakebox[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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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

















  • 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










2 Answers
2






active

oldest

votes


















24














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 parboxes 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):



documentclassbook
usepackagetitlesec
usepackageetoolbox
usepackagelipsum

setcountersecnumdepth5
renewcommandthesectionarabicsection

% this length controls tha hanging indent for titles
% change the value according to your needs
newlengthtitleindent
setlengthtitleindent2cm

pretocmdparagraphstepcountersubsection
pretocmdsubparagraphstepcountersubsubsection

titleformatchapter[block]
normalfonthugebfseries0pthspace*-titleindent

titleformatsection
normalfontLargebfseriesllapparboxtitleindentthesectionhfill0em

titleformatsubsection
normalfontlargellapparboxtitleindentthesubsectionhfill0embfseries

titleformatsubsubsection
normalfontnormalsizellapparboxtitleindentthesubsubsection0embfseries

titleformatparagraph[runin]
normalfontlargellapparboxtitleindentthesubsectionhfill0em

titleformatsubparagraph[runin]
normalfontnormalsizellapparboxtitleindentthesubsubsectionhfill0em

titlespacing*chapter0pt0pt20pt
titlespacing*subsubsection0pt3.25ex plus 1ex minus .2ex1.5ex plus .2ex
titlespacing*paragraph0pt3.25ex plus 1ex minus .2ex0em
titlespacing*subparagraph0pt3.25ex plus 1ex minus .2ex0em

begindocument

chapterTest chapter
sectionTest Section
lipsum[2]
subsectionTest Subsection
lipsum[2]
paragraph% acts like a numbered subsection without title
lipsum[2]
subsubsectionTest Subsubsection
lipsum[2]
subparagraph% acts like a numbered subsubsection without title
lipsum[2]

enddocument


enter image description here



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:



documentclassbook
usepackagetitlesec,titletoc
usepackageetoolbox
usepackagelipsum

setcountersecnumdepth5
renewcommandthesectionarabicsection

% this length controls tha hanging indent for titles
% change the value according to your needs
newlengthtitleindent
setlengthtitleindent2cm

% counters for the new sectional units
newcountersubsectionwt
newcountersubsubsectionwt

% definition of the new sectional units with the representation of the counters
titleclasssubsectionwtstraight[subsubsection]
renewcommandthesubsectionwtthesection.arabicsubsectionwt

titleclasssubsubsectionwtstraight[subsectionwt]
renewcommandthesubsubsectionwtthesubsection.arabicsubsubsectionwt

% subsection must increase the subsectionwt counter
% and subsectionwt must increase the subsection counter
% Analogous treatment for subsubsection and subsubsectionwt
pretocmdsubsectionwtstepcountersubsection
pretocmdsubsectionstepcountersubsectionwt
pretocmdsubsubsectionwtstepcountersubsubsection
pretocmdsubsubsectionstepcountersubsubsectionwt

% format for the sectional units
titleformatchapter[block]
normalfonthugebfseries0pthspace*-titleindent

titleformatsection
normalfontLargebfseriesllapparboxtitleindentthesectionhfill0em

titleformatsubsection
normalfontlargellapparboxtitleindentthesubsectionhfill0embfseries

titleformatsubsectionwt[runin]
normalfontlargellapparboxtitleindentthesubsectionwthfill0embfseries

titleformatsubsubsection
normalfontnormalsizellapparboxtitleindentthesubsubsection0embfseries

titleformatsubsubsectionwt[runin]
normalfontnormalsizellapparboxtitleindentthesubsubsectionwt0embfseries

titlespacing*chapter0pt0pt20pt
titlespacing*subsection0pt3.25ex plus 1ex minus .2ex1.5ex plus .2ex
titlespacing*subsectionwt0pt3.25ex plus 1ex minus .2ex0em
titlespacing*subsubsection0pt3.25ex plus 1ex minus .2ex1.5ex plus .2ex
titlespacing*subsubsectionwt0pt3.25ex plus 1ex minus .2ex0em

% numbered entries without title shouldn't go to the ToC
titlecontentssubsectionwt[]
titlecontentssubsubsectionwt[]

begindocument

tableofcontents

chapterTest chapter
sectionTest Section
lipsum[2]
subsectionTest Subsection
lipsum[2]
subsectionwt% for numbered subsections without title
lipsum[2]
subsubsectionTest Subsubsection
lipsum[2]
subsubsectionwt% for numbered subsubsections without title
lipsum[2]

enddocument





share|improve this answer

























  • 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, newcountersubsectionwt[section] does the trick

    – Helios
    Dec 30 '14 at 18:03



















0














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.






share|improve this answer








New contributor




Tupolev._ is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















    Your Answer








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

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

    else
    createEditor();

    );

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



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%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









    24














    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 parboxes 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):



    documentclassbook
    usepackagetitlesec
    usepackageetoolbox
    usepackagelipsum

    setcountersecnumdepth5
    renewcommandthesectionarabicsection

    % this length controls tha hanging indent for titles
    % change the value according to your needs
    newlengthtitleindent
    setlengthtitleindent2cm

    pretocmdparagraphstepcountersubsection
    pretocmdsubparagraphstepcountersubsubsection

    titleformatchapter[block]
    normalfonthugebfseries0pthspace*-titleindent

    titleformatsection
    normalfontLargebfseriesllapparboxtitleindentthesectionhfill0em

    titleformatsubsection
    normalfontlargellapparboxtitleindentthesubsectionhfill0embfseries

    titleformatsubsubsection
    normalfontnormalsizellapparboxtitleindentthesubsubsection0embfseries

    titleformatparagraph[runin]
    normalfontlargellapparboxtitleindentthesubsectionhfill0em

    titleformatsubparagraph[runin]
    normalfontnormalsizellapparboxtitleindentthesubsubsectionhfill0em

    titlespacing*chapter0pt0pt20pt
    titlespacing*subsubsection0pt3.25ex plus 1ex minus .2ex1.5ex plus .2ex
    titlespacing*paragraph0pt3.25ex plus 1ex minus .2ex0em
    titlespacing*subparagraph0pt3.25ex plus 1ex minus .2ex0em

    begindocument

    chapterTest chapter
    sectionTest Section
    lipsum[2]
    subsectionTest Subsection
    lipsum[2]
    paragraph% acts like a numbered subsection without title
    lipsum[2]
    subsubsectionTest Subsubsection
    lipsum[2]
    subparagraph% acts like a numbered subsubsection without title
    lipsum[2]

    enddocument


    enter image description here



    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:



    documentclassbook
    usepackagetitlesec,titletoc
    usepackageetoolbox
    usepackagelipsum

    setcountersecnumdepth5
    renewcommandthesectionarabicsection

    % this length controls tha hanging indent for titles
    % change the value according to your needs
    newlengthtitleindent
    setlengthtitleindent2cm

    % counters for the new sectional units
    newcountersubsectionwt
    newcountersubsubsectionwt

    % definition of the new sectional units with the representation of the counters
    titleclasssubsectionwtstraight[subsubsection]
    renewcommandthesubsectionwtthesection.arabicsubsectionwt

    titleclasssubsubsectionwtstraight[subsectionwt]
    renewcommandthesubsubsectionwtthesubsection.arabicsubsubsectionwt

    % subsection must increase the subsectionwt counter
    % and subsectionwt must increase the subsection counter
    % Analogous treatment for subsubsection and subsubsectionwt
    pretocmdsubsectionwtstepcountersubsection
    pretocmdsubsectionstepcountersubsectionwt
    pretocmdsubsubsectionwtstepcountersubsubsection
    pretocmdsubsubsectionstepcountersubsubsectionwt

    % format for the sectional units
    titleformatchapter[block]
    normalfonthugebfseries0pthspace*-titleindent

    titleformatsection
    normalfontLargebfseriesllapparboxtitleindentthesectionhfill0em

    titleformatsubsection
    normalfontlargellapparboxtitleindentthesubsectionhfill0embfseries

    titleformatsubsectionwt[runin]
    normalfontlargellapparboxtitleindentthesubsectionwthfill0embfseries

    titleformatsubsubsection
    normalfontnormalsizellapparboxtitleindentthesubsubsection0embfseries

    titleformatsubsubsectionwt[runin]
    normalfontnormalsizellapparboxtitleindentthesubsubsectionwt0embfseries

    titlespacing*chapter0pt0pt20pt
    titlespacing*subsection0pt3.25ex plus 1ex minus .2ex1.5ex plus .2ex
    titlespacing*subsectionwt0pt3.25ex plus 1ex minus .2ex0em
    titlespacing*subsubsection0pt3.25ex plus 1ex minus .2ex1.5ex plus .2ex
    titlespacing*subsubsectionwt0pt3.25ex plus 1ex minus .2ex0em

    % numbered entries without title shouldn't go to the ToC
    titlecontentssubsectionwt[]
    titlecontentssubsubsectionwt[]

    begindocument

    tableofcontents

    chapterTest chapter
    sectionTest Section
    lipsum[2]
    subsectionTest Subsection
    lipsum[2]
    subsectionwt% for numbered subsections without title
    lipsum[2]
    subsubsectionTest Subsubsection
    lipsum[2]
    subsubsectionwt% for numbered subsubsections without title
    lipsum[2]

    enddocument





    share|improve this answer

























    • 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, newcountersubsectionwt[section] does the trick

      – Helios
      Dec 30 '14 at 18:03
















    24














    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 parboxes 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):



    documentclassbook
    usepackagetitlesec
    usepackageetoolbox
    usepackagelipsum

    setcountersecnumdepth5
    renewcommandthesectionarabicsection

    % this length controls tha hanging indent for titles
    % change the value according to your needs
    newlengthtitleindent
    setlengthtitleindent2cm

    pretocmdparagraphstepcountersubsection
    pretocmdsubparagraphstepcountersubsubsection

    titleformatchapter[block]
    normalfonthugebfseries0pthspace*-titleindent

    titleformatsection
    normalfontLargebfseriesllapparboxtitleindentthesectionhfill0em

    titleformatsubsection
    normalfontlargellapparboxtitleindentthesubsectionhfill0embfseries

    titleformatsubsubsection
    normalfontnormalsizellapparboxtitleindentthesubsubsection0embfseries

    titleformatparagraph[runin]
    normalfontlargellapparboxtitleindentthesubsectionhfill0em

    titleformatsubparagraph[runin]
    normalfontnormalsizellapparboxtitleindentthesubsubsectionhfill0em

    titlespacing*chapter0pt0pt20pt
    titlespacing*subsubsection0pt3.25ex plus 1ex minus .2ex1.5ex plus .2ex
    titlespacing*paragraph0pt3.25ex plus 1ex minus .2ex0em
    titlespacing*subparagraph0pt3.25ex plus 1ex minus .2ex0em

    begindocument

    chapterTest chapter
    sectionTest Section
    lipsum[2]
    subsectionTest Subsection
    lipsum[2]
    paragraph% acts like a numbered subsection without title
    lipsum[2]
    subsubsectionTest Subsubsection
    lipsum[2]
    subparagraph% acts like a numbered subsubsection without title
    lipsum[2]

    enddocument


    enter image description here



    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:



    documentclassbook
    usepackagetitlesec,titletoc
    usepackageetoolbox
    usepackagelipsum

    setcountersecnumdepth5
    renewcommandthesectionarabicsection

    % this length controls tha hanging indent for titles
    % change the value according to your needs
    newlengthtitleindent
    setlengthtitleindent2cm

    % counters for the new sectional units
    newcountersubsectionwt
    newcountersubsubsectionwt

    % definition of the new sectional units with the representation of the counters
    titleclasssubsectionwtstraight[subsubsection]
    renewcommandthesubsectionwtthesection.arabicsubsectionwt

    titleclasssubsubsectionwtstraight[subsectionwt]
    renewcommandthesubsubsectionwtthesubsection.arabicsubsubsectionwt

    % subsection must increase the subsectionwt counter
    % and subsectionwt must increase the subsection counter
    % Analogous treatment for subsubsection and subsubsectionwt
    pretocmdsubsectionwtstepcountersubsection
    pretocmdsubsectionstepcountersubsectionwt
    pretocmdsubsubsectionwtstepcountersubsubsection
    pretocmdsubsubsectionstepcountersubsubsectionwt

    % format for the sectional units
    titleformatchapter[block]
    normalfonthugebfseries0pthspace*-titleindent

    titleformatsection
    normalfontLargebfseriesllapparboxtitleindentthesectionhfill0em

    titleformatsubsection
    normalfontlargellapparboxtitleindentthesubsectionhfill0embfseries

    titleformatsubsectionwt[runin]
    normalfontlargellapparboxtitleindentthesubsectionwthfill0embfseries

    titleformatsubsubsection
    normalfontnormalsizellapparboxtitleindentthesubsubsection0embfseries

    titleformatsubsubsectionwt[runin]
    normalfontnormalsizellapparboxtitleindentthesubsubsectionwt0embfseries

    titlespacing*chapter0pt0pt20pt
    titlespacing*subsection0pt3.25ex plus 1ex minus .2ex1.5ex plus .2ex
    titlespacing*subsectionwt0pt3.25ex plus 1ex minus .2ex0em
    titlespacing*subsubsection0pt3.25ex plus 1ex minus .2ex1.5ex plus .2ex
    titlespacing*subsubsectionwt0pt3.25ex plus 1ex minus .2ex0em

    % numbered entries without title shouldn't go to the ToC
    titlecontentssubsectionwt[]
    titlecontentssubsubsectionwt[]

    begindocument

    tableofcontents

    chapterTest chapter
    sectionTest Section
    lipsum[2]
    subsectionTest Subsection
    lipsum[2]
    subsectionwt% for numbered subsections without title
    lipsum[2]
    subsubsectionTest Subsubsection
    lipsum[2]
    subsubsectionwt% for numbered subsubsections without title
    lipsum[2]

    enddocument





    share|improve this answer

























    • 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, newcountersubsectionwt[section] does the trick

      – Helios
      Dec 30 '14 at 18:03














    24












    24








    24







    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 parboxes 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):



    documentclassbook
    usepackagetitlesec
    usepackageetoolbox
    usepackagelipsum

    setcountersecnumdepth5
    renewcommandthesectionarabicsection

    % this length controls tha hanging indent for titles
    % change the value according to your needs
    newlengthtitleindent
    setlengthtitleindent2cm

    pretocmdparagraphstepcountersubsection
    pretocmdsubparagraphstepcountersubsubsection

    titleformatchapter[block]
    normalfonthugebfseries0pthspace*-titleindent

    titleformatsection
    normalfontLargebfseriesllapparboxtitleindentthesectionhfill0em

    titleformatsubsection
    normalfontlargellapparboxtitleindentthesubsectionhfill0embfseries

    titleformatsubsubsection
    normalfontnormalsizellapparboxtitleindentthesubsubsection0embfseries

    titleformatparagraph[runin]
    normalfontlargellapparboxtitleindentthesubsectionhfill0em

    titleformatsubparagraph[runin]
    normalfontnormalsizellapparboxtitleindentthesubsubsectionhfill0em

    titlespacing*chapter0pt0pt20pt
    titlespacing*subsubsection0pt3.25ex plus 1ex minus .2ex1.5ex plus .2ex
    titlespacing*paragraph0pt3.25ex plus 1ex minus .2ex0em
    titlespacing*subparagraph0pt3.25ex plus 1ex minus .2ex0em

    begindocument

    chapterTest chapter
    sectionTest Section
    lipsum[2]
    subsectionTest Subsection
    lipsum[2]
    paragraph% acts like a numbered subsection without title
    lipsum[2]
    subsubsectionTest Subsubsection
    lipsum[2]
    subparagraph% acts like a numbered subsubsection without title
    lipsum[2]

    enddocument


    enter image description here



    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:



    documentclassbook
    usepackagetitlesec,titletoc
    usepackageetoolbox
    usepackagelipsum

    setcountersecnumdepth5
    renewcommandthesectionarabicsection

    % this length controls tha hanging indent for titles
    % change the value according to your needs
    newlengthtitleindent
    setlengthtitleindent2cm

    % counters for the new sectional units
    newcountersubsectionwt
    newcountersubsubsectionwt

    % definition of the new sectional units with the representation of the counters
    titleclasssubsectionwtstraight[subsubsection]
    renewcommandthesubsectionwtthesection.arabicsubsectionwt

    titleclasssubsubsectionwtstraight[subsectionwt]
    renewcommandthesubsubsectionwtthesubsection.arabicsubsubsectionwt

    % subsection must increase the subsectionwt counter
    % and subsectionwt must increase the subsection counter
    % Analogous treatment for subsubsection and subsubsectionwt
    pretocmdsubsectionwtstepcountersubsection
    pretocmdsubsectionstepcountersubsectionwt
    pretocmdsubsubsectionwtstepcountersubsubsection
    pretocmdsubsubsectionstepcountersubsubsectionwt

    % format for the sectional units
    titleformatchapter[block]
    normalfonthugebfseries0pthspace*-titleindent

    titleformatsection
    normalfontLargebfseriesllapparboxtitleindentthesectionhfill0em

    titleformatsubsection
    normalfontlargellapparboxtitleindentthesubsectionhfill0embfseries

    titleformatsubsectionwt[runin]
    normalfontlargellapparboxtitleindentthesubsectionwthfill0embfseries

    titleformatsubsubsection
    normalfontnormalsizellapparboxtitleindentthesubsubsection0embfseries

    titleformatsubsubsectionwt[runin]
    normalfontnormalsizellapparboxtitleindentthesubsubsectionwt0embfseries

    titlespacing*chapter0pt0pt20pt
    titlespacing*subsection0pt3.25ex plus 1ex minus .2ex1.5ex plus .2ex
    titlespacing*subsectionwt0pt3.25ex plus 1ex minus .2ex0em
    titlespacing*subsubsection0pt3.25ex plus 1ex minus .2ex1.5ex plus .2ex
    titlespacing*subsubsectionwt0pt3.25ex plus 1ex minus .2ex0em

    % numbered entries without title shouldn't go to the ToC
    titlecontentssubsectionwt[]
    titlecontentssubsubsectionwt[]

    begindocument

    tableofcontents

    chapterTest chapter
    sectionTest Section
    lipsum[2]
    subsectionTest Subsection
    lipsum[2]
    subsectionwt% for numbered subsections without title
    lipsum[2]
    subsubsectionTest Subsubsection
    lipsum[2]
    subsubsectionwt% for numbered subsubsections without title
    lipsum[2]

    enddocument





    share|improve this answer















    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 parboxes 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):



    documentclassbook
    usepackagetitlesec
    usepackageetoolbox
    usepackagelipsum

    setcountersecnumdepth5
    renewcommandthesectionarabicsection

    % this length controls tha hanging indent for titles
    % change the value according to your needs
    newlengthtitleindent
    setlengthtitleindent2cm

    pretocmdparagraphstepcountersubsection
    pretocmdsubparagraphstepcountersubsubsection

    titleformatchapter[block]
    normalfonthugebfseries0pthspace*-titleindent

    titleformatsection
    normalfontLargebfseriesllapparboxtitleindentthesectionhfill0em

    titleformatsubsection
    normalfontlargellapparboxtitleindentthesubsectionhfill0embfseries

    titleformatsubsubsection
    normalfontnormalsizellapparboxtitleindentthesubsubsection0embfseries

    titleformatparagraph[runin]
    normalfontlargellapparboxtitleindentthesubsectionhfill0em

    titleformatsubparagraph[runin]
    normalfontnormalsizellapparboxtitleindentthesubsubsectionhfill0em

    titlespacing*chapter0pt0pt20pt
    titlespacing*subsubsection0pt3.25ex plus 1ex minus .2ex1.5ex plus .2ex
    titlespacing*paragraph0pt3.25ex plus 1ex minus .2ex0em
    titlespacing*subparagraph0pt3.25ex plus 1ex minus .2ex0em

    begindocument

    chapterTest chapter
    sectionTest Section
    lipsum[2]
    subsectionTest Subsection
    lipsum[2]
    paragraph% acts like a numbered subsection without title
    lipsum[2]
    subsubsectionTest Subsubsection
    lipsum[2]
    subparagraph% acts like a numbered subsubsection without title
    lipsum[2]

    enddocument


    enter image description here



    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:



    documentclassbook
    usepackagetitlesec,titletoc
    usepackageetoolbox
    usepackagelipsum

    setcountersecnumdepth5
    renewcommandthesectionarabicsection

    % this length controls tha hanging indent for titles
    % change the value according to your needs
    newlengthtitleindent
    setlengthtitleindent2cm

    % counters for the new sectional units
    newcountersubsectionwt
    newcountersubsubsectionwt

    % definition of the new sectional units with the representation of the counters
    titleclasssubsectionwtstraight[subsubsection]
    renewcommandthesubsectionwtthesection.arabicsubsectionwt

    titleclasssubsubsectionwtstraight[subsectionwt]
    renewcommandthesubsubsectionwtthesubsection.arabicsubsubsectionwt

    % subsection must increase the subsectionwt counter
    % and subsectionwt must increase the subsection counter
    % Analogous treatment for subsubsection and subsubsectionwt
    pretocmdsubsectionwtstepcountersubsection
    pretocmdsubsectionstepcountersubsectionwt
    pretocmdsubsubsectionwtstepcountersubsubsection
    pretocmdsubsubsectionstepcountersubsubsectionwt

    % format for the sectional units
    titleformatchapter[block]
    normalfonthugebfseries0pthspace*-titleindent

    titleformatsection
    normalfontLargebfseriesllapparboxtitleindentthesectionhfill0em

    titleformatsubsection
    normalfontlargellapparboxtitleindentthesubsectionhfill0embfseries

    titleformatsubsectionwt[runin]
    normalfontlargellapparboxtitleindentthesubsectionwthfill0embfseries

    titleformatsubsubsection
    normalfontnormalsizellapparboxtitleindentthesubsubsection0embfseries

    titleformatsubsubsectionwt[runin]
    normalfontnormalsizellapparboxtitleindentthesubsubsectionwt0embfseries

    titlespacing*chapter0pt0pt20pt
    titlespacing*subsection0pt3.25ex plus 1ex minus .2ex1.5ex plus .2ex
    titlespacing*subsectionwt0pt3.25ex plus 1ex minus .2ex0em
    titlespacing*subsubsection0pt3.25ex plus 1ex minus .2ex1.5ex plus .2ex
    titlespacing*subsubsectionwt0pt3.25ex plus 1ex minus .2ex0em

    % numbered entries without title shouldn't go to the ToC
    titlecontentssubsectionwt[]
    titlecontentssubsubsectionwt[]

    begindocument

    tableofcontents

    chapterTest chapter
    sectionTest Section
    lipsum[2]
    subsectionTest Subsection
    lipsum[2]
    subsectionwt% for numbered subsections without title
    lipsum[2]
    subsubsectionTest Subsubsection
    lipsum[2]
    subsubsectionwt% for numbered subsubsections without title
    lipsum[2]

    enddocument






    share|improve this answer














    share|improve this answer



    share|improve this answer








    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 a subsectionwt as first, it's numbered as 0 - If you increase the section counter, the subsectionwt counter should be reset for the second, newcountersubsectionwt[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, newcountersubsectionwt[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, newcountersubsectionwt[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, newcountersubsectionwt[section] does the trick

    – Helios
    Dec 30 '14 at 18:03












    0














    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.






    share|improve this answer








    New contributor




    Tupolev._ is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.
























      0














      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.






      share|improve this answer








      New contributor




      Tupolev._ is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















        0












        0








        0







        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.






        share|improve this answer








        New contributor




        Tupolev._ is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.










        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.







        share|improve this answer








        New contributor




        Tupolev._ is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        share|improve this answer



        share|improve this answer






        New contributor




        Tupolev._ is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        answered 22 mins ago









        Tupolev._Tupolev._

        1011




        1011




        New contributor




        Tupolev._ is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.





        New contributor





        Tupolev._ is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.






        Tupolev._ is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.



























            draft saved

            draft discarded
















































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


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

            But avoid


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

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

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




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f55197%2fhow-can-i-number-paragraphs-and-sections-in-the-margin%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown