scrbook - How to add one horizontal line above and one below the chapter-entry without (!) using titlesec?How...
What was the first Intel x86 processor with "Base + Index * Scale + Displacement" addressing mode?
What happened to Captain America in Endgame?
Why does processed meat contain preservatives, while canned fish needs not?
Why other Westeros houses don't use wildfire?
Please, smoke with good manners
Is there an official tutorial for installing Ubuntu 18.04+ on a device with an SSD and an additional internal hard drive?
Do I have an "anti-research" personality?
A Note on N!
Does Gita support doctrine of eternal cycle of birth and death for evil people?
How to get a plain text file version of a CP/M .BAS (M-BASIC) program?
To say I met a person for the first time
What's the polite way to say "I need to urinate"?
How to make a pipeline wait for end-of-file or stop after an error?
Can SQL Server create collisions in system generated constraint names?
Can someone publish a story that happened to you?
How to pronounce 'C++' in Spanish
Map of water taps to fill bottles
How to have a sharp product image?
In order to check if a field is required or not, is the result of isNillable method sufficient?
Normal Map bad shading in Rendered display
Is there really no use for MD5 anymore?
Why was the Spitfire's elliptical wing almost uncopied by other aircraft of World War 2?
Which big number is bigger?
What route did the Hindenburg take when traveling from Germany to the U.S.?
scrbook - How to add one horizontal line above and one below the chapter-entry without (!) using titlesec?
How to add a line between chapter number and chapter titleAdd a rule after chapter title using titlesecTwo horizontal lines above and under chapter-entryHow to move section number and section into margin with scrbook without titlesecChange spacing above and below chapterSame chapterformat for chapter and chapter* without titlesectitleformat (in titlesec) doesn't show any horizontal line for chapterKOMA-Script line above and below chapter titleHorizontal lines above and below textChapter page numbers off-by-one when using SCRBook without chapter pagebreaks
I want to add one horizontal line above and one below the chapter-entry as well.
Before using the scrbook
-class, I used this simple solution made by titlesec
-package:
newpagestyle{headrules}{
headrule
% for twosided layout, use:
sethead[thepage][chaptertitle][] % even pages (left side of book)
{chaptertitle}{sectiontitle}{thepage} % odd pages (right side of book)
% for onesided layout, use:
% sethead{thechapter. chaptertitle}{}{thepage} % in this case, the document only has odd pages
}
Working minimum example:
documentclass{book}
usepackage[english]{babel}
usepackage[automark]{scrpage2}
usepackage[pagestyles]{titlesec}
usepackage{blindtext}
titleformat{chapter}[display]{fontfamily{pag}Largebfseries}{titlerule[4pt]chaptertitlename thechapter}{5pt}{large}[{titlerule[2pt]}]
titleformat{section}{fontfamily{pag}normalsizebfseries}{thesection}{5pt}{normalsize}
titleformat{subsection}{fontfamily{pag}normalsizebfseries}{thesubsection}{5pt}{normalsize}
titlespacing*{chapter}{0pt}{30pt}{20pt}
titlespacing*{section}{0pt}{20pt}{10pt}
titlespacing*{subsection}{0pt}{20pt}{5pt}
newpagestyle{headrules}{
headrule
% for twosided layout, use:
sethead[thepage][chaptertitle][] % even pages (left side of book)
{chaptertitle}{sectiontitle}{thepage} % odd pages (right side of book)
% for onesided layout, use:
% sethead{thechapter. chaptertitle}{}{thepage} % in this case, the document only has odd pages
}
setlength{headheight}{1.1baselineskip} % adjusting the height of head
pagestyle{headrules} % use this style instead of pagestyle{plain}
begin{document}
blinddocument
end{document}
Screenshot:
So, the question now is: How can I solve this without using the titlesec
-package anymore? Using titlesec
together with a KOMA-class is not recommended, and I prefer to use the scrbook
-class instead of book
because of those many great advantages (for example addchap
and others)...
Do I have to change the pagestyle plain
-format for this?
Thank you very much for your help!
The following solution from clemens for separating chapters
and addchaps
seems to make sense, but it doesn't work in the following minimal-example (don't know why):
documentclass[chapterprefix=true]{scrbook}
renewcommand*chapterheadstartvskip{%
ifnumbered{chapter}
{noindentrule{linewidth}{4pt}parvspace*{-4pt}}
{}%
}
renewcommand*chapterheadendvskip{%
ifnumbered{chapter}
{vspace*{-4pt}noindentrule{linewidth}{2pt}parvspace{baselineskip}}
{}%
}
begin{document}
chapter{Experimental chapter-entry}
addchap{Experimental addchap-entry}
end{document}
It doesn't matter if there's a numbered chapter
or an unnumbered addchap
- either the selected line is existent or absent in both selectors...
Is there any mistake in my line of thought?
Solution: Upgrading to KOMA-Script v3.18 brought the solution for me, too! Thank you very much clemens and all the others who were helping me!
Thanks a lot for your patient help!
sectioning chapters koma-script rules scrbook
|
show 4 more comments
I want to add one horizontal line above and one below the chapter-entry as well.
Before using the scrbook
-class, I used this simple solution made by titlesec
-package:
newpagestyle{headrules}{
headrule
% for twosided layout, use:
sethead[thepage][chaptertitle][] % even pages (left side of book)
{chaptertitle}{sectiontitle}{thepage} % odd pages (right side of book)
% for onesided layout, use:
% sethead{thechapter. chaptertitle}{}{thepage} % in this case, the document only has odd pages
}
Working minimum example:
documentclass{book}
usepackage[english]{babel}
usepackage[automark]{scrpage2}
usepackage[pagestyles]{titlesec}
usepackage{blindtext}
titleformat{chapter}[display]{fontfamily{pag}Largebfseries}{titlerule[4pt]chaptertitlename thechapter}{5pt}{large}[{titlerule[2pt]}]
titleformat{section}{fontfamily{pag}normalsizebfseries}{thesection}{5pt}{normalsize}
titleformat{subsection}{fontfamily{pag}normalsizebfseries}{thesubsection}{5pt}{normalsize}
titlespacing*{chapter}{0pt}{30pt}{20pt}
titlespacing*{section}{0pt}{20pt}{10pt}
titlespacing*{subsection}{0pt}{20pt}{5pt}
newpagestyle{headrules}{
headrule
% for twosided layout, use:
sethead[thepage][chaptertitle][] % even pages (left side of book)
{chaptertitle}{sectiontitle}{thepage} % odd pages (right side of book)
% for onesided layout, use:
% sethead{thechapter. chaptertitle}{}{thepage} % in this case, the document only has odd pages
}
setlength{headheight}{1.1baselineskip} % adjusting the height of head
pagestyle{headrules} % use this style instead of pagestyle{plain}
begin{document}
blinddocument
end{document}
Screenshot:
So, the question now is: How can I solve this without using the titlesec
-package anymore? Using titlesec
together with a KOMA-class is not recommended, and I prefer to use the scrbook
-class instead of book
because of those many great advantages (for example addchap
and others)...
Do I have to change the pagestyle plain
-format for this?
Thank you very much for your help!
The following solution from clemens for separating chapters
and addchaps
seems to make sense, but it doesn't work in the following minimal-example (don't know why):
documentclass[chapterprefix=true]{scrbook}
renewcommand*chapterheadstartvskip{%
ifnumbered{chapter}
{noindentrule{linewidth}{4pt}parvspace*{-4pt}}
{}%
}
renewcommand*chapterheadendvskip{%
ifnumbered{chapter}
{vspace*{-4pt}noindentrule{linewidth}{2pt}parvspace{baselineskip}}
{}%
}
begin{document}
chapter{Experimental chapter-entry}
addchap{Experimental addchap-entry}
end{document}
It doesn't matter if there's a numbered chapter
or an unnumbered addchap
- either the selected line is existent or absent in both selectors...
Is there any mistake in my line of thought?
Solution: Upgrading to KOMA-Script v3.18 brought the solution for me, too! Thank you very much clemens and all the others who were helping me!
Thanks a lot for your patient help!
sectioning chapters koma-script rules scrbook
It is a wellknown fact that KOMA classes andtitlesec
should not used together (And no,fancyhdr
is no good idea with KOMA as well)
– user31729
Jul 11 '15 at 11:27
Of course, this is a well known fact! But thanks a lot for your hint, I've changed the subject and explanatory text a bit...
– Dave
Jul 11 '15 at 11:36
Thescrpage2
package is outdated. Usescrlayer-scrpage
instead.
– user31729
Jul 11 '15 at 11:41
3
I would usechapterheadstartvskip
andchapterheadendvskip
to add the lines. (And it is imho a not so well known fact, that it is difficult to create fancy sectioning commands only with KOMA-tools. )
– Ulrike Fischer
Jul 11 '15 at 11:46
See komascript.de/node/486
– Andrew Swann
Jul 11 '15 at 13:07
|
show 4 more comments
I want to add one horizontal line above and one below the chapter-entry as well.
Before using the scrbook
-class, I used this simple solution made by titlesec
-package:
newpagestyle{headrules}{
headrule
% for twosided layout, use:
sethead[thepage][chaptertitle][] % even pages (left side of book)
{chaptertitle}{sectiontitle}{thepage} % odd pages (right side of book)
% for onesided layout, use:
% sethead{thechapter. chaptertitle}{}{thepage} % in this case, the document only has odd pages
}
Working minimum example:
documentclass{book}
usepackage[english]{babel}
usepackage[automark]{scrpage2}
usepackage[pagestyles]{titlesec}
usepackage{blindtext}
titleformat{chapter}[display]{fontfamily{pag}Largebfseries}{titlerule[4pt]chaptertitlename thechapter}{5pt}{large}[{titlerule[2pt]}]
titleformat{section}{fontfamily{pag}normalsizebfseries}{thesection}{5pt}{normalsize}
titleformat{subsection}{fontfamily{pag}normalsizebfseries}{thesubsection}{5pt}{normalsize}
titlespacing*{chapter}{0pt}{30pt}{20pt}
titlespacing*{section}{0pt}{20pt}{10pt}
titlespacing*{subsection}{0pt}{20pt}{5pt}
newpagestyle{headrules}{
headrule
% for twosided layout, use:
sethead[thepage][chaptertitle][] % even pages (left side of book)
{chaptertitle}{sectiontitle}{thepage} % odd pages (right side of book)
% for onesided layout, use:
% sethead{thechapter. chaptertitle}{}{thepage} % in this case, the document only has odd pages
}
setlength{headheight}{1.1baselineskip} % adjusting the height of head
pagestyle{headrules} % use this style instead of pagestyle{plain}
begin{document}
blinddocument
end{document}
Screenshot:
So, the question now is: How can I solve this without using the titlesec
-package anymore? Using titlesec
together with a KOMA-class is not recommended, and I prefer to use the scrbook
-class instead of book
because of those many great advantages (for example addchap
and others)...
Do I have to change the pagestyle plain
-format for this?
Thank you very much for your help!
The following solution from clemens for separating chapters
and addchaps
seems to make sense, but it doesn't work in the following minimal-example (don't know why):
documentclass[chapterprefix=true]{scrbook}
renewcommand*chapterheadstartvskip{%
ifnumbered{chapter}
{noindentrule{linewidth}{4pt}parvspace*{-4pt}}
{}%
}
renewcommand*chapterheadendvskip{%
ifnumbered{chapter}
{vspace*{-4pt}noindentrule{linewidth}{2pt}parvspace{baselineskip}}
{}%
}
begin{document}
chapter{Experimental chapter-entry}
addchap{Experimental addchap-entry}
end{document}
It doesn't matter if there's a numbered chapter
or an unnumbered addchap
- either the selected line is existent or absent in both selectors...
Is there any mistake in my line of thought?
Solution: Upgrading to KOMA-Script v3.18 brought the solution for me, too! Thank you very much clemens and all the others who were helping me!
Thanks a lot for your patient help!
sectioning chapters koma-script rules scrbook
I want to add one horizontal line above and one below the chapter-entry as well.
Before using the scrbook
-class, I used this simple solution made by titlesec
-package:
newpagestyle{headrules}{
headrule
% for twosided layout, use:
sethead[thepage][chaptertitle][] % even pages (left side of book)
{chaptertitle}{sectiontitle}{thepage} % odd pages (right side of book)
% for onesided layout, use:
% sethead{thechapter. chaptertitle}{}{thepage} % in this case, the document only has odd pages
}
Working minimum example:
documentclass{book}
usepackage[english]{babel}
usepackage[automark]{scrpage2}
usepackage[pagestyles]{titlesec}
usepackage{blindtext}
titleformat{chapter}[display]{fontfamily{pag}Largebfseries}{titlerule[4pt]chaptertitlename thechapter}{5pt}{large}[{titlerule[2pt]}]
titleformat{section}{fontfamily{pag}normalsizebfseries}{thesection}{5pt}{normalsize}
titleformat{subsection}{fontfamily{pag}normalsizebfseries}{thesubsection}{5pt}{normalsize}
titlespacing*{chapter}{0pt}{30pt}{20pt}
titlespacing*{section}{0pt}{20pt}{10pt}
titlespacing*{subsection}{0pt}{20pt}{5pt}
newpagestyle{headrules}{
headrule
% for twosided layout, use:
sethead[thepage][chaptertitle][] % even pages (left side of book)
{chaptertitle}{sectiontitle}{thepage} % odd pages (right side of book)
% for onesided layout, use:
% sethead{thechapter. chaptertitle}{}{thepage} % in this case, the document only has odd pages
}
setlength{headheight}{1.1baselineskip} % adjusting the height of head
pagestyle{headrules} % use this style instead of pagestyle{plain}
begin{document}
blinddocument
end{document}
Screenshot:
So, the question now is: How can I solve this without using the titlesec
-package anymore? Using titlesec
together with a KOMA-class is not recommended, and I prefer to use the scrbook
-class instead of book
because of those many great advantages (for example addchap
and others)...
Do I have to change the pagestyle plain
-format for this?
Thank you very much for your help!
The following solution from clemens for separating chapters
and addchaps
seems to make sense, but it doesn't work in the following minimal-example (don't know why):
documentclass[chapterprefix=true]{scrbook}
renewcommand*chapterheadstartvskip{%
ifnumbered{chapter}
{noindentrule{linewidth}{4pt}parvspace*{-4pt}}
{}%
}
renewcommand*chapterheadendvskip{%
ifnumbered{chapter}
{vspace*{-4pt}noindentrule{linewidth}{2pt}parvspace{baselineskip}}
{}%
}
begin{document}
chapter{Experimental chapter-entry}
addchap{Experimental addchap-entry}
end{document}
It doesn't matter if there's a numbered chapter
or an unnumbered addchap
- either the selected line is existent or absent in both selectors...
Is there any mistake in my line of thought?
Solution: Upgrading to KOMA-Script v3.18 brought the solution for me, too! Thank you very much clemens and all the others who were helping me!
Thanks a lot for your patient help!
sectioning chapters koma-script rules scrbook
sectioning chapters koma-script rules scrbook
edited Jul 11 '15 at 17:51
Dave
asked Jul 11 '15 at 11:24
DaveDave
1,336621
1,336621
It is a wellknown fact that KOMA classes andtitlesec
should not used together (And no,fancyhdr
is no good idea with KOMA as well)
– user31729
Jul 11 '15 at 11:27
Of course, this is a well known fact! But thanks a lot for your hint, I've changed the subject and explanatory text a bit...
– Dave
Jul 11 '15 at 11:36
Thescrpage2
package is outdated. Usescrlayer-scrpage
instead.
– user31729
Jul 11 '15 at 11:41
3
I would usechapterheadstartvskip
andchapterheadendvskip
to add the lines. (And it is imho a not so well known fact, that it is difficult to create fancy sectioning commands only with KOMA-tools. )
– Ulrike Fischer
Jul 11 '15 at 11:46
See komascript.de/node/486
– Andrew Swann
Jul 11 '15 at 13:07
|
show 4 more comments
It is a wellknown fact that KOMA classes andtitlesec
should not used together (And no,fancyhdr
is no good idea with KOMA as well)
– user31729
Jul 11 '15 at 11:27
Of course, this is a well known fact! But thanks a lot for your hint, I've changed the subject and explanatory text a bit...
– Dave
Jul 11 '15 at 11:36
Thescrpage2
package is outdated. Usescrlayer-scrpage
instead.
– user31729
Jul 11 '15 at 11:41
3
I would usechapterheadstartvskip
andchapterheadendvskip
to add the lines. (And it is imho a not so well known fact, that it is difficult to create fancy sectioning commands only with KOMA-tools. )
– Ulrike Fischer
Jul 11 '15 at 11:46
See komascript.de/node/486
– Andrew Swann
Jul 11 '15 at 13:07
It is a wellknown fact that KOMA classes and
titlesec
should not used together (And no, fancyhdr
is no good idea with KOMA as well)– user31729
Jul 11 '15 at 11:27
It is a wellknown fact that KOMA classes and
titlesec
should not used together (And no, fancyhdr
is no good idea with KOMA as well)– user31729
Jul 11 '15 at 11:27
Of course, this is a well known fact! But thanks a lot for your hint, I've changed the subject and explanatory text a bit...
– Dave
Jul 11 '15 at 11:36
Of course, this is a well known fact! But thanks a lot for your hint, I've changed the subject and explanatory text a bit...
– Dave
Jul 11 '15 at 11:36
The
scrpage2
package is outdated. Use scrlayer-scrpage
instead.– user31729
Jul 11 '15 at 11:41
The
scrpage2
package is outdated. Use scrlayer-scrpage
instead.– user31729
Jul 11 '15 at 11:41
3
3
I would use
chapterheadstartvskip
and chapterheadendvskip
to add the lines. (And it is imho a not so well known fact, that it is difficult to create fancy sectioning commands only with KOMA-tools. )– Ulrike Fischer
Jul 11 '15 at 11:46
I would use
chapterheadstartvskip
and chapterheadendvskip
to add the lines. (And it is imho a not so well known fact, that it is difficult to create fancy sectioning commands only with KOMA-tools. )– Ulrike Fischer
Jul 11 '15 at 11:46
See komascript.de/node/486
– Andrew Swann
Jul 11 '15 at 13:07
See komascript.de/node/486
– Andrew Swann
Jul 11 '15 at 13:07
|
show 4 more comments
2 Answers
2
active
oldest
votes
Update
With KOMA-Script Version 3.19 or newer there is another possibility: you can redefine the new command chapterlineswithprefixformat
to insert the lines:
newcommandtitlerule[1][1pt]{rule{textwidth}{#1}}
renewcommandchapterlineswithprefixformat[3]{%
ifstr{#2}{}{}{titlerule[4pt]par}%
#2#3titlerule[2pt]%
}
MWE:
documentclass[
chapterprefix=true
]{scrbook}[2015/09/29]% needs version 3.19 or newer
RedeclareSectionCommand[
beforeskip=0pt,
afterskip=1baselineskip
]{chapter}
newcommandtitlerule[1][1pt]{rule{textwidth}{#1}}
renewcommandchapterlineswithprefixformat[3]{%
ifstr{#2}{}{}{titlerule[4pt]parnobreak}%
#2#3parnobreaktitlerule[2pt]%
}
usepackage{blindtext}
begin{document}
chapter{Experimental chapter-entry}
blindtext
addchap{Experimental addchap-entry}
blindtext
chapter*{Experimental chapter*-entry}
blindtext
addchap*{Experimental addchap*-entry}
blindtext
end{document}
If this should also work with option chapterprefixline=false
add the following lines to the preamble:
makeatletter
renewcommandchapterlinesformat[3]{%
@hangfrom{#2}{#3}parnobreaktitlerule%
}
makeatother
Original answer
If the line above the chapter heading should only be inserted if the chapterprefix
is written you could insert this line in chapterformat
. This works also for chapter*
and addchap*
.
documentclass[chapterprefix=true]{scrbook}
RedeclareSectionCommand[
beforeskip=0pt,
afterskip=1baselineskip
]{chapter}
usepackage{etoolbox}
newcommandtitlerule[1][1pt]{noindentrule{linewidth}{#1}par}
pretochapterformat{IfUsePrefixLine{vspace{-baselineskip}titlerule[4pt]}{}}
pretochapterheadendvskip{titlerule[2pt]}
usepackage{blindtext}
begin{document}
chapter{Experimental chapter-entry}
blindtext
addchap{Experimental addchap-entry}
blindtext
chapter*{Experimental chapter*-entry}
blindtext
addchap*{Experimental addchap*-entry}
blindtext
end{document}
add a comment |
Despite their name the usual way with KOMA-Script is to redefine chapterheadstartvskip
and chapterheadendvskip
:
documentclass[chapterprefix=true]{scrbook}
renewcommand*chapterheadstartvskip{noindentrule{linewidth}{4pt}par}
renewcommand*chapterheadendvskip{noindentrule{linewidth}{2pt}parvspace{baselineskip}}
usepackage{blindtext}
begin{document}
blinddocument
end{document}
With slightly altered definitions only number chapters will get the rules. Adding vspace*
s at the right place will move the lines closer to the text:
renewcommand*chapterheadstartvskip{%
ifnumbered{chapter}
{noindentrule{linewidth}{4pt}parvspace*{-4pt}}
{}%
}
renewcommand*chapterheadendvskip{%
ifnumbered{chapter}
{vspace*{-4pt}noindentrule{linewidth}{2pt}parvspace{baselineskip}}
{}%
}
Thank you very much for your advice! This works actually perfect! There are only two more things: 1.) Like in the advice from Andrew Swann, I can't adjust the space between the chapters name and therule
. I've tried to setrule[2mm]{linewidth}
, but this does only move the existing text below the line, but not the line itself... 2.) How can I set making the toprule
only to "real/original" chapter-headlines, but not toaddchap
-headlines? The foreword, table of content, acronymslist e.g. only useaddchap
-headlines, and they should not get the top line (for those only line below).
– Dave
Jul 11 '15 at 14:08
@Dave Do you mean between the first rule and the text or between the text and the second rule? Anyway, somevspace*
in the right place should do. Withifnumbered{chapter}{<true>}{<false>}
within the redefinition you can add the rules only for numbered chapters if placing them in the<true>
branch
– clemens
Jul 11 '15 at 14:15
... or should I poste a new question because of that: "How to select only "real"chapter
-headlines exceptaddchap
-headlines simultaneously?"
– Dave
Jul 11 '15 at 14:17
Thank you very much for your great support! The spaces are customized now! Thevspace*
-command has been at the wrong place during my experiment indeed, it has to be placed beforenoindent
and everything works fine now! Furthermore I've tried to setifnumbered{chapter}{renewcommand*chapterheadstartvskip{noindentrule{linewidth}{4pt}par}}{}
, but this doesn't work. Is there any mistake?
– Dave
Jul 11 '15 at 14:35
@Daveifnumbered
needs to be inside the definition, see my edited answer
– clemens
Jul 11 '15 at 14:37
|
show 3 more comments
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%2f254824%2fscrbook-how-to-add-one-horizontal-line-above-and-one-below-the-chapter-entry-w%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
Update
With KOMA-Script Version 3.19 or newer there is another possibility: you can redefine the new command chapterlineswithprefixformat
to insert the lines:
newcommandtitlerule[1][1pt]{rule{textwidth}{#1}}
renewcommandchapterlineswithprefixformat[3]{%
ifstr{#2}{}{}{titlerule[4pt]par}%
#2#3titlerule[2pt]%
}
MWE:
documentclass[
chapterprefix=true
]{scrbook}[2015/09/29]% needs version 3.19 or newer
RedeclareSectionCommand[
beforeskip=0pt,
afterskip=1baselineskip
]{chapter}
newcommandtitlerule[1][1pt]{rule{textwidth}{#1}}
renewcommandchapterlineswithprefixformat[3]{%
ifstr{#2}{}{}{titlerule[4pt]parnobreak}%
#2#3parnobreaktitlerule[2pt]%
}
usepackage{blindtext}
begin{document}
chapter{Experimental chapter-entry}
blindtext
addchap{Experimental addchap-entry}
blindtext
chapter*{Experimental chapter*-entry}
blindtext
addchap*{Experimental addchap*-entry}
blindtext
end{document}
If this should also work with option chapterprefixline=false
add the following lines to the preamble:
makeatletter
renewcommandchapterlinesformat[3]{%
@hangfrom{#2}{#3}parnobreaktitlerule%
}
makeatother
Original answer
If the line above the chapter heading should only be inserted if the chapterprefix
is written you could insert this line in chapterformat
. This works also for chapter*
and addchap*
.
documentclass[chapterprefix=true]{scrbook}
RedeclareSectionCommand[
beforeskip=0pt,
afterskip=1baselineskip
]{chapter}
usepackage{etoolbox}
newcommandtitlerule[1][1pt]{noindentrule{linewidth}{#1}par}
pretochapterformat{IfUsePrefixLine{vspace{-baselineskip}titlerule[4pt]}{}}
pretochapterheadendvskip{titlerule[2pt]}
usepackage{blindtext}
begin{document}
chapter{Experimental chapter-entry}
blindtext
addchap{Experimental addchap-entry}
blindtext
chapter*{Experimental chapter*-entry}
blindtext
addchap*{Experimental addchap*-entry}
blindtext
end{document}
add a comment |
Update
With KOMA-Script Version 3.19 or newer there is another possibility: you can redefine the new command chapterlineswithprefixformat
to insert the lines:
newcommandtitlerule[1][1pt]{rule{textwidth}{#1}}
renewcommandchapterlineswithprefixformat[3]{%
ifstr{#2}{}{}{titlerule[4pt]par}%
#2#3titlerule[2pt]%
}
MWE:
documentclass[
chapterprefix=true
]{scrbook}[2015/09/29]% needs version 3.19 or newer
RedeclareSectionCommand[
beforeskip=0pt,
afterskip=1baselineskip
]{chapter}
newcommandtitlerule[1][1pt]{rule{textwidth}{#1}}
renewcommandchapterlineswithprefixformat[3]{%
ifstr{#2}{}{}{titlerule[4pt]parnobreak}%
#2#3parnobreaktitlerule[2pt]%
}
usepackage{blindtext}
begin{document}
chapter{Experimental chapter-entry}
blindtext
addchap{Experimental addchap-entry}
blindtext
chapter*{Experimental chapter*-entry}
blindtext
addchap*{Experimental addchap*-entry}
blindtext
end{document}
If this should also work with option chapterprefixline=false
add the following lines to the preamble:
makeatletter
renewcommandchapterlinesformat[3]{%
@hangfrom{#2}{#3}parnobreaktitlerule%
}
makeatother
Original answer
If the line above the chapter heading should only be inserted if the chapterprefix
is written you could insert this line in chapterformat
. This works also for chapter*
and addchap*
.
documentclass[chapterprefix=true]{scrbook}
RedeclareSectionCommand[
beforeskip=0pt,
afterskip=1baselineskip
]{chapter}
usepackage{etoolbox}
newcommandtitlerule[1][1pt]{noindentrule{linewidth}{#1}par}
pretochapterformat{IfUsePrefixLine{vspace{-baselineskip}titlerule[4pt]}{}}
pretochapterheadendvskip{titlerule[2pt]}
usepackage{blindtext}
begin{document}
chapter{Experimental chapter-entry}
blindtext
addchap{Experimental addchap-entry}
blindtext
chapter*{Experimental chapter*-entry}
blindtext
addchap*{Experimental addchap*-entry}
blindtext
end{document}
add a comment |
Update
With KOMA-Script Version 3.19 or newer there is another possibility: you can redefine the new command chapterlineswithprefixformat
to insert the lines:
newcommandtitlerule[1][1pt]{rule{textwidth}{#1}}
renewcommandchapterlineswithprefixformat[3]{%
ifstr{#2}{}{}{titlerule[4pt]par}%
#2#3titlerule[2pt]%
}
MWE:
documentclass[
chapterprefix=true
]{scrbook}[2015/09/29]% needs version 3.19 or newer
RedeclareSectionCommand[
beforeskip=0pt,
afterskip=1baselineskip
]{chapter}
newcommandtitlerule[1][1pt]{rule{textwidth}{#1}}
renewcommandchapterlineswithprefixformat[3]{%
ifstr{#2}{}{}{titlerule[4pt]parnobreak}%
#2#3parnobreaktitlerule[2pt]%
}
usepackage{blindtext}
begin{document}
chapter{Experimental chapter-entry}
blindtext
addchap{Experimental addchap-entry}
blindtext
chapter*{Experimental chapter*-entry}
blindtext
addchap*{Experimental addchap*-entry}
blindtext
end{document}
If this should also work with option chapterprefixline=false
add the following lines to the preamble:
makeatletter
renewcommandchapterlinesformat[3]{%
@hangfrom{#2}{#3}parnobreaktitlerule%
}
makeatother
Original answer
If the line above the chapter heading should only be inserted if the chapterprefix
is written you could insert this line in chapterformat
. This works also for chapter*
and addchap*
.
documentclass[chapterprefix=true]{scrbook}
RedeclareSectionCommand[
beforeskip=0pt,
afterskip=1baselineskip
]{chapter}
usepackage{etoolbox}
newcommandtitlerule[1][1pt]{noindentrule{linewidth}{#1}par}
pretochapterformat{IfUsePrefixLine{vspace{-baselineskip}titlerule[4pt]}{}}
pretochapterheadendvskip{titlerule[2pt]}
usepackage{blindtext}
begin{document}
chapter{Experimental chapter-entry}
blindtext
addchap{Experimental addchap-entry}
blindtext
chapter*{Experimental chapter*-entry}
blindtext
addchap*{Experimental addchap*-entry}
blindtext
end{document}
Update
With KOMA-Script Version 3.19 or newer there is another possibility: you can redefine the new command chapterlineswithprefixformat
to insert the lines:
newcommandtitlerule[1][1pt]{rule{textwidth}{#1}}
renewcommandchapterlineswithprefixformat[3]{%
ifstr{#2}{}{}{titlerule[4pt]par}%
#2#3titlerule[2pt]%
}
MWE:
documentclass[
chapterprefix=true
]{scrbook}[2015/09/29]% needs version 3.19 or newer
RedeclareSectionCommand[
beforeskip=0pt,
afterskip=1baselineskip
]{chapter}
newcommandtitlerule[1][1pt]{rule{textwidth}{#1}}
renewcommandchapterlineswithprefixformat[3]{%
ifstr{#2}{}{}{titlerule[4pt]parnobreak}%
#2#3parnobreaktitlerule[2pt]%
}
usepackage{blindtext}
begin{document}
chapter{Experimental chapter-entry}
blindtext
addchap{Experimental addchap-entry}
blindtext
chapter*{Experimental chapter*-entry}
blindtext
addchap*{Experimental addchap*-entry}
blindtext
end{document}
If this should also work with option chapterprefixline=false
add the following lines to the preamble:
makeatletter
renewcommandchapterlinesformat[3]{%
@hangfrom{#2}{#3}parnobreaktitlerule%
}
makeatother
Original answer
If the line above the chapter heading should only be inserted if the chapterprefix
is written you could insert this line in chapterformat
. This works also for chapter*
and addchap*
.
documentclass[chapterprefix=true]{scrbook}
RedeclareSectionCommand[
beforeskip=0pt,
afterskip=1baselineskip
]{chapter}
usepackage{etoolbox}
newcommandtitlerule[1][1pt]{noindentrule{linewidth}{#1}par}
pretochapterformat{IfUsePrefixLine{vspace{-baselineskip}titlerule[4pt]}{}}
pretochapterheadendvskip{titlerule[2pt]}
usepackage{blindtext}
begin{document}
chapter{Experimental chapter-entry}
blindtext
addchap{Experimental addchap-entry}
blindtext
chapter*{Experimental chapter*-entry}
blindtext
addchap*{Experimental addchap*-entry}
blindtext
end{document}
edited 40 mins ago
answered Jul 12 '15 at 7:14
esddesdd
60.4k34793
60.4k34793
add a comment |
add a comment |
Despite their name the usual way with KOMA-Script is to redefine chapterheadstartvskip
and chapterheadendvskip
:
documentclass[chapterprefix=true]{scrbook}
renewcommand*chapterheadstartvskip{noindentrule{linewidth}{4pt}par}
renewcommand*chapterheadendvskip{noindentrule{linewidth}{2pt}parvspace{baselineskip}}
usepackage{blindtext}
begin{document}
blinddocument
end{document}
With slightly altered definitions only number chapters will get the rules. Adding vspace*
s at the right place will move the lines closer to the text:
renewcommand*chapterheadstartvskip{%
ifnumbered{chapter}
{noindentrule{linewidth}{4pt}parvspace*{-4pt}}
{}%
}
renewcommand*chapterheadendvskip{%
ifnumbered{chapter}
{vspace*{-4pt}noindentrule{linewidth}{2pt}parvspace{baselineskip}}
{}%
}
Thank you very much for your advice! This works actually perfect! There are only two more things: 1.) Like in the advice from Andrew Swann, I can't adjust the space between the chapters name and therule
. I've tried to setrule[2mm]{linewidth}
, but this does only move the existing text below the line, but not the line itself... 2.) How can I set making the toprule
only to "real/original" chapter-headlines, but not toaddchap
-headlines? The foreword, table of content, acronymslist e.g. only useaddchap
-headlines, and they should not get the top line (for those only line below).
– Dave
Jul 11 '15 at 14:08
@Dave Do you mean between the first rule and the text or between the text and the second rule? Anyway, somevspace*
in the right place should do. Withifnumbered{chapter}{<true>}{<false>}
within the redefinition you can add the rules only for numbered chapters if placing them in the<true>
branch
– clemens
Jul 11 '15 at 14:15
... or should I poste a new question because of that: "How to select only "real"chapter
-headlines exceptaddchap
-headlines simultaneously?"
– Dave
Jul 11 '15 at 14:17
Thank you very much for your great support! The spaces are customized now! Thevspace*
-command has been at the wrong place during my experiment indeed, it has to be placed beforenoindent
and everything works fine now! Furthermore I've tried to setifnumbered{chapter}{renewcommand*chapterheadstartvskip{noindentrule{linewidth}{4pt}par}}{}
, but this doesn't work. Is there any mistake?
– Dave
Jul 11 '15 at 14:35
@Daveifnumbered
needs to be inside the definition, see my edited answer
– clemens
Jul 11 '15 at 14:37
|
show 3 more comments
Despite their name the usual way with KOMA-Script is to redefine chapterheadstartvskip
and chapterheadendvskip
:
documentclass[chapterprefix=true]{scrbook}
renewcommand*chapterheadstartvskip{noindentrule{linewidth}{4pt}par}
renewcommand*chapterheadendvskip{noindentrule{linewidth}{2pt}parvspace{baselineskip}}
usepackage{blindtext}
begin{document}
blinddocument
end{document}
With slightly altered definitions only number chapters will get the rules. Adding vspace*
s at the right place will move the lines closer to the text:
renewcommand*chapterheadstartvskip{%
ifnumbered{chapter}
{noindentrule{linewidth}{4pt}parvspace*{-4pt}}
{}%
}
renewcommand*chapterheadendvskip{%
ifnumbered{chapter}
{vspace*{-4pt}noindentrule{linewidth}{2pt}parvspace{baselineskip}}
{}%
}
Thank you very much for your advice! This works actually perfect! There are only two more things: 1.) Like in the advice from Andrew Swann, I can't adjust the space between the chapters name and therule
. I've tried to setrule[2mm]{linewidth}
, but this does only move the existing text below the line, but not the line itself... 2.) How can I set making the toprule
only to "real/original" chapter-headlines, but not toaddchap
-headlines? The foreword, table of content, acronymslist e.g. only useaddchap
-headlines, and they should not get the top line (for those only line below).
– Dave
Jul 11 '15 at 14:08
@Dave Do you mean between the first rule and the text or between the text and the second rule? Anyway, somevspace*
in the right place should do. Withifnumbered{chapter}{<true>}{<false>}
within the redefinition you can add the rules only for numbered chapters if placing them in the<true>
branch
– clemens
Jul 11 '15 at 14:15
... or should I poste a new question because of that: "How to select only "real"chapter
-headlines exceptaddchap
-headlines simultaneously?"
– Dave
Jul 11 '15 at 14:17
Thank you very much for your great support! The spaces are customized now! Thevspace*
-command has been at the wrong place during my experiment indeed, it has to be placed beforenoindent
and everything works fine now! Furthermore I've tried to setifnumbered{chapter}{renewcommand*chapterheadstartvskip{noindentrule{linewidth}{4pt}par}}{}
, but this doesn't work. Is there any mistake?
– Dave
Jul 11 '15 at 14:35
@Daveifnumbered
needs to be inside the definition, see my edited answer
– clemens
Jul 11 '15 at 14:37
|
show 3 more comments
Despite their name the usual way with KOMA-Script is to redefine chapterheadstartvskip
and chapterheadendvskip
:
documentclass[chapterprefix=true]{scrbook}
renewcommand*chapterheadstartvskip{noindentrule{linewidth}{4pt}par}
renewcommand*chapterheadendvskip{noindentrule{linewidth}{2pt}parvspace{baselineskip}}
usepackage{blindtext}
begin{document}
blinddocument
end{document}
With slightly altered definitions only number chapters will get the rules. Adding vspace*
s at the right place will move the lines closer to the text:
renewcommand*chapterheadstartvskip{%
ifnumbered{chapter}
{noindentrule{linewidth}{4pt}parvspace*{-4pt}}
{}%
}
renewcommand*chapterheadendvskip{%
ifnumbered{chapter}
{vspace*{-4pt}noindentrule{linewidth}{2pt}parvspace{baselineskip}}
{}%
}
Despite their name the usual way with KOMA-Script is to redefine chapterheadstartvskip
and chapterheadendvskip
:
documentclass[chapterprefix=true]{scrbook}
renewcommand*chapterheadstartvskip{noindentrule{linewidth}{4pt}par}
renewcommand*chapterheadendvskip{noindentrule{linewidth}{2pt}parvspace{baselineskip}}
usepackage{blindtext}
begin{document}
blinddocument
end{document}
With slightly altered definitions only number chapters will get the rules. Adding vspace*
s at the right place will move the lines closer to the text:
renewcommand*chapterheadstartvskip{%
ifnumbered{chapter}
{noindentrule{linewidth}{4pt}parvspace*{-4pt}}
{}%
}
renewcommand*chapterheadendvskip{%
ifnumbered{chapter}
{vspace*{-4pt}noindentrule{linewidth}{2pt}parvspace{baselineskip}}
{}%
}
edited Jul 11 '15 at 14:36
answered Jul 11 '15 at 13:44
clemensclemens
51.9k5132285
51.9k5132285
Thank you very much for your advice! This works actually perfect! There are only two more things: 1.) Like in the advice from Andrew Swann, I can't adjust the space between the chapters name and therule
. I've tried to setrule[2mm]{linewidth}
, but this does only move the existing text below the line, but not the line itself... 2.) How can I set making the toprule
only to "real/original" chapter-headlines, but not toaddchap
-headlines? The foreword, table of content, acronymslist e.g. only useaddchap
-headlines, and they should not get the top line (for those only line below).
– Dave
Jul 11 '15 at 14:08
@Dave Do you mean between the first rule and the text or between the text and the second rule? Anyway, somevspace*
in the right place should do. Withifnumbered{chapter}{<true>}{<false>}
within the redefinition you can add the rules only for numbered chapters if placing them in the<true>
branch
– clemens
Jul 11 '15 at 14:15
... or should I poste a new question because of that: "How to select only "real"chapter
-headlines exceptaddchap
-headlines simultaneously?"
– Dave
Jul 11 '15 at 14:17
Thank you very much for your great support! The spaces are customized now! Thevspace*
-command has been at the wrong place during my experiment indeed, it has to be placed beforenoindent
and everything works fine now! Furthermore I've tried to setifnumbered{chapter}{renewcommand*chapterheadstartvskip{noindentrule{linewidth}{4pt}par}}{}
, but this doesn't work. Is there any mistake?
– Dave
Jul 11 '15 at 14:35
@Daveifnumbered
needs to be inside the definition, see my edited answer
– clemens
Jul 11 '15 at 14:37
|
show 3 more comments
Thank you very much for your advice! This works actually perfect! There are only two more things: 1.) Like in the advice from Andrew Swann, I can't adjust the space between the chapters name and therule
. I've tried to setrule[2mm]{linewidth}
, but this does only move the existing text below the line, but not the line itself... 2.) How can I set making the toprule
only to "real/original" chapter-headlines, but not toaddchap
-headlines? The foreword, table of content, acronymslist e.g. only useaddchap
-headlines, and they should not get the top line (for those only line below).
– Dave
Jul 11 '15 at 14:08
@Dave Do you mean between the first rule and the text or between the text and the second rule? Anyway, somevspace*
in the right place should do. Withifnumbered{chapter}{<true>}{<false>}
within the redefinition you can add the rules only for numbered chapters if placing them in the<true>
branch
– clemens
Jul 11 '15 at 14:15
... or should I poste a new question because of that: "How to select only "real"chapter
-headlines exceptaddchap
-headlines simultaneously?"
– Dave
Jul 11 '15 at 14:17
Thank you very much for your great support! The spaces are customized now! Thevspace*
-command has been at the wrong place during my experiment indeed, it has to be placed beforenoindent
and everything works fine now! Furthermore I've tried to setifnumbered{chapter}{renewcommand*chapterheadstartvskip{noindentrule{linewidth}{4pt}par}}{}
, but this doesn't work. Is there any mistake?
– Dave
Jul 11 '15 at 14:35
@Daveifnumbered
needs to be inside the definition, see my edited answer
– clemens
Jul 11 '15 at 14:37
Thank you very much for your advice! This works actually perfect! There are only two more things: 1.) Like in the advice from Andrew Swann, I can't adjust the space between the chapters name and the
rule
. I've tried to set rule[2mm]{linewidth}
, but this does only move the existing text below the line, but not the line itself... 2.) How can I set making the top rule
only to "real/original" chapter-headlines, but not to addchap
-headlines? The foreword, table of content, acronymslist e.g. only use addchap
-headlines, and they should not get the top line (for those only line below).– Dave
Jul 11 '15 at 14:08
Thank you very much for your advice! This works actually perfect! There are only two more things: 1.) Like in the advice from Andrew Swann, I can't adjust the space between the chapters name and the
rule
. I've tried to set rule[2mm]{linewidth}
, but this does only move the existing text below the line, but not the line itself... 2.) How can I set making the top rule
only to "real/original" chapter-headlines, but not to addchap
-headlines? The foreword, table of content, acronymslist e.g. only use addchap
-headlines, and they should not get the top line (for those only line below).– Dave
Jul 11 '15 at 14:08
@Dave Do you mean between the first rule and the text or between the text and the second rule? Anyway, some
vspace*
in the right place should do. With ifnumbered{chapter}{<true>}{<false>}
within the redefinition you can add the rules only for numbered chapters if placing them in the <true>
branch– clemens
Jul 11 '15 at 14:15
@Dave Do you mean between the first rule and the text or between the text and the second rule? Anyway, some
vspace*
in the right place should do. With ifnumbered{chapter}{<true>}{<false>}
within the redefinition you can add the rules only for numbered chapters if placing them in the <true>
branch– clemens
Jul 11 '15 at 14:15
... or should I poste a new question because of that: "How to select only "real"
chapter
-headlines except addchap
-headlines simultaneously?"– Dave
Jul 11 '15 at 14:17
... or should I poste a new question because of that: "How to select only "real"
chapter
-headlines except addchap
-headlines simultaneously?"– Dave
Jul 11 '15 at 14:17
Thank you very much for your great support! The spaces are customized now! The
vspace*
-command has been at the wrong place during my experiment indeed, it has to be placed before noindent
and everything works fine now! Furthermore I've tried to set ifnumbered{chapter}{renewcommand*chapterheadstartvskip{noindentrule{linewidth}{4pt}par}}{}
, but this doesn't work. Is there any mistake?– Dave
Jul 11 '15 at 14:35
Thank you very much for your great support! The spaces are customized now! The
vspace*
-command has been at the wrong place during my experiment indeed, it has to be placed before noindent
and everything works fine now! Furthermore I've tried to set ifnumbered{chapter}{renewcommand*chapterheadstartvskip{noindentrule{linewidth}{4pt}par}}{}
, but this doesn't work. Is there any mistake?– Dave
Jul 11 '15 at 14:35
@Dave
ifnumbered
needs to be inside the definition, see my edited answer– clemens
Jul 11 '15 at 14:37
@Dave
ifnumbered
needs to be inside the definition, see my edited answer– clemens
Jul 11 '15 at 14:37
|
show 3 more comments
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%2f254824%2fscrbook-how-to-add-one-horizontal-line-above-and-one-below-the-chapter-entry-w%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
It is a wellknown fact that KOMA classes and
titlesec
should not used together (And no,fancyhdr
is no good idea with KOMA as well)– user31729
Jul 11 '15 at 11:27
Of course, this is a well known fact! But thanks a lot for your hint, I've changed the subject and explanatory text a bit...
– Dave
Jul 11 '15 at 11:36
The
scrpage2
package is outdated. Usescrlayer-scrpage
instead.– user31729
Jul 11 '15 at 11:41
3
I would use
chapterheadstartvskip
andchapterheadendvskip
to add the lines. (And it is imho a not so well known fact, that it is difficult to create fancy sectioning commands only with KOMA-tools. )– Ulrike Fischer
Jul 11 '15 at 11:46
See komascript.de/node/486
– Andrew Swann
Jul 11 '15 at 13:07