help: looking for a generic (and elegant) array (variable) map syntax to keep stuff
My apologies if this has been discussed elsewhere, but if it was I couldn't find it.
I am the author of a template for academic thesis for my university, but I'm definitely not a TeX expert. In this template I make extensive use of configuration file(s) that use an ad-hoc (self) defined array map. E.g.:
arraymay{cover}
cover{phd}={phd_cover_file.pdf}
cover{msg}={msc_cover_file.pdf}
arraymap{margin}
margin{cover,left}={5cm}
margin{cover,right}={5cm}
margin{cover,top}={4cm}
margin{cover,bottom}={4cm}
margin{main,left}={3cm}
margin{main,right}={3cm}
margin{main,top}={2cm}
margin{main,bottom}={2cm}
Commas in keys are used for visual effect and considered as a normal character, i.e., in “margin{cover,bottom}={2cm}
” the key is “cover,bottom
”.
I can later access the values as in:
defmanuscripttype{phd}
The cover file is ``thecover[manuscripttype]'' and the margins for the cover are ``themargin[cover,left], themargin[cover,right], themargin[cover,top], and themargin[cover,bottom].''
will produce
The cover file is “phd_cover_file.pdf” and the margins for the cover are “3cm, 3cm, 2cm, and 2cm.”
Is there any other (solid) package implementing this functionality? If not, is there some solid way to implement it (maybe based in one of the KV packages)? Thanks.
macros options
add a comment |
My apologies if this has been discussed elsewhere, but if it was I couldn't find it.
I am the author of a template for academic thesis for my university, but I'm definitely not a TeX expert. In this template I make extensive use of configuration file(s) that use an ad-hoc (self) defined array map. E.g.:
arraymay{cover}
cover{phd}={phd_cover_file.pdf}
cover{msg}={msc_cover_file.pdf}
arraymap{margin}
margin{cover,left}={5cm}
margin{cover,right}={5cm}
margin{cover,top}={4cm}
margin{cover,bottom}={4cm}
margin{main,left}={3cm}
margin{main,right}={3cm}
margin{main,top}={2cm}
margin{main,bottom}={2cm}
Commas in keys are used for visual effect and considered as a normal character, i.e., in “margin{cover,bottom}={2cm}
” the key is “cover,bottom
”.
I can later access the values as in:
defmanuscripttype{phd}
The cover file is ``thecover[manuscripttype]'' and the margins for the cover are ``themargin[cover,left], themargin[cover,right], themargin[cover,top], and themargin[cover,bottom].''
will produce
The cover file is “phd_cover_file.pdf” and the margins for the cover are “3cm, 3cm, 2cm, and 2cm.”
Is there any other (solid) package implementing this functionality? If not, is there some solid way to implement it (maybe based in one of the KV packages)? Thanks.
macros options
I'd much prefer something likemargin{cover/left=5cm,cover/right=5cm,...}
– egreg
Mar 4 at 22:14
@egreg, I agree with you and I was precisely looking at pgfkeys. Any suggestion?
– João Lourenço
Mar 4 at 22:47
add a comment |
My apologies if this has been discussed elsewhere, but if it was I couldn't find it.
I am the author of a template for academic thesis for my university, but I'm definitely not a TeX expert. In this template I make extensive use of configuration file(s) that use an ad-hoc (self) defined array map. E.g.:
arraymay{cover}
cover{phd}={phd_cover_file.pdf}
cover{msg}={msc_cover_file.pdf}
arraymap{margin}
margin{cover,left}={5cm}
margin{cover,right}={5cm}
margin{cover,top}={4cm}
margin{cover,bottom}={4cm}
margin{main,left}={3cm}
margin{main,right}={3cm}
margin{main,top}={2cm}
margin{main,bottom}={2cm}
Commas in keys are used for visual effect and considered as a normal character, i.e., in “margin{cover,bottom}={2cm}
” the key is “cover,bottom
”.
I can later access the values as in:
defmanuscripttype{phd}
The cover file is ``thecover[manuscripttype]'' and the margins for the cover are ``themargin[cover,left], themargin[cover,right], themargin[cover,top], and themargin[cover,bottom].''
will produce
The cover file is “phd_cover_file.pdf” and the margins for the cover are “3cm, 3cm, 2cm, and 2cm.”
Is there any other (solid) package implementing this functionality? If not, is there some solid way to implement it (maybe based in one of the KV packages)? Thanks.
macros options
My apologies if this has been discussed elsewhere, but if it was I couldn't find it.
I am the author of a template for academic thesis for my university, but I'm definitely not a TeX expert. In this template I make extensive use of configuration file(s) that use an ad-hoc (self) defined array map. E.g.:
arraymay{cover}
cover{phd}={phd_cover_file.pdf}
cover{msg}={msc_cover_file.pdf}
arraymap{margin}
margin{cover,left}={5cm}
margin{cover,right}={5cm}
margin{cover,top}={4cm}
margin{cover,bottom}={4cm}
margin{main,left}={3cm}
margin{main,right}={3cm}
margin{main,top}={2cm}
margin{main,bottom}={2cm}
Commas in keys are used for visual effect and considered as a normal character, i.e., in “margin{cover,bottom}={2cm}
” the key is “cover,bottom
”.
I can later access the values as in:
defmanuscripttype{phd}
The cover file is ``thecover[manuscripttype]'' and the margins for the cover are ``themargin[cover,left], themargin[cover,right], themargin[cover,top], and themargin[cover,bottom].''
will produce
The cover file is “phd_cover_file.pdf” and the margins for the cover are “3cm, 3cm, 2cm, and 2cm.”
Is there any other (solid) package implementing this functionality? If not, is there some solid way to implement it (maybe based in one of the KV packages)? Thanks.
macros options
macros options
edited Mar 4 at 20:40
João Lourenço
asked Mar 4 at 20:03
João LourençoJoão Lourenço
686
686
I'd much prefer something likemargin{cover/left=5cm,cover/right=5cm,...}
– egreg
Mar 4 at 22:14
@egreg, I agree with you and I was precisely looking at pgfkeys. Any suggestion?
– João Lourenço
Mar 4 at 22:47
add a comment |
I'd much prefer something likemargin{cover/left=5cm,cover/right=5cm,...}
– egreg
Mar 4 at 22:14
@egreg, I agree with you and I was precisely looking at pgfkeys. Any suggestion?
– João Lourenço
Mar 4 at 22:47
I'd much prefer something like
margin{cover/left=5cm,cover/right=5cm,...}
– egreg
Mar 4 at 22:14
I'd much prefer something like
margin{cover/left=5cm,cover/right=5cm,...}
– egreg
Mar 4 at 22:14
@egreg, I agree with you and I was precisely looking at pgfkeys. Any suggestion?
– João Lourenço
Mar 4 at 22:47
@egreg, I agree with you and I was precisely looking at pgfkeys. Any suggestion?
– João Lourenço
Mar 4 at 22:47
add a comment |
1 Answer
1
active
oldest
votes
You can do it with pgfkeys
:
documentclass{article}
usepackage[T1]{fontenc}
usepackage{pgfkeys}
pgfkeys{
lourenco/.cd,
cover/phd/.initial={},
cover/msc/.initial={},
margin/cover/left/.initial=0pt,
margin/cover/right/.initial=0pt,
margin/cover/top/.initial=0pt,
margin/cover/bottom/.initial=0pt,
margin/main/left/.initial=0pt,
margin/main/right/.initial=0pt,
margin/main/top/.initial=0pt,
margin/main/bottom/.initial=0pt,
}
newcommand{setlourenco}[1]{pgfkeys{lourenco/.cd,#1}}
newcommand{thecover}[1]{%
pgfkeysvalueof{/lourenco/cover/#1}%
}
newcommand{themargin}[1]{%
pgfkeysvalueof{/lourenco/margin/#1}%
}
%% settings
setlourenco{
cover/phd=phd-cover-file.pdf,
cover/msc=msc-cover-file.pdf,
margin/cover/left=5cm,
margin/cover/right=5cm,
margin/cover/top=4cm,
margin/cover/bottom=4cm,
margin/main/left=3cm,
margin/main/right=3cm,
margin/main/top=2cm,
margin/main/bottom=2cm,
}
defmanuscripttype{phd}
begin{document}
The cover file is ``thecover{manuscripttype}'' and the margins
for the cover are ``themargin{cover/left}, themargin{cover/right},
themargin{cover/top}, and themargin{cover/bottom}.''
end{document}
I am going to nit-pick as it has Very Very frequently caused editorial problems and measurement errors when numbers are butted up hard agains units and whilst it may be common practice in many non American organisations the old rule was best USE SPACE FOR CLARITY see english.stackexchange.com/questions/2794/punctuation-with-units in dim light is that 4c m or 40 m
– KJO
Mar 5 at 0:36
@KJO Here the purpose is to show how to access the values, not to pretty print them. The OP wants to usethemargin{cover/top}
for passing the value togeometry
or for doing a direct assignment to a parameter.
– egreg
Mar 5 at 0:38
I am worried it is for a global "template" unless its target is Chicago style I suggest it could be made universally acceptable.
– KJO
Mar 5 at 0:47
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%2f477766%2fhelp-looking-for-a-generic-and-elegant-array-variable-map-syntax-to-keep-st%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can do it with pgfkeys
:
documentclass{article}
usepackage[T1]{fontenc}
usepackage{pgfkeys}
pgfkeys{
lourenco/.cd,
cover/phd/.initial={},
cover/msc/.initial={},
margin/cover/left/.initial=0pt,
margin/cover/right/.initial=0pt,
margin/cover/top/.initial=0pt,
margin/cover/bottom/.initial=0pt,
margin/main/left/.initial=0pt,
margin/main/right/.initial=0pt,
margin/main/top/.initial=0pt,
margin/main/bottom/.initial=0pt,
}
newcommand{setlourenco}[1]{pgfkeys{lourenco/.cd,#1}}
newcommand{thecover}[1]{%
pgfkeysvalueof{/lourenco/cover/#1}%
}
newcommand{themargin}[1]{%
pgfkeysvalueof{/lourenco/margin/#1}%
}
%% settings
setlourenco{
cover/phd=phd-cover-file.pdf,
cover/msc=msc-cover-file.pdf,
margin/cover/left=5cm,
margin/cover/right=5cm,
margin/cover/top=4cm,
margin/cover/bottom=4cm,
margin/main/left=3cm,
margin/main/right=3cm,
margin/main/top=2cm,
margin/main/bottom=2cm,
}
defmanuscripttype{phd}
begin{document}
The cover file is ``thecover{manuscripttype}'' and the margins
for the cover are ``themargin{cover/left}, themargin{cover/right},
themargin{cover/top}, and themargin{cover/bottom}.''
end{document}
I am going to nit-pick as it has Very Very frequently caused editorial problems and measurement errors when numbers are butted up hard agains units and whilst it may be common practice in many non American organisations the old rule was best USE SPACE FOR CLARITY see english.stackexchange.com/questions/2794/punctuation-with-units in dim light is that 4c m or 40 m
– KJO
Mar 5 at 0:36
@KJO Here the purpose is to show how to access the values, not to pretty print them. The OP wants to usethemargin{cover/top}
for passing the value togeometry
or for doing a direct assignment to a parameter.
– egreg
Mar 5 at 0:38
I am worried it is for a global "template" unless its target is Chicago style I suggest it could be made universally acceptable.
– KJO
Mar 5 at 0:47
add a comment |
You can do it with pgfkeys
:
documentclass{article}
usepackage[T1]{fontenc}
usepackage{pgfkeys}
pgfkeys{
lourenco/.cd,
cover/phd/.initial={},
cover/msc/.initial={},
margin/cover/left/.initial=0pt,
margin/cover/right/.initial=0pt,
margin/cover/top/.initial=0pt,
margin/cover/bottom/.initial=0pt,
margin/main/left/.initial=0pt,
margin/main/right/.initial=0pt,
margin/main/top/.initial=0pt,
margin/main/bottom/.initial=0pt,
}
newcommand{setlourenco}[1]{pgfkeys{lourenco/.cd,#1}}
newcommand{thecover}[1]{%
pgfkeysvalueof{/lourenco/cover/#1}%
}
newcommand{themargin}[1]{%
pgfkeysvalueof{/lourenco/margin/#1}%
}
%% settings
setlourenco{
cover/phd=phd-cover-file.pdf,
cover/msc=msc-cover-file.pdf,
margin/cover/left=5cm,
margin/cover/right=5cm,
margin/cover/top=4cm,
margin/cover/bottom=4cm,
margin/main/left=3cm,
margin/main/right=3cm,
margin/main/top=2cm,
margin/main/bottom=2cm,
}
defmanuscripttype{phd}
begin{document}
The cover file is ``thecover{manuscripttype}'' and the margins
for the cover are ``themargin{cover/left}, themargin{cover/right},
themargin{cover/top}, and themargin{cover/bottom}.''
end{document}
I am going to nit-pick as it has Very Very frequently caused editorial problems and measurement errors when numbers are butted up hard agains units and whilst it may be common practice in many non American organisations the old rule was best USE SPACE FOR CLARITY see english.stackexchange.com/questions/2794/punctuation-with-units in dim light is that 4c m or 40 m
– KJO
Mar 5 at 0:36
@KJO Here the purpose is to show how to access the values, not to pretty print them. The OP wants to usethemargin{cover/top}
for passing the value togeometry
or for doing a direct assignment to a parameter.
– egreg
Mar 5 at 0:38
I am worried it is for a global "template" unless its target is Chicago style I suggest it could be made universally acceptable.
– KJO
Mar 5 at 0:47
add a comment |
You can do it with pgfkeys
:
documentclass{article}
usepackage[T1]{fontenc}
usepackage{pgfkeys}
pgfkeys{
lourenco/.cd,
cover/phd/.initial={},
cover/msc/.initial={},
margin/cover/left/.initial=0pt,
margin/cover/right/.initial=0pt,
margin/cover/top/.initial=0pt,
margin/cover/bottom/.initial=0pt,
margin/main/left/.initial=0pt,
margin/main/right/.initial=0pt,
margin/main/top/.initial=0pt,
margin/main/bottom/.initial=0pt,
}
newcommand{setlourenco}[1]{pgfkeys{lourenco/.cd,#1}}
newcommand{thecover}[1]{%
pgfkeysvalueof{/lourenco/cover/#1}%
}
newcommand{themargin}[1]{%
pgfkeysvalueof{/lourenco/margin/#1}%
}
%% settings
setlourenco{
cover/phd=phd-cover-file.pdf,
cover/msc=msc-cover-file.pdf,
margin/cover/left=5cm,
margin/cover/right=5cm,
margin/cover/top=4cm,
margin/cover/bottom=4cm,
margin/main/left=3cm,
margin/main/right=3cm,
margin/main/top=2cm,
margin/main/bottom=2cm,
}
defmanuscripttype{phd}
begin{document}
The cover file is ``thecover{manuscripttype}'' and the margins
for the cover are ``themargin{cover/left}, themargin{cover/right},
themargin{cover/top}, and themargin{cover/bottom}.''
end{document}
You can do it with pgfkeys
:
documentclass{article}
usepackage[T1]{fontenc}
usepackage{pgfkeys}
pgfkeys{
lourenco/.cd,
cover/phd/.initial={},
cover/msc/.initial={},
margin/cover/left/.initial=0pt,
margin/cover/right/.initial=0pt,
margin/cover/top/.initial=0pt,
margin/cover/bottom/.initial=0pt,
margin/main/left/.initial=0pt,
margin/main/right/.initial=0pt,
margin/main/top/.initial=0pt,
margin/main/bottom/.initial=0pt,
}
newcommand{setlourenco}[1]{pgfkeys{lourenco/.cd,#1}}
newcommand{thecover}[1]{%
pgfkeysvalueof{/lourenco/cover/#1}%
}
newcommand{themargin}[1]{%
pgfkeysvalueof{/lourenco/margin/#1}%
}
%% settings
setlourenco{
cover/phd=phd-cover-file.pdf,
cover/msc=msc-cover-file.pdf,
margin/cover/left=5cm,
margin/cover/right=5cm,
margin/cover/top=4cm,
margin/cover/bottom=4cm,
margin/main/left=3cm,
margin/main/right=3cm,
margin/main/top=2cm,
margin/main/bottom=2cm,
}
defmanuscripttype{phd}
begin{document}
The cover file is ``thecover{manuscripttype}'' and the margins
for the cover are ``themargin{cover/left}, themargin{cover/right},
themargin{cover/top}, and themargin{cover/bottom}.''
end{document}
answered Mar 5 at 0:23
egregegreg
726k8819193228
726k8819193228
I am going to nit-pick as it has Very Very frequently caused editorial problems and measurement errors when numbers are butted up hard agains units and whilst it may be common practice in many non American organisations the old rule was best USE SPACE FOR CLARITY see english.stackexchange.com/questions/2794/punctuation-with-units in dim light is that 4c m or 40 m
– KJO
Mar 5 at 0:36
@KJO Here the purpose is to show how to access the values, not to pretty print them. The OP wants to usethemargin{cover/top}
for passing the value togeometry
or for doing a direct assignment to a parameter.
– egreg
Mar 5 at 0:38
I am worried it is for a global "template" unless its target is Chicago style I suggest it could be made universally acceptable.
– KJO
Mar 5 at 0:47
add a comment |
I am going to nit-pick as it has Very Very frequently caused editorial problems and measurement errors when numbers are butted up hard agains units and whilst it may be common practice in many non American organisations the old rule was best USE SPACE FOR CLARITY see english.stackexchange.com/questions/2794/punctuation-with-units in dim light is that 4c m or 40 m
– KJO
Mar 5 at 0:36
@KJO Here the purpose is to show how to access the values, not to pretty print them. The OP wants to usethemargin{cover/top}
for passing the value togeometry
or for doing a direct assignment to a parameter.
– egreg
Mar 5 at 0:38
I am worried it is for a global "template" unless its target is Chicago style I suggest it could be made universally acceptable.
– KJO
Mar 5 at 0:47
I am going to nit-pick as it has Very Very frequently caused editorial problems and measurement errors when numbers are butted up hard agains units and whilst it may be common practice in many non American organisations the old rule was best USE SPACE FOR CLARITY see english.stackexchange.com/questions/2794/punctuation-with-units in dim light is that 4c m or 40 m
– KJO
Mar 5 at 0:36
I am going to nit-pick as it has Very Very frequently caused editorial problems and measurement errors when numbers are butted up hard agains units and whilst it may be common practice in many non American organisations the old rule was best USE SPACE FOR CLARITY see english.stackexchange.com/questions/2794/punctuation-with-units in dim light is that 4c m or 40 m
– KJO
Mar 5 at 0:36
@KJO Here the purpose is to show how to access the values, not to pretty print them. The OP wants to use
themargin{cover/top}
for passing the value to geometry
or for doing a direct assignment to a parameter.– egreg
Mar 5 at 0:38
@KJO Here the purpose is to show how to access the values, not to pretty print them. The OP wants to use
themargin{cover/top}
for passing the value to geometry
or for doing a direct assignment to a parameter.– egreg
Mar 5 at 0:38
I am worried it is for a global "template" unless its target is Chicago style I suggest it could be made universally acceptable.
– KJO
Mar 5 at 0:47
I am worried it is for a global "template" unless its target is Chicago style I suggest it could be made universally acceptable.
– KJO
Mar 5 at 0:47
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%2f477766%2fhelp-looking-for-a-generic-and-elegant-array-variable-map-syntax-to-keep-st%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
I'd much prefer something like
margin{cover/left=5cm,cover/right=5cm,...}
– egreg
Mar 4 at 22:14
@egreg, I agree with you and I was precisely looking at pgfkeys. Any suggestion?
– João Lourenço
Mar 4 at 22:47