Indent Whole paragraphs after subsections












2















Basically, I need to indent paragraphs after a subsection as shown here:



example



Basically, I need to indent the all the content after a subsection. I already have the proper formatting for the heading of the subsection as follows:



documentclass[12pt]{report}
usepackage{titlesec}
titleformat{subsection}[block]{bfseriesitshapenormalsizehspace{2em}}{thesubsection}{1em}{}
begin{document}
end{document}


I found a solution here: Indenting a whole paragraph



However, the problem is that in order to apply the solution I will need to manually add code before and after each subsection.



Another solution here: Indent every subsubsection element



proposes using a new environment:



documentclass{article}
usepackage{changepage}

usepackage{lipsum}
newenvironment{subs}
{adjustwidth{3em}{0pt}}
{endadjustwidth}
begin{document}
subsection{A subsection}


lipsum[2]

begin{subs}
subsubsection{One}

lipsum[3]

subsubsection{Two}

lipsum[4]

end{subs}
end{document}


However, this has the same problem: I would need to manually add begin...end of the environment for each subsection I have. Is there a better solution?










share|improve this question


















  • 2





    Automation of this is hard to do because the sectioning commands are not environments (an unfortunate design choice in some ways). So as a result, you can't hook into the end of a section/subsection etc. which is what you would need to have this work.

    – Alan Munn
    Jan 29 at 19:19
















2















Basically, I need to indent paragraphs after a subsection as shown here:



example



Basically, I need to indent the all the content after a subsection. I already have the proper formatting for the heading of the subsection as follows:



documentclass[12pt]{report}
usepackage{titlesec}
titleformat{subsection}[block]{bfseriesitshapenormalsizehspace{2em}}{thesubsection}{1em}{}
begin{document}
end{document}


I found a solution here: Indenting a whole paragraph



However, the problem is that in order to apply the solution I will need to manually add code before and after each subsection.



Another solution here: Indent every subsubsection element



proposes using a new environment:



documentclass{article}
usepackage{changepage}

usepackage{lipsum}
newenvironment{subs}
{adjustwidth{3em}{0pt}}
{endadjustwidth}
begin{document}
subsection{A subsection}


lipsum[2]

begin{subs}
subsubsection{One}

lipsum[3]

subsubsection{Two}

lipsum[4]

end{subs}
end{document}


However, this has the same problem: I would need to manually add begin...end of the environment for each subsection I have. Is there a better solution?










share|improve this question


















  • 2





    Automation of this is hard to do because the sectioning commands are not environments (an unfortunate design choice in some ways). So as a result, you can't hook into the end of a section/subsection etc. which is what you would need to have this work.

    – Alan Munn
    Jan 29 at 19:19














2












2








2


2






Basically, I need to indent paragraphs after a subsection as shown here:



example



Basically, I need to indent the all the content after a subsection. I already have the proper formatting for the heading of the subsection as follows:



documentclass[12pt]{report}
usepackage{titlesec}
titleformat{subsection}[block]{bfseriesitshapenormalsizehspace{2em}}{thesubsection}{1em}{}
begin{document}
end{document}


I found a solution here: Indenting a whole paragraph



However, the problem is that in order to apply the solution I will need to manually add code before and after each subsection.



Another solution here: Indent every subsubsection element



proposes using a new environment:



documentclass{article}
usepackage{changepage}

usepackage{lipsum}
newenvironment{subs}
{adjustwidth{3em}{0pt}}
{endadjustwidth}
begin{document}
subsection{A subsection}


lipsum[2]

begin{subs}
subsubsection{One}

lipsum[3]

subsubsection{Two}

lipsum[4]

end{subs}
end{document}


However, this has the same problem: I would need to manually add begin...end of the environment for each subsection I have. Is there a better solution?










share|improve this question














Basically, I need to indent paragraphs after a subsection as shown here:



example



Basically, I need to indent the all the content after a subsection. I already have the proper formatting for the heading of the subsection as follows:



documentclass[12pt]{report}
usepackage{titlesec}
titleformat{subsection}[block]{bfseriesitshapenormalsizehspace{2em}}{thesubsection}{1em}{}
begin{document}
end{document}


I found a solution here: Indenting a whole paragraph



