How to cumulate texts at the end into various groups?Repeating a block of text until it fills a pageEpigraph...
A bug in Excel? Conditional formatting for marking duplicates also highlights unique value
How can I handle a player who pre-plans arguments about my rulings on RAW?
A right or the right?
In iTunes 12 on macOS, how can I reset the skip count of a song?
Borrowing Characters
Can throughput exceed the bandwidth of a network
Plagiarism of code by other PhD student
Get length of the longest sequence of numbers with the same sign
In the comics did Thanos "kill" just sentient beings or all creatures with the snap?
What could trigger powerful quakes on icy world?
Filling in Area Under Curve Causes Alignment Issues
What is better: yes / no radio, or simple checkbox?
Real life puzzle: Unknown alphabet or shorthand
Book about a time-travel war fought by computers
I encountered my boss during an on-site interview at another company. Should I bring it up when seeing him next time?
How can half agree with the 3 percent of research that can't
Dystopian novel where telepathic humans live under a dome
Pure Functions: Does "No Side Effects" Imply "Always Same Output, Given Same Input"?
Why is s'abonner reflexive?
When was drinking water recognized as crucial in marathon running?
How to kill a localhost:8080
Erro: incompatible type for argument 1 of 'printf'
Wrap all numerics in JSON with quotes
What's the difference between the XOR instructions "VPXORD", "VXORPS" and "VXORPD" in Intel's AVX2
How to cumulate texts at the end into various groups?
Repeating a block of text until it fills a pageEpigraph in the end of the pageWhy the end-of-line % in macro definitions?How to create groups of table rows with alternating colors?How do I split large numbers into groups of five digits?How do you define a command to select nested groups?How can I make multiple references to the same footnote?Quote with author reference at the endSync the flow of two textsHow to add the chapter number into the chapter title using memoir class?
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 yesterday
Phelype Oleinik
23.8k54587
23.8k54587
asked yesterday
Prabhanjan NaibPrabhanjan Naib
1,37131632
1,37131632
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
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 |
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 |
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
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 5 hours ago
egregegreg
724k8819173222
724k8819173222
add a comment |
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}
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 2 hours ago
answered 8 hours ago
Ulrich DiezUlrich Diez
5,195619
5,195619
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