help: looking for a generic (and elegant) array (variable) map syntax to keep stuffWhat is the recommended...

Inverse of the covariance matrix of a multivariate normal distribution

Achieving MPPT of a solar panel with LM2596

Does an unattuned Frost Brand weapon still glow in freezing temperatures?

How to mitigate "bandwagon attacking" from players?

Detect if page is on experience editor Sitecore 9 via Javascript?

Are small insurances worth it

In the comics did Thanos "kill" just sentient beings or all creatures with the snap?

Pure Functions: Does "No Side Effects" Imply "Always Same Output, Given Same Input"?

When should a commit not be version tagged?

Center single line(s) in align

Why is s'abonner reflexive?

Reason why dimensional travelling would be restricted

Are there any other Chaos-worshipping races?

Where is the line between being obedient and getting bullied by a boss

Did Amazon pay $0 in taxes last year?

Can I become debt free or should I file for bankruptcy? How do I manage my debt and finances?

What should one use the left pedal for on an upright?

Levi-Civita symbol: 3D matrix

Giving a talk in my old university, how prominently should I tell students my salary?

What am I? I am in theaters and computer programs

Can throughput exceed the bandwidth of a network

Called into a meeting and told we are being made redundant (laid off) and "not to share outside". Can I tell my partner?

I can't die. Who am I?

What could trigger powerful quakes on icy world?



help: looking for a generic (and elegant) array (variable) map syntax to keep stuff


What is the recommended way to assign a value to a variable and retrieve it for later use?Emulate a “tuple” data structure when the syntax for creating a tuple is predefined and cannot be alteredHelp for a complicated macro: breaking pages at custom places and itemize environmentsyntax for in@ and using a macro as an argumentHow would you create syntax for variable substitutionswriting newcommands, user interface advice requestLaTeX syntax for “newcommand” and “cat”Math macro for typesetting partial derivative with variable placeholder for both numerator and denominatorTroubleshooting some mildly convoluted code, inserting 'missing $' without good reasontabularx repeat headers at the start of each new page













1















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.










share|improve this question

























  • I'd much prefer something like margin{cover/left=5cm,cover/right=5cm,...}

    – egreg
    23 hours ago











  • @egreg, I agree with you and I was precisely looking at pgfkeys. Any suggestion?

    – João Lourenço
    23 hours ago
















1















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.










share|improve this question

























  • I'd much prefer something like margin{cover/left=5cm,cover/right=5cm,...}

    – egreg
    23 hours ago











  • @egreg, I agree with you and I was precisely looking at pgfkeys. Any suggestion?

    – João Lourenço
    23 hours ago














1












1








1








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.










share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited yesterday







João Lourenço

















asked yesterday









João LourençoJoão Lourenço

686




686













  • I'd much prefer something like margin{cover/left=5cm,cover/right=5cm,...}

    – egreg
    23 hours ago











  • @egreg, I agree with you and I was precisely looking at pgfkeys. Any suggestion?

    – João Lourenço
    23 hours ago



















  • I'd much prefer something like margin{cover/left=5cm,cover/right=5cm,...}

    – egreg
    23 hours ago











  • @egreg, I agree with you and I was precisely looking at pgfkeys. Any suggestion?

    – João Lourenço
    23 hours ago

















I'd much prefer something like margin{cover/left=5cm,cover/right=5cm,...}

– egreg
23 hours ago





I'd much prefer something like margin{cover/left=5cm,cover/right=5cm,...}

– egreg
23 hours ago













@egreg, I agree with you and I was precisely looking at pgfkeys. Any suggestion?

– João Lourenço
23 hours ago





@egreg, I agree with you and I was precisely looking at pgfkeys. Any suggestion?

– João Lourenço
23 hours ago










1 Answer
1






active

oldest

votes


















2














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}


enter image description here






share|improve this answer
























  • 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
    21 hours ago













  • @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
    21 hours ago













  • I am worried it is for a global "template" unless its target is Chicago style I suggest it could be made universally acceptable.

    – KJO
    21 hours ago













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
});


}
});














draft saved

draft discarded


















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









2














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}


enter image description here






share|improve this answer
























  • 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
    21 hours ago













  • @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
    21 hours ago













  • I am worried it is for a global "template" unless its target is Chicago style I suggest it could be made universally acceptable.

    – KJO
    21 hours ago


















2














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}


enter image description here






share|improve this answer
























  • 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
    21 hours ago













  • @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
    21 hours ago













  • I am worried it is for a global "template" unless its target is Chicago style I suggest it could be made universally acceptable.

    – KJO
    21 hours ago
















2












2








2







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}


enter image description here






share|improve this answer













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}


enter image description here







share|improve this answer












share|improve this answer



share|improve this answer










answered 21 hours ago









egregegreg

724k8819173222




724k8819173222













  • 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
    21 hours ago













  • @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
    21 hours ago













  • I am worried it is for a global "template" unless its target is Chicago style I suggest it could be made universally acceptable.

    – KJO
    21 hours ago





















  • 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
    21 hours ago













  • @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
    21 hours ago













  • I am worried it is for a global "template" unless its target is Chicago style I suggest it could be made universally acceptable.

    – KJO
    21 hours ago



















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
21 hours ago







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
21 hours ago















@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
21 hours ago







@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
21 hours ago















I am worried it is for a global "template" unless its target is Chicago style I suggest it could be made universally acceptable.

– KJO
21 hours ago







I am worried it is for a global "template" unless its target is Chicago style I suggest it could be made universally acceptable.

– KJO
21 hours ago




















draft saved

draft discarded




















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

El tren de la libertad Índice Antecedentes "Porque yo decido" Desarrollo de la...

Castillo d'Acher Características Menú de navegación

Connecting two nodes from the same mother node horizontallyTikZ: What EXACTLY does the the |- notation for...