However, the problem is that in order to apply the solution I will need to manually add code before and after each subsection.



Another solution here: Indent every subsubsection element



proposes using a new environment:



documentclass{article}
usepackage{changepage}

usepackage{lipsum}
newenvironment{subs}
{adjustwidth{3em}{0pt}}
{endadjustwidth}
begin{document}
subsection{A subsection}


lipsum[2]

begin{subs}
subsubsection{One}

lipsum[3]

subsubsection{Two}

lipsum[4]

end{subs}
end{document}


However, this has the same problem: I would need to manually add begin...end of the environment for each subsection I have. Is there a better solution?







sectioning indentation






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jan 29 at 19:08









MhmdMhmd

1134




1134








  • 2





    Automation of this is hard to do because the sectioning commands are not environments (an unfortunate design choice in some ways). So as a result, you can't hook into the end of a section/subsection etc. which is what you would need to have this work.

    – Alan Munn
    Jan 29 at 19:19














  • 2





    Automation of this is hard to do because the sectioning commands are not environments (an unfortunate design choice in some ways). So as a result, you can't hook into the end of a section/subsection etc. which is what you would need to have this work.

    – Alan Munn
    Jan 29 at 19:19








2




2





Automation of this is hard to do because the sectioning commands are not environments (an unfortunate design choice in some ways). So as a result, you can't hook into the end of a section/subsection etc. which is what you would need to have this work.

– Alan Munn
Jan 29 at 19:19





Automation of this is hard to do because the sectioning commands are not environments (an unfortunate design choice in some ways). So as a result, you can't hook into the end of a section/subsection etc. which is what you would need to have this work.

– Alan Munn
Jan 29 at 19:19










1 Answer
1






active

oldest

votes


















3














In the same spirit as your first quoted answer and using etoolbox's patchcmd you can assume that leftskip is not used dor anything else, the magic is :



patchcmd{subsection}{-3.25ex@plus -1ex @minus -.2ex}{3.25ex@plus -1ex @minus -.2exsetlength{leftskip}{0cm}}{}{}
patchcmd{subsection}{1.5ex @plus .2ex}{1.5ex @plus .2exsetlength{leftskip}{2cm}}{}{}
patchcmd{section}{-3.5ex @plus -1ex @minus -.2ex}{-3.5ex @plus -1ex @minus -.2exsetlength{leftskip}{0cm}}{}{}


which switches off the shift at the beginning of the section and subsection, and switches it on when entering into subsection. Here is a MWE, in the which I changed the page size to fit the example on two pages:



documentclass[12pt,a4paper]{report}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
usepackage{lmodern}
usepackage{etoolbox}
usepackage{lipsum}
usepackage[margin=25mm]{geometry}

makeatletter
patchcmd{section}{-3.5ex @plus -1ex @minus -.2ex}{-3.5ex @plus -1ex @minus -.2exsetlength{leftskip}{0cm}}{}{}
patchcmd{subsection}{-3.25ex@plus -1ex @minus -.2ex}{3.25ex@plus -1ex @minus -.2exsetlength{leftskip}{0cm}}{}{}
patchcmd{subsection}{1.5ex @plus .2ex}{1.5ex @plus .2exsetlength{leftskip}{2cm}}{}{}
makeatother
begin{document}
setcounter{chapter}{3}
section{Section Foo}
lipsum[1]
subsection{A subsection}label{s:first}
lipsum[2]
subsection{Another subsection}
lipsum[3-5]

section{Section Bar}
textbf{As seen in section ref{s:first}}
lipsum[5]
subsection{Test again}
lipsum[5]
end{document}


with the result:
enter image description here



Note 1: this works also with hyperref, provided you make the patch before loading it.



Note 2: This approach is likely not compatible with titlesec. It assumes that the sectioning commands (below chapter) are based on the standard @startsection command. This is not an issue as you can also patch in a similar way the format of the title for getting italic



Note 3: To determine the value of the second argument of patchcmd (which depends on the class and ptsize) you have to look at the content of the sectionng commands. For this purpose I use a custom command :



