Looping over charts and names simultaneouslyIncrements in foreach loop with two variables, TikZLooping and linking with TikZlooping in tabularCreate a document looping through imagesLooping over elements to change font in math modeLooping Through a Nested ListTikZ scaling graphic and adjust node position and keep font sizeLooping over stringsLooping over macro arguments with spaces and building partial commandsAlternating/looping section dividerstikzset does not work in foreach loop
How to return a security deposit to a tenant
Can U.S. Tax Forms Be Legally HTMLified?
Soft question: Examples where lack of mathematical rigour cause security breaches?
How can electric fields be used to detect cracks in metals?
Mathematically, why does mass matrix / load vector lumping work?
Do simulator games use a realistic trajectory to get into orbit?
Can tefillin be "switched"?
Did Milano or Benatar approve or comment on their namesake MCU ships?
Existence of a pointwise convergent subsequence
How can I tell the difference between unmarked sugar and stevia?
Winning Strategy for the Magician and his Apprentice
How to hide an urban landmark?
Why is only the fundamental frequency component said to give useful power?
Is using haveibeenpwned to validate password strength rational?
What is the actual quality of machine translations?
Thread Pool C++ Implementation
SOQL Not Recognizing Field?
How can I end combat quickly when the outcome is inevitable?
Someone whose aspirations exceed abilities or means
Preventing employees from either switching to competitors or opening their own business
How Often Do Health Insurance Providers Drop Coverage?
Are there any important biographies of nobodies?
Why is one of Madera Municipal's runways labelled with only "R" on both sides?
Medieval flying castle propulsion
Looping over charts and names simultaneously
Increments in foreach loop with two variables, TikZLooping and linking with TikZlooping in tabularCreate a document looping through imagesLooping over elements to change font in math modeLooping Through a Nested ListTikZ scaling graphic and adjust node position and keep font sizeLooping over stringsLooping over macro arguments with spaces and building partial commandsAlternating/looping section dividerstikzset does not work in foreach loop
I want to use a common index to loop over two separate comma-separated lists at once, one which is a list of abbreviations and one a list of names. I want to use the abbreviations to import charts as pdfs, and the names to label them.
This is what I have so far:
documentclass[12pt]article
usepackagetikz
usepackagegraphicx
defnamelist"New York", "Illinois","Texas"
defabrevlistNY,IL,TX
begindocument
foreach x in abrevlist %
newpage
section*x % <-- I want to use the state name here
beginfigure[h!]
includegraphics[width=.5textwidth]../charts/summary/x _compare.pdf
captionx % <-- I want to use the state name here
endfigure
enddocument
This imports the figures as I want, but does nothing with the state names. I would like to replace the section and captions with, for example, "New York" in place of "NYC".
Obviously, one could create an index i
and loop over that to index the abbreviation or name as necessary. But I can't make that work. Any suggestions? Thanks!
tikz-pgf macros graphics loops
add a comment |
I want to use a common index to loop over two separate comma-separated lists at once, one which is a list of abbreviations and one a list of names. I want to use the abbreviations to import charts as pdfs, and the names to label them.
This is what I have so far:
documentclass[12pt]article
usepackagetikz
usepackagegraphicx
defnamelist"New York", "Illinois","Texas"
defabrevlistNY,IL,TX
begindocument
foreach x in abrevlist %
newpage
section*x % <-- I want to use the state name here
beginfigure[h!]
includegraphics[width=.5textwidth]../charts/summary/x _compare.pdf
captionx % <-- I want to use the state name here
endfigure
enddocument
This imports the figures as I want, but does nothing with the state names. I would like to replace the section and captions with, for example, "New York" in place of "NYC".
Obviously, one could create an index i
and loop over that to index the abbreviation or name as necessary. But I can't make that work. Any suggestions? Thanks!
tikz-pgf macros graphics loops
add a comment |
I want to use a common index to loop over two separate comma-separated lists at once, one which is a list of abbreviations and one a list of names. I want to use the abbreviations to import charts as pdfs, and the names to label them.
This is what I have so far:
documentclass[12pt]article
usepackagetikz
usepackagegraphicx
defnamelist"New York", "Illinois","Texas"
defabrevlistNY,IL,TX
begindocument
foreach x in abrevlist %
newpage
section*x % <-- I want to use the state name here
beginfigure[h!]
includegraphics[width=.5textwidth]../charts/summary/x _compare.pdf
captionx % <-- I want to use the state name here
endfigure
enddocument
This imports the figures as I want, but does nothing with the state names. I would like to replace the section and captions with, for example, "New York" in place of "NYC".
Obviously, one could create an index i
and loop over that to index the abbreviation or name as necessary. But I can't make that work. Any suggestions? Thanks!
tikz-pgf macros graphics loops
I want to use a common index to loop over two separate comma-separated lists at once, one which is a list of abbreviations and one a list of names. I want to use the abbreviations to import charts as pdfs, and the names to label them.
This is what I have so far:
documentclass[12pt]article
usepackagetikz
usepackagegraphicx
defnamelist"New York", "Illinois","Texas"
defabrevlistNY,IL,TX
begindocument
foreach x in abrevlist %
newpage
section*x % <-- I want to use the state name here
beginfigure[h!]
includegraphics[width=.5textwidth]../charts/summary/x _compare.pdf
captionx % <-- I want to use the state name here
endfigure
enddocument
This imports the figures as I want, but does nothing with the state names. I would like to replace the section and captions with, for example, "New York" in place of "NYC".
Obviously, one could create an index i
and loop over that to index the abbreviation or name as necessary. But I can't make that work. Any suggestions? Thanks!
tikz-pgf macros graphics loops
tikz-pgf macros graphics loops
asked May 21 at 20:49
squipbarsquipbar
1283
1283
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
If you do not need both lists elsewhere, you can just combine them in a single list:
documentclass[12pt]article
%usepackagetikz
usepackagepgffor
usepackagegraphicx
defnamelistNew York/NY,Illinois/IL,Texas/TX
begindocument
foreach x/y in namelist %
newpage
section*x % <-- I want to use the state name here
beginfigure[h!]
% includegraphics[width=.5textwidth]../charts/summary/x _compare.pdf
texttt../charts/summary/y-compare.pdf
captionx % <-- I want to use the state name here
endfigure
enddocument
(The texttt
part shamelessly copied from @egreg)
It is not necessary to load the whole tikz
, pgffor
is enough for this.
add a comment |
documentclass[12pt]article
usepackagetikz
defnamelist"New York", "Illinois","Texas"
defabrevlistNY,IL,TX
begindocument
foreach X [count=Y starting from 0] in abrevlist %
newpagepgfmathsetmacromystatenamelist[Y]
section*mystate % <-- I want to use the state name here
beginfigure[h!]
%includegraphics[width=.5textwidth]../charts/summary/X _compare.pdf
captionX % <-- I want to use the state name here
endfigure
enddocument
Nice, but you removed the line that references the filename for the figure. Can you edit to retain that? Will your X still work ok there?
– squipbar
May 21 at 21:13
@squipbar Good catch. I removed it because I do not have your graphics files.Now it should work if you uncomment it. (There are reasons whyX
might be better thanx
, even though here it does not matter.)
– marmot
May 21 at 21:18
This still gives me an error. I get:! Package PGF Math Error: Unknown function
New' (in 'New York,Illinois,Texas[0]').`
– squipbar
May 21 at 21:54
@squipbar Do you run the precise code from above or a version in which you removed the"
fromnamelist
? The error message suggests that you are using something likedefnamelistNew York,Illinois,Texas
ordefnamelistNew York,Illinois,Texas
. Also the number ofis important in
pgfmathsetmacromystatenamelist[Y]
, i.e.pgfmathsetmacromystatenamelist[Y]
won't work.
– marmot
May 21 at 21:57
Yes, I was removing the"
. But only because I was getting an error when I included them! With them, I get! Missing number, treated as zero. <to be read again> N l.18 ~
. So it looks like this solution is indexing the "N" somehow, rather than the whole fist entry, "New York" (evidence: if I change the first state to Illinois, thatN
becomes anI
).
– squipbar
May 22 at 14:39
|
show 1 more comment
Here's my proposal.
documentclassarticle
usepackagexparse
ExplSyntaxOn
NewDocumentCommandmaketwoprongedlistm m
prop_new:c g_squipbar_list_#1_plist
seq_new:c g_squipbar_list_#1_seq
clist_map_inline:nn #2
__squipbar_list_entry:nnn #1 ##1
cs_new_protected:Nn __squipbar_list_entry:nnn
seq_gput_right:cn g_squipbar_list_#1_seq #2
prop_gput:cnn g_squipbar_list_#1_plist short@#2 #2
prop_gput:cnn g_squipbar_list_#1_plist long@#2 #3
NewDocumentCommandusetwoprongedlistm +m
cs_set_protected:Nn __squipbar_list_entry:nn #2
seq_map_inline:cn g_squipbar_list_#1_seq
__squipbar_list_entry:nn
prop_item:cn g_squipbar_list_#1_plist short@##1
prop_item:cn g_squipbar_list_#1_plist long@##1
ExplSyntaxOff
maketwoprongedliststates
NYNew York,
ILIllinois,
TXTexas
begindocument
usetwoprongedliststates%
newpage
section*#2 % <-- I want to use the state name here
beginfigure[h!]
centering
%includegraphics[width=.5textwidth]../charts/summary/x _compare.pdf
texttt../charts/summary/#1-compare.pdf
caption#2 % <-- I want to use the state name here
endfigure
enddocument
Since I don't have your pictures, I emulated them by just printing the file name.
How does this work?
First of all, I define a list giving it a name. The items are comma separated and should consist of <abbreviation><full name>
. The first part is also used for indexing and so it should consist of characters only (but this might be overcome, in case of need).
Each part is then stored as an item in a property list, indexed as short@<abbreviation>
and long@<abbreviation>
. Also a sequence is maintained containing the abbreviations, for later usage; the order will be that of input.
The usetwoprongedlist
command has two arguments: the first is the list to be processed; the second argument is a template, just like the main argument to foreach
; the difference is that #1
and #2
are used to denote the short and long versions of the current item.
A scratch function is defined and then the sequence indexing the list's items is mapped, calling the scratch function with arguments
prop_item:cn <list name> short@<current item>
and
prop_item:cn <list name> long@<current item>
respectively. Et voilà.
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%2f492002%2flooping-over-charts-and-names-simultaneously%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
If you do not need both lists elsewhere, you can just combine them in a single list:
documentclass[12pt]article
%usepackagetikz
usepackagepgffor
usepackagegraphicx
defnamelistNew York/NY,Illinois/IL,Texas/TX
begindocument
foreach x/y in namelist %
newpage
section*x % <-- I want to use the state name here
beginfigure[h!]
% includegraphics[width=.5textwidth]../charts/summary/x _compare.pdf
texttt../charts/summary/y-compare.pdf
captionx % <-- I want to use the state name here
endfigure
enddocument
(The texttt
part shamelessly copied from @egreg)
It is not necessary to load the whole tikz
, pgffor
is enough for this.
add a comment |
If you do not need both lists elsewhere, you can just combine them in a single list:
documentclass[12pt]article
%usepackagetikz
usepackagepgffor
usepackagegraphicx
defnamelistNew York/NY,Illinois/IL,Texas/TX
begindocument
foreach x/y in namelist %
newpage
section*x % <-- I want to use the state name here
beginfigure[h!]
% includegraphics[width=.5textwidth]../charts/summary/x _compare.pdf
texttt../charts/summary/y-compare.pdf
captionx % <-- I want to use the state name here
endfigure
enddocument
(The texttt
part shamelessly copied from @egreg)
It is not necessary to load the whole tikz
, pgffor
is enough for this.
add a comment |
If you do not need both lists elsewhere, you can just combine them in a single list:
documentclass[12pt]article
%usepackagetikz
usepackagepgffor
usepackagegraphicx
defnamelistNew York/NY,Illinois/IL,Texas/TX
begindocument
foreach x/y in namelist %
newpage
section*x % <-- I want to use the state name here
beginfigure[h!]
% includegraphics[width=.5textwidth]../charts/summary/x _compare.pdf
texttt../charts/summary/y-compare.pdf
captionx % <-- I want to use the state name here
endfigure
enddocument
(The texttt
part shamelessly copied from @egreg)
It is not necessary to load the whole tikz
, pgffor
is enough for this.
If you do not need both lists elsewhere, you can just combine them in a single list:
documentclass[12pt]article
%usepackagetikz
usepackagepgffor
usepackagegraphicx
defnamelistNew York/NY,Illinois/IL,Texas/TX
begindocument
foreach x/y in namelist %
newpage
section*x % <-- I want to use the state name here
beginfigure[h!]
% includegraphics[width=.5textwidth]../charts/summary/x _compare.pdf
texttt../charts/summary/y-compare.pdf
captionx % <-- I want to use the state name here
endfigure
enddocument
(The texttt
part shamelessly copied from @egreg)
It is not necessary to load the whole tikz
, pgffor
is enough for this.
answered May 22 at 15:47
Raoul KesselsRaoul Kessels
2,021617
2,021617
add a comment |
add a comment |
documentclass[12pt]article
usepackagetikz
defnamelist"New York", "Illinois","Texas"
defabrevlistNY,IL,TX
begindocument
foreach X [count=Y starting from 0] in abrevlist %
newpagepgfmathsetmacromystatenamelist[Y]
section*mystate % <-- I want to use the state name here
beginfigure[h!]
%includegraphics[width=.5textwidth]../charts/summary/X _compare.pdf
captionX % <-- I want to use the state name here
endfigure
enddocument
Nice, but you removed the line that references the filename for the figure. Can you edit to retain that? Will your X still work ok there?
– squipbar
May 21 at 21:13
@squipbar Good catch. I removed it because I do not have your graphics files.Now it should work if you uncomment it. (There are reasons whyX
might be better thanx
, even though here it does not matter.)
– marmot
May 21 at 21:18
This still gives me an error. I get:! Package PGF Math Error: Unknown function
New' (in 'New York,Illinois,Texas[0]').`
– squipbar
May 21 at 21:54
@squipbar Do you run the precise code from above or a version in which you removed the"
fromnamelist
? The error message suggests that you are using something likedefnamelistNew York,Illinois,Texas
ordefnamelistNew York,Illinois,Texas
. Also the number ofis important in
pgfmathsetmacromystatenamelist[Y]
, i.e.pgfmathsetmacromystatenamelist[Y]
won't work.
– marmot
May 21 at 21:57
Yes, I was removing the"
. But only because I was getting an error when I included them! With them, I get! Missing number, treated as zero. <to be read again> N l.18 ~
. So it looks like this solution is indexing the "N" somehow, rather than the whole fist entry, "New York" (evidence: if I change the first state to Illinois, thatN
becomes anI
).
– squipbar
May 22 at 14:39
|
show 1 more comment
documentclass[12pt]article
usepackagetikz
defnamelist"New York", "Illinois","Texas"
defabrevlistNY,IL,TX
begindocument
foreach X [count=Y starting from 0] in abrevlist %
newpagepgfmathsetmacromystatenamelist[Y]
section*mystate % <-- I want to use the state name here
beginfigure[h!]
%includegraphics[width=.5textwidth]../charts/summary/X _compare.pdf
captionX % <-- I want to use the state name here
endfigure
enddocument
Nice, but you removed the line that references the filename for the figure. Can you edit to retain that? Will your X still work ok there?
– squipbar
May 21 at 21:13
@squipbar Good catch. I removed it because I do not have your graphics files.Now it should work if you uncomment it. (There are reasons whyX
might be better thanx
, even though here it does not matter.)
– marmot
May 21 at 21:18
This still gives me an error. I get:! Package PGF Math Error: Unknown function
New' (in 'New York,Illinois,Texas[0]').`
– squipbar
May 21 at 21:54
@squipbar Do you run the precise code from above or a version in which you removed the"
fromnamelist
? The error message suggests that you are using something likedefnamelistNew York,Illinois,Texas
ordefnamelistNew York,Illinois,Texas
. Also the number ofis important in
pgfmathsetmacromystatenamelist[Y]
, i.e.pgfmathsetmacromystatenamelist[Y]
won't work.
– marmot
May 21 at 21:57
Yes, I was removing the"
. But only because I was getting an error when I included them! With them, I get! Missing number, treated as zero. <to be read again> N l.18 ~
. So it looks like this solution is indexing the "N" somehow, rather than the whole fist entry, "New York" (evidence: if I change the first state to Illinois, thatN
becomes anI
).
– squipbar
May 22 at 14:39
|
show 1 more comment
documentclass[12pt]article
usepackagetikz
defnamelist"New York", "Illinois","Texas"
defabrevlistNY,IL,TX
begindocument
foreach X [count=Y starting from 0] in abrevlist %
newpagepgfmathsetmacromystatenamelist[Y]
section*mystate % <-- I want to use the state name here
beginfigure[h!]
%includegraphics[width=.5textwidth]../charts/summary/X _compare.pdf
captionX % <-- I want to use the state name here
endfigure
enddocument
documentclass[12pt]article
usepackagetikz
defnamelist"New York", "Illinois","Texas"
defabrevlistNY,IL,TX
begindocument
foreach X [count=Y starting from 0] in abrevlist %
newpagepgfmathsetmacromystatenamelist[Y]
section*mystate % <-- I want to use the state name here
beginfigure[h!]
%includegraphics[width=.5textwidth]../charts/summary/X _compare.pdf
captionX % <-- I want to use the state name here
endfigure
enddocument
edited May 21 at 21:16
answered May 21 at 21:00
marmotmarmot
133k6169319
133k6169319
Nice, but you removed the line that references the filename for the figure. Can you edit to retain that? Will your X still work ok there?
– squipbar
May 21 at 21:13
@squipbar Good catch. I removed it because I do not have your graphics files.Now it should work if you uncomment it. (There are reasons whyX
might be better thanx
, even though here it does not matter.)
– marmot
May 21 at 21:18
This still gives me an error. I get:! Package PGF Math Error: Unknown function
New' (in 'New York,Illinois,Texas[0]').`
– squipbar
May 21 at 21:54
@squipbar Do you run the precise code from above or a version in which you removed the"
fromnamelist
? The error message suggests that you are using something likedefnamelistNew York,Illinois,Texas
ordefnamelistNew York,Illinois,Texas
. Also the number ofis important in
pgfmathsetmacromystatenamelist[Y]
, i.e.pgfmathsetmacromystatenamelist[Y]
won't work.
– marmot
May 21 at 21:57
Yes, I was removing the"
. But only because I was getting an error when I included them! With them, I get! Missing number, treated as zero. <to be read again> N l.18 ~
. So it looks like this solution is indexing the "N" somehow, rather than the whole fist entry, "New York" (evidence: if I change the first state to Illinois, thatN
becomes anI
).
– squipbar
May 22 at 14:39
|
show 1 more comment
Nice, but you removed the line that references the filename for the figure. Can you edit to retain that? Will your X still work ok there?
– squipbar
May 21 at 21:13
@squipbar Good catch. I removed it because I do not have your graphics files.Now it should work if you uncomment it. (There are reasons whyX
might be better thanx
, even though here it does not matter.)
– marmot
May 21 at 21:18
This still gives me an error. I get:! Package PGF Math Error: Unknown function
New' (in 'New York,Illinois,Texas[0]').`
– squipbar
May 21 at 21:54
@squipbar Do you run the precise code from above or a version in which you removed the"
fromnamelist
? The error message suggests that you are using something likedefnamelistNew York,Illinois,Texas
ordefnamelistNew York,Illinois,Texas
. Also the number ofis important in
pgfmathsetmacromystatenamelist[Y]
, i.e.pgfmathsetmacromystatenamelist[Y]
won't work.
– marmot
May 21 at 21:57
Yes, I was removing the"
. But only because I was getting an error when I included them! With them, I get! Missing number, treated as zero. <to be read again> N l.18 ~
. So it looks like this solution is indexing the "N" somehow, rather than the whole fist entry, "New York" (evidence: if I change the first state to Illinois, thatN
becomes anI
).
– squipbar
May 22 at 14:39
Nice, but you removed the line that references the filename for the figure. Can you edit to retain that? Will your X still work ok there?
– squipbar
May 21 at 21:13
Nice, but you removed the line that references the filename for the figure. Can you edit to retain that? Will your X still work ok there?
– squipbar
May 21 at 21:13
@squipbar Good catch. I removed it because I do not have your graphics files.Now it should work if you uncomment it. (There are reasons why
X
might be better than x
, even though here it does not matter.)– marmot
May 21 at 21:18
@squipbar Good catch. I removed it because I do not have your graphics files.Now it should work if you uncomment it. (There are reasons why
X
might be better than x
, even though here it does not matter.)– marmot
May 21 at 21:18
This still gives me an error. I get:
! Package PGF Math Error: Unknown function
New' (in 'New York,Illinois,Texas[0]').`– squipbar
May 21 at 21:54
This still gives me an error. I get:
! Package PGF Math Error: Unknown function
New' (in 'New York,Illinois,Texas[0]').`– squipbar
May 21 at 21:54
@squipbar Do you run the precise code from above or a version in which you removed the
"
from namelist
? The error message suggests that you are using something like defnamelistNew York,Illinois,Texas
or defnamelistNew York,Illinois,Texas
. Also the number of
is important in pgfmathsetmacromystatenamelist[Y]
, i.e. pgfmathsetmacromystatenamelist[Y]
won't work.– marmot
May 21 at 21:57
@squipbar Do you run the precise code from above or a version in which you removed the
"
from namelist
? The error message suggests that you are using something like defnamelistNew York,Illinois,Texas
or defnamelistNew York,Illinois,Texas
. Also the number of
is important in pgfmathsetmacromystatenamelist[Y]
, i.e. pgfmathsetmacromystatenamelist[Y]
won't work.– marmot
May 21 at 21:57
Yes, I was removing the
"
. But only because I was getting an error when I included them! With them, I get ! Missing number, treated as zero. <to be read again> N l.18 ~
. So it looks like this solution is indexing the "N" somehow, rather than the whole fist entry, "New York" (evidence: if I change the first state to Illinois, that N
becomes an I
).– squipbar
May 22 at 14:39
Yes, I was removing the
"
. But only because I was getting an error when I included them! With them, I get ! Missing number, treated as zero. <to be read again> N l.18 ~
. So it looks like this solution is indexing the "N" somehow, rather than the whole fist entry, "New York" (evidence: if I change the first state to Illinois, that N
becomes an I
).– squipbar
May 22 at 14:39
|
show 1 more comment
Here's my proposal.
documentclassarticle
usepackagexparse
ExplSyntaxOn
NewDocumentCommandmaketwoprongedlistm m
prop_new:c g_squipbar_list_#1_plist
seq_new:c g_squipbar_list_#1_seq
clist_map_inline:nn #2
__squipbar_list_entry:nnn #1 ##1
cs_new_protected:Nn __squipbar_list_entry:nnn
seq_gput_right:cn g_squipbar_list_#1_seq #2
prop_gput:cnn g_squipbar_list_#1_plist short@#2 #2
prop_gput:cnn g_squipbar_list_#1_plist long@#2 #3
NewDocumentCommandusetwoprongedlistm +m
cs_set_protected:Nn __squipbar_list_entry:nn #2
seq_map_inline:cn g_squipbar_list_#1_seq
__squipbar_list_entry:nn
prop_item:cn g_squipbar_list_#1_plist short@##1
prop_item:cn g_squipbar_list_#1_plist long@##1
ExplSyntaxOff
maketwoprongedliststates
NYNew York,
ILIllinois,
TXTexas
begindocument
usetwoprongedliststates%
newpage
section*#2 % <-- I want to use the state name here
beginfigure[h!]
centering
%includegraphics[width=.5textwidth]../charts/summary/x _compare.pdf
texttt../charts/summary/#1-compare.pdf
caption#2 % <-- I want to use the state name here
endfigure
enddocument
Since I don't have your pictures, I emulated them by just printing the file name.
How does this work?
First of all, I define a list giving it a name. The items are comma separated and should consist of <abbreviation><full name>
. The first part is also used for indexing and so it should consist of characters only (but this might be overcome, in case of need).
Each part is then stored as an item in a property list, indexed as short@<abbreviation>
and long@<abbreviation>
. Also a sequence is maintained containing the abbreviations, for later usage; the order will be that of input.
The usetwoprongedlist
command has two arguments: the first is the list to be processed; the second argument is a template, just like the main argument to foreach
; the difference is that #1
and #2
are used to denote the short and long versions of the current item.
A scratch function is defined and then the sequence indexing the list's items is mapped, calling the scratch function with arguments
prop_item:cn <list name> short@<current item>
and
prop_item:cn <list name> long@<current item>
respectively. Et voilà.
add a comment |
Here's my proposal.
documentclassarticle
usepackagexparse
ExplSyntaxOn
NewDocumentCommandmaketwoprongedlistm m
prop_new:c g_squipbar_list_#1_plist
seq_new:c g_squipbar_list_#1_seq
clist_map_inline:nn #2
__squipbar_list_entry:nnn #1 ##1
cs_new_protected:Nn __squipbar_list_entry:nnn
seq_gput_right:cn g_squipbar_list_#1_seq #2
prop_gput:cnn g_squipbar_list_#1_plist short@#2 #2
prop_gput:cnn g_squipbar_list_#1_plist long@#2 #3
NewDocumentCommandusetwoprongedlistm +m
cs_set_protected:Nn __squipbar_list_entry:nn #2
seq_map_inline:cn g_squipbar_list_#1_seq
__squipbar_list_entry:nn
prop_item:cn g_squipbar_list_#1_plist short@##1
prop_item:cn g_squipbar_list_#1_plist long@##1
ExplSyntaxOff
maketwoprongedliststates
NYNew York,
ILIllinois,
TXTexas
begindocument
usetwoprongedliststates%
newpage
section*#2 % <-- I want to use the state name here
beginfigure[h!]
centering
%includegraphics[width=.5textwidth]../charts/summary/x _compare.pdf
texttt../charts/summary/#1-compare.pdf
caption#2 % <-- I want to use the state name here
endfigure
enddocument
Since I don't have your pictures, I emulated them by just printing the file name.
How does this work?
First of all, I define a list giving it a name. The items are comma separated and should consist of <abbreviation><full name>
. The first part is also used for indexing and so it should consist of characters only (but this might be overcome, in case of need).
Each part is then stored as an item in a property list, indexed as short@<abbreviation>
and long@<abbreviation>
. Also a sequence is maintained containing the abbreviations, for later usage; the order will be that of input.
The usetwoprongedlist
command has two arguments: the first is the list to be processed; the second argument is a template, just like the main argument to foreach
; the difference is that #1
and #2
are used to denote the short and long versions of the current item.
A scratch function is defined and then the sequence indexing the list's items is mapped, calling the scratch function with arguments
prop_item:cn <list name> short@<current item>
and
prop_item:cn <list name> long@<current item>
respectively. Et voilà.
add a comment |
Here's my proposal.
documentclassarticle
usepackagexparse
ExplSyntaxOn
NewDocumentCommandmaketwoprongedlistm m
prop_new:c g_squipbar_list_#1_plist
seq_new:c g_squipbar_list_#1_seq
clist_map_inline:nn #2
__squipbar_list_entry:nnn #1 ##1
cs_new_protected:Nn __squipbar_list_entry:nnn
seq_gput_right:cn g_squipbar_list_#1_seq #2
prop_gput:cnn g_squipbar_list_#1_plist short@#2 #2
prop_gput:cnn g_squipbar_list_#1_plist long@#2 #3
NewDocumentCommandusetwoprongedlistm +m
cs_set_protected:Nn __squipbar_list_entry:nn #2
seq_map_inline:cn g_squipbar_list_#1_seq
__squipbar_list_entry:nn
prop_item:cn g_squipbar_list_#1_plist short@##1
prop_item:cn g_squipbar_list_#1_plist long@##1
ExplSyntaxOff
maketwoprongedliststates
NYNew York,
ILIllinois,
TXTexas
begindocument
usetwoprongedliststates%
newpage
section*#2 % <-- I want to use the state name here
beginfigure[h!]
centering
%includegraphics[width=.5textwidth]../charts/summary/x _compare.pdf
texttt../charts/summary/#1-compare.pdf
caption#2 % <-- I want to use the state name here
endfigure
enddocument
Since I don't have your pictures, I emulated them by just printing the file name.
How does this work?
First of all, I define a list giving it a name. The items are comma separated and should consist of <abbreviation><full name>
. The first part is also used for indexing and so it should consist of characters only (but this might be overcome, in case of need).
Each part is then stored as an item in a property list, indexed as short@<abbreviation>
and long@<abbreviation>
. Also a sequence is maintained containing the abbreviations, for later usage; the order will be that of input.
The usetwoprongedlist
command has two arguments: the first is the list to be processed; the second argument is a template, just like the main argument to foreach
; the difference is that #1
and #2
are used to denote the short and long versions of the current item.
A scratch function is defined and then the sequence indexing the list's items is mapped, calling the scratch function with arguments
prop_item:cn <list name> short@<current item>
and
prop_item:cn <list name> long@<current item>
respectively. Et voilà.
Here's my proposal.
documentclassarticle
usepackagexparse
ExplSyntaxOn
NewDocumentCommandmaketwoprongedlistm m
prop_new:c g_squipbar_list_#1_plist
seq_new:c g_squipbar_list_#1_seq
clist_map_inline:nn #2
__squipbar_list_entry:nnn #1 ##1
cs_new_protected:Nn __squipbar_list_entry:nnn
seq_gput_right:cn g_squipbar_list_#1_seq #2
prop_gput:cnn g_squipbar_list_#1_plist short@#2 #2
prop_gput:cnn g_squipbar_list_#1_plist long@#2 #3
NewDocumentCommandusetwoprongedlistm +m
cs_set_protected:Nn __squipbar_list_entry:nn #2
seq_map_inline:cn g_squipbar_list_#1_seq
__squipbar_list_entry:nn
prop_item:cn g_squipbar_list_#1_plist short@##1
prop_item:cn g_squipbar_list_#1_plist long@##1
ExplSyntaxOff
maketwoprongedliststates
NYNew York,
ILIllinois,
TXTexas
begindocument
usetwoprongedliststates%
newpage
section*#2 % <-- I want to use the state name here
beginfigure[h!]
centering
%includegraphics[width=.5textwidth]../charts/summary/x _compare.pdf
texttt../charts/summary/#1-compare.pdf
caption#2 % <-- I want to use the state name here
endfigure
enddocument
Since I don't have your pictures, I emulated them by just printing the file name.
How does this work?
First of all, I define a list giving it a name. The items are comma separated and should consist of <abbreviation><full name>
. The first part is also used for indexing and so it should consist of characters only (but this might be overcome, in case of need).
Each part is then stored as an item in a property list, indexed as short@<abbreviation>
and long@<abbreviation>
. Also a sequence is maintained containing the abbreviations, for later usage; the order will be that of input.
The usetwoprongedlist
command has two arguments: the first is the list to be processed; the second argument is a template, just like the main argument to foreach
; the difference is that #1
and #2
are used to denote the short and long versions of the current item.
A scratch function is defined and then the sequence indexing the list's items is mapped, calling the scratch function with arguments
prop_item:cn <list name> short@<current item>
and
prop_item:cn <list name> long@<current item>
respectively. Et voilà.
answered May 21 at 21:48
egregegreg
746k8919543295
746k8919543295
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%2f492002%2flooping-over-charts-and-names-simultaneously%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