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

If nine coins are tossed, what is the probability that the number of heads is even?

What am I? I am in theaters and computer programs

How to evaluate the limit where something is raised to a power of x?

Skis versus snow shoes - when to choose which for travelling the backcountry?

I encountered my boss during an on-site interview at another company. Should I bring it up when seeing him next time?

Do higher etale homotopy groups of spectrum of a field always vanish?

At what level can a party fight a mimic?

Inverse of the covariance matrix of a multivariate normal distribution

In iTunes 12 on macOS, how can I reset the skip count of a song?

How can atoms be electrically neutral when there is a difference in the positions of the charges?

How can I create a Table like this in Latex?

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

What type of investment is best suited for a 1-year investment on a down payment?

Achieving MPPT of a solar panel with LM2596

Erro: incompatible type for argument 1 of 'printf'

How can I handle a player who pre-plans arguments about my rulings on RAW?

Heating basement floor with water heater

VAT refund for a conference ticket in Sweden

Can a space-faring robot still function over a billion years?

Why do phishing e-mails use faked e-mail addresses instead of the real one?

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

Sometimes a banana is just a banana

Misplaced tyre lever - alternatives?

When should a commit not be version tagged?



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
    yesterday











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

    – João Lourenço
    yesterday
















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
    yesterday











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

    – João Lourenço
    yesterday














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
    yesterday











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

    – João Lourenço
    yesterday



















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

    – egreg
    yesterday











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

    – João Lourenço
    yesterday

















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

– egreg
yesterday





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

– egreg
yesterday













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

– João Lourenço
yesterday





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

– João Lourenço
yesterday










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
    23 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
    23 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
    22 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
    23 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
    23 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
    22 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
    23 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
    23 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
    22 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 23 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
    23 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
    23 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
    22 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
    23 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
    23 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
    22 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
23 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
23 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
23 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
23 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
22 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
22 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...