How can I patch the abstract, list of figures, and list of tables macros to be included in the ToC...
We can definitely use phantomsection addcontentsline{toc}{chapter}{<name>}
right after we begin the environments or type the relevant macro, which would include abstract, list of figures and list of tables in the ToC. Is here a way to patch these commands so that we no longer need to type phantomsection addcontentsline{toc}{chapter}{<name>}
?
This question is meant to teach me how to patch commands with an example, not that I don't want to manually use phantomsection
and addcontentsline
documentclass[notitlepage]{book}
usepackage[no-math]{fontspec}
usepackage[inline]{enumitem}
usepackage{blindtext}
usepackage[showframe]{geometry}
usepackage{tocloft}
usepackage{etoolbox}
patchcmd{frontmatter}{pagenumbering{roman}}{pagenumbering{Roman}}{}{}
% ===== Define abstract environment =====
makeatletter
if@titlepage
newenvironment{abstract}{%
titlepage
nullvfil
@beginparpenalty@lowpenalty
begin{center}%
bfseries abstractname
@endparpenalty@M
end{center}}%
{parvfilnullendtitlepage}
else
newenvironment{abstract}{%
if@twocolumn
section*{abstractname}%
else
small
begin{center}%
{bfseries abstractnamevspace{-.5em}vspace{z@}}%
end{center}%
quotation
fi}
{if@twocolumnelseendquotationfi}
fi
makeatother
begin{document}
frontmatter
pagestyle{plain}
tableofcontents
pagestyle{headings}
cleardoublepage
begin{abstract}
thispagestyle{plain}
blindtext
end{abstract}
phantomsection addcontentsline{toc}{chapter}{abstractname}
cleardoublepage
phantomsection addcontentsline{toc}{chapter}{listfigurename}
listoffigures
cleardoublepage
phantomsection addcontentsline{toc}{chapter}{listtablename}
listoftables
mainmatter
Blinddocument
Blinddocument
Blinddocument
end{document}
table-of-contents environments tocloft etoolbox patching
add a comment |
We can definitely use phantomsection addcontentsline{toc}{chapter}{<name>}
right after we begin the environments or type the relevant macro, which would include abstract, list of figures and list of tables in the ToC. Is here a way to patch these commands so that we no longer need to type phantomsection addcontentsline{toc}{chapter}{<name>}
?
This question is meant to teach me how to patch commands with an example, not that I don't want to manually use phantomsection
and addcontentsline
documentclass[notitlepage]{book}
usepackage[no-math]{fontspec}
usepackage[inline]{enumitem}
usepackage{blindtext}
usepackage[showframe]{geometry}
usepackage{tocloft}
usepackage{etoolbox}
patchcmd{frontmatter}{pagenumbering{roman}}{pagenumbering{Roman}}{}{}
% ===== Define abstract environment =====
makeatletter
if@titlepage
newenvironment{abstract}{%
titlepage
nullvfil
@beginparpenalty@lowpenalty
begin{center}%
bfseries abstractname
@endparpenalty@M
end{center}}%
{parvfilnullendtitlepage}
else
newenvironment{abstract}{%
if@twocolumn
section*{abstractname}%
else
small
begin{center}%
{bfseries abstractnamevspace{-.5em}vspace{z@}}%
end{center}%
quotation
fi}
{if@twocolumnelseendquotationfi}
fi
makeatother
begin{document}
frontmatter
pagestyle{plain}
tableofcontents
pagestyle{headings}
cleardoublepage
begin{abstract}
thispagestyle{plain}
blindtext
end{abstract}
phantomsection addcontentsline{toc}{chapter}{abstractname}
cleardoublepage
phantomsection addcontentsline{toc}{chapter}{listfigurename}
listoffigures
cleardoublepage
phantomsection addcontentsline{toc}{chapter}{listtablename}
listoftables
mainmatter
Blinddocument
Blinddocument
Blinddocument
end{document}
table-of-contents environments tocloft etoolbox patching
You can add the line into the definition of abstract, see my answer from earlier today. For the list of stuff, simply use package tocbibind
– Johannes_B
Aug 13 at 7:50
Yes, but how about the list of tables and list of figures?
– Al-Motasem Aldaoudeyeh
Aug 13 at 16:18
Packagetocbibind
. See section 2.1 of the documentation.
– Johannes_B
Aug 13 at 16:30
add a comment |
We can definitely use phantomsection addcontentsline{toc}{chapter}{<name>}
right after we begin the environments or type the relevant macro, which would include abstract, list of figures and list of tables in the ToC. Is here a way to patch these commands so that we no longer need to type phantomsection addcontentsline{toc}{chapter}{<name>}
?
This question is meant to teach me how to patch commands with an example, not that I don't want to manually use phantomsection
and addcontentsline
documentclass[notitlepage]{book}
usepackage[no-math]{fontspec}
usepackage[inline]{enumitem}
usepackage{blindtext}
usepackage[showframe]{geometry}
usepackage{tocloft}
usepackage{etoolbox}
patchcmd{frontmatter}{pagenumbering{roman}}{pagenumbering{Roman}}{}{}
% ===== Define abstract environment =====
makeatletter
if@titlepage
newenvironment{abstract}{%
titlepage
nullvfil
@beginparpenalty@lowpenalty
begin{center}%
bfseries abstractname
@endparpenalty@M
end{center}}%
{parvfilnullendtitlepage}
else
newenvironment{abstract}{%
if@twocolumn
section*{abstractname}%
else
small
begin{center}%
{bfseries abstractnamevspace{-.5em}vspace{z@}}%
end{center}%
quotation
fi}
{if@twocolumnelseendquotationfi}
fi
makeatother
begin{document}
frontmatter
pagestyle{plain}
tableofcontents
pagestyle{headings}
cleardoublepage
begin{abstract}
thispagestyle{plain}
blindtext
end{abstract}
phantomsection addcontentsline{toc}{chapter}{abstractname}
cleardoublepage
phantomsection addcontentsline{toc}{chapter}{listfigurename}
listoffigures
cleardoublepage
phantomsection addcontentsline{toc}{chapter}{listtablename}
listoftables
mainmatter
Blinddocument
Blinddocument
Blinddocument
end{document}
table-of-contents environments tocloft etoolbox patching
We can definitely use phantomsection addcontentsline{toc}{chapter}{<name>}
right after we begin the environments or type the relevant macro, which would include abstract, list of figures and list of tables in the ToC. Is here a way to patch these commands so that we no longer need to type phantomsection addcontentsline{toc}{chapter}{<name>}
?
This question is meant to teach me how to patch commands with an example, not that I don't want to manually use phantomsection
and addcontentsline
documentclass[notitlepage]{book}
usepackage[no-math]{fontspec}
usepackage[inline]{enumitem}
usepackage{blindtext}
usepackage[showframe]{geometry}
usepackage{tocloft}
usepackage{etoolbox}
patchcmd{frontmatter}{pagenumbering{roman}}{pagenumbering{Roman}}{}{}
% ===== Define abstract environment =====
makeatletter
if@titlepage
newenvironment{abstract}{%
titlepage
nullvfil
@beginparpenalty@lowpenalty
begin{center}%
bfseries abstractname
@endparpenalty@M
end{center}}%
{parvfilnullendtitlepage}
else
newenvironment{abstract}{%
if@twocolumn
section*{abstractname}%
else
small
begin{center}%
{bfseries abstractnamevspace{-.5em}vspace{z@}}%
end{center}%
quotation
fi}
{if@twocolumnelseendquotationfi}
fi
makeatother
begin{document}
frontmatter
pagestyle{plain}
tableofcontents
pagestyle{headings}
cleardoublepage
begin{abstract}
thispagestyle{plain}
blindtext
end{abstract}
phantomsection addcontentsline{toc}{chapter}{abstractname}
cleardoublepage
phantomsection addcontentsline{toc}{chapter}{listfigurename}
listoffigures
cleardoublepage
phantomsection addcontentsline{toc}{chapter}{listtablename}
listoftables
mainmatter
Blinddocument
Blinddocument
Blinddocument
end{document}
table-of-contents environments tocloft etoolbox patching
table-of-contents environments tocloft etoolbox patching
asked Aug 13 at 6:38
Al-Motasem Aldaoudeyeh
1,405311
1,405311
You can add the line into the definition of abstract, see my answer from earlier today. For the list of stuff, simply use package tocbibind
– Johannes_B
Aug 13 at 7:50
Yes, but how about the list of tables and list of figures?
– Al-Motasem Aldaoudeyeh
Aug 13 at 16:18
Packagetocbibind
. See section 2.1 of the documentation.
– Johannes_B
Aug 13 at 16:30
add a comment |
You can add the line into the definition of abstract, see my answer from earlier today. For the list of stuff, simply use package tocbibind
– Johannes_B
Aug 13 at 7:50
Yes, but how about the list of tables and list of figures?
– Al-Motasem Aldaoudeyeh
Aug 13 at 16:18
Packagetocbibind
. See section 2.1 of the documentation.
– Johannes_B
Aug 13 at 16:30
You can add the line into the definition of abstract, see my answer from earlier today. For the list of stuff, simply use package tocbibind
– Johannes_B
Aug 13 at 7:50
You can add the line into the definition of abstract, see my answer from earlier today. For the list of stuff, simply use package tocbibind
– Johannes_B
Aug 13 at 7:50
Yes, but how about the list of tables and list of figures?
– Al-Motasem Aldaoudeyeh
Aug 13 at 16:18
Yes, but how about the list of tables and list of figures?
– Al-Motasem Aldaoudeyeh
Aug 13 at 16:18
Package
tocbibind
. See section 2.1 of the documentation.– Johannes_B
Aug 13 at 16:30
Package
tocbibind
. See section 2.1 of the documentation.– Johannes_B
Aug 13 at 16:30
add a comment |
1 Answer
1
active
oldest
votes
documentclass[notitlepage]{book}
usepackage[no-math]{fontspec}
usepackage[inline]{enumitem}
usepackage{blindtext}
usepackage[showframe]{geometry}
usepackage{tocbibind}
usepackage{tocloft}
usepackage{etoolbox}
patchcmd{frontmatter}{pagenumbering{roman}}{pagenumbering{Roman}}{}{}
% ===== Define abstract environment =====
makeatletter
@ifclassloaded{report}{%
% Do nothing, everything seems to be setup already
}{@ifclassloaded{article}{%
% Do nothing, everything seems to be setup already
}{%
% Any other class that does not provide an abstract environment
% We have to define `abstractname` and the abstract environment (most likely)
% After that, load the abstract package
@ifundefined{abstractname}{newcommand{abstractname}{Abstract}}{}
@ifundefined{abstract}{%
if@titlepage
newenvironment{abstract}{%
titlepage
nullvfil
@beginparpenalty@lowpenalty
begin{center}%
bfseries abstractname
@endparpenalty@M
end{center}}%
{parvfilnullendtitlepage}
else
newenvironment{abstract}{%
if@twocolumn
section*{abstractname}%
% addcontentsline{toc}{section}{protectabstractname} Or add it here....
else
small
begin{center}%
{bfseries abstractnamevspace{-.5em}vspace{z@}}%
end{center}%
quotation
fi}
{if@twocolumnelseendquotationfi}
fi
% Eventually a check about the existence of endabstract, i.e. @ifundefined{endabstract}{}{}
}{%
% abstract environment presumably exists
}
}% End of @ifclassloaded{article}
}% End of @ifclassloaded{report}
makeatother
usepackage[addtotoc]{abstract}
begin{document}
frontmatter
pagestyle{plain}
tableofcontents
pagestyle{headings}
cleardoublepage
begin{abstract}
thispagestyle{plain}
blindtext
end{abstract}
cleardoublepage
listoffigures
cleardoublepage
listoftables
mainmatter
Blinddocument
Blinddocument
Blinddocument
end{document}
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%2f445834%2fhow-can-i-patch-the-abstract-list-of-figures-and-list-of-tables-macros-to-be-i%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
documentclass[notitlepage]{book}
usepackage[no-math]{fontspec}
usepackage[inline]{enumitem}
usepackage{blindtext}
usepackage[showframe]{geometry}
usepackage{tocbibind}
usepackage{tocloft}
usepackage{etoolbox}
patchcmd{frontmatter}{pagenumbering{roman}}{pagenumbering{Roman}}{}{}
% ===== Define abstract environment =====
makeatletter
@ifclassloaded{report}{%
% Do nothing, everything seems to be setup already
}{@ifclassloaded{article}{%
% Do nothing, everything seems to be setup already
}{%
% Any other class that does not provide an abstract environment
% We have to define `abstractname` and the abstract environment (most likely)
% After that, load the abstract package
@ifundefined{abstractname}{newcommand{abstractname}{Abstract}}{}
@ifundefined{abstract}{%
if@titlepage
newenvironment{abstract}{%
titlepage
nullvfil
@beginparpenalty@lowpenalty
begin{center}%
bfseries abstractname
@endparpenalty@M
end{center}}%
{parvfilnullendtitlepage}
else
newenvironment{abstract}{%
if@twocolumn
section*{abstractname}%
% addcontentsline{toc}{section}{protectabstractname} Or add it here....
else
small
begin{center}%
{bfseries abstractnamevspace{-.5em}vspace{z@}}%
end{center}%
quotation
fi}
{if@twocolumnelseendquotationfi}
fi
% Eventually a check about the existence of endabstract, i.e. @ifundefined{endabstract}{}{}
}{%
% abstract environment presumably exists
}
}% End of @ifclassloaded{article}
}% End of @ifclassloaded{report}
makeatother
usepackage[addtotoc]{abstract}
begin{document}
frontmatter
pagestyle{plain}
tableofcontents
pagestyle{headings}
cleardoublepage
begin{abstract}
thispagestyle{plain}
blindtext
end{abstract}
cleardoublepage
listoffigures
cleardoublepage
listoftables
mainmatter
Blinddocument
Blinddocument
Blinddocument
end{document}
add a comment |
documentclass[notitlepage]{book}
usepackage[no-math]{fontspec}
usepackage[inline]{enumitem}
usepackage{blindtext}
usepackage[showframe]{geometry}
usepackage{tocbibind}
usepackage{tocloft}
usepackage{etoolbox}
patchcmd{frontmatter}{pagenumbering{roman}}{pagenumbering{Roman}}{}{}
% ===== Define abstract environment =====
makeatletter
@ifclassloaded{report}{%
% Do nothing, everything seems to be setup already
}{@ifclassloaded{article}{%
% Do nothing, everything seems to be setup already
}{%
% Any other class that does not provide an abstract environment
% We have to define `abstractname` and the abstract environment (most likely)
% After that, load the abstract package
@ifundefined{abstractname}{newcommand{abstractname}{Abstract}}{}
@ifundefined{abstract}{%
if@titlepage
newenvironment{abstract}{%
titlepage
nullvfil
@beginparpenalty@lowpenalty
begin{center}%
bfseries abstractname
@endparpenalty@M
end{center}}%
{parvfilnullendtitlepage}
else
newenvironment{abstract}{%
if@twocolumn
section*{abstractname}%
% addcontentsline{toc}{section}{protectabstractname} Or add it here....
else
small
begin{center}%
{bfseries abstractnamevspace{-.5em}vspace{z@}}%
end{center}%
quotation
fi}
{if@twocolumnelseendquotationfi}
fi
% Eventually a check about the existence of endabstract, i.e. @ifundefined{endabstract}{}{}
}{%
% abstract environment presumably exists
}
}% End of @ifclassloaded{article}
}% End of @ifclassloaded{report}
makeatother
usepackage[addtotoc]{abstract}
begin{document}
frontmatter
pagestyle{plain}
tableofcontents
pagestyle{headings}
cleardoublepage
begin{abstract}
thispagestyle{plain}
blindtext
end{abstract}
cleardoublepage
listoffigures
cleardoublepage
listoftables
mainmatter
Blinddocument
Blinddocument
Blinddocument
end{document}
add a comment |
documentclass[notitlepage]{book}
usepackage[no-math]{fontspec}
usepackage[inline]{enumitem}
usepackage{blindtext}
usepackage[showframe]{geometry}
usepackage{tocbibind}
usepackage{tocloft}
usepackage{etoolbox}
patchcmd{frontmatter}{pagenumbering{roman}}{pagenumbering{Roman}}{}{}
% ===== Define abstract environment =====
makeatletter
@ifclassloaded{report}{%
% Do nothing, everything seems to be setup already
}{@ifclassloaded{article}{%
% Do nothing, everything seems to be setup already
}{%
% Any other class that does not provide an abstract environment
% We have to define `abstractname` and the abstract environment (most likely)
% After that, load the abstract package
@ifundefined{abstractname}{newcommand{abstractname}{Abstract}}{}
@ifundefined{abstract}{%
if@titlepage
newenvironment{abstract}{%
titlepage
nullvfil
@beginparpenalty@lowpenalty
begin{center}%
bfseries abstractname
@endparpenalty@M
end{center}}%
{parvfilnullendtitlepage}
else
newenvironment{abstract}{%
if@twocolumn
section*{abstractname}%
% addcontentsline{toc}{section}{protectabstractname} Or add it here....
else
small
begin{center}%
{bfseries abstractnamevspace{-.5em}vspace{z@}}%
end{center}%
quotation
fi}
{if@twocolumnelseendquotationfi}
fi
% Eventually a check about the existence of endabstract, i.e. @ifundefined{endabstract}{}{}
}{%
% abstract environment presumably exists
}
}% End of @ifclassloaded{article}
}% End of @ifclassloaded{report}
makeatother
usepackage[addtotoc]{abstract}
begin{document}
frontmatter
pagestyle{plain}
tableofcontents
pagestyle{headings}
cleardoublepage
begin{abstract}
thispagestyle{plain}
blindtext
end{abstract}
cleardoublepage
listoffigures
cleardoublepage
listoftables
mainmatter
Blinddocument
Blinddocument
Blinddocument
end{document}
documentclass[notitlepage]{book}
usepackage[no-math]{fontspec}
usepackage[inline]{enumitem}
usepackage{blindtext}
usepackage[showframe]{geometry}
usepackage{tocbibind}
usepackage{tocloft}
usepackage{etoolbox}
patchcmd{frontmatter}{pagenumbering{roman}}{pagenumbering{Roman}}{}{}
% ===== Define abstract environment =====
makeatletter
@ifclassloaded{report}{%
% Do nothing, everything seems to be setup already
}{@ifclassloaded{article}{%
% Do nothing, everything seems to be setup already
}{%
% Any other class that does not provide an abstract environment
% We have to define `abstractname` and the abstract environment (most likely)
% After that, load the abstract package
@ifundefined{abstractname}{newcommand{abstractname}{Abstract}}{}
@ifundefined{abstract}{%
if@titlepage
newenvironment{abstract}{%
titlepage
nullvfil
@beginparpenalty@lowpenalty
begin{center}%
bfseries abstractname
@endparpenalty@M
end{center}}%
{parvfilnullendtitlepage}
else
newenvironment{abstract}{%
if@twocolumn
section*{abstractname}%
% addcontentsline{toc}{section}{protectabstractname} Or add it here....
else
small
begin{center}%
{bfseries abstractnamevspace{-.5em}vspace{z@}}%
end{center}%
quotation
fi}
{if@twocolumnelseendquotationfi}
fi
% Eventually a check about the existence of endabstract, i.e. @ifundefined{endabstract}{}{}
}{%
% abstract environment presumably exists
}
}% End of @ifclassloaded{article}
}% End of @ifclassloaded{report}
makeatother
usepackage[addtotoc]{abstract}
begin{document}
frontmatter
pagestyle{plain}
tableofcontents
pagestyle{headings}
cleardoublepage
begin{abstract}
thispagestyle{plain}
blindtext
end{abstract}
cleardoublepage
listoffigures
cleardoublepage
listoftables
mainmatter
Blinddocument
Blinddocument
Blinddocument
end{document}
answered 3 mins ago
Christian Hupfer
147k14192386
147k14192386
add a comment |
add a comment |
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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%2f445834%2fhow-can-i-patch-the-abstract-list-of-figures-and-list-of-tables-macros-to-be-i%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
You can add the line into the definition of abstract, see my answer from earlier today. For the list of stuff, simply use package tocbibind
– Johannes_B
Aug 13 at 7:50
Yes, but how about the list of tables and list of figures?
– Al-Motasem Aldaoudeyeh
Aug 13 at 16:18
Package
tocbibind
. See section 2.1 of the documentation.– Johannes_B
Aug 13 at 16:30