Configuring a section alias in LaTeXAdding to section names based on their contentsName a section in Latex...
Is Diceware more secure than a long passphrase?
Help with my training data
Why doesn't the standard consider a template constructor as a copy constructor?
std::unique_ptr of base class holding reference of derived class does not show warning in gcc compiler while naked pointer shows it. Why?
What *exactly* is electrical current, voltage, and resistance?
Unknown code in script
What makes accurate emulation of old systems a difficult task?
I preordered a game on my Xbox while on the home screen of my friend's account. Which of us owns the game?
Find a stone which is not the lightest one
Apply a different color ramp to subset of categorized symbols in QGIS?
Contradiction proof for inequality of P and NP?
What is the best way to deal with NPC-NPC combat?
What to do with someone that cheated their way through university and a PhD program?
Drawing a german abacus as in the books of Adam Ries
Nails holding drywall
Could moose/elk survive in the Amazon forest?
Why do real positive eigenvalues result in an unstable system? What about eigenvalues between 0 and 1? or 1?
Conditionally enable edit in lightning:datatable
Is Electric Central Heating worth it if using Solar Panels?
Why is the underscore command _ useful?
"The cow" OR "a cow" OR "cows" in this context
What does "function" actually mean in music?
How bug prioritization works in agile projects vs non agile
Do I need to watch Ant-Man and the Wasp and Captain Marvel before watching Avengers: Endgame?
Configuring a section alias in LaTeX
Adding to section names based on their contentsName a section in Latex TOC (add subtitle to contentsline)Command To Remove Just Deeper Level Headlines From The ToCmake section headings invisible?href macro in section conflicts with local hyperref linking in ToCHow to display partial TOC (only one section at a time)?Suppressing section name in table of contentsIgnore section hfill in table of contentsListing Subsection title in same TOC line as Section in MemoirTOC at the upper side of the beamer
Every week I produce a couple of A5 booklets (A4 folded) for my wife, an active colleague in church ministry, from which I am recently retired. I call the booklets a pulpit manuscript, as it includes the basic script of everything that is said or sung in the course of the service. Each part of the service is given a section, such as section{Prayer}, section{Reading}, etc. Each goes into the tableofcontents, so that inside the cover, I have the service running order at a glance. I have used various TeX approaches such as memoir, koma-script, ConTeXt, etc., and every editor available. I am settled on Auctex, using Spacemacs.
Although I have been using LaTeX for years, recently, I ventured into splitting my preamble into .cls and .sty files, which has all worked out fine for me. This inspired me to consider whether there might be some way in which I could save myself the tedium of writing this sort of thing every time I want to include a hymn in the order of service:
section{textbf{Hymn 360} hfill textit{normalsize Praise, my soul}}
This results in Hymn 360 Praise, my soul, which is pretty much what I want.
I tried the xparse package, which allows me to use
NewDocumentCommand{hymn}{mm}{textbf{#1}{hfill}textit{#2}}
in the preamble, and then hymn{}{} in the document. It looks pleasing enough, but, unfortunately, it does not go into the toc. (I know that I can use addcontentsline, but that would be to make the shortcut longer than the route. I am trying to make life easier, not more complex.)
I have also tried lethymnsection and renewcommand{hymn}{section}, which does put the hymn into the toc, but I do not know how to format the section in the text in a way that matches exactly what I have from xparse above. I am told that it is not a good idea to use an alias for section but, in my use case, I do not foresee that as a problem.
I am wondering is someone could show me how to get a nicely formatted section header from hymn{Hymn 360}{Praise, my soul}. I like what xparse produces but I am not able to get it into the toc. When I make hymn an alias for section, I do not know how to format the section behind the scenes so that it produces Hymn 360 Praise, my soul. Basically, I want to achieve that in such a way that for each new document, I do not need to make a lot of manual formatting.
I have tried to be painstakingly clear as to what I have tried, and what I want, but am happy to elaborate if required. In reality, I could get by as I do now with the section{textbf{Hymn 360} hfill textit{normalsize Praise, my soul}} but I like to dream that there is a better way.
table-of-contents sectioning package-writing xparse
bumped to the homepage by Community♦ 18 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
|
show 4 more comments
Every week I produce a couple of A5 booklets (A4 folded) for my wife, an active colleague in church ministry, from which I am recently retired. I call the booklets a pulpit manuscript, as it includes the basic script of everything that is said or sung in the course of the service. Each part of the service is given a section, such as section{Prayer}, section{Reading}, etc. Each goes into the tableofcontents, so that inside the cover, I have the service running order at a glance. I have used various TeX approaches such as memoir, koma-script, ConTeXt, etc., and every editor available. I am settled on Auctex, using Spacemacs.
Although I have been using LaTeX for years, recently, I ventured into splitting my preamble into .cls and .sty files, which has all worked out fine for me. This inspired me to consider whether there might be some way in which I could save myself the tedium of writing this sort of thing every time I want to include a hymn in the order of service:
section{textbf{Hymn 360} hfill textit{normalsize Praise, my soul}}
This results in Hymn 360 Praise, my soul, which is pretty much what I want.
I tried the xparse package, which allows me to use
NewDocumentCommand{hymn}{mm}{textbf{#1}{hfill}textit{#2}}
in the preamble, and then hymn{}{} in the document. It looks pleasing enough, but, unfortunately, it does not go into the toc. (I know that I can use addcontentsline, but that would be to make the shortcut longer than the route. I am trying to make life easier, not more complex.)
I have also tried lethymnsection and renewcommand{hymn}{section}, which does put the hymn into the toc, but I do not know how to format the section in the text in a way that matches exactly what I have from xparse above. I am told that it is not a good idea to use an alias for section but, in my use case, I do not foresee that as a problem.
I am wondering is someone could show me how to get a nicely formatted section header from hymn{Hymn 360}{Praise, my soul}. I like what xparse produces but I am not able to get it into the toc. When I make hymn an alias for section, I do not know how to format the section behind the scenes so that it produces Hymn 360 Praise, my soul. Basically, I want to achieve that in such a way that for each new document, I do not need to make a lot of manual formatting.
I have tried to be painstakingly clear as to what I have tried, and what I want, but am happy to elaborate if required. In reality, I could get by as I do now with the section{textbf{Hymn 360} hfill textit{normalsize Praise, my soul}} but I like to dream that there is a better way.
table-of-contents sectioning package-writing xparse
bumped to the homepage by Community♦ 18 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
2
Why don't you just include thesectionwrapper in the definition ofhymn?
– Steven B. Segletes
Aug 27 '18 at 12:53
Or put the adding to contents in the definition ofhymn. A proper minimum working example would encourage others to help you. That's much more useful than a fragment of code.
– cfr
Aug 27 '18 at 14:06
OK, I have made progress by adopting the first suggestion offered by @StevenB.Segletes. My nicely formatted hymn appears in the toc. However, it is no longer nicely formatted in the text, as the section command causes the whole heading to be in bold rather than the first line of the hymn being in italics. It looks as I wish it in the toc.
– Calum MacLeod
Aug 27 '18 at 19:39
How do I upvote that first comment, please?
– Calum MacLeod
Aug 27 '18 at 19:40
1
By looking in other forums, I have learned that the font that I use must include an italic version, such as kpfonts. That has allowed me to do what I wanted. I now consider both my original question, and my supplementary one to have been answered. Thanks for the advice from the two who commented, which helped me head towards a solution, as I have outlined above. I do not know if I am able to upvote or mark the question as answered, but, in any case, thanks.
– Calum MacLeod
Aug 27 '18 at 21:49
|
show 4 more comments
Every week I produce a couple of A5 booklets (A4 folded) for my wife, an active colleague in church ministry, from which I am recently retired. I call the booklets a pulpit manuscript, as it includes the basic script of everything that is said or sung in the course of the service. Each part of the service is given a section, such as section{Prayer}, section{Reading}, etc. Each goes into the tableofcontents, so that inside the cover, I have the service running order at a glance. I have used various TeX approaches such as memoir, koma-script, ConTeXt, etc., and every editor available. I am settled on Auctex, using Spacemacs.
Although I have been using LaTeX for years, recently, I ventured into splitting my preamble into .cls and .sty files, which has all worked out fine for me. This inspired me to consider whether there might be some way in which I could save myself the tedium of writing this sort of thing every time I want to include a hymn in the order of service:
section{textbf{Hymn 360} hfill textit{normalsize Praise, my soul}}
This results in Hymn 360 Praise, my soul, which is pretty much what I want.
I tried the xparse package, which allows me to use
NewDocumentCommand{hymn}{mm}{textbf{#1}{hfill}textit{#2}}
in the preamble, and then hymn{}{} in the document. It looks pleasing enough, but, unfortunately, it does not go into the toc. (I know that I can use addcontentsline, but that would be to make the shortcut longer than the route. I am trying to make life easier, not more complex.)
I have also tried lethymnsection and renewcommand{hymn}{section}, which does put the hymn into the toc, but I do not know how to format the section in the text in a way that matches exactly what I have from xparse above. I am told that it is not a good idea to use an alias for section but, in my use case, I do not foresee that as a problem.
I am wondering is someone could show me how to get a nicely formatted section header from hymn{Hymn 360}{Praise, my soul}. I like what xparse produces but I am not able to get it into the toc. When I make hymn an alias for section, I do not know how to format the section behind the scenes so that it produces Hymn 360 Praise, my soul. Basically, I want to achieve that in such a way that for each new document, I do not need to make a lot of manual formatting.
I have tried to be painstakingly clear as to what I have tried, and what I want, but am happy to elaborate if required. In reality, I could get by as I do now with the section{textbf{Hymn 360} hfill textit{normalsize Praise, my soul}} but I like to dream that there is a better way.
table-of-contents sectioning package-writing xparse
Every week I produce a couple of A5 booklets (A4 folded) for my wife, an active colleague in church ministry, from which I am recently retired. I call the booklets a pulpit manuscript, as it includes the basic script of everything that is said or sung in the course of the service. Each part of the service is given a section, such as section{Prayer}, section{Reading}, etc. Each goes into the tableofcontents, so that inside the cover, I have the service running order at a glance. I have used various TeX approaches such as memoir, koma-script, ConTeXt, etc., and every editor available. I am settled on Auctex, using Spacemacs.
Although I have been using LaTeX for years, recently, I ventured into splitting my preamble into .cls and .sty files, which has all worked out fine for me. This inspired me to consider whether there might be some way in which I could save myself the tedium of writing this sort of thing every time I want to include a hymn in the order of service:
section{textbf{Hymn 360} hfill textit{normalsize Praise, my soul}}
This results in Hymn 360 Praise, my soul, which is pretty much what I want.
I tried the xparse package, which allows me to use
NewDocumentCommand{hymn}{mm}{textbf{#1}{hfill}textit{#2}}
in the preamble, and then hymn{}{} in the document. It looks pleasing enough, but, unfortunately, it does not go into the toc. (I know that I can use addcontentsline, but that would be to make the shortcut longer than the route. I am trying to make life easier, not more complex.)
I have also tried lethymnsection and renewcommand{hymn}{section}, which does put the hymn into the toc, but I do not know how to format the section in the text in a way that matches exactly what I have from xparse above. I am told that it is not a good idea to use an alias for section but, in my use case, I do not foresee that as a problem.
I am wondering is someone could show me how to get a nicely formatted section header from hymn{Hymn 360}{Praise, my soul}. I like what xparse produces but I am not able to get it into the toc. When I make hymn an alias for section, I do not know how to format the section behind the scenes so that it produces Hymn 360 Praise, my soul. Basically, I want to achieve that in such a way that for each new document, I do not need to make a lot of manual formatting.
I have tried to be painstakingly clear as to what I have tried, and what I want, but am happy to elaborate if required. In reality, I could get by as I do now with the section{textbf{Hymn 360} hfill textit{normalsize Praise, my soul}} but I like to dream that there is a better way.
table-of-contents sectioning package-writing xparse
table-of-contents sectioning package-writing xparse
edited Aug 27 '18 at 14:07
cfr
159k8191395
159k8191395
asked Aug 27 '18 at 12:49
Calum MacLeodCalum MacLeod
113
113
bumped to the homepage by Community♦ 18 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
bumped to the homepage by Community♦ 18 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
2
Why don't you just include thesectionwrapper in the definition ofhymn?
– Steven B. Segletes
Aug 27 '18 at 12:53
Or put the adding to contents in the definition ofhymn. A proper minimum working example would encourage others to help you. That's much more useful than a fragment of code.
– cfr
Aug 27 '18 at 14:06
OK, I have made progress by adopting the first suggestion offered by @StevenB.Segletes. My nicely formatted hymn appears in the toc. However, it is no longer nicely formatted in the text, as the section command causes the whole heading to be in bold rather than the first line of the hymn being in italics. It looks as I wish it in the toc.
– Calum MacLeod
Aug 27 '18 at 19:39
How do I upvote that first comment, please?
– Calum MacLeod
Aug 27 '18 at 19:40
1
By looking in other forums, I have learned that the font that I use must include an italic version, such as kpfonts. That has allowed me to do what I wanted. I now consider both my original question, and my supplementary one to have been answered. Thanks for the advice from the two who commented, which helped me head towards a solution, as I have outlined above. I do not know if I am able to upvote or mark the question as answered, but, in any case, thanks.
– Calum MacLeod
Aug 27 '18 at 21:49
|
show 4 more comments
2
Why don't you just include thesectionwrapper in the definition ofhymn?
– Steven B. Segletes
Aug 27 '18 at 12:53
Or put the adding to contents in the definition ofhymn. A proper minimum working example would encourage others to help you. That's much more useful than a fragment of code.
– cfr
Aug 27 '18 at 14:06
OK, I have made progress by adopting the first suggestion offered by @StevenB.Segletes. My nicely formatted hymn appears in the toc. However, it is no longer nicely formatted in the text, as the section command causes the whole heading to be in bold rather than the first line of the hymn being in italics. It looks as I wish it in the toc.
– Calum MacLeod
Aug 27 '18 at 19:39
How do I upvote that first comment, please?
– Calum MacLeod
Aug 27 '18 at 19:40
1
By looking in other forums, I have learned that the font that I use must include an italic version, such as kpfonts. That has allowed me to do what I wanted. I now consider both my original question, and my supplementary one to have been answered. Thanks for the advice from the two who commented, which helped me head towards a solution, as I have outlined above. I do not know if I am able to upvote or mark the question as answered, but, in any case, thanks.
– Calum MacLeod
Aug 27 '18 at 21:49
2
2
Why don't you just include the
section wrapper in the definition of hymn?– Steven B. Segletes
Aug 27 '18 at 12:53
Why don't you just include the
section wrapper in the definition of hymn?– Steven B. Segletes
Aug 27 '18 at 12:53
Or put the adding to contents in the definition of
hymn. A proper minimum working example would encourage others to help you. That's much more useful than a fragment of code.– cfr
Aug 27 '18 at 14:06
Or put the adding to contents in the definition of
hymn. A proper minimum working example would encourage others to help you. That's much more useful than a fragment of code.– cfr
Aug 27 '18 at 14:06
OK, I have made progress by adopting the first suggestion offered by @StevenB.Segletes. My nicely formatted hymn appears in the toc. However, it is no longer nicely formatted in the text, as the section command causes the whole heading to be in bold rather than the first line of the hymn being in italics. It looks as I wish it in the toc.
– Calum MacLeod
Aug 27 '18 at 19:39
OK, I have made progress by adopting the first suggestion offered by @StevenB.Segletes. My nicely formatted hymn appears in the toc. However, it is no longer nicely formatted in the text, as the section command causes the whole heading to be in bold rather than the first line of the hymn being in italics. It looks as I wish it in the toc.
– Calum MacLeod
Aug 27 '18 at 19:39
How do I upvote that first comment, please?
– Calum MacLeod
Aug 27 '18 at 19:40
How do I upvote that first comment, please?
– Calum MacLeod
Aug 27 '18 at 19:40
1
1
By looking in other forums, I have learned that the font that I use must include an italic version, such as kpfonts. That has allowed me to do what I wanted. I now consider both my original question, and my supplementary one to have been answered. Thanks for the advice from the two who commented, which helped me head towards a solution, as I have outlined above. I do not know if I am able to upvote or mark the question as answered, but, in any case, thanks.
– Calum MacLeod
Aug 27 '18 at 21:49
By looking in other forums, I have learned that the font that I use must include an italic version, such as kpfonts. That has allowed me to do what I wanted. I now consider both my original question, and my supplementary one to have been answered. Thanks for the advice from the two who commented, which helped me head towards a solution, as I have outlined above. I do not know if I am able to upvote or mark the question as answered, but, in any case, thanks.
– Calum MacLeod
Aug 27 '18 at 21:49
|
show 4 more comments
1 Answer
1
active
oldest
votes
In the production of a booklet for my wife, who conducts church services more than once a week, I use a section heading to mark each component of the service. For most components, this is straightforward enough. For instance: section{Prayer}.
However, I like to add some formatting to the section for a hymn so that it looks like: Hymn 646 The day thou gavest. As it is an A5 booklet, I like to make the text of the first line of the hymn fit, and then I use normalsize to make the line take up less space.
Although it is hardly an inconvenience to format the hymn line in this way, I wondered if I could do this automatically, so that all I would need to do was put {} round the hymn number and also the first line, so that in the text I would write hymn{Hymn 646}{The day thou gavest}, and LaTeX would look after the formatting. The other requirement was that the hymn should be listed in the tableofcontents.
I discovered that the following code in the preamble would do what I wanted as far as formatting the hymn heading was concerned. However, it did not appear in the toc.
usepackage{xparse}
NewDocumentCommand{hymn}{mm}{textbf{#1}{hfill}textit{#2}}
It was put to me that I should "include the section wrapper in the definition of hymn". As I use the documentclass scrbook by Koma-script, and did not want a numbered section, I used addsec rather than section. That resulting code was as shown below:
RequirePackage{xparse}
NewDocumentCommand{hymn}{mm}{addsec{textbf{#1}{hfill}textit{#2}}}
This worked in so far as it put the hymn into the toc. However, I lost the nice formatting of the addsec heading in the text. The italics were gone! A little research revealed that I needed a font that had an italics version, such as kpfonts. I made that my font for the document, and, finally, I had achieved my goal.
Thanks to those who commented by suggesting steps I felt unable to take. After some thought, I realised what they were saying. Should colleagues using LaTeX for service booklets find this answer of interest, I should be happy to hear from them.
"I use the documentclass scrbook ... so I should use addsec rather than section." That's not true.addsecis a nice feature of KoMa classes which allows you to have unnumbered sections in thetoc, but it's not a general replacement.
– campa
Aug 28 '18 at 11:40
@campa, you are correct, and i have amended my answer accordingly. Thanks for drawing that to my attention.
– Calum MacLeod
Aug 28 '18 at 11:46
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f447970%2fconfiguring-a-section-alias-in-latex%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
In the production of a booklet for my wife, who conducts church services more than once a week, I use a section heading to mark each component of the service. For most components, this is straightforward enough. For instance: section{Prayer}.
However, I like to add some formatting to the section for a hymn so that it looks like: Hymn 646 The day thou gavest. As it is an A5 booklet, I like to make the text of the first line of the hymn fit, and then I use normalsize to make the line take up less space.
Although it is hardly an inconvenience to format the hymn line in this way, I wondered if I could do this automatically, so that all I would need to do was put {} round the hymn number and also the first line, so that in the text I would write hymn{Hymn 646}{The day thou gavest}, and LaTeX would look after the formatting. The other requirement was that the hymn should be listed in the tableofcontents.
I discovered that the following code in the preamble would do what I wanted as far as formatting the hymn heading was concerned. However, it did not appear in the toc.
usepackage{xparse}
NewDocumentCommand{hymn}{mm}{textbf{#1}{hfill}textit{#2}}
It was put to me that I should "include the section wrapper in the definition of hymn". As I use the documentclass scrbook by Koma-script, and did not want a numbered section, I used addsec rather than section. That resulting code was as shown below:
RequirePackage{xparse}
NewDocumentCommand{hymn}{mm}{addsec{textbf{#1}{hfill}textit{#2}}}
This worked in so far as it put the hymn into the toc. However, I lost the nice formatting of the addsec heading in the text. The italics were gone! A little research revealed that I needed a font that had an italics version, such as kpfonts. I made that my font for the document, and, finally, I had achieved my goal.
Thanks to those who commented by suggesting steps I felt unable to take. After some thought, I realised what they were saying. Should colleagues using LaTeX for service booklets find this answer of interest, I should be happy to hear from them.
"I use the documentclass scrbook ... so I should use addsec rather than section." That's not true.addsecis a nice feature of KoMa classes which allows you to have unnumbered sections in thetoc, but it's not a general replacement.
– campa
Aug 28 '18 at 11:40
@campa, you are correct, and i have amended my answer accordingly. Thanks for drawing that to my attention.
– Calum MacLeod
Aug 28 '18 at 11:46
add a comment |
In the production of a booklet for my wife, who conducts church services more than once a week, I use a section heading to mark each component of the service. For most components, this is straightforward enough. For instance: section{Prayer}.
However, I like to add some formatting to the section for a hymn so that it looks like: Hymn 646 The day thou gavest. As it is an A5 booklet, I like to make the text of the first line of the hymn fit, and then I use normalsize to make the line take up less space.
Although it is hardly an inconvenience to format the hymn line in this way, I wondered if I could do this automatically, so that all I would need to do was put {} round the hymn number and also the first line, so that in the text I would write hymn{Hymn 646}{The day thou gavest}, and LaTeX would look after the formatting. The other requirement was that the hymn should be listed in the tableofcontents.
I discovered that the following code in the preamble would do what I wanted as far as formatting the hymn heading was concerned. However, it did not appear in the toc.
usepackage{xparse}
NewDocumentCommand{hymn}{mm}{textbf{#1}{hfill}textit{#2}}
It was put to me that I should "include the section wrapper in the definition of hymn". As I use the documentclass scrbook by Koma-script, and did not want a numbered section, I used addsec rather than section. That resulting code was as shown below:
RequirePackage{xparse}
NewDocumentCommand{hymn}{mm}{addsec{textbf{#1}{hfill}textit{#2}}}
This worked in so far as it put the hymn into the toc. However, I lost the nice formatting of the addsec heading in the text. The italics were gone! A little research revealed that I needed a font that had an italics version, such as kpfonts. I made that my font for the document, and, finally, I had achieved my goal.
Thanks to those who commented by suggesting steps I felt unable to take. After some thought, I realised what they were saying. Should colleagues using LaTeX for service booklets find this answer of interest, I should be happy to hear from them.
"I use the documentclass scrbook ... so I should use addsec rather than section." That's not true.addsecis a nice feature of KoMa classes which allows you to have unnumbered sections in thetoc, but it's not a general replacement.
– campa
Aug 28 '18 at 11:40
@campa, you are correct, and i have amended my answer accordingly. Thanks for drawing that to my attention.
– Calum MacLeod
Aug 28 '18 at 11:46
add a comment |
In the production of a booklet for my wife, who conducts church services more than once a week, I use a section heading to mark each component of the service. For most components, this is straightforward enough. For instance: section{Prayer}.
However, I like to add some formatting to the section for a hymn so that it looks like: Hymn 646 The day thou gavest. As it is an A5 booklet, I like to make the text of the first line of the hymn fit, and then I use normalsize to make the line take up less space.
Although it is hardly an inconvenience to format the hymn line in this way, I wondered if I could do this automatically, so that all I would need to do was put {} round the hymn number and also the first line, so that in the text I would write hymn{Hymn 646}{The day thou gavest}, and LaTeX would look after the formatting. The other requirement was that the hymn should be listed in the tableofcontents.
I discovered that the following code in the preamble would do what I wanted as far as formatting the hymn heading was concerned. However, it did not appear in the toc.
usepackage{xparse}
NewDocumentCommand{hymn}{mm}{textbf{#1}{hfill}textit{#2}}
It was put to me that I should "include the section wrapper in the definition of hymn". As I use the documentclass scrbook by Koma-script, and did not want a numbered section, I used addsec rather than section. That resulting code was as shown below:
RequirePackage{xparse}
NewDocumentCommand{hymn}{mm}{addsec{textbf{#1}{hfill}textit{#2}}}
This worked in so far as it put the hymn into the toc. However, I lost the nice formatting of the addsec heading in the text. The italics were gone! A little research revealed that I needed a font that had an italics version, such as kpfonts. I made that my font for the document, and, finally, I had achieved my goal.
Thanks to those who commented by suggesting steps I felt unable to take. After some thought, I realised what they were saying. Should colleagues using LaTeX for service booklets find this answer of interest, I should be happy to hear from them.
In the production of a booklet for my wife, who conducts church services more than once a week, I use a section heading to mark each component of the service. For most components, this is straightforward enough. For instance: section{Prayer}.
However, I like to add some formatting to the section for a hymn so that it looks like: Hymn 646 The day thou gavest. As it is an A5 booklet, I like to make the text of the first line of the hymn fit, and then I use normalsize to make the line take up less space.
Although it is hardly an inconvenience to format the hymn line in this way, I wondered if I could do this automatically, so that all I would need to do was put {} round the hymn number and also the first line, so that in the text I would write hymn{Hymn 646}{The day thou gavest}, and LaTeX would look after the formatting. The other requirement was that the hymn should be listed in the tableofcontents.
I discovered that the following code in the preamble would do what I wanted as far as formatting the hymn heading was concerned. However, it did not appear in the toc.
usepackage{xparse}
NewDocumentCommand{hymn}{mm}{textbf{#1}{hfill}textit{#2}}
It was put to me that I should "include the section wrapper in the definition of hymn". As I use the documentclass scrbook by Koma-script, and did not want a numbered section, I used addsec rather than section. That resulting code was as shown below:
RequirePackage{xparse}
NewDocumentCommand{hymn}{mm}{addsec{textbf{#1}{hfill}textit{#2}}}
This worked in so far as it put the hymn into the toc. However, I lost the nice formatting of the addsec heading in the text. The italics were gone! A little research revealed that I needed a font that had an italics version, such as kpfonts. I made that my font for the document, and, finally, I had achieved my goal.
Thanks to those who commented by suggesting steps I felt unable to take. After some thought, I realised what they were saying. Should colleagues using LaTeX for service booklets find this answer of interest, I should be happy to hear from them.
edited Aug 28 '18 at 18:00
answered Aug 28 '18 at 10:48
Calum MacLeodCalum MacLeod
113
113
"I use the documentclass scrbook ... so I should use addsec rather than section." That's not true.addsecis a nice feature of KoMa classes which allows you to have unnumbered sections in thetoc, but it's not a general replacement.
– campa
Aug 28 '18 at 11:40
@campa, you are correct, and i have amended my answer accordingly. Thanks for drawing that to my attention.
– Calum MacLeod
Aug 28 '18 at 11:46
add a comment |
"I use the documentclass scrbook ... so I should use addsec rather than section." That's not true.addsecis a nice feature of KoMa classes which allows you to have unnumbered sections in thetoc, but it's not a general replacement.
– campa
Aug 28 '18 at 11:40
@campa, you are correct, and i have amended my answer accordingly. Thanks for drawing that to my attention.
– Calum MacLeod
Aug 28 '18 at 11:46
"I use the documentclass scrbook ... so I should use addsec rather than section." That's not true.
addsec is a nice feature of KoMa classes which allows you to have unnumbered sections in the toc, but it's not a general replacement.– campa
Aug 28 '18 at 11:40
"I use the documentclass scrbook ... so I should use addsec rather than section." That's not true.
addsec is a nice feature of KoMa classes which allows you to have unnumbered sections in the toc, but it's not a general replacement.– campa
Aug 28 '18 at 11:40
@campa, you are correct, and i have amended my answer accordingly. Thanks for drawing that to my attention.
– Calum MacLeod
Aug 28 '18 at 11:46
@campa, you are correct, and i have amended my answer accordingly. Thanks for drawing that to my attention.
– Calum MacLeod
Aug 28 '18 at 11:46
add a comment |
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f447970%2fconfiguring-a-section-alias-in-latex%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
2
Why don't you just include the
sectionwrapper in the definition ofhymn?– Steven B. Segletes
Aug 27 '18 at 12:53
Or put the adding to contents in the definition of
hymn. A proper minimum working example would encourage others to help you. That's much more useful than a fragment of code.– cfr
Aug 27 '18 at 14:06
OK, I have made progress by adopting the first suggestion offered by @StevenB.Segletes. My nicely formatted hymn appears in the toc. However, it is no longer nicely formatted in the text, as the section command causes the whole heading to be in bold rather than the first line of the hymn being in italics. It looks as I wish it in the toc.
– Calum MacLeod
Aug 27 '18 at 19:39
How do I upvote that first comment, please?
– Calum MacLeod
Aug 27 '18 at 19:40
1
By looking in other forums, I have learned that the font that I use must include an italic version, such as kpfonts. That has allowed me to do what I wanted. I now consider both my original question, and my supplementary one to have been answered. Thanks for the advice from the two who commented, which helped me head towards a solution, as I have outlined above. I do not know if I am able to upvote or mark the question as answered, but, in any case, thanks.
– Calum MacLeod
Aug 27 '18 at 21:49