How to cumulate texts at the end into various groups?
Please help:
I am editing a .tex
file (memoir class) with lot of text, and I want to collect sentences like important questions, quotes, words, etc and collect them into their respective groups and be able to put them end of the book.
For example:
.tex
file
chapter{xyz}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam metus massa, molestie elementum tincidunt at, mollis et quam.
collectQuestion{Donec viverra posuere lorem, ac sagittis eros tincidunt interdum?}
Phasellus feugiat id justo at pretium.
Duis sed commodo velit. collectPhrase{Cras tempus} fermentum leo, ac congue nisl convallis vel.
chapter{abc}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam metus massa, molestie elementum tincidunt at, mollis et quam.
Donec viverra posuere lorem, ac sagittis eros tincidunt interdum.
Phasellus feugiat id justo at pretium. collectQuestion{Sed placerat sodales lorem sed sodales?}
Duis sed commodo velit. Cras tempus fermentum leo, collectPhrase{ac congue nisl} convallis vel.
.pdf
file
.
.
.
Questions?
- Donec viverra posuere lorem, ac sagittis eros tincidunt
interdum?..pg x - Sed placerat sodales lorem sed
sodales?........................................pg y
Phrases:
- Cras tempus (pg x)
- ac congue nisl (pg y)
macros memoir
add a comment |
Please help:
I am editing a .tex
file (memoir class) with lot of text, and I want to collect sentences like important questions, quotes, words, etc and collect them into their respective groups and be able to put them end of the book.
For example:
.tex
file
chapter{xyz}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam metus massa, molestie elementum tincidunt at, mollis et quam.
collectQuestion{Donec viverra posuere lorem, ac sagittis eros tincidunt interdum?}
Phasellus feugiat id justo at pretium.
Duis sed commodo velit. collectPhrase{Cras tempus} fermentum leo, ac congue nisl convallis vel.
chapter{abc}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam metus massa, molestie elementum tincidunt at, mollis et quam.
Donec viverra posuere lorem, ac sagittis eros tincidunt interdum.
Phasellus feugiat id justo at pretium. collectQuestion{Sed placerat sodales lorem sed sodales?}
Duis sed commodo velit. Cras tempus fermentum leo, collectPhrase{ac congue nisl} convallis vel.
.pdf
file
.
.
.
Questions?
- Donec viverra posuere lorem, ac sagittis eros tincidunt
interdum?..pg x - Sed placerat sodales lorem sed
sodales?........................................pg y
Phrases:
- Cras tempus (pg x)
- ac congue nisl (pg y)
macros memoir
add a comment |
Please help:
I am editing a .tex
file (memoir class) with lot of text, and I want to collect sentences like important questions, quotes, words, etc and collect them into their respective groups and be able to put them end of the book.
For example:
.tex
file
chapter{xyz}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam metus massa, molestie elementum tincidunt at, mollis et quam.
collectQuestion{Donec viverra posuere lorem, ac sagittis eros tincidunt interdum?}
Phasellus feugiat id justo at pretium.
Duis sed commodo velit. collectPhrase{Cras tempus} fermentum leo, ac congue nisl convallis vel.
chapter{abc}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam metus massa, molestie elementum tincidunt at, mollis et quam.
Donec viverra posuere lorem, ac sagittis eros tincidunt interdum.
Phasellus feugiat id justo at pretium. collectQuestion{Sed placerat sodales lorem sed sodales?}
Duis sed commodo velit. Cras tempus fermentum leo, collectPhrase{ac congue nisl} convallis vel.
.pdf
file
.
.
.
Questions?
- Donec viverra posuere lorem, ac sagittis eros tincidunt
interdum?..pg x - Sed placerat sodales lorem sed
sodales?........................................pg y
Phrases:
- Cras tempus (pg x)
- ac congue nisl (pg y)
macros memoir
Please help:
I am editing a .tex
file (memoir class) with lot of text, and I want to collect sentences like important questions, quotes, words, etc and collect them into their respective groups and be able to put them end of the book.
For example:
.tex
file
chapter{xyz}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam metus massa, molestie elementum tincidunt at, mollis et quam.
collectQuestion{Donec viverra posuere lorem, ac sagittis eros tincidunt interdum?}
Phasellus feugiat id justo at pretium.
Duis sed commodo velit. collectPhrase{Cras tempus} fermentum leo, ac congue nisl convallis vel.
chapter{abc}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam metus massa, molestie elementum tincidunt at, mollis et quam.
Donec viverra posuere lorem, ac sagittis eros tincidunt interdum.
Phasellus feugiat id justo at pretium. collectQuestion{Sed placerat sodales lorem sed sodales?}
Duis sed commodo velit. Cras tempus fermentum leo, collectPhrase{ac congue nisl} convallis vel.
.pdf
file
.
.
.
Questions?
- Donec viverra posuere lorem, ac sagittis eros tincidunt
interdum?..pg x - Sed placerat sodales lorem sed
sodales?........................................pg y
Phrases:
- Cras tempus (pg x)
- ac congue nisl (pg y)
macros memoir
macros memoir
edited Mar 4 at 19:53
Phelype Oleinik
24.1k54688
24.1k54688
asked Mar 4 at 19:47
Prabhanjan NaibPrabhanjan Naib
1,38331632
1,38331632
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
Please forgive me slight hints of irony:
"The Memoir Class", which as the basic user manual of memoir has only 611 pages, says that one can do something like this:
documentclass{memoir}
%usepackage{hyperref}
newcommand{listofphrasesname}{Phrases:}%
newlistof{listofphrases}{phr}{listofphrasesname}%
newlistentry{phrase}{phr}{0}%
cftpagenumbersoff{phrase}%
%
newcounter{phrases}
renewcommand{thephrases}{arabic{phrases}.}
newcommand{collectPhrase}[1]{%
#1%
stepcounter{phrases}%
addcontentsline{phr}{phrase}{protectnumberline{thephrases}#1~(pg~thepage)}%
}
newcommand{listofquestionsname}{Questions?}%
newlistof{listofquestions}{qst}{listofquestionsname}%
newlistentry{question}{qst}{0}%
cftpagenumberson{question}%
%
newcounter{questions}
renewcommand{thequestions}{arabic{questions}.}
newcommand{collectQuestion}[1]{%
#1%
stepcounter{questions}%
addcontentsline{qst}{question}{protectnumberline{thequestions}#1}%
}
makeatletter
newlengthmypagenumwidth
settowidthmypagenumwidth{@nameuse{cftquestionpagefont}pg~hb@xt@@pnumwidth{}}%
renewcommandcftquestionformatpnumhook[4]{%
hb@xt@mypagenumwidth{hfil@nameuse{cftquestionpagefont}pg~#1}%
}%
makeatother
begin{document}
tableofcontents
chapter{xyz}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam
metus massa, molestie elementum tincidunt at, mollis et
quam. collectQuestion{Donec viverra posuere lorem, ac sagittis
eros tincidunt interdum?} Phasellus feugiat id justo at pretium.
Duis sed commodo velit. collectPhrase{Cras tempus} fermentum
leo, ac congue nisl convallis vel.
chapter{abc}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam
metus massa, molestie elementum tincidunt at, mollis et
quam. Donec viverra posuere lorem, ac sagittis eros tincidunt
interdum. Phasellus feugiat id justo at
pretium. collectQuestion{Sed placerat sodales lorem sed
sodales?} Duis sed commodo velit. Cras tempus fermentum leo,
collectPhrase{ac congue nisl} convallis vel.
cleardoublepage
listofquestions*
listofphrases*
end{document}
Alternatively you can do something that keeps track of the width of the number of the question/phrase/page and saves the width of the widest question-number/phrase-number/page-number into a label from which it can in future LaTeX-runs be retrieved for setting cftqestionnumwidth
/cftphrasenumwidth
/the width of the hbox
that contains the page number:
documentclass{memoir}
%usepackage{hyperref}
makeatletter
newcommand{listofphrasesname}{Phrases:}%
newlistof{listofphrases}{phr}{listofphrasesname}%
newlistentry{phrase}{phr}{0}%
cftpagenumbersoff{phrase}%
%
newcounter{phrases}
renewcommand{thephrases}{arabic{phrases}.}
newlengthmaxphrasenumwidth
setlengthmaxphrasenumwidth{0pt}%
newcommand{collectPhrase}[1]{%
#1%
stepcounter{phrases}%
begingroup
settowidth{@tempdima}{@nameuse{cftphrasepagefont}thephrases~}%
ifdim@tempdima>maxphrasenumwidth
setlengthmaxphrasenumwidth@tempdima
globalmaxphrasenumwidthmaxphrasenumwidth
fi
endgroup
addcontentsline{phr}{phrase}{%
protectnumberline{protecthfillthephrasesprotect~}%
#1protect~(pgprotect~thepage)%
}%
}
AtBeginDocument{%
@ifundefined{r@maxphrasenumwidth}{%
settowidthcftphrasenumwidth{@nameuse{cftphrasepagefont}100.~}%
}{%
setlengthcftphrasenumwidth{r@maxphrasenumwidth}%
}%
}%
AtEndDocument{%
immediatewrite@auxout{%
stringnewlabel{maxphrasenumwidth}{themaxphrasenumwidth}%
}%
}%
newlengthmypagenumwidth
newlengthmypagenumsep
newcommand{listofquestionsname}{Questions?}%
newlistof{listofquestions}{qst}{listofquestionsname}%
newlistentry{question}{qst}{0}%
cftpagenumberson{question}%
newcounter{questions}
renewcommand{thequestions}{arabic{questions}.}
newlengthmaxquestnumwidth
setlengthmaxquestnumwidth{0pt}%
newlengthmaxpagenumwidth
setlengthmaxpagenumwidth{0pt}%
newcommand{collectQuestion}[1]{%
#1%
stepcounter{questions}%
begingroup
settowidth{@tempdima}{@nameuse{cftquestionpagefont}thequestions~}%
ifdim@tempdima>maxquestnumwidth
setlengthmaxquestnumwidth@tempdima
globalmaxquestnumwidthmaxquestnumwidth
fi
settowidth{@tempdima}{@nameuse{cftquestionpagefont}pg~thepage}%
ifdim@tempdima>maxpagenumwidth
setlengthmaxpagenumwidth@tempdima
globalmaxpagenumwidthmaxpagenumwidth
fi
endgroup
addcontentsline{qst}{question}{%
protectnumberline{protecthfillthequestionsprotect~}#1%
}%
}%
AtBeginDocument{%
settowidthmypagenumsep{@nameuse{cftquestionpagefont}m}%
setlengthmypagenumsep{1.5mypagenumsep}%
@ifundefined{r@maxquestnumwidth}{%
settowidthcftquestionnumwidth{@nameuse{cftquestionpagefont}100.~}%
}{%
setlengthcftquestionnumwidth{r@maxquestnumwidth}%
}%
@ifundefined{r@maxpagenumwidth}{%
settowidthmypagenumwidth{%
@nameuse{cftquestionpagefont}pg~hb@xt@@pnumwidth{}%
}%
}{%
setlengthmypagenumwidth{r@maxpagenumwidth}%
}%
cftinsertcode{questionrightadjust}{%
setpnumwidth{mypagenumwidth}%
setrmarg{dimexprmypagenumsep+mypagenumwidthrelax}%
}%
cftinserthook{qst}{questionrightadjust}%
}%
AtEndDocument{%
immediatewrite@auxout{%
stringnewlabel{maxquestnumwidth}{themaxquestnumwidth}%
}%
immediatewrite@auxout{%
stringnewlabel{maxpagenumwidth}{themaxpagenumwidth}%
}%
}%
renewcommandcftquestionformatpnumhook[4]{%
hb@xt@mypagenumwidth{@nameuse{cftquestionpagefont}pg~#1hfil}%
%hb@xt@mypagenumwidth{@nameuse{cftquestionpagefont}pghfil#1}%
%hbox{@nameuse{cftquestionpagefont}pg~#1}%
}%
makeatother
begin{document}
tableofcontents
chapter{xyz}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam
metus massa, molestie elementum tincidunt at, mollis et
quam. collectQuestion{Donec viverra posuere lorem, ac sagittis
eros tincidunt interdum?} Phasellus feugiat id justo at pretium.
Duis sed commodo velit. collectPhrase{Cras tempus} fermentum
leo, ac congue nisl convallis vel.
chapter{abc}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam
metus massa, molestie elementum tincidunt at, mollis et
quam. Donec viverra posuere lorem, ac sagittis eros tincidunt
interdum. Phasellus feugiat id justo at
pretium. collectQuestion{Sed placerat sodales lorem sed
sodales?} Duis sed commodo velit. Cras tempus fermentum leo,
collectPhrase{ac congue nisl} convallis vel.
collectPhrase{ac congue nisl}.
collectPhrase{ac congue nisl}.
collectPhrase{ac congue nisl}.
collectPhrase{ac congue nisl}.
collectPhrase{ac congue nisl}.
collectPhrase{ac congue nisl}.
collectPhrase{ac congue nisl}.
collectPhrase{ac congue nisl}.
collectPhrase{ac congue nisl}.
collectPhrase{ac congue nisl}.
collectPhrase{ac congue nisl}.
collectPhrase{ac congue nisl}.
newpagesetcounter{page}{1000}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam
metus massa, molestie elementum tincidunt at, mollis et quam.
collectQuestion{Sed placerat sodales lorem sed
sodales?} collectPhrase{Cras tempus} fermentum
leo, ac congue nisl convallis vel.
cleardoublepage
listofquestions*
listofphrases*
end{document}
add a comment |
If you want to write the questions and phrases at the end, in the order they appeared:
documentclass[a4paper]{memoir}
usepackage{xparse}
makeatletter
newcommand{mdotfill}[1][1em]{%
leavevmode
linebreak[0]%
mbox{}nobreak
cleaders hb@xt@ .44em{hss.hss}hskip #1 plus 1fill
kernz@
}
makeatother
ExplSyntaxOn
NewDocumentCommand{collectQuestion}{m}
{
naib_collect:Nnn g_naib_collect_question_seq { #1 } { mdotfill }
}
NewDocumentCommand{collectPhrase}{m}
{
naib_collect:Nnn g_naib_collect_phrase_seq { #1 } { nobreakspace }
}
NewDocumentCommand{printQuestions}{}
{
begin{enumerate}
seq_use:Nn g_naib_collect_question_seq {}
end{enumerate}
}
NewDocumentCommand{printPhrases}{}
{
begin{enumerate}
seq_use:Nn g_naib_collect_phrase_seq {}
end{enumerate}
}
int_new:N g_naib_collect_int
seq_new:N g_naib_collect_question_seq
seq_new:N g_naib_collect_phrase_seq
cs_new_protected:Nn naib_collect:Nnn
{
int_gincr:N g_naib_collect_int
label{ naib @ int_to_roman:n { g_naib_collect_int } }
naib_collect_append:Nenn
#1
{ naib @ int_to_roman:n { g_naib_collect_int } } % the generated label
{ #2 } % the text
{ #3 } % the separation
}
cs_new_protected:Nn naib_collect_append:Nnnn
{
seq_gput_right:Nn #1 { naib_collect_print:nnn {#2}{#3}{#4} }
}
cs_generate_variant:Nn naib_collect_append:Nnnn { Ne }
cs_new_protected:Nn naib_collect_print:nnn
{
item #2#3(pg.nobreakspacepageref{#1})
}
ExplSyntaxOff
begin{document}
chapter{xyz}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam metus massa, molestie elementum
tincidunt at, mollis et quam.collectQuestion{Donec viverra posuere lorem, ac sagittis eros tincidunt
interdum feugiat?} Phasellus feugiat id justo at pretium. Duis sed commodo velit.collectPhrase{Cras
tempus} fermentum leo, ac congue nisl convallis vel.
chapter{abc}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam metus massa, molestie elementum
tincidunt at, mollis et quam. Donec viverra posuere lorem, ac sagittis eros tincidunt interdum.
Phasellus feugiat id justo at pretium. collectQuestion{Sed placerat sodales lorem sed sodales?} Duis
sed commodo velit. Cras tempus fermentum leo, collectPhrase{ac congue nisl} convallis vel.
chapter{QP}
section{Questions}
printQuestions
section{Phrases}
printPhrases
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%2f477762%2fhow-to-cumulate-texts-at-the-end-into-various-groups%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
Please forgive me slight hints of irony:
"The Memoir Class", which as the basic user manual of memoir has only 611 pages, says that one can do something like this:
documentclass{memoir}
%usepackage{hyperref}
newcommand{listofphrasesname}{Phrases:}%
newlistof{listofphrases}{phr}{listofphrasesname}%
newlistentry{phrase}{phr}{0}%
cftpagenumbersoff{phrase}%
%
newcounter{phrases}
renewcommand{thephrases}{arabic{phrases}.}
newcommand{collectPhrase}[1]{%
#1%
stepcounter{phrases}%
addcontentsline{phr}{phrase}{protectnumberline{thephrases}#1~(pg~thepage)}%
}
newcommand{listofquestionsname}{Questions?}%
newlistof{listofquestions}{qst}{listofquestionsname}%
newlistentry{question}{qst}{0}%
cftpagenumberson{question}%
%
newcounter{questions}
renewcommand{thequestions}{arabic{questions}.}
newcommand{collectQuestion}[1]{%
#1%
stepcounter{questions}%
addcontentsline{qst}{question}{protectnumberline{thequestions}#1}%
}
makeatletter
newlengthmypagenumwidth
settowidthmypagenumwidth{@nameuse{cftquestionpagefont}pg~hb@xt@@pnumwidth{}}%
renewcommandcftquestionformatpnumhook[4]{%
hb@xt@mypagenumwidth{hfil@nameuse{cftquestionpagefont}pg~#1}%
}%
makeatother
begin{document}
tableofcontents
chapter{xyz}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam
metus massa, molestie elementum tincidunt at, mollis et
quam. collectQuestion{Donec viverra posuere lorem, ac sagittis
eros tincidunt interdum?} Phasellus feugiat id justo at pretium.
Duis sed commodo velit. collectPhrase{Cras tempus} fermentum
leo, ac congue nisl convallis vel.
chapter{abc}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam
metus massa, molestie elementum tincidunt at, mollis et
quam. Donec viverra posuere lorem, ac sagittis eros tincidunt
interdum. Phasellus feugiat id justo at
pretium. collectQuestion{Sed placerat sodales lorem sed
sodales?} Duis sed commodo velit. Cras tempus fermentum leo,
collectPhrase{ac congue nisl} convallis vel.
cleardoublepage
listofquestions*
listofphrases*
end{document}
Alternatively you can do something that keeps track of the width of the number of the question/phrase/page and saves the width of the widest question-number/phrase-number/page-number into a label from which it can in future LaTeX-runs be retrieved for setting cftqestionnumwidth
/cftphrasenumwidth
/the width of the hbox
that contains the page number:
documentclass{memoir}
%usepackage{hyperref}
makeatletter
newcommand{listofphrasesname}{Phrases:}%
newlistof{listofphrases}{phr}{listofphrasesname}%
newlistentry{phrase}{phr}{0}%
cftpagenumbersoff{phrase}%
%
newcounter{phrases}
renewcommand{thephrases}{arabic{phrases}.}
newlengthmaxphrasenumwidth
setlengthmaxphrasenumwidth{0pt}%
newcommand{collectPhrase}[1]{%
#1%
stepcounter{phrases}%
begingroup
settowidth{@tempdima}{@nameuse{cftphrasepagefont}thephrases~}%
ifdim@tempdima>maxphrasenumwidth
setlengthmaxphrasenumwidth@tempdima
globalmaxphrasenumwidthmaxphrasenumwidth
fi
endgroup
addcontentsline{phr}{phrase}{%
protectnumberline{protecthfillthephrasesprotect~}%
#1protect~(pgprotect~thepage)%
}%
}
AtBeginDocument{%
@ifundefined{r@maxphrasenumwidth}{%
settowidthcftphrasenumwidth{@nameuse{cftphrasepagefont}100.~}%
}{%
setlengthcftphrasenumwidth{r@maxphrasenumwidth}%
}%
}%
AtEndDocument{%
immediatewrite@auxout{%
stringnewlabel{maxphrasenumwidth}{themaxphrasenumwidth}%
}%
}%
newlengthmypagenumwidth
newlengthmypagenumsep
newcommand{listofquestionsname}{Questions?}%
newlistof{listofquestions}{qst}{listofquestionsname}%
newlistentry{question}{qst}{0}%
cftpagenumberson{question}%
newcounter{questions}
renewcommand{thequestions}{arabic{questions}.}
newlengthmaxquestnumwidth
setlengthmaxquestnumwidth{0pt}%
newlengthmaxpagenumwidth
setlengthmaxpagenumwidth{0pt}%
newcommand{collectQuestion}[1]{%
#1%
stepcounter{questions}%
begingroup
settowidth{@tempdima}{@nameuse{cftquestionpagefont}thequestions~}%
ifdim@tempdima>maxquestnumwidth
setlengthmaxquestnumwidth@tempdima
globalmaxquestnumwidthmaxquestnumwidth
fi
settowidth{@tempdima}{@nameuse{cftquestionpagefont}pg~thepage}%
ifdim@tempdima>maxpagenumwidth
setlengthmaxpagenumwidth@tempdima
globalmaxpagenumwidthmaxpagenumwidth
fi
endgroup
addcontentsline{qst}{question}{%
protectnumberline{protecthfillthequestionsprotect~}#1%
}%
}%
AtBeginDocument{%
settowidthmypagenumsep{@nameuse{cftquestionpagefont}m}%
setlengthmypagenumsep{1.5mypagenumsep}%
@ifundefined{r@maxquestnumwidth}{%
settowidthcftquestionnumwidth{@nameuse{cftquestionpagefont}100.~}%
}{%
setlengthcftquestionnumwidth{r@maxquestnumwidth}%
}%
@ifundefined{r@maxpagenumwidth}{%
settowidthmypagenumwidth{%
@nameuse{cftquestionpagefont}pg~hb@xt@@pnumwidth{}%
}%
}{%
setlengthmypagenumwidth{r@maxpagenumwidth}%
}%
cftinsertcode{questionrightadjust}{%
setpnumwidth{mypagenumwidth}%
setrmarg{dimexprmypagenumsep+mypagenumwidthrelax}%
}%
cftinserthook{qst}{questionrightadjust}%
}%
AtEndDocument{%
immediatewrite@auxout{%
stringnewlabel{maxquestnumwidth}{themaxquestnumwidth}%
}%
immediatewrite@auxout{%
stringnewlabel{maxpagenumwidth}{themaxpagenumwidth}%
}%
}%
renewcommandcftquestionformatpnumhook[4]{%
hb@xt@mypagenumwidth{@nameuse{cftquestionpagefont}pg~#1hfil}%
%hb@xt@mypagenumwidth{@nameuse{cftquestionpagefont}pghfil#1}%
%hbox{@nameuse{cftquestionpagefont}pg~#1}%
}%
makeatother
begin{document}
tableofcontents
chapter{xyz}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam
metus massa, molestie elementum tincidunt at, mollis et
quam. collectQuestion{Donec viverra posuere lorem, ac sagittis
eros tincidunt interdum?} Phasellus feugiat id justo at pretium.
Duis sed commodo velit. collectPhrase{Cras tempus} fermentum
leo, ac congue nisl convallis vel.
chapter{abc}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam
metus massa, molestie elementum tincidunt at, mollis et
quam. Donec viverra posuere lorem, ac sagittis eros tincidunt
interdum. Phasellus feugiat id justo at
pretium. collectQuestion{Sed placerat sodales lorem sed
sodales?} Duis sed commodo velit. Cras tempus fermentum leo,
collectPhrase{ac congue nisl} convallis vel.
collectPhrase{ac congue nisl}.
collectPhrase{ac congue nisl}.
collectPhrase{ac congue nisl}.
collectPhrase{ac congue nisl}.
collectPhrase{ac congue nisl}.
collectPhrase{ac congue nisl}.
collectPhrase{ac congue nisl}.
collectPhrase{ac congue nisl}.
collectPhrase{ac congue nisl}.
collectPhrase{ac congue nisl}.
collectPhrase{ac congue nisl}.
collectPhrase{ac congue nisl}.
newpagesetcounter{page}{1000}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam
metus massa, molestie elementum tincidunt at, mollis et quam.
collectQuestion{Sed placerat sodales lorem sed
sodales?} collectPhrase{Cras tempus} fermentum
leo, ac congue nisl convallis vel.
cleardoublepage
listofquestions*
listofphrases*
end{document}
add a comment |
Please forgive me slight hints of irony:
"The Memoir Class", which as the basic user manual of memoir has only 611 pages, says that one can do something like this:
documentclass{memoir}
%usepackage{hyperref}
newcommand{listofphrasesname}{Phrases:}%
newlistof{listofphrases}{phr}{listofphrasesname}%
newlistentry{phrase}{phr}{0}%
cftpagenumbersoff{phrase}%
%
newcounter{phrases}
renewcommand{thephrases}{arabic{phrases}.}
newcommand{collectPhrase}[1]{%
#1%
stepcounter{phrases}%
addcontentsline{phr}{phrase}{protectnumberline{thephrases}#1~(pg~thepage)}%
}
newcommand{listofquestionsname}{Questions?}%
newlistof{listofquestions}{qst}{listofquestionsname}%
newlistentry{question}{qst}{0}%
cftpagenumberson{question}%
%
newcounter{questions}
renewcommand{thequestions}{arabic{questions}.}
newcommand{collectQuestion}[1]{%
#1%
stepcounter{questions}%
addcontentsline{qst}{question}{protectnumberline{thequestions}#1}%
}
makeatletter
newlengthmypagenumwidth
settowidthmypagenumwidth{@nameuse{cftquestionpagefont}pg~hb@xt@@pnumwidth{}}%
renewcommandcftquestionformatpnumhook[4]{%
hb@xt@mypagenumwidth{hfil@nameuse{cftquestionpagefont}pg~#1}%
}%
makeatother
begin{document}
tableofcontents
chapter{xyz}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam
metus massa, molestie elementum tincidunt at, mollis et
quam. collectQuestion{Donec viverra posuere lorem, ac sagittis
eros tincidunt interdum?} Phasellus feugiat id justo at pretium.
Duis sed commodo velit. collectPhrase{Cras tempus} fermentum
leo, ac congue nisl convallis vel.
chapter{abc}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam
metus massa, molestie elementum tincidunt at, mollis et
quam. Donec viverra posuere lorem, ac sagittis eros tincidunt
interdum. Phasellus feugiat id justo at
pretium. collectQuestion{Sed placerat sodales lorem sed
sodales?} Duis sed commodo velit. Cras tempus fermentum leo,
collectPhrase{ac congue nisl} convallis vel.
cleardoublepage
listofquestions*
listofphrases*
end{document}
Alternatively you can do something that keeps track of the width of the number of the question/phrase/page and saves the width of the widest question-number/phrase-number/page-number into a label from which it can in future LaTeX-runs be retrieved for setting cftqestionnumwidth
/cftphrasenumwidth
/the width of the hbox
that contains the page number:
documentclass{memoir}
%usepackage{hyperref}
makeatletter
newcommand{listofphrasesname}{Phrases:}%
newlistof{listofphrases}{phr}{listofphrasesname}%
newlistentry{phrase}{phr}{0}%
cftpagenumbersoff{phrase}%
%
newcounter{phrases}
renewcommand{thephrases}{arabic{phrases}.}
newlengthmaxphrasenumwidth
setlengthmaxphrasenumwidth{0pt}%
newcommand{collectPhrase}[1]{%
#1%
stepcounter{phrases}%
begingroup
settowidth{@tempdima}{@nameuse{cftphrasepagefont}thephrases~}%
ifdim@tempdima>maxphrasenumwidth
setlengthmaxphrasenumwidth@tempdima
globalmaxphrasenumwidthmaxphrasenumwidth
fi
endgroup
addcontentsline{phr}{phrase}{%
protectnumberline{protecthfillthephrasesprotect~}%
#1protect~(pgprotect~thepage)%
}%
}
AtBeginDocument{%
@ifundefined{r@maxphrasenumwidth}{%
settowidthcftphrasenumwidth{@nameuse{cftphrasepagefont}100.~}%
}{%
setlengthcftphrasenumwidth{r@maxphrasenumwidth}%
}%
}%
AtEndDocument{%
immediatewrite@auxout{%
stringnewlabel{maxphrasenumwidth}{themaxphrasenumwidth}%
}%
}%
newlengthmypagenumwidth
newlengthmypagenumsep
newcommand{listofquestionsname}{Questions?}%
newlistof{listofquestions}{qst}{listofquestionsname}%
newlistentry{question}{qst}{0}%
cftpagenumberson{question}%
newcounter{questions}
renewcommand{thequestions}{arabic{questions}.}
newlengthmaxquestnumwidth
setlengthmaxquestnumwidth{0pt}%
newlengthmaxpagenumwidth
setlengthmaxpagenumwidth{0pt}%
newcommand{collectQuestion}[1]{%
#1%
stepcounter{questions}%
begingroup
settowidth{@tempdima}{@nameuse{cftquestionpagefont}thequestions~}%
ifdim@tempdima>maxquestnumwidth
setlengthmaxquestnumwidth@tempdima
globalmaxquestnumwidthmaxquestnumwidth
fi
settowidth{@tempdima}{@nameuse{cftquestionpagefont}pg~thepage}%
ifdim@tempdima>maxpagenumwidth
setlengthmaxpagenumwidth@tempdima
globalmaxpagenumwidthmaxpagenumwidth
fi
endgroup
addcontentsline{qst}{question}{%
protectnumberline{protecthfillthequestionsprotect~}#1%
}%
}%
AtBeginDocument{%
settowidthmypagenumsep{@nameuse{cftquestionpagefont}m}%
setlengthmypagenumsep{1.5mypagenumsep}%
@ifundefined{r@maxquestnumwidth}{%
settowidthcftquestionnumwidth{@nameuse{cftquestionpagefont}100.~}%
}{%
setlengthcftquestionnumwidth{r@maxquestnumwidth}%
}%
@ifundefined{r@maxpagenumwidth}{%
settowidthmypagenumwidth{%
@nameuse{cftquestionpagefont}pg~hb@xt@@pnumwidth{}%
}%
}{%
setlengthmypagenumwidth{r@maxpagenumwidth}%
}%
cftinsertcode{questionrightadjust}{%
setpnumwidth{mypagenumwidth}%
setrmarg{dimexprmypagenumsep+mypagenumwidthrelax}%
}%
cftinserthook{qst}{questionrightadjust}%
}%
AtEndDocument{%
immediatewrite@auxout{%
stringnewlabel{maxquestnumwidth}{themaxquestnumwidth}%
}%
immediatewrite@auxout{%
stringnewlabel{maxpagenumwidth}{themaxpagenumwidth}%
}%
}%
renewcommandcftquestionformatpnumhook[4]{%
hb@xt@mypagenumwidth{@nameuse{cftquestionpagefont}pg~#1hfil}%
%hb@xt@mypagenumwidth{@nameuse{cftquestionpagefont}pghfil#1}%
%hbox{@nameuse{cftquestionpagefont}pg~#1}%
}%
makeatother
begin{document}
tableofcontents
chapter{xyz}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam
metus massa, molestie elementum tincidunt at, mollis et
quam. collectQuestion{Donec viverra posuere lorem, ac sagittis
eros tincidunt interdum?} Phasellus feugiat id justo at pretium.
Duis sed commodo velit. collectPhrase{Cras tempus} fermentum
leo, ac congue nisl convallis vel.
chapter{abc}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam
metus massa, molestie elementum tincidunt at, mollis et
quam. Donec viverra posuere lorem, ac sagittis eros tincidunt
interdum. Phasellus feugiat id justo at
pretium. collectQuestion{Sed placerat sodales lorem sed
sodales?} Duis sed commodo velit. Cras tempus fermentum leo,
collectPhrase{ac congue nisl} convallis vel.
collectPhrase{ac congue nisl}.
collectPhrase{ac congue nisl}.
collectPhrase{ac congue nisl}.
collectPhrase{ac congue nisl}.
collectPhrase{ac congue nisl}.
collectPhrase{ac congue nisl}.
collectPhrase{ac congue nisl}.
collectPhrase{ac congue nisl}.
collectPhrase{ac congue nisl}.
collectPhrase{ac congue nisl}.
collectPhrase{ac congue nisl}.
collectPhrase{ac congue nisl}.
newpagesetcounter{page}{1000}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam
metus massa, molestie elementum tincidunt at, mollis et quam.
collectQuestion{Sed placerat sodales lorem sed
sodales?} collectPhrase{Cras tempus} fermentum
leo, ac congue nisl convallis vel.
cleardoublepage
listofquestions*
listofphrases*
end{document}
add a comment |
Please forgive me slight hints of irony:
"The Memoir Class", which as the basic user manual of memoir has only 611 pages, says that one can do something like this:
documentclass{memoir}
%usepackage{hyperref}
newcommand{listofphrasesname}{Phrases:}%
newlistof{listofphrases}{phr}{listofphrasesname}%
newlistentry{phrase}{phr}{0}%
cftpagenumbersoff{phrase}%
%
newcounter{phrases}
renewcommand{thephrases}{arabic{phrases}.}
newcommand{collectPhrase}[1]{%
#1%
stepcounter{phrases}%
addcontentsline{phr}{phrase}{protectnumberline{thephrases}#1~(pg~thepage)}%
}
newcommand{listofquestionsname}{Questions?}%
newlistof{listofquestions}{qst}{listofquestionsname}%
newlistentry{question}{qst}{0}%
cftpagenumberson{question}%
%
newcounter{questions}
renewcommand{thequestions}{arabic{questions}.}
newcommand{collectQuestion}[1]{%
#1%
stepcounter{questions}%
addcontentsline{qst}{question}{protectnumberline{thequestions}#1}%
}
makeatletter
newlengthmypagenumwidth
settowidthmypagenumwidth{@nameuse{cftquestionpagefont}pg~hb@xt@@pnumwidth{}}%
renewcommandcftquestionformatpnumhook[4]{%
hb@xt@mypagenumwidth{hfil@nameuse{cftquestionpagefont}pg~#1}%
}%
makeatother
begin{document}
tableofcontents
chapter{xyz}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam
metus massa, molestie elementum tincidunt at, mollis et
quam. collectQuestion{Donec viverra posuere lorem, ac sagittis
eros tincidunt interdum?} Phasellus feugiat id justo at pretium.
Duis sed commodo velit. collectPhrase{Cras tempus} fermentum
leo, ac congue nisl convallis vel.
chapter{abc}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam
metus massa, molestie elementum tincidunt at, mollis et
quam. Donec viverra posuere lorem, ac sagittis eros tincidunt
interdum. Phasellus feugiat id justo at
pretium. collectQuestion{Sed placerat sodales lorem sed
sodales?} Duis sed commodo velit. Cras tempus fermentum leo,
collectPhrase{ac congue nisl} convallis vel.
cleardoublepage
listofquestions*
listofphrases*
end{document}
Alternatively you can do something that keeps track of the width of the number of the question/phrase/page and saves the width of the widest question-number/phrase-number/page-number into a label from which it can in future LaTeX-runs be retrieved for setting cftqestionnumwidth
/cftphrasenumwidth
/the width of the hbox
that contains the page number:
documentclass{memoir}
%usepackage{hyperref}
makeatletter
newcommand{listofphrasesname}{Phrases:}%
newlistof{listofphrases}{phr}{listofphrasesname}%
newlistentry{phrase}{phr}{0}%
cftpagenumbersoff{phrase}%
%
newcounter{phrases}
renewcommand{thephrases}{arabic{phrases}.}
newlengthmaxphrasenumwidth
setlengthmaxphrasenumwidth{0pt}%
newcommand{collectPhrase}[1]{%
#1%
stepcounter{phrases}%
begingroup
settowidth{@tempdima}{@nameuse{cftphrasepagefont}thephrases~}%
ifdim@tempdima>maxphrasenumwidth
setlengthmaxphrasenumwidth@tempdima
globalmaxphrasenumwidthmaxphrasenumwidth
fi
endgroup
addcontentsline{phr}{phrase}{%
protectnumberline{protecthfillthephrasesprotect~}%
#1protect~(pgprotect~thepage)%
}%
}
AtBeginDocument{%
@ifundefined{r@maxphrasenumwidth}{%
settowidthcftphrasenumwidth{@nameuse{cftphrasepagefont}100.~}%
}{%
setlengthcftphrasenumwidth{r@maxphrasenumwidth}%
}%
}%
AtEndDocument{%
immediatewrite@auxout{%
stringnewlabel{maxphrasenumwidth}{themaxphrasenumwidth}%
}%
}%
newlengthmypagenumwidth
newlengthmypagenumsep
newcommand{listofquestionsname}{Questions?}%
newlistof{listofquestions}{qst}{listofquestionsname}%
newlistentry{question}{qst}{0}%
cftpagenumberson{question}%
newcounter{questions}
renewcommand{thequestions}{arabic{questions}.}
newlengthmaxquestnumwidth
setlengthmaxquestnumwidth{0pt}%
newlengthmaxpagenumwidth
setlengthmaxpagenumwidth{0pt}%
newcommand{collectQuestion}[1]{%
#1%
stepcounter{questions}%
begingroup
settowidth{@tempdima}{@nameuse{cftquestionpagefont}thequestions~}%
ifdim@tempdima>maxquestnumwidth
setlengthmaxquestnumwidth@tempdima
globalmaxquestnumwidthmaxquestnumwidth
fi
settowidth{@tempdima}{@nameuse{cftquestionpagefont}pg~thepage}%
ifdim@tempdima>maxpagenumwidth
setlengthmaxpagenumwidth@tempdima
globalmaxpagenumwidthmaxpagenumwidth
fi
endgroup
addcontentsline{qst}{question}{%
protectnumberline{protecthfillthequestionsprotect~}#1%
}%
}%
AtBeginDocument{%
settowidthmypagenumsep{@nameuse{cftquestionpagefont}m}%
setlengthmypagenumsep{1.5mypagenumsep}%
@ifundefined{r@maxquestnumwidth}{%
settowidthcftquestionnumwidth{@nameuse{cftquestionpagefont}100.~}%
}{%
setlengthcftquestionnumwidth{r@maxquestnumwidth}%
}%
@ifundefined{r@maxpagenumwidth}{%
settowidthmypagenumwidth{%
@nameuse{cftquestionpagefont}pg~hb@xt@@pnumwidth{}%
}%
}{%
setlengthmypagenumwidth{r@maxpagenumwidth}%
}%
cftinsertcode{questionrightadjust}{%
setpnumwidth{mypagenumwidth}%
setrmarg{dimexprmypagenumsep+mypagenumwidthrelax}%
}%
cftinserthook{qst}{questionrightadjust}%
}%
AtEndDocument{%
immediatewrite@auxout{%
stringnewlabel{maxquestnumwidth}{themaxquestnumwidth}%
}%
immediatewrite@auxout{%
stringnewlabel{maxpagenumwidth}{themaxpagenumwidth}%
}%
}%
renewcommandcftquestionformatpnumhook[4]{%
hb@xt@mypagenumwidth{@nameuse{cftquestionpagefont}pg~#1hfil}%
%hb@xt@mypagenumwidth{@nameuse{cftquestionpagefont}pghfil#1}%
%hbox{@nameuse{cftquestionpagefont}pg~#1}%
}%
makeatother
begin{document}
tableofcontents
chapter{xyz}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam
metus massa, molestie elementum tincidunt at, mollis et
quam. collectQuestion{Donec viverra posuere lorem, ac sagittis
eros tincidunt interdum?} Phasellus feugiat id justo at pretium.
Duis sed commodo velit. collectPhrase{Cras tempus} fermentum
leo, ac congue nisl convallis vel.
chapter{abc}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam
metus massa, molestie elementum tincidunt at, mollis et
quam. Donec viverra posuere lorem, ac sagittis eros tincidunt
interdum. Phasellus feugiat id justo at
pretium. collectQuestion{Sed placerat sodales lorem sed
sodales?} Duis sed commodo velit. Cras tempus fermentum leo,
collectPhrase{ac congue nisl} convallis vel.
collectPhrase{ac congue nisl}.
collectPhrase{ac congue nisl}.
collectPhrase{ac congue nisl}.
collectPhrase{ac congue nisl}.
collectPhrase{ac congue nisl}.
collectPhrase{ac congue nisl}.
collectPhrase{ac congue nisl}.
collectPhrase{ac congue nisl}.
collectPhrase{ac congue nisl}.
collectPhrase{ac congue nisl}.
collectPhrase{ac congue nisl}.
collectPhrase{ac congue nisl}.
newpagesetcounter{page}{1000}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam
metus massa, molestie elementum tincidunt at, mollis et quam.
collectQuestion{Sed placerat sodales lorem sed
sodales?} collectPhrase{Cras tempus} fermentum
leo, ac congue nisl convallis vel.
cleardoublepage
listofquestions*
listofphrases*
end{document}
Please forgive me slight hints of irony:
"The Memoir Class", which as the basic user manual of memoir has only 611 pages, says that one can do something like this:
documentclass{memoir}
%usepackage{hyperref}
newcommand{listofphrasesname}{Phrases:}%
newlistof{listofphrases}{phr}{listofphrasesname}%
newlistentry{phrase}{phr}{0}%
cftpagenumbersoff{phrase}%
%
newcounter{phrases}
renewcommand{thephrases}{arabic{phrases}.}
newcommand{collectPhrase}[1]{%
#1%
stepcounter{phrases}%
addcontentsline{phr}{phrase}{protectnumberline{thephrases}#1~(pg~thepage)}%
}
newcommand{listofquestionsname}{Questions?}%
newlistof{listofquestions}{qst}{listofquestionsname}%
newlistentry{question}{qst}{0}%
cftpagenumberson{question}%
%
newcounter{questions}
renewcommand{thequestions}{arabic{questions}.}
newcommand{collectQuestion}[1]{%
#1%
stepcounter{questions}%
addcontentsline{qst}{question}{protectnumberline{thequestions}#1}%
}
makeatletter
newlengthmypagenumwidth
settowidthmypagenumwidth{@nameuse{cftquestionpagefont}pg~hb@xt@@pnumwidth{}}%
renewcommandcftquestionformatpnumhook[4]{%
hb@xt@mypagenumwidth{hfil@nameuse{cftquestionpagefont}pg~#1}%
}%
makeatother
begin{document}
tableofcontents
chapter{xyz}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam
metus massa, molestie elementum tincidunt at, mollis et
quam. collectQuestion{Donec viverra posuere lorem, ac sagittis
eros tincidunt interdum?} Phasellus feugiat id justo at pretium.
Duis sed commodo velit. collectPhrase{Cras tempus} fermentum
leo, ac congue nisl convallis vel.
chapter{abc}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam
metus massa, molestie elementum tincidunt at, mollis et
quam. Donec viverra posuere lorem, ac sagittis eros tincidunt
interdum. Phasellus feugiat id justo at
pretium. collectQuestion{Sed placerat sodales lorem sed
sodales?} Duis sed commodo velit. Cras tempus fermentum leo,
collectPhrase{ac congue nisl} convallis vel.
cleardoublepage
listofquestions*
listofphrases*
end{document}
Alternatively you can do something that keeps track of the width of the number of the question/phrase/page and saves the width of the widest question-number/phrase-number/page-number into a label from which it can in future LaTeX-runs be retrieved for setting cftqestionnumwidth
/cftphrasenumwidth
/the width of the hbox
that contains the page number:
documentclass{memoir}
%usepackage{hyperref}
makeatletter
newcommand{listofphrasesname}{Phrases:}%
newlistof{listofphrases}{phr}{listofphrasesname}%
newlistentry{phrase}{phr}{0}%
cftpagenumbersoff{phrase}%
%
newcounter{phrases}
renewcommand{thephrases}{arabic{phrases}.}
newlengthmaxphrasenumwidth
setlengthmaxphrasenumwidth{0pt}%
newcommand{collectPhrase}[1]{%
#1%
stepcounter{phrases}%
begingroup
settowidth{@tempdima}{@nameuse{cftphrasepagefont}thephrases~}%
ifdim@tempdima>maxphrasenumwidth
setlengthmaxphrasenumwidth@tempdima
globalmaxphrasenumwidthmaxphrasenumwidth
fi
endgroup
addcontentsline{phr}{phrase}{%
protectnumberline{protecthfillthephrasesprotect~}%
#1protect~(pgprotect~thepage)%
}%
}
AtBeginDocument{%
@ifundefined{r@maxphrasenumwidth}{%
settowidthcftphrasenumwidth{@nameuse{cftphrasepagefont}100.~}%
}{%
setlengthcftphrasenumwidth{r@maxphrasenumwidth}%
}%
}%
AtEndDocument{%
immediatewrite@auxout{%
stringnewlabel{maxphrasenumwidth}{themaxphrasenumwidth}%
}%
}%
newlengthmypagenumwidth
newlengthmypagenumsep
newcommand{listofquestionsname}{Questions?}%
newlistof{listofquestions}{qst}{listofquestionsname}%
newlistentry{question}{qst}{0}%
cftpagenumberson{question}%
newcounter{questions}
renewcommand{thequestions}{arabic{questions}.}
newlengthmaxquestnumwidth
setlengthmaxquestnumwidth{0pt}%
newlengthmaxpagenumwidth
setlengthmaxpagenumwidth{0pt}%
newcommand{collectQuestion}[1]{%
#1%
stepcounter{questions}%
begingroup
settowidth{@tempdima}{@nameuse{cftquestionpagefont}thequestions~}%
ifdim@tempdima>maxquestnumwidth
setlengthmaxquestnumwidth@tempdima
globalmaxquestnumwidthmaxquestnumwidth
fi
settowidth{@tempdima}{@nameuse{cftquestionpagefont}pg~thepage}%
ifdim@tempdima>maxpagenumwidth
setlengthmaxpagenumwidth@tempdima
globalmaxpagenumwidthmaxpagenumwidth
fi
endgroup
addcontentsline{qst}{question}{%
protectnumberline{protecthfillthequestionsprotect~}#1%
}%
}%
AtBeginDocument{%
settowidthmypagenumsep{@nameuse{cftquestionpagefont}m}%
setlengthmypagenumsep{1.5mypagenumsep}%
@ifundefined{r@maxquestnumwidth}{%
settowidthcftquestionnumwidth{@nameuse{cftquestionpagefont}100.~}%
}{%
setlengthcftquestionnumwidth{r@maxquestnumwidth}%
}%
@ifundefined{r@maxpagenumwidth}{%
settowidthmypagenumwidth{%
@nameuse{cftquestionpagefont}pg~hb@xt@@pnumwidth{}%
}%
}{%
setlengthmypagenumwidth{r@maxpagenumwidth}%
}%
cftinsertcode{questionrightadjust}{%
setpnumwidth{mypagenumwidth}%
setrmarg{dimexprmypagenumsep+mypagenumwidthrelax}%
}%
cftinserthook{qst}{questionrightadjust}%
}%
AtEndDocument{%
immediatewrite@auxout{%
stringnewlabel{maxquestnumwidth}{themaxquestnumwidth}%
}%
immediatewrite@auxout{%
stringnewlabel{maxpagenumwidth}{themaxpagenumwidth}%
}%
}%
renewcommandcftquestionformatpnumhook[4]{%
hb@xt@mypagenumwidth{@nameuse{cftquestionpagefont}pg~#1hfil}%
%hb@xt@mypagenumwidth{@nameuse{cftquestionpagefont}pghfil#1}%
%hbox{@nameuse{cftquestionpagefont}pg~#1}%
}%
makeatother
begin{document}
tableofcontents
chapter{xyz}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam
metus massa, molestie elementum tincidunt at, mollis et
quam. collectQuestion{Donec viverra posuere lorem, ac sagittis
eros tincidunt interdum?} Phasellus feugiat id justo at pretium.
Duis sed commodo velit. collectPhrase{Cras tempus} fermentum
leo, ac congue nisl convallis vel.
chapter{abc}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam
metus massa, molestie elementum tincidunt at, mollis et
quam. Donec viverra posuere lorem, ac sagittis eros tincidunt
interdum. Phasellus feugiat id justo at
pretium. collectQuestion{Sed placerat sodales lorem sed
sodales?} Duis sed commodo velit. Cras tempus fermentum leo,
collectPhrase{ac congue nisl} convallis vel.
collectPhrase{ac congue nisl}.
collectPhrase{ac congue nisl}.
collectPhrase{ac congue nisl}.
collectPhrase{ac congue nisl}.
collectPhrase{ac congue nisl}.
collectPhrase{ac congue nisl}.
collectPhrase{ac congue nisl}.
collectPhrase{ac congue nisl}.
collectPhrase{ac congue nisl}.
collectPhrase{ac congue nisl}.
collectPhrase{ac congue nisl}.
collectPhrase{ac congue nisl}.
newpagesetcounter{page}{1000}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam
metus massa, molestie elementum tincidunt at, mollis et quam.
collectQuestion{Sed placerat sodales lorem sed
sodales?} collectPhrase{Cras tempus} fermentum
leo, ac congue nisl convallis vel.
cleardoublepage
listofquestions*
listofphrases*
end{document}
edited Mar 5 at 19:39
answered Mar 5 at 14:00
Ulrich DiezUlrich Diez
5,390619
5,390619
add a comment |
add a comment |
If you want to write the questions and phrases at the end, in the order they appeared:
documentclass[a4paper]{memoir}
usepackage{xparse}
makeatletter
newcommand{mdotfill}[1][1em]{%
leavevmode
linebreak[0]%
mbox{}nobreak
cleaders hb@xt@ .44em{hss.hss}hskip #1 plus 1fill
kernz@
}
makeatother
ExplSyntaxOn
NewDocumentCommand{collectQuestion}{m}
{
naib_collect:Nnn g_naib_collect_question_seq { #1 } { mdotfill }
}
NewDocumentCommand{collectPhrase}{m}
{
naib_collect:Nnn g_naib_collect_phrase_seq { #1 } { nobreakspace }
}
NewDocumentCommand{printQuestions}{}
{
begin{enumerate}
seq_use:Nn g_naib_collect_question_seq {}
end{enumerate}
}
NewDocumentCommand{printPhrases}{}
{
begin{enumerate}
seq_use:Nn g_naib_collect_phrase_seq {}
end{enumerate}
}
int_new:N g_naib_collect_int
seq_new:N g_naib_collect_question_seq
seq_new:N g_naib_collect_phrase_seq
cs_new_protected:Nn naib_collect:Nnn
{
int_gincr:N g_naib_collect_int
label{ naib @ int_to_roman:n { g_naib_collect_int } }
naib_collect_append:Nenn
#1
{ naib @ int_to_roman:n { g_naib_collect_int } } % the generated label
{ #2 } % the text
{ #3 } % the separation
}
cs_new_protected:Nn naib_collect_append:Nnnn
{
seq_gput_right:Nn #1 { naib_collect_print:nnn {#2}{#3}{#4} }
}
cs_generate_variant:Nn naib_collect_append:Nnnn { Ne }
cs_new_protected:Nn naib_collect_print:nnn
{
item #2#3(pg.nobreakspacepageref{#1})
}
ExplSyntaxOff
begin{document}
chapter{xyz}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam metus massa, molestie elementum
tincidunt at, mollis et quam.collectQuestion{Donec viverra posuere lorem, ac sagittis eros tincidunt
interdum feugiat?} Phasellus feugiat id justo at pretium. Duis sed commodo velit.collectPhrase{Cras
tempus} fermentum leo, ac congue nisl convallis vel.
chapter{abc}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam metus massa, molestie elementum
tincidunt at, mollis et quam. Donec viverra posuere lorem, ac sagittis eros tincidunt interdum.
Phasellus feugiat id justo at pretium. collectQuestion{Sed placerat sodales lorem sed sodales?} Duis
sed commodo velit. Cras tempus fermentum leo, collectPhrase{ac congue nisl} convallis vel.
chapter{QP}
section{Questions}
printQuestions
section{Phrases}
printPhrases
end{document}
add a comment |
If you want to write the questions and phrases at the end, in the order they appeared:
documentclass[a4paper]{memoir}
usepackage{xparse}
makeatletter
newcommand{mdotfill}[1][1em]{%
leavevmode
linebreak[0]%
mbox{}nobreak
cleaders hb@xt@ .44em{hss.hss}hskip #1 plus 1fill
kernz@
}
makeatother
ExplSyntaxOn
NewDocumentCommand{collectQuestion}{m}
{
naib_collect:Nnn g_naib_collect_question_seq { #1 } { mdotfill }
}
NewDocumentCommand{collectPhrase}{m}
{
naib_collect:Nnn g_naib_collect_phrase_seq { #1 } { nobreakspace }
}
NewDocumentCommand{printQuestions}{}
{
begin{enumerate}
seq_use:Nn g_naib_collect_question_seq {}
end{enumerate}
}
NewDocumentCommand{printPhrases}{}
{
begin{enumerate}
seq_use:Nn g_naib_collect_phrase_seq {}
end{enumerate}
}
int_new:N g_naib_collect_int
seq_new:N g_naib_collect_question_seq
seq_new:N g_naib_collect_phrase_seq
cs_new_protected:Nn naib_collect:Nnn
{
int_gincr:N g_naib_collect_int
label{ naib @ int_to_roman:n { g_naib_collect_int } }
naib_collect_append:Nenn
#1
{ naib @ int_to_roman:n { g_naib_collect_int } } % the generated label
{ #2 } % the text
{ #3 } % the separation
}
cs_new_protected:Nn naib_collect_append:Nnnn
{
seq_gput_right:Nn #1 { naib_collect_print:nnn {#2}{#3}{#4} }
}
cs_generate_variant:Nn naib_collect_append:Nnnn { Ne }
cs_new_protected:Nn naib_collect_print:nnn
{
item #2#3(pg.nobreakspacepageref{#1})
}
ExplSyntaxOff
begin{document}
chapter{xyz}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam metus massa, molestie elementum
tincidunt at, mollis et quam.collectQuestion{Donec viverra posuere lorem, ac sagittis eros tincidunt
interdum feugiat?} Phasellus feugiat id justo at pretium. Duis sed commodo velit.collectPhrase{Cras
tempus} fermentum leo, ac congue nisl convallis vel.
chapter{abc}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam metus massa, molestie elementum
tincidunt at, mollis et quam. Donec viverra posuere lorem, ac sagittis eros tincidunt interdum.
Phasellus feugiat id justo at pretium. collectQuestion{Sed placerat sodales lorem sed sodales?} Duis
sed commodo velit. Cras tempus fermentum leo, collectPhrase{ac congue nisl} convallis vel.
chapter{QP}
section{Questions}
printQuestions
section{Phrases}
printPhrases
end{document}
add a comment |
If you want to write the questions and phrases at the end, in the order they appeared:
documentclass[a4paper]{memoir}
usepackage{xparse}
makeatletter
newcommand{mdotfill}[1][1em]{%
leavevmode
linebreak[0]%
mbox{}nobreak
cleaders hb@xt@ .44em{hss.hss}hskip #1 plus 1fill
kernz@
}
makeatother
ExplSyntaxOn
NewDocumentCommand{collectQuestion}{m}
{
naib_collect:Nnn g_naib_collect_question_seq { #1 } { mdotfill }
}
NewDocumentCommand{collectPhrase}{m}
{
naib_collect:Nnn g_naib_collect_phrase_seq { #1 } { nobreakspace }
}
NewDocumentCommand{printQuestions}{}
{
begin{enumerate}
seq_use:Nn g_naib_collect_question_seq {}
end{enumerate}
}
NewDocumentCommand{printPhrases}{}
{
begin{enumerate}
seq_use:Nn g_naib_collect_phrase_seq {}
end{enumerate}
}
int_new:N g_naib_collect_int
seq_new:N g_naib_collect_question_seq
seq_new:N g_naib_collect_phrase_seq
cs_new_protected:Nn naib_collect:Nnn
{
int_gincr:N g_naib_collect_int
label{ naib @ int_to_roman:n { g_naib_collect_int } }
naib_collect_append:Nenn
#1
{ naib @ int_to_roman:n { g_naib_collect_int } } % the generated label
{ #2 } % the text
{ #3 } % the separation
}
cs_new_protected:Nn naib_collect_append:Nnnn
{
seq_gput_right:Nn #1 { naib_collect_print:nnn {#2}{#3}{#4} }
}
cs_generate_variant:Nn naib_collect_append:Nnnn { Ne }
cs_new_protected:Nn naib_collect_print:nnn
{
item #2#3(pg.nobreakspacepageref{#1})
}
ExplSyntaxOff
begin{document}
chapter{xyz}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam metus massa, molestie elementum
tincidunt at, mollis et quam.collectQuestion{Donec viverra posuere lorem, ac sagittis eros tincidunt
interdum feugiat?} Phasellus feugiat id justo at pretium. Duis sed commodo velit.collectPhrase{Cras
tempus} fermentum leo, ac congue nisl convallis vel.
chapter{abc}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam metus massa, molestie elementum
tincidunt at, mollis et quam. Donec viverra posuere lorem, ac sagittis eros tincidunt interdum.
Phasellus feugiat id justo at pretium. collectQuestion{Sed placerat sodales lorem sed sodales?} Duis
sed commodo velit. Cras tempus fermentum leo, collectPhrase{ac congue nisl} convallis vel.
chapter{QP}
section{Questions}
printQuestions
section{Phrases}
printPhrases
end{document}
If you want to write the questions and phrases at the end, in the order they appeared:
documentclass[a4paper]{memoir}
usepackage{xparse}
makeatletter
newcommand{mdotfill}[1][1em]{%
leavevmode
linebreak[0]%
mbox{}nobreak
cleaders hb@xt@ .44em{hss.hss}hskip #1 plus 1fill
kernz@
}
makeatother
ExplSyntaxOn
NewDocumentCommand{collectQuestion}{m}
{
naib_collect:Nnn g_naib_collect_question_seq { #1 } { mdotfill }
}
NewDocumentCommand{collectPhrase}{m}
{
naib_collect:Nnn g_naib_collect_phrase_seq { #1 } { nobreakspace }
}
NewDocumentCommand{printQuestions}{}
{
begin{enumerate}
seq_use:Nn g_naib_collect_question_seq {}
end{enumerate}
}
NewDocumentCommand{printPhrases}{}
{
begin{enumerate}
seq_use:Nn g_naib_collect_phrase_seq {}
end{enumerate}
}
int_new:N g_naib_collect_int
seq_new:N g_naib_collect_question_seq
seq_new:N g_naib_collect_phrase_seq
cs_new_protected:Nn naib_collect:Nnn
{
int_gincr:N g_naib_collect_int
label{ naib @ int_to_roman:n { g_naib_collect_int } }
naib_collect_append:Nenn
#1
{ naib @ int_to_roman:n { g_naib_collect_int } } % the generated label
{ #2 } % the text
{ #3 } % the separation
}
cs_new_protected:Nn naib_collect_append:Nnnn
{
seq_gput_right:Nn #1 { naib_collect_print:nnn {#2}{#3}{#4} }
}
cs_generate_variant:Nn naib_collect_append:Nnnn { Ne }
cs_new_protected:Nn naib_collect_print:nnn
{
item #2#3(pg.nobreakspacepageref{#1})
}
ExplSyntaxOff
begin{document}
chapter{xyz}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam metus massa, molestie elementum
tincidunt at, mollis et quam.collectQuestion{Donec viverra posuere lorem, ac sagittis eros tincidunt
interdum feugiat?} Phasellus feugiat id justo at pretium. Duis sed commodo velit.collectPhrase{Cras
tempus} fermentum leo, ac congue nisl convallis vel.
chapter{abc}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam metus massa, molestie elementum
tincidunt at, mollis et quam. Donec viverra posuere lorem, ac sagittis eros tincidunt interdum.
Phasellus feugiat id justo at pretium. collectQuestion{Sed placerat sodales lorem sed sodales?} Duis
sed commodo velit. Cras tempus fermentum leo, collectPhrase{ac congue nisl} convallis vel.
chapter{QP}
section{Questions}
printQuestions
section{Phrases}
printPhrases
end{document}
answered Mar 5 at 17:01
egregegreg
726k8819193228
726k8819193228
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.
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%2f477762%2fhow-to-cumulate-texts-at-the-end-into-various-groups%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