How to define a comma separated list of arguments for includegraphics
Clash Royale CLAN TAG#URR8PPP
up vote
7
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
add a comment |Â
up vote
7
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
2
expandafterincludegrapgicsexpandafter[settingsA]...
untested (currently not at pc), the key value interpreter does not expand the optional argument before parsing it
â daleif
Sep 28 at 6:27
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
Sep 28 at 8:23
add a comment |Â
up vote
7
down vote
favorite
up vote
7
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
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
asked Sep 28 at 6:16
J. Zar
362
362
2
expandafterincludegrapgicsexpandafter[settingsA]...
untested (currently not at pc), the key value interpreter does not expand the optional argument before parsing it
â daleif
Sep 28 at 6:27
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
Sep 28 at 8:23
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
Sep 28 at 6:27
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
Sep 28 at 8:23
2
2
expandafterincludegrapgicsexpandafter[settingsA]...
untested (currently not at pc), the key value interpreter does not expand the optional argument before parsing itâ daleif
Sep 28 at 6:27
expandafterincludegrapgicsexpandafter[settingsA]...
untested (currently not at pc), the key value interpreter does not expand the optional argument before parsing itâ daleif
Sep 28 at 6:27
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
Sep 28 at 8:23
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
Sep 28 at 8:23
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
10
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
2
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
10
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
10
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
10
down vote
up vote
10
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 Sep 28 at 8:55
answered Sep 28 at 8:36
egreg
687k8418313078
687k8418313078
add a comment |Â
add a comment |Â
up vote
2
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
2
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
2
down vote
up vote
2
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 Sep 28 at 6:28
A.Ellett
35.2k1063163
35.2k1063163
add a comment |Â
add a comment |Â
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
Sep 28 at 6:27
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
Sep 28 at 8:23