newcommand{mymeaning}[1]{{smallnoindent{bfseries string #1} = meaning #1parmedskip}}


based on the standard command meaning with some cosmetic, and do e.g. mymeaning{subsection} in the document.






share|improve this answer





















  • 1





    If you have chapters or part, ending a subsection you would have to apply to the corresponding command the same patch as for section, disabling the shift. I will soon provide the patch for the standard chapter. An other option (for chaoter) would be to alter the clearpage command.

    – Jhor
    Jan 31 at 7:48











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%2f472440%2findent-whole-paragraphs-after-subsections%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









3














In the same spirit as your first quoted answer and using etoolbox's patchcmd you can assume that leftskip is not used dor anything else, the magic is :



patchcmd{subsection}{-3.25ex@plus -1ex @minus -.2ex}{3.25ex@plus -1ex @minus -.2exsetlength{leftskip}{0cm}}{}{}
patchcmd{subsection}{1.5ex @plus .2ex}{1.5ex @plus .2exsetlength{leftskip}{2cm}}{}{}
patchcmd{section}{-3.5ex @plus -1ex @minus -.2ex}{-3.5ex @plus -1ex @minus -.2exsetlength{leftskip}{0cm}}{}{}


which switches off the shift at the beginning of the section and subsection, and switches it on when entering into subsection. Here is a MWE, in the which I changed the page size to fit the example on two pages:



documentclass[12pt,a4paper]{report}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
usepackage{lmodern}
usepackage{etoolbox}
usepackage{lipsum}
usepackage[margin=25mm]{geometry}

makeatletter
patchcmd{section}{-3.5ex @plus -1ex @minus -.2ex}{-3.5ex @plus -1ex @minus -.2exsetlength{leftskip}{0cm}}{}{}
patchcmd{subsection}{-3.25ex@plus -1ex @minus -.2ex}{3.25ex@plus -1ex @minus -.2exsetlength{leftskip}{0cm}}{}{}
patchcmd{subsection}{1.5ex @plus .2ex}{1.5ex @plus .2exsetlength{leftskip}{2cm}}{}{}
makeatother
begin{document}
setcounter{chapter}{3}
section{Section Foo}
lipsum[1]
subsection{A subsection}label{s:first}
lipsum[2]
subsection{Another subsection}
lipsum[3-5]

section{Section Bar}
textbf{As seen in section ref{s:first}}
lipsum[5]
subsection{Test again}
lipsum[5]
end{document}


with the result:
enter image description here



Note 1: this works also with hyperref, provided you make the patch before loading it.



Note 2: This approach is likely not compatible with titlesec. It assumes that the sectioning commands (below chapter) are based on the standard @startsection command. This is not an issue as you can also patch in a similar way the format of the title for getting italic



Note 3: To determine the value of the second argument of patchcmd (which depends on the class and ptsize) you have to look at the content of the sectionng commands. For this purpose I use a custom command :



newcommand{mymeaning}[1]{{smallnoindent{bfseries string #1} = meaning #1parmedskip}}


based on the standard command meaning with some cosmetic, and do e.g. mymeaning{subsection} in the document.






share|improve this answer





















  • 1





    If you have chapters or part, ending a subsection you would have to apply to the corresponding command the same patch as for section, disabling the shift. I will soon provide the patch for the standard chapter. An other option (for chaoter) would be to alter the clearpage command.

    – Jhor
    Jan 31 at 7:48
















3














In the same spirit as your first quoted answer and using etoolbox's patchcmd you can assume that leftskip is not used dor anything else, the magic is :



patchcmd{subsection}{-3.25ex@plus -1ex @minus -.2ex}{3.25ex@plus -1ex @minus -.2exsetlength{leftskip}{0cm}}{}{}
patchcmd{subsection}{1.5ex @plus .2ex}{1.5ex @plus .2exsetlength{leftskip}{2cm}}{}{}
patchcmd{section}{-3.5ex @plus -1ex @minus -.2ex}{-3.5ex @plus -1ex @minus -.2exsetlength{leftskip}{0cm}}{}{}


which switches off the shift at the beginning of the section and subsection, and switches it on when entering into subsection. Here is a MWE, in the which I changed the page size to fit the example on two pages:



documentclass[12pt,a4paper]{report}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
usepackage{lmodern}
usepackage{etoolbox}
usepackage{lipsum}
usepackage[margin=25mm]{geometry}

makeatletter
patchcmd{section}{-3.5ex @plus -1ex @minus -.2ex}{-3.5ex @plus -1ex @minus -.2exsetlength{leftskip}{0cm}}{}{}
patchcmd{subsection}{-3.25ex@plus -1ex @minus -.2ex}{3.25ex@plus -1ex @minus -.2exsetlength{leftskip}{0cm}}{}{}
patchcmd{subsection}{1.5ex @plus .2ex}{1.5ex @plus .2exsetlength{leftskip}{2cm}}{}{}
makeatother
begin{document}
setcounter{chapter}{3}
section{Section Foo}
lipsum[1]
subsection{A subsection}label{s:first}
lipsum[2]
subsection{Another subsection}
lipsum[3-5]

section{Section Bar}
textbf{As seen in section ref{s:first}}
lipsum[5]
subsection{Test again}
lipsum[5]
end{document}


with the result:
enter image description here



Note 1: this works also with hyperref, provided you make the patch before loading it.



Note 2: This approach is likely not compatible with titlesec. It assumes that the sectioning commands (below chapter) are based on the standard @startsection command. This is not an issue as you can also patch in a similar way the format of the title for getting italic



Note 3: To determine the value of the second argument of patchcmd (which depends on the class and ptsize) you have to look at the content of the sectionng commands. For this purpose I use a custom command :



newcommand{mymeaning}[1]{{smallnoindent{bfseries string #1} = meaning #1parmedskip}}


based on the standard command meaning with some cosmetic, and do e.g. mymeaning{subsection} in the document.






share|improve this answer





















  • 1





    If you have chapters or part, ending a subsection you would have to apply to the corresponding command the same patch as for section, disabling the shift. I will soon provide the patch for the standard chapter. An other option (for chaoter) would be to alter the clearpage command.

    – Jhor
    Jan 31 at 7:48














3












3








3







In the same spirit as your first quoted answer and using etoolbox's patchcmd you can assume that leftskip is not used dor anything else, the magic is :



patchcmd{subsection}{-3.25ex@plus -1ex @minus -.2ex}{3.25ex@plus -1ex @minus -.2exsetlength{leftskip}{0cm}}{}{}
patchcmd{subsection}{1.5ex @plus .2ex}{1.5ex @plus .2exsetlength{leftskip}{2cm}}{}{}
patchcmd{section}{-3.5ex @plus -1ex @minus -.2ex}{-3.5ex @plus -1ex @minus -.2exsetlength{leftskip}{0cm}}{}{}


which switches off the shift at the beginning of the section and subsection, and switches it on when entering into subsection. Here is a MWE, in the which I changed the page size to fit the example on two pages:



documentclass[12pt,a4paper]{report}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
usepackage{lmodern}
usepackage{etoolbox}
usepackage{lipsum}
usepackage[margin=25mm]{geometry}

makeatletter
patchcmd{section}{-3.5ex @plus -1ex @minus -.2ex}{-3.5ex @plus -1ex @minus -.2exsetlength{leftskip}{0cm}}{}{}
patchcmd{subsection}{-3.25ex@plus -1ex @minus -.2ex}{3.25ex@plus -1ex @minus -.2exsetlength{leftskip}{0cm}}{}{}
patchcmd{subsection}{1.5ex @plus .2ex}{1.5ex @plus .2exsetlength{leftskip}{2cm}}{}{}
makeatother
begin{document}
setcounter{chapter}{3}
section{Section Foo}
lipsum[1]
subsection{A subsection}label{s:first}
lipsum[2]
subsection{Another subsection}
lipsum[3-5]

section{Section Bar}
textbf{As seen in section ref{s:first}}
lipsum[5]
subsection{Test again}
lipsum[5]
end{document}


with the result:
enter image description here



Note 1: this works also with hyperref, provided you make the patch before loading it.



Note 2: This approach is likely not compatible with titlesec. It assumes that the sectioning commands (below chapter) are based on the standard @startsection command. This is not an issue as you can also patch in a similar way the format of the title for getting italic



Note 3: To determine the value of the second argument of patchcmd (which depends on the class and ptsize) you have to look at the content of the sectionng commands. For this purpose I use a custom command :



newcommand{mymeaning}[1]{{smallnoindent{bfseries string #1} = meaning #1parmedskip}}


based on the standard command meaning with some cosmetic, and do e.g. mymeaning{subsection} in the document.






share|improve this answer















In the same spirit as your first quoted answer and using etoolbox's patchcmd you can assume that leftskip is not used dor anything else, the magic is :



patchcmd{subsection}{-3.25ex@plus -1ex @minus -.2ex}{3.25ex@plus -1ex @minus -.2exsetlength{leftskip}{0cm}}{}{}
patchcmd{subsection}{1.5ex @plus .2ex}{1.5ex @plus .2exsetlength{leftskip}{2cm}}{}{}
patchcmd{section}{-3.5ex @plus -1ex @minus -.2ex}{-3.5ex @plus -1ex @minus -.2exsetlength{leftskip}{0cm}}{}{}


which switches off the shift at the beginning of the section and subsection, and switches it on when entering into subsection. Here is a MWE, in the which I changed the page size to fit the example on two pages:



documentclass[12pt,a4paper]{report}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
usepackage{lmodern}
usepackage{etoolbox}
usepackage{lipsum}
usepackage[margin=25mm]{geometry}

makeatletter
patchcmd{section}{-3.5ex @plus -1ex @minus -.2ex}{-3.5ex @plus -1ex @minus -.2exsetlength{leftskip}{0cm}}{}{}
patchcmd{subsection}{-3.25ex@plus -1ex @minus -.2ex}{3.25ex@plus -1ex @minus -.2exsetlength{leftskip}{0cm}}{}{}
patchcmd{subsection}{1.5ex @plus .2ex}{1.5ex @plus .2exsetlength{leftskip}{2cm}}{}{}
makeatother
begin{document}
setcounter{chapter}{3}
section{Section Foo}
lipsum[1]
subsection{A subsection}label{s:first}
lipsum[2]
subsection{Another subsection}
lipsum[3-5]

section{Section Bar}
textbf{As seen in section ref{s:first}}
lipsum[5]
subsection{Test again}
lipsum[5]
end{document}


with the result:
enter image description here



Note 1: this works also with hyperref, provided you make the patch before loading it.



Note 2: This approach is likely not compatible with titlesec. It assumes that the sectioning commands (below chapter) are based on the standard @startsection command. This is not an issue as you can also patch in a similar way the format of the title for getting italic



Note 3: To determine the value of the second argument of patchcmd (which depends on the class and ptsize) you have to look at the content of the sectionng commands. For this purpose I use a custom command :



newcommand{mymeaning}[1]{{smallnoindent{bfseries string #1} = meaning #1parmedskip}}


based on the standard command meaning with some cosmetic, and do e.g. mymeaning{subsection} in the document.







share|improve this answer














share|improve this answer



share|improve this answer








edited Jan 31 at 7:54

























answered Jan 30 at 22:59









JhorJhor

2,2741014




2,2741014








  • 1





    If you have chapters or part, ending a subsection you would have to apply to the corresponding command the same patch as for section, disabling the shift. I will soon provide the patch for the standard chapter. An other option (for chaoter) would be to alter the clearpage command.

    – Jhor
    Jan 31 at 7:48














  • 1





    If you have chapters or part, ending a subsection you would have to apply to the corresponding command the same patch as for section, disabling the shift. I will soon provide the patch for the standard chapter. An other option (for chaoter) would be to alter the clearpage command.

    – Jhor
    Jan 31 at 7:48








1




1





If you have chapters or part, ending a subsection you would have to apply to the corresponding command the same patch as for section, disabling the shift. I will soon provide the patch for the standard chapter. An other option (for chaoter) would be to alter the clearpage command.

– Jhor
Jan 31 at 7:48





If you have chapters or part, ending a subsection you would have to apply to the corresponding command the same patch as for section, disabling the shift. I will soon provide the patch for the standard chapter. An other option (for chaoter) would be to alter the clearpage command.

– Jhor
Jan 31 at 7:48


















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%2f472440%2findent-whole-paragraphs-after-subsections%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

How to change which sound is reproduced for terminal bell?

Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

Can I use Tabulator js library in my java Spring + Thymeleaf project?