How to define a comma separated list of arguments for includegraphics
Clash Royale CLAN TAG#URR8PPP
up vote
3
down vote
favorite
I have a large set of pictures, and I want to apply predefined settings to each using the optional argument of the includegraphics
macro from the graphicx package.
I would like to define the settings once at the top of the file (like defsettingswidth=textwidth, angle=90
), and then apply them to all of my images so that I can modify all of the settings from one place.
If I run the following code block, it gives me the versions of the error "Package xkeyval Error: 'width=textwidth, angle=90' undefined in families 'Gin'", which seems to be because it's interpreting my entire group of settings as a single key input.
documentclassarticle
usepackagegraphix
begindocument
defsettingsAwidth=textwidth, angle=90
defsettingsBpage=1, scale=.1
defsettingsCangle=90, scale=.5
beginfigure
includegraphics[settingsA]filename1.png
labelfig:oneofonehundred
endfigure
beginfigure
includegraphics[settingsB]filename2.pdf
labelfig:twoofonehundred
endfigure
beginfigure
includegraphics[settingsC]filename3.jpg
labelfig:threeofonehundred
endfigure
enddocument
What is the technique to modify this settings string so that it is interpreted correctly? How do I pass an optional argument that is interpreted as a set of arguments instead of one string?
Thanks in advance!
errors optional-arguments strings arguments
New contributor
J. Zar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |Â
up vote
3
down vote
favorite
I have a large set of pictures, and I want to apply predefined settings to each using the optional argument of the includegraphics
macro from the graphicx package.
I would like to define the settings once at the top of the file (like defsettingswidth=textwidth, angle=90
), and then apply them to all of my images so that I can modify all of the settings from one place.
If I run the following code block, it gives me the versions of the error "Package xkeyval Error: 'width=textwidth, angle=90' undefined in families 'Gin'", which seems to be because it's interpreting my entire group of settings as a single key input.
documentclassarticle
usepackagegraphix
begindocument
defsettingsAwidth=textwidth, angle=90
defsettingsBpage=1, scale=.1
defsettingsCangle=90, scale=.5
beginfigure
includegraphics[settingsA]filename1.png
labelfig:oneofonehundred
endfigure
beginfigure
includegraphics[settingsB]filename2.pdf
labelfig:twoofonehundred
endfigure
beginfigure
includegraphics[settingsC]filename3.jpg
labelfig:threeofonehundred
endfigure
enddocument
What is the technique to modify this settings string so that it is interpreted correctly? How do I pass an optional argument that is interpreted as a set of arguments instead of one string?
Thanks in advance!
errors optional-arguments strings arguments
New contributor
J. Zar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
2
expandafterincludegrapgicsexpandafter[settingsA]...
untested (currently not at pc), the key value interpreter does not expand the optional argument before parsing it
– daleif
2 hours ago
In my opinion, built-in expansion of the optional arg ofincludegraphics
is worth being filed as a feature request to github.com/latex3/latex2e/issues?utf8=%E2%9C%93&q=graphicx
– AlexG
45 mins ago
add a comment |Â
up vote
3
down vote
favorite
up vote
3
down vote
favorite
I have a large set of pictures, and I want to apply predefined settings to each using the optional argument of the includegraphics
macro from the graphicx package.
I would like to define the settings once at the top of the file (like defsettingswidth=textwidth, angle=90
), and then apply them to all of my images so that I can modify all of the settings from one place.
If I run the following code block, it gives me the versions of the error "Package xkeyval Error: 'width=textwidth, angle=90' undefined in families 'Gin'", which seems to be because it's interpreting my entire group of settings as a single key input.
documentclassarticle
usepackagegraphix
begindocument
defsettingsAwidth=textwidth, angle=90
defsettingsBpage=1, scale=.1
defsettingsCangle=90, scale=.5
beginfigure
includegraphics[settingsA]filename1.png
labelfig:oneofonehundred
endfigure
beginfigure
includegraphics[settingsB]filename2.pdf
labelfig:twoofonehundred
endfigure
beginfigure
includegraphics[settingsC]filename3.jpg
labelfig:threeofonehundred
endfigure
enddocument
What is the technique to modify this settings string so that it is interpreted correctly? How do I pass an optional argument that is interpreted as a set of arguments instead of one string?
Thanks in advance!
errors optional-arguments strings arguments
New contributor
J. Zar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
I have a large set of pictures, and I want to apply predefined settings to each using the optional argument of the includegraphics
macro from the graphicx package.
I would like to define the settings once at the top of the file (like defsettingswidth=textwidth, angle=90
), and then apply them to all of my images so that I can modify all of the settings from one place.
If I run the following code block, it gives me the versions of the error "Package xkeyval Error: 'width=textwidth, angle=90' undefined in families 'Gin'", which seems to be because it's interpreting my entire group of settings as a single key input.
documentclassarticle
usepackagegraphix
begindocument
defsettingsAwidth=textwidth, angle=90
defsettingsBpage=1, scale=.1
defsettingsCangle=90, scale=.5
beginfigure
includegraphics[settingsA]filename1.png
labelfig:oneofonehundred
endfigure
beginfigure
includegraphics[settingsB]filename2.pdf
labelfig:twoofonehundred
endfigure
beginfigure
includegraphics[settingsC]filename3.jpg
labelfig:threeofonehundred
endfigure
enddocument
What is the technique to modify this settings string so that it is interpreted correctly? How do I pass an optional argument that is interpreted as a set of arguments instead of one string?
Thanks in advance!
errors optional-arguments strings arguments
errors optional-arguments strings arguments
New contributor
J. Zar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
J. Zar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
J. Zar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked 2 hours ago
J. Zar
162
162
New contributor
J. Zar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
J. Zar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
J. Zar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
2
expandafterincludegrapgicsexpandafter[settingsA]...
untested (currently not at pc), the key value interpreter does not expand the optional argument before parsing it
– daleif
2 hours ago
In my opinion, built-in expansion of the optional arg ofincludegraphics
is worth being filed as a feature request to github.com/latex3/latex2e/issues?utf8=%E2%9C%93&q=graphicx
– AlexG
45 mins ago
add a comment |Â
2
expandafterincludegrapgicsexpandafter[settingsA]...
untested (currently not at pc), the key value interpreter does not expand the optional argument before parsing it
– daleif
2 hours ago
In my opinion, built-in expansion of the optional arg ofincludegraphics
is worth being filed as a feature request to github.com/latex3/latex2e/issues?utf8=%E2%9C%93&q=graphicx
– AlexG
45 mins ago
2
2
expandafterincludegrapgicsexpandafter[settingsA]...
untested (currently not at pc), the key value interpreter does not expand the optional argument before parsing it– daleif
2 hours ago
expandafterincludegrapgicsexpandafter[settingsA]...
untested (currently not at pc), the key value interpreter does not expand the optional argument before parsing it– daleif
2 hours ago
In my opinion, built-in expansion of the optional arg of
includegraphics
is worth being filed as a feature request to github.com/latex3/latex2e/issues?utf8=%E2%9C%93&q=graphicx– AlexG
45 mins ago
In my opinion, built-in expansion of the optional arg of
includegraphics
is worth being filed as a feature request to github.com/latex3/latex2e/issues?utf8=%E2%9C%93&q=graphicx– AlexG
45 mins ago
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
3
down vote
Just define new keys:
documentclassarticle
usepackagegraphicx
makeatletter
define@keyGinsettingsAsetkeysGinwidth=textwidth, angle=90
define@keyGinsettingsBsetkeysGinpage=1, scale=.1
define@keyGinsettingsCsetkeysGinangle=-90, scale=.5
makeatother
begindocument
includegraphics[settingsA]example-image-a
includegraphics[settingsB]example-image-b
includegraphics[settingsC]example-image-c
enddocument
A bit of explanation. The graphicx
package relies on keyval
provided key-value syntax and reserves Gin
(Graphic inclusion) as the family name of the keys for includegraphics
. A new key is simply added by
define@keyGin<name>[<default value>]<code>
The includegraphics[<options>]file
command will do
setkeysGin<options>
and every known key will be processed. The default empty value given for settingsA
and so on is so that you can simply type settingsA
without =something
.
One could even improve it; say that in settingsC
you want to be able to vary the angle; with
define@keyGinsettingsC[-90]setkeysGinangle=#1, scale=.5
you can specify settingsC
for the angle to be -90
or
settingsC=45
for the angle to be 45
.
Caveat Be sure not to define an already existing key: define@key
would silently overwrite it.
add a comment |Â
up vote
1
down vote
Make your own include graphics command. Something like the following:
newcommandmyincludegraphics[2]%%
expandafterincludegraphicsexpandafter[#1]#2
The problem with your code is that in the construction
includegraphics[settingsA]filehandle
The unexpanded settingsA
is getting passed to the key parser where it will fail to match any keys. By using the above command, you can write something like,
myincludegraphicssettingsAfilehandle
By using expandafter
, settingsA
will be expanded by the time includegraphics
has a chance to pass the optional arguments to its parser.
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
Just define new keys:
documentclassarticle
usepackagegraphicx
makeatletter
define@keyGinsettingsAsetkeysGinwidth=textwidth, angle=90
define@keyGinsettingsBsetkeysGinpage=1, scale=.1
define@keyGinsettingsCsetkeysGinangle=-90, scale=.5
makeatother
begindocument
includegraphics[settingsA]example-image-a
includegraphics[settingsB]example-image-b
includegraphics[settingsC]example-image-c
enddocument
A bit of explanation. The graphicx
package relies on keyval
provided key-value syntax and reserves Gin
(Graphic inclusion) as the family name of the keys for includegraphics
. A new key is simply added by
define@keyGin<name>[<default value>]<code>
The includegraphics[<options>]file
command will do
setkeysGin<options>
and every known key will be processed. The default empty value given for settingsA
and so on is so that you can simply type settingsA
without =something
.
One could even improve it; say that in settingsC
you want to be able to vary the angle; with
define@keyGinsettingsC[-90]setkeysGinangle=#1, scale=.5
you can specify settingsC
for the angle to be -90
or
settingsC=45
for the angle to be 45
.
Caveat Be sure not to define an already existing key: define@key
would silently overwrite it.
add a comment |Â
up vote
3
down vote
Just define new keys:
documentclassarticle
usepackagegraphicx
makeatletter
define@keyGinsettingsAsetkeysGinwidth=textwidth, angle=90
define@keyGinsettingsBsetkeysGinpage=1, scale=.1
define@keyGinsettingsCsetkeysGinangle=-90, scale=.5
makeatother
begindocument
includegraphics[settingsA]example-image-a
includegraphics[settingsB]example-image-b
includegraphics[settingsC]example-image-c
enddocument
A bit of explanation. The graphicx
package relies on keyval
provided key-value syntax and reserves Gin
(Graphic inclusion) as the family name of the keys for includegraphics
. A new key is simply added by
define@keyGin<name>[<default value>]<code>
The includegraphics[<options>]file
command will do
setkeysGin<options>
and every known key will be processed. The default empty value given for settingsA
and so on is so that you can simply type settingsA
without =something
.
One could even improve it; say that in settingsC
you want to be able to vary the angle; with
define@keyGinsettingsC[-90]setkeysGinangle=#1, scale=.5
you can specify settingsC
for the angle to be -90
or
settingsC=45
for the angle to be 45
.
Caveat Be sure not to define an already existing key: define@key
would silently overwrite it.
add a comment |Â
up vote
3
down vote
up vote
3
down vote
Just define new keys:
documentclassarticle
usepackagegraphicx
makeatletter
define@keyGinsettingsAsetkeysGinwidth=textwidth, angle=90
define@keyGinsettingsBsetkeysGinpage=1, scale=.1
define@keyGinsettingsCsetkeysGinangle=-90, scale=.5
makeatother
begindocument
includegraphics[settingsA]example-image-a
includegraphics[settingsB]example-image-b
includegraphics[settingsC]example-image-c
enddocument
A bit of explanation. The graphicx
package relies on keyval
provided key-value syntax and reserves Gin
(Graphic inclusion) as the family name of the keys for includegraphics
. A new key is simply added by
define@keyGin<name>[<default value>]<code>
The includegraphics[<options>]file
command will do
setkeysGin<options>
and every known key will be processed. The default empty value given for settingsA
and so on is so that you can simply type settingsA
without =something
.
One could even improve it; say that in settingsC
you want to be able to vary the angle; with
define@keyGinsettingsC[-90]setkeysGinangle=#1, scale=.5
you can specify settingsC
for the angle to be -90
or
settingsC=45
for the angle to be 45
.
Caveat Be sure not to define an already existing key: define@key
would silently overwrite it.
Just define new keys:
documentclassarticle
usepackagegraphicx
makeatletter
define@keyGinsettingsAsetkeysGinwidth=textwidth, angle=90
define@keyGinsettingsBsetkeysGinpage=1, scale=.1
define@keyGinsettingsCsetkeysGinangle=-90, scale=.5
makeatother
begindocument
includegraphics[settingsA]example-image-a
includegraphics[settingsB]example-image-b
includegraphics[settingsC]example-image-c
enddocument
A bit of explanation. The graphicx
package relies on keyval
provided key-value syntax and reserves Gin
(Graphic inclusion) as the family name of the keys for includegraphics
. A new key is simply added by
define@keyGin<name>[<default value>]<code>
The includegraphics[<options>]file
command will do
setkeysGin<options>
and every known key will be processed. The default empty value given for settingsA
and so on is so that you can simply type settingsA
without =something
.
One could even improve it; say that in settingsC
you want to be able to vary the angle; with
define@keyGinsettingsC[-90]setkeysGinangle=#1, scale=.5
you can specify settingsC
for the angle to be -90
or
settingsC=45
for the angle to be 45
.
Caveat Be sure not to define an already existing key: define@key
would silently overwrite it.
edited 12 mins ago
answered 32 mins ago


egreg
685k8418263075
685k8418263075
add a comment |Â
add a comment |Â
up vote
1
down vote
Make your own include graphics command. Something like the following:
newcommandmyincludegraphics[2]%%
expandafterincludegraphicsexpandafter[#1]#2
The problem with your code is that in the construction
includegraphics[settingsA]filehandle
The unexpanded settingsA
is getting passed to the key parser where it will fail to match any keys. By using the above command, you can write something like,
myincludegraphicssettingsAfilehandle
By using expandafter
, settingsA
will be expanded by the time includegraphics
has a chance to pass the optional arguments to its parser.
add a comment |Â
up vote
1
down vote
Make your own include graphics command. Something like the following:
newcommandmyincludegraphics[2]%%
expandafterincludegraphicsexpandafter[#1]#2
The problem with your code is that in the construction
includegraphics[settingsA]filehandle
The unexpanded settingsA
is getting passed to the key parser where it will fail to match any keys. By using the above command, you can write something like,
myincludegraphicssettingsAfilehandle
By using expandafter
, settingsA
will be expanded by the time includegraphics
has a chance to pass the optional arguments to its parser.
add a comment |Â
up vote
1
down vote
up vote
1
down vote
Make your own include graphics command. Something like the following:
newcommandmyincludegraphics[2]%%
expandafterincludegraphicsexpandafter[#1]#2
The problem with your code is that in the construction
includegraphics[settingsA]filehandle
The unexpanded settingsA
is getting passed to the key parser where it will fail to match any keys. By using the above command, you can write something like,
myincludegraphicssettingsAfilehandle
By using expandafter
, settingsA
will be expanded by the time includegraphics
has a chance to pass the optional arguments to its parser.
Make your own include graphics command. Something like the following:
newcommandmyincludegraphics[2]%%
expandafterincludegraphicsexpandafter[#1]#2
The problem with your code is that in the construction
includegraphics[settingsA]filehandle
The unexpanded settingsA
is getting passed to the key parser where it will fail to match any keys. By using the above command, you can write something like,
myincludegraphicssettingsAfilehandle
By using expandafter
, settingsA
will be expanded by the time includegraphics
has a chance to pass the optional arguments to its parser.
answered 2 hours ago


A.Ellett
34.5k1063162
34.5k1063162
add a comment |Â
add a comment |Â
J. Zar is a new contributor. Be nice, and check out our Code of Conduct.
J. Zar is a new contributor. Be nice, and check out our Code of Conduct.
J. Zar is a new contributor. Be nice, and check out our Code of Conduct.
J. Zar is a new contributor. Be nice, and check out our Code of Conduct.
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
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f452882%2fhow-to-define-a-comma-separated-list-of-arguments-for-includegraphics%23new-answer', 'question_page');
);
Post as a guest
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
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
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
2
expandafterincludegrapgicsexpandafter[settingsA]...
untested (currently not at pc), the key value interpreter does not expand the optional argument before parsing it– daleif
2 hours ago
In my opinion, built-in expansion of the optional arg of
includegraphics
is worth being filed as a feature request to github.com/latex3/latex2e/issues?utf8=%E2%9C%93&q=graphicx– AlexG
45 mins